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

@@ -13,7 +13,7 @@ import { InfiniteSelect, type InfiniteSelectOption, type InfiniteSelectProps } f
import { Checkbox } from "@/components/ui/checkbox";
import { StepBarCards, type StepCardItem } from "@/components/stepBarV2";
import { useCreateBranch, useUpdateBranch, useInfiniteProvinces } from "@/features/branches/hooks/useBranches";
import type { Branch } from "@/features/branches/api/branchesApi";
import { resolveLocalizedName, type Branch } from "@/features/branches/api/branchesApi";
import { createBranchFormSchema, validateStep, DEFAULT_FORM_VALUES, buildPayload } from "@/features/branches/schemas/branch.schema";
import type { BranchFormData } from "@/features/branches/schemas/branch.schema";
@@ -278,15 +278,15 @@ export interface BranchFormProps {
function mapInitial(data: Branch): Partial<BranchFormData> {
return {
nameTk: data.name.tm,
nameRu: data.name.ru,
nameEn: data.name.en,
nameTk: resolveLocalizedName(data.name, "tm"),
nameRu: resolveLocalizedName(data.name, "ru"),
nameEn: resolveLocalizedName(data.name, "en"),
uniqueCode: data.uniqueCode,
provinceId: String(data.provinceId),
region: data.region,
addressTk: data.address.tm,
addressRu: data.address.ru,
addressEn: data.address.en,
addressTk: resolveLocalizedName(data.address, "tm"),
addressRu: resolveLocalizedName(data.address, "ru"),
addressEn: resolveLocalizedName(data.address, "en"),
phoneNumbers: data.phoneNumbers,
billingUsername: data.billingUsername,
billingPassword: data.billingPassword,
@@ -316,14 +316,14 @@ export function BranchForm({ mode, initialData }: BranchFormProps) {
const provinceSelect: Omit<InfiniteSelectProps, "label" | "required" | "placeholder"> = useMemo(() => {
const opts: InfiniteSelectOption[] = (provinceQuery.data?.pages ?? [])
.flatMap((p) => p?.provinces ?? [])
.map((p) => ({ value: String(p.id), label: p.name[lang] }));
.map((p) => ({ value: String(p.id), label: resolveLocalizedName(p.name, lang) }));
// Ensure the currently-selected province is present (edit mode), even if it
// lives beyond the pages loaded so far.
if (initialData) {
const current = String(initialData.provinceId);
if (!opts.some((o) => o.value === current)) {
opts.unshift({ value: current, label: initialData.provinceName?.[lang] ?? current });
opts.unshift({ value: current, label: resolveLocalizedName(initialData.provinceName, lang) || current });
}
}