cautpartener / client / src / public / geo.ts
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**
 * Location slugs for public profile docs (docs/PROTOCOL.md §3, profile.county).
 * 44 curated slugs: "romania" (country-wide, deliberately first — the widest
 * shard and the default landing) + the 41 Romanian counties + București +
 * Diaspora (Romanians abroad — distinct semantics from country-wide). Slugs
 * are the wire values (ASCII, stable forever); the wire itself shape-validates
 * (public-doc isSlug), so additions here are append-only and never a breaking
 * change. County labels are proper nouns, identical in every language;
 * "romania" is the one translated label (i18n key countyRomania).
 */

import { t } from "../app/i18n";

export const COUNTY_SLUGS = [
  "romania",
  "alba",
  "arad",
  "arges",
  "bacau",
  "bihor",
  "bistrita-nasaud",
  "botosani",
  "brasov",
  "braila",
  "bucuresti",
  "buzau",
  "caras-severin",
  "calarasi",
  "cluj",
  "constanta",
  "covasna",
  "dambovita",
  "dolj",
  "galati",
  "giurgiu",
  "gorj",
  "harghita",
  "hunedoara",
  "ialomita",
  "iasi",
  "ilfov",
  "maramures",
  "mehedinti",
  "mures",
  "neamt",
  "olt",
  "prahova",
  "satu-mare",
  "salaj",
  "sibiu",
  "suceava",
  "teleorman",
  "timis",
  "tulcea",
  "vaslui",
  "valcea",
  "vrancea",
  "diaspora",
] as const;

export type CountySlug = (typeof COUNTY_SLUGS)[number];

const LABELS: Record<Exclude<CountySlug, "romania">, string> = {
  alba: "Alba",
  arad: "Arad",
  arges: "Argeș",
  bacau: "Bacău",
  bihor: "Bihor",
  "bistrita-nasaud": "Bistrița-Năsăud",
  botosani: "Botoșani",
  brasov: "Brașov",
  braila: "Brăila",
  bucuresti: "București",
  buzau: "Buzău",
  "caras-severin": "Caraș-Severin",
  calarasi: "Călărași",
  cluj: "Cluj",
  constanta: "Constanța",
  covasna: "Covasna",
  dambovita: "Dâmbovița",
  dolj: "Dolj",
  galati: "Galați",
  giurgiu: "Giurgiu",
  gorj: "Gorj",
  harghita: "Harghita",
  hunedoara: "Hunedoara",
  ialomita: "Ialomița",
  iasi: "Iași",
  ilfov: "Ilfov",
  maramures: "Maramureș",
  mehedinti: "Mehedinți",
  mures: "Mureș",
  neamt: "Neamț",
  olt: "Olt",
  prahova: "Prahova",
  "satu-mare": "Satu Mare",
  salaj: "Sălaj",
  sibiu: "Sibiu",
  suceava: "Suceava",
  teleorman: "Teleorman",
  timis: "Timiș",
  tulcea: "Tulcea",
  vaslui: "Vaslui",
  valcea: "Vâlcea",
  vrancea: "Vrancea",
  diaspora: "Diaspora",
};

export function isCountySlug(v: unknown): v is CountySlug {
  return typeof v === "string" && (COUNTY_SLUGS as readonly string[]).includes(v);
}

export function countyLabel(slug: string): string {
  if (slug === "romania") return t("countyRomania");
  return isCountySlug(slug) && slug !== "romania" ? LABELS[slug] : slug;
}

static mirror of HEAD · about · clone: git clone https://cod-sursa.cautpartener.ro/cautpartener.git