added lang param to api

This commit is contained in:
Jelaletdin12 committed 2026-10-25 00:30:50 +05:00
1 parent 11903e23bf
commit 524733ad9f
50 files changed
+798 -361

No files matched your search

+17 -8
View File
@@ -3,17 +3,26 @@ import apiClient from "@/lib/api/client";
// ─── Localized text (backend keys: tm | ru | en) ──────────────────────────────
export interface LocalizedText {
tm: string;
ru: string;
en: string;
tm?: string;
ru?: string;
en?: string;
}
export type LocalizedField = string | LocalizedText;
export function resolveLocalizedName(val: LocalizedField | null | undefined, lang = "tm"): string {
if (!val) return "";
if (typeof val === "string") return val;
const key = (lang === "tk" ? "tm" : lang) as keyof LocalizedText;
return val[key] ?? val.tm ?? val.en ?? val.ru ?? "";
}
// ─── Province (for the provinceId select) ─────────────────────────────────────
export interface Province {
id: number;
name: LocalizedText;
region: LocalizedText;
name: LocalizedField;
region: LocalizedField;
active: boolean;
}
@@ -22,11 +31,11 @@ export interface Province {
export interface Branch {
id: number;
uniqueCode: string;
name: LocalizedText;
address: LocalizedText;
name: LocalizedField;
address: LocalizedField;
region: string;
provinceId: number;
provinceName: LocalizedText;
provinceName: LocalizedField;
phoneNumbers: string;
billingUsername: string;
billingPassword: string;