cautpartener / client / src / public / categories.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
/**
 * Activity-category slugs for public profile docs (and M5 feed shards —
 * docs/PROTOCOL.md §2 `shard = "<category>|<countySlug>"`). 19 curated wire
 * slugs; display labels live in the locale files (catSport …).
 *
 * The list is the CURATED UI vocabulary (pickers, labels), not a wire enum:
 * the wire shape-validates slugs (public-doc isSlug) so additions here are
 * append-only and never a breaking change. Existing slugs are stable forever.
 * "general" is deliberately first — it is the default landing shard.
 */

import type { MsgKey } from "../app/i18n";

export const CATEGORY_SLUGS = [
  "general",
  "sport",
  "drumetii",
  "calatorii",
  "dans",
  "arta",
  "jocuri",
  "gastronomie",
  "invatare",
  "muzica",
  "afaceri",
  "tech",
  "filme-seriale",
  "carti",
  "voluntariat",
  "parinti",
  "animale",
  "foto",
  "partener-viata",
] as const;

export type CategorySlug = (typeof CATEGORY_SLUGS)[number];

const LABEL_KEYS: Record<CategorySlug, MsgKey> = {
  general: "catGeneral",
  sport: "catSport",
  drumetii: "catDrumetii",
  calatorii: "catCalatorii",
  dans: "catDans",
  arta: "catArta",
  jocuri: "catJocuri",
  gastronomie: "catGastronomie",
  invatare: "catInvatare",
  muzica: "catMuzica",
  afaceri: "catAfaceri",
  tech: "catTech",
  "filme-seriale": "catFilmeSeriale",
  carti: "catCarti",
  voluntariat: "catVoluntariat",
  parinti: "catParinti",
  animale: "catAnimale",
  foto: "catFoto",
  "partener-viata": "catPartenerViata",
};

export function isCategorySlug(v: unknown): v is CategorySlug {
  return typeof v === "string" && (CATEGORY_SLUGS as readonly string[]).includes(v);
}

/** i18n key for a category slug (t(categoryKey(slug)) → display label). */
export function categoryKey(slug: CategorySlug): MsgKey {
  return LABEL_KEYS[slug];
}

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