92 lines
3.1 KiB
TypeScript
92 lines
3.1 KiB
TypeScript
import type { SelectOption } from "@/components/formInput";
|
|
import { buildEnumOptions, getEnumLabel, type EnumConfig, type TranslateFn } from "@/constants/enumLabels";
|
|
|
|
// ─── Education level ──────────────────────────────────────────────────────────
|
|
|
|
export const EDUCATION_VALUES = [
|
|
"high",
|
|
"higher",
|
|
"unfinished_high",
|
|
"masters",
|
|
"phd",
|
|
"middle",
|
|
"secondary",
|
|
"school",
|
|
"school_dropout",
|
|
] as const;
|
|
|
|
export type EducationValue = (typeof EDUCATION_VALUES)[number];
|
|
|
|
export const EDUCATION_LABELS: Record<EducationValue, string> = {
|
|
high: "Higher secondary",
|
|
higher: "Higher education",
|
|
unfinished_high: "Incomplete higher secondary",
|
|
masters: "Master's degree",
|
|
phd: "Doctor of science",
|
|
middle: "Secondary school",
|
|
secondary: "Secondary education",
|
|
school: "Secondary education",
|
|
school_dropout: "Incomplete secondary education",
|
|
};
|
|
|
|
const EDUCATION_ENUM: EnumConfig<EducationValue> = {
|
|
values: EDUCATION_VALUES,
|
|
labels: EDUCATION_LABELS,
|
|
prefix: "options.education",
|
|
};
|
|
|
|
// ─── Marital status ───────────────────────────────────────────────────────────
|
|
|
|
export const MARRIAGE_VALUES = ["MARRIED", "SINGLE", "DIVORCED", "WIDOW", "LEGAL"] as const;
|
|
|
|
export type MarriageValue = (typeof MARRIAGE_VALUES)[number];
|
|
|
|
export const MARRIAGE_LABELS: Record<MarriageValue, string> = {
|
|
MARRIED: "Married",
|
|
SINGLE: "Single",
|
|
DIVORCED: "Divorced",
|
|
WIDOW: "Widowed",
|
|
LEGAL: "Not married / legally single",
|
|
};
|
|
|
|
const MARRIAGE_ENUM: EnumConfig<MarriageValue> = {
|
|
values: MARRIAGE_VALUES,
|
|
labels: MARRIAGE_LABELS,
|
|
prefix: "options.marriage",
|
|
};
|
|
|
|
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
|
|
export function getEducationOptions(t?: TranslateFn): SelectOption[] {
|
|
return buildEnumOptions(EDUCATION_ENUM, t);
|
|
}
|
|
|
|
export function getEducationLabel(value: string, t?: TranslateFn): string {
|
|
return getEnumLabel(EDUCATION_ENUM, value, t);
|
|
}
|
|
|
|
export function getMarriageOptions(t?: TranslateFn): SelectOption[] {
|
|
return buildEnumOptions(MARRIAGE_ENUM, t);
|
|
}
|
|
|
|
export function getMarriageLabel(value: string, t?: TranslateFn): string {
|
|
return getEnumLabel(MARRIAGE_ENUM, value, t);
|
|
}
|
|
|
|
/** Month options for date pickers, "01" … "12". */
|
|
export const MONTH_OPTIONS: SelectOption[] = Array.from({ length: 12 }, (_, i) => {
|
|
const val = String(i + 1).padStart(2, "0");
|
|
return { value: val, label: val };
|
|
});
|
|
|
|
export const YEAR_OPTIONS: SelectOption[] = Array.from({ length: 15 }, (_, i) => {
|
|
const year = String(new Date().getFullYear() + i);
|
|
return { value: year, label: year };
|
|
});
|
|
|
|
/** Longer expiry range used by card balance / requisites / transaction forms. */
|
|
export const CARD_YEAR_OPTIONS: SelectOption[] = Array.from({ length: 20 }, (_, i) => {
|
|
const year = String(new Date().getFullYear() + i);
|
|
return { value: year, label: year };
|
|
});
|