36 lines
1020 B
TypeScript
36 lines
1020 B
TypeScript
import type { TFunction } from "i18next";
|
|
import type { SelectOption } from "@/components/formInput";
|
|
|
|
export const REGION_CODES = ["AG", "AH", "BN", "DZ", "LB", "MR", "BL"] as const;
|
|
|
|
export type RegionCode = (typeof REGION_CODES)[number];
|
|
|
|
/** Distinct region set used by loan paid-off letters. */
|
|
export const LOAN_PAID_OFF_REGION_CODES = ["AG", "AH", "BA", "DA", "LE", "MA"] as const;
|
|
|
|
export type LoanPaidOffRegionCode = (typeof LOAN_PAID_OFF_REGION_CODES)[number];
|
|
|
|
export const REGION_LABELS: Record<string, string> = {
|
|
AG: "Aşgabat",
|
|
AH: "Ahal",
|
|
BN: "Balkan",
|
|
BL: "Balkan",
|
|
DZ: "Daşoguz",
|
|
LB: "Lebap",
|
|
MR: "Mary",
|
|
};
|
|
|
|
type TranslateFn = TFunction | ((key: string, fallback?: string) => string);
|
|
|
|
export function getRegionOptions(
|
|
t: TranslateFn,
|
|
prefix = "loanOrders",
|
|
codes: readonly string[] = REGION_CODES,
|
|
labels?: Record<string, string>,
|
|
): SelectOption[] {
|
|
return codes.map((code) => ({
|
|
value: code,
|
|
label: t(`${prefix}.regions.${code}`, labels?.[code] ?? code),
|
|
}));
|
|
}
|