Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
54 lines
1.9 KiB
TypeScript
54 lines
1.9 KiB
TypeScript
import { texts } from '@/texts'
|
|
|
|
export const EVENT_GENDER_RESTRICTIONS = ['open', 'female_only', 'male_only'] as const
|
|
export type EventGenderRestriction = (typeof EVENT_GENDER_RESTRICTIONS)[number]
|
|
|
|
export const EVENT_AGE_RESTRICTIONS = ['open', 'age_15_19', 'age_20_24', 'age_25_plus'] as const
|
|
export type EventAgeRestriction = (typeof EVENT_AGE_RESTRICTIONS)[number]
|
|
|
|
export const GENDER_RESTRICTION_OPTIONS = [
|
|
{ name: texts.events.genderOpen, selectKey: 'open' },
|
|
{ name: texts.events.genderFemaleOnly, selectKey: 'female_only' },
|
|
{ name: texts.events.genderMaleOnly, selectKey: 'male_only' },
|
|
] as const
|
|
|
|
export const AGE_RESTRICTION_OPTIONS = [
|
|
{ name: texts.events.genderOpen, selectKey: 'open' },
|
|
{ name: texts.events.age15_19, selectKey: 'age_15_19' },
|
|
{ name: texts.events.age20_24, selectKey: 'age_20_24' },
|
|
{ name: texts.events.age25Plus, selectKey: 'age_25_plus' },
|
|
] as const
|
|
|
|
const GENDER_LABELS: Record<EventGenderRestriction, string> = {
|
|
open: texts.events.genderOpen,
|
|
female_only: texts.events.genderFemaleOnly,
|
|
male_only: texts.events.genderMaleOnly,
|
|
}
|
|
|
|
const AGE_LABELS: Record<EventAgeRestriction, string> = {
|
|
open: texts.events.genderOpen,
|
|
age_15_19: texts.events.age15_19,
|
|
age_20_24: texts.events.age20_24,
|
|
age_25_plus: texts.events.age25Plus,
|
|
}
|
|
|
|
export function isEventGenderRestriction(value: unknown): value is EventGenderRestriction {
|
|
return EVENT_GENDER_RESTRICTIONS.includes(value as EventGenderRestriction)
|
|
}
|
|
|
|
export function isEventAgeRestriction(value: unknown): value is EventAgeRestriction {
|
|
return EVENT_AGE_RESTRICTIONS.includes(value as EventAgeRestriction)
|
|
}
|
|
|
|
export function genderRestrictionLabel(value: string | null | undefined): string {
|
|
if (isEventGenderRestriction(value)) return GENDER_LABELS[value]
|
|
|
|
return GENDER_LABELS.open
|
|
}
|
|
|
|
export function ageRestrictionLabel(value: string | null | undefined): string {
|
|
if (isEventAgeRestriction(value)) return AGE_LABELS[value]
|
|
|
|
return AGE_LABELS.open
|
|
}
|