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

+7 -4
View File
@@ -13,8 +13,11 @@ import { useCardPins, useDeleteCardPin } from "@/features/cardPins/hooks/useCard
import type { CardPinOrder } from "@/features/cardPins/api/cardPinApi";
import { useBranches } from "@/features/branches/hooks/useBranches";
import { resolveLocalizedName } from "@/features/branches/api/branchesApi";
import { useDistricts } from "@/features/districts/hooks/useDistricts";
import { resolveDistrictName } from "@/features/districts/api/districtsApi";
import { useCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
import { resolveCardTypeTitle } from "@/features/cardTypes/api/cardTypesApi";
import { getStatusOptions, StatusCell } from "@/constants";
import { formatFromApiDate } from "@/lib/utils";
// ─── Filter field IDs ──────────────────────────────────────────────────────────
@@ -171,15 +174,15 @@ export default function CardPinsPage() {
label: t("cardPin.filter.branch", "Şahamça"),
options: (branchesData?.branches ?? []).map((b) => ({
value: String(b.id),
label: b.name[lang] || b.name.tm,
label: resolveLocalizedName(b.name, lang),
})),
},
{
id: "region",
label: t("cardPin.filter.region", "Sebit"),
options: (districtsData?.provinces ?? []).map((d) => ({
value: d.region?.tm || d.name.tm,
label: d.name[lang] || d.name.tm,
value: resolveDistrictName(d.region, "tm") || resolveDistrictName(d.name, "tm"),
label: resolveDistrictName(d.name, lang),
})),
},
{
@@ -192,7 +195,7 @@ export default function CardPinsPage() {
label: t("cardPin.filter.cardTypeId", "Kart görnüşi"),
options: (cardTypesData?.paymentCards ?? []).map((ct) => ({
value: String(ct.id),
label: ct.title[lang] || ct.title.tm,
label: resolveCardTypeTitle(ct.title, lang),
})),
},
],
@@ -15,7 +15,9 @@ import { useCardRequisites, useDeleteCardRequisite } from "@/features/cardRequis
import type { CardRequisite } from "@/features/cardRequisites/api/cardRequisitesApi";
import { resolveLocalizedName } from "@/features/cardRequisites/api/cardRequisitesApi";
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
import { resolveLocalizedName as resolveBranchName } from "@/features/branches/api/branchesApi";
import { useInfiniteCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
import { resolveCardTypeTitle } from "@/features/cardTypes/api/cardTypesApi";
import { useInfiniteClients } from "@/features/clients/hooks/useClients";
import { getRegionOptions, StatusCell } from "@/constants";
@@ -67,7 +69,7 @@ export default function CardRequisitesPage() {
(branchesInfiniteData?.pages ?? []).flatMap((page) =>
(page?.branches ?? []).map((b) => ({
value: String(b.id),
label: b.name[lang] || b.name.tm || String(b.id),
label: resolveBranchName(b.name, lang) || String(b.id),
})),
),
[branchesInfiniteData, lang],
@@ -87,7 +89,7 @@ export default function CardRequisitesPage() {
(cardTypesInfiniteData?.pages ?? []).flatMap((page) =>
(page?.paymentCards ?? []).map((ct) => ({
value: String(ct.id),
label: ct.title[lang] || ct.title.tm || String(ct.id),
label: resolveCardTypeTitle(ct.title, lang) || String(ct.id),
})),
),
[cardTypesInfiniteData, lang],
@@ -11,6 +11,7 @@ import { useCardTransactions, useDeleteCardTransaction } from "@/features/cardTr
import type { Card } from "@/features/cardTransactions/api/cardTransactionsApi";
import { useInfiniteClients } from "@/features/clients/hooks/useClients";
import { useInfiniteCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
import { resolveCardTypeTitle } from "@/features/cardTypes/api/cardTypesApi";
import { formatFromApiDate } from "@/lib/utils";
// ─── Page ─────────────────────────────────────────────────────────────────────
@@ -72,7 +73,7 @@ export default function CardTransactionsPage() {
return (cardTypesData?.pages ?? []).flatMap((p) =>
(p?.paymentCards ?? []).map((c) => ({
value: String(c.id),
label: c.title?.[langKey] || c.title?.tm || c.title?.en || String(c.id),
label: resolveCardTypeTitle(c.title, langKey) || String(c.id),
})),
);
}, [cardTypesData, i18n.language]);
@@ -12,7 +12,9 @@ import { DeleteDialog } from "@/components/deleteDialog";
import { useCards, useDeleteCard } from "@/features/orderNewCard/hooks/useOrderNewCard";
import type { CardOrder } from "@/features/orderNewCard/api/orderNewCardApi";
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
import { resolveLocalizedName as resolveBranchName } from "@/features/branches/api/branchesApi";
import { useInfiniteCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
import { resolveCardTypeTitle } from "@/features/cardTypes/api/cardTypesApi";
import { useInfiniteClients } from "@/features/clients/hooks/useClients";
import type { LocalizedText } from "@/features/branches/api/branchesApi";
import { getStatusOptions, getRegionOptions, StatusCell, ActiveStatusCell } from "@/constants";
@@ -243,7 +245,7 @@ export default function CardOrdersPage() {
(branchesInfiniteData?.pages ?? []).flatMap((page) =>
(page?.branches ?? []).map((b) => ({
value: String(b.id),
label: b.name[lang] || b.name.tm,
label: resolveBranchName(b.name, lang),
})),
),
[branchesInfiniteData, lang],
@@ -256,7 +258,7 @@ export default function CardOrdersPage() {
(cardTypesInfiniteData?.pages ?? []).flatMap((page) =>
(page?.paymentCards ?? []).map((ct) => ({
value: String(ct.id),
label: ct.title[lang] || ct.title.tm,
label: resolveCardTypeTitle(ct.title, lang),
})),
),
[cardTypesInfiniteData, lang],
@@ -9,7 +9,7 @@ import { DataTableToolbar } from "@/components/dataTableToolbar";
import { TableSearchInput } from "@/components/tableSearch";
import { CreateButton } from "@/components/createButton";
import { useGetVisaMasterSettings, useDeleteVisaMasterSetting } from "@/features/visaMasterSberSettings/hooks/useVisaMasterSettings";
import type { VisaMasterSetting } from "@/features/visaMasterSberSettings/api/visaMasterSberSettingsApi";
import { type VisaMasterSetting, resolveVisaMasterText } from "@/features/visaMasterSberSettings/api/visaMasterSberSettingsApi";
const DEFAULT_VISIBILITY = { code: true, name: true, text: true, isActive: true, updatedAt: true, updatedByName: true };
const DEFAULT_ORDER = ["code", "name", "text", "isActive", "updatedAt", "updatedByName", "actions"];
@@ -56,9 +56,9 @@ export default function VisaMasterSettingsPage() {
},
{
id: "text",
accessorFn: (row) => row.text?.tm ?? "",
accessorFn: (row) => resolveVisaMasterText(row.text),
header: t("visaMasterSettings.columns.yazgy", "YAZGY"),
cell: ({ row }) => <span className="text-foreground line-clamp-1 max-w-xs">{row.original.text?.tm}</span>,
cell: ({ row }) => <span className="text-foreground line-clamp-1 max-w-xs">{resolveVisaMasterText(row.original.text) || "—"}</span>,
},
{
accessorKey: "isActive",
@@ -338,10 +338,7 @@ export default function IntlPaymentViewPage() {
</div>
{/* Single history table */}
<PaymentHistoryTable
orderId={data.id}
paymentId={(data as any).paymentId ?? (data as any).payment_id ?? (data as any).payment?.id}
/>
<PaymentHistoryTable orderId={data.id} />
</section>
</div>
);
@@ -11,6 +11,7 @@ import { TableActions } from "@/components/tableActions";
import { useLoanOrderMobiles, useDeleteLoanOrderMobile } from "@/features/loanOrderMobiles/hooks/useLoanOrderMobiles";
import type { LoanOrderMobile, LoanOrderMobileStatus } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi";
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
import { resolveLocalizedName } from "@/features/branches/api/branchesApi";
import { DeleteDialog } from "@/components/deleteDialog";
import { getStatusOptions, getRegionOptions, StatusCell } from "@/constants";
import { formatFromApiDate } from "@/lib/utils";
@@ -53,7 +54,7 @@ export default function LoanOrderMobilesPage() {
(branchesInfiniteData?.pages ?? []).flatMap((page) =>
(page?.branches ?? []).map((b) => ({
value: String(b.id),
label: b.name[lang] || b.name.tm,
label: resolveLocalizedName(b.name, lang),
})),
),
[branchesInfiniteData, lang],
@@ -10,6 +10,7 @@ import { TableActions } from "@/components/tableActions";
import { useLoanOrders, useDeleteLoanOrder } from "@/features/loanOrders/hooks/useLoanOrders";
import type { LoanOrder, LoanOrderStatus } from "@/features/loanOrders/api/loanOrdersApi";
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
import { resolveLocalizedName } from "@/features/branches/api/branchesApi";
import { DeleteDialog } from "@/components/deleteDialog";
import { getStatusOptions, getRegionOptions, StatusCell } from "@/constants";
import { formatFromApiDate } from "@/lib/utils";
@@ -51,7 +52,7 @@ export default function LoanOrdersPage() {
(branchesInfiniteData?.pages ?? []).flatMap((page) =>
(page?.branches ?? []).map((b) => ({
value: String(b.id),
label: b.name[lang] || b.name.tm,
label: resolveLocalizedName(b.name, lang),
})),
),
[branchesInfiniteData, lang],
@@ -13,7 +13,9 @@ import { useLoanPaidOffLetters, useDeleteLoanPaidOffLetter } from "@/features/lo
import type { LoanPaidOffLetter } from "@/features/loanPaidOffLetters/api/loanPaidOffLettersApi";
import { DeleteDialog } from "@/components/deleteDialog";
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
import { resolveLocalizedName } from "@/features/branches/api/branchesApi";
import { useInfiniteDistricts } from "@/features/districts/hooks/useDistricts";
import { resolveDistrictName } from "@/features/districts/api/districtsApi";
import { getStatusOptions, StatusCell } from "@/constants";
// ─── Column IDs ────────────────────────────────────────────────────────────────
@@ -120,7 +122,7 @@ export default function LoanPaidOffLettersPage() {
(branchesInfiniteData?.pages ?? []).flatMap((page) =>
(page?.branches ?? []).map((b) => ({
value: String(b.id),
label: b.name[lang] || b.name.tm,
label: resolveLocalizedName(b.name, lang),
})),
),
[branchesInfiniteData, lang],
@@ -130,8 +132,8 @@ export default function LoanPaidOffLettersPage() {
() =>
(districtsInfiniteData?.pages ?? []).flatMap((page) =>
(page?.provinces ?? []).map((d) => ({
value: d.region?.tm || d.name.tm,
label: d.name[lang] || d.name.tm,
value: resolveDistrictName(d.region, "tm") || resolveDistrictName(d.name, "tm"),
label: resolveDistrictName(d.name, lang),
})),
),
[districtsInfiniteData, lang],
+2 -1
View File
@@ -13,6 +13,7 @@ import type { OnlinePayment, PaymentSortField, PaymentSortOrder } from "@/featur
import { GatewayStatusBadge, PaidBadge } from "../../features/onlinePaymentHistory/components/PaymentStatusBadge";
import { getPaymentHistoryStatusOptions } from "@/constants/paymentStatus";
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
import { resolveLocalizedName } from "@/features/branches/api/branchesApi";
// ─── Helpers ──────────────────────────────────────────────────────────────────
@@ -108,7 +109,7 @@ export default function OnlinePaymentHistoryPage() {
(branchesInfiniteData?.pages ?? []).flatMap((p) =>
(p?.branches ?? []).map((b) => ({
value: String(b.id),
label: b.name[lang] || b.name.tm,
label: resolveLocalizedName(b.name, lang),
})),
),
[branchesInfiniteData, lang],
@@ -6,9 +6,8 @@ import { Button } from "@/components/ui/button";
import { Skeleton } from "@/components/ui/skeleton";
import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents";
import { GatewayStatusBadge, PaidBadge } from "@/features/onlinePaymentHistory/components/PaymentStatusBadge";
import { useGetOnlinePaymentDetail, useGetOnlinePaymentById } from "@/features/onlinePaymentHistory/hooks/useOnlinePaymentsHistory";
import { useGetOnlinePaymentDetail } from "@/features/onlinePaymentHistory/hooks/useOnlinePaymentsHistory";
import { formatFromApiDate } from "@/lib/utils/dateUtils";
import { rawEnumKey, type TranslateFn } from "@/constants/enumLabels";
function formatDateTime(iso: string | null | undefined): string {
if (!iso) return "—";
@@ -21,10 +20,6 @@ function resolveLang(lang: string): "en" | "ru" | "tm" {
return "en";
}
function detailKeyLabel(key: string, t: TranslateFn): string {
return t(`onlinePayments.detailKeys.${key}`, rawEnumKey(key));
}
export default function OnlinePaymentDetailViewPage() {
const { id } = useParams<{ id: string }>();
const navigate = useNavigate();
@@ -32,7 +27,6 @@ export default function OnlinePaymentDetailViewPage() {
const lang = resolveLang(i18n.language);
const { data, isLoading, isError } = useGetOnlinePaymentDetail(id!);
const { data: steps } = useGetOnlinePaymentById(data?.orderId ?? (data?.id || 0));
if (isLoading) {
return (
@@ -100,7 +94,10 @@ export default function OnlinePaymentDetailViewPage() {
<AlertTriangle className="size-5 shrink-0 mt-0.5" />
<div className="space-y-1 text-sm">
<div className="font-semibold">
Gateway Ýalňyşlygy {data.gatewayResponse.errorCode ? `(Kod: ${data.gatewayResponse.errorCode})` : ""}
{t("onlinePayments.gatewayErrorTitle", "Gateway error")}{" "}
{data.gatewayResponse.errorCode
? ` (${t("onlinePayments.gateway.errorCode", "Error code")}: ${data.gatewayResponse.errorCode})`
: ""}
</div>
{data.gatewayResponse.errorMessage && <div className="text-foreground/90">{data.gatewayResponse.errorMessage}</div>}
</div>
@@ -192,39 +189,72 @@ export default function OnlinePaymentDetailViewPage() {
</BentoCard>
</BentoGrid>
{/* ── Row 3: Last Payment Step ──────────────────────────────────────────── */}
{steps &&
steps.length > 0 &&
(() => {
const lastStep = [...steps].sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())[0];
const detailEntries = Object.entries(lastStep.detail ?? {});
{/* ── Row 3: Gateway details ──────────────────────────────────────────── */}
{data.gatewayResponse && (
<BentoGrid cols={2}>
<BentoCard title={t("onlinePayments.gatewaySection", "Gateway maglumaty")}>
<InfoRow label={t("onlinePayments.columns.gatewayStatus", "Gateway statusy")}>
<GatewayStatusBadge status={data.gatewayStatus} />
</InfoRow>
<InfoRow
label={t("onlinePayments.gateway.orderStatus", "Gateway order statusy")}
value={data.gatewayResponse.orderStatus ?? "—"}
/>
<InfoRow label={t("onlinePayments.gateway.errorCode", "Error code")} value={data.gatewayResponse.errorCode || "—"} />
<InfoRow label={t("onlinePayments.gateway.errorMessage", "Gateway jogaby")} value={data.gatewayResponse.errorMessage || "—"} />
<InfoRow label={t("onlinePayments.gateway.actionCode", "Action code")} value={data.gatewayResponse.actionCode ?? "—"} />
<InfoRow
label={t("onlinePayments.gateway.actionDescription", "Action düşündirişi")}
value={data.gatewayResponse.actionCodeDescription || "—"}
/>
<InfoRow label={t("onlinePayments.gateway.terminal", "Terminal")} value={data.gatewayResponse.terminalId || "—"} />
<InfoRow label={t("onlinePayments.gateway.ip", "IP adres")} value={data.gatewayResponse.ip || "—"} />
</BentoCard>
return (
<BentoCard title={t("onlinePayments.lastStep.title", "Iň soňky işlem")}>
<div className="p-4 space-y-3">
{/* Header: status + time + operator */}
<div className="flex flex-wrap items-center gap-3">
<GatewayStatusBadge status={lastStep.step} />
<span className="text-xs text-muted-foreground whitespace-nowrap">{formatDateTime(lastStep.createdAt)}</span>
{lastStep.createdByName && <span className="text-xs text-muted-foreground">{lastStep.createdByName}</span>}
<span className="text-xs text-muted-foreground font-mono ml-auto">Step ID: {lastStep.id}</span>
</div>
<BentoCard title={t("onlinePayments.gatewayCardSection", "Kart we bank maglumatlary")}>
<InfoRow
label={t("onlinePayments.columns.cardholderName", "Kart eýesi")}
value={data.gatewayResponse.cardAuthInfo?.cardholderName || data.cardholderName || "—"}
/>
<InfoRow
label={t("onlinePayments.columns.maskedPan", "Kart belgisi")}
value={data.gatewayResponse.cardAuthInfo?.pan || data.maskedPan || "—"}
/>
<InfoRow
label={t("onlinePayments.gateway.expiration", "Möhleti")}
value={data.gatewayResponse.cardAuthInfo?.expiration || "—"}
/>
<InfoRow
label={t("onlinePayments.gateway.approvalCode", "Approval code")}
value={data.gatewayResponse.cardAuthInfo?.approvalCode || "—"}
/>
<InfoRow
label={t("onlinePayments.gateway.bankCountry", "Bank döwleti")}
value={data.gatewayResponse.bankInfo?.bankCountryName || "—"}
/>
<InfoRow label={t("onlinePayments.gateway.currency", "Walýuta")} value={data.gatewayResponse.currency || "—"} />
<InfoRow
label={t("onlinePayments.gateway.paymentState", "Payment state")}
value={data.gatewayResponse.paymentAmountInfo?.paymentState || "—"}
/>
<InfoRow
label={t("onlinePayments.gateway.approvedAmount", "Tassyklanan möçber")}
value={data.gatewayResponse.paymentAmountInfo?.approvedAmount ?? "—"}
/>
</BentoCard>
</BentoGrid>
)}
{/* Detail key-value rows */}
{detailEntries.length > 0 && (
<div className="rounded-md border bg-muted/30 px-3 py-2 space-y-1">
{detailEntries.map(([key, value]) => (
<div key={key} className="flex gap-2 text-xs">
<span className="text-muted-foreground font-medium min-w-[130px] shrink-0">{detailKeyLabel(key, t)}</span>
<span className="text-foreground break-all">{String(value)}</span>
</div>
))}
</div>
)}
</div>
</BentoCard>
);
})()}
<BentoCard title={t("onlinePayments.callbackSection", "Callback we baglanyşyk")}>
<div className="grid grid-cols-1 gap-x-8 md:grid-cols-2">
<InfoRow label={t("onlinePayments.columns.gatewayReference", "Gateway reference")} value={data.gatewayReference || "—"} />
<InfoRow label={t("onlinePayments.columns.callbackStatus", "Callback statusy")} value={data.callbackStatus || "—"} />
<InfoRow label={t("onlinePayments.columns.callbackAt", "Callback wagty")} value={formatDateTime(data.callbackAt)} />
<InfoRow label={t("onlinePayments.columns.apiClientName", "API client")} value={data.apiClientName || data.apiClient || "—"} />
<InfoRow label={t("onlinePayments.columns.formUrl", "Form URL")} value={data.formUrl || "—"} />
<InfoRow label={t("onlinePayments.columns.successUrl", "Success URL")} value={data.successUrl || "—"} />
</div>
</BentoCard>
</div>
);
}
+2 -2
View File
@@ -12,7 +12,7 @@ import { Checkbox } from "@/components/ui/checkbox";
import { ActiveStatusCell } from "@/constants";
import type { FilterField, ActiveFilter } from "@/components/dataTableToolbar";
import { useCardTypes, useDeleteCardType, useUpdateCardTypeActive } from "@/features/cardTypes/hooks/useCardTypes";
import type { CardType } from "@/features/cardTypes/api/cardTypesApi";
import { type CardType, resolveCardTypeTitle } from "@/features/cardTypes/api/cardTypesApi";
export function CardTypesListPage() {
const { t, i18n } = useTranslation();
@@ -70,7 +70,7 @@ export function CardTypesListPage() {
accessorKey: "title",
id: "name",
header: t("cardTypes.fields.name", "ADY").toUpperCase(),
cell: ({ row }) => <span className="text-sm text-foreground">{row.original.title[lang]}</span>,
cell: ({ row }) => <span className="text-sm text-foreground">{resolveCardTypeTitle(row.original.title, lang)}</span>,
},
{
accessorKey: "price",
@@ -4,23 +4,26 @@ import { Skeleton } from "@/components/ui/skeleton";
import { Section, InfoRow, MultiLangRow, ViewActions } from "@/components/viewPageComponents";
import { ActiveStatusCell } from "@/constants";
import { useCardTypeById, useDeleteCardType } from "@/features/cardTypes/hooks/useCardTypes";
import { resolveCardTypeTitle } from "@/features/cardTypes/api/cardTypesApi";
export function CardTypeViewPage() {
const { id } = useParams<{ id: string }>();
const navigate = useNavigate();
const { t } = useTranslation();
const { t, i18n } = useTranslation();
const numericId = Number(id);
const { data, isLoading } = useCardTypeById(numericId);
const deleteMutation = useDeleteCardType();
const lang = (i18n.language === "ru" ? "ru" : i18n.language === "en" ? "en" : "tm") as "tm" | "ru" | "en";
return (
<div>
<div className="flex items-start justify-between mb-6">
<div>
<h1 className="text-2xl font-bold text-foreground">
{isLoading ? "..." : `${t("cardTypes.view.title", "Kart görnüşi giňişleýin")}: ${data?.title.tm ?? ""}`}
{isLoading ? "..." : `${t("cardTypes.view.title", "Kart görnüşi giňişleýin")}: ${resolveCardTypeTitle(data?.title, lang)}`}
</h1>
</div>
+2 -2
View File
@@ -11,7 +11,7 @@ import { CreateButton } from "@/components/createButton";
import { TableActions } from "@/components/tableActions";
import type { FilterField, ActiveFilter } from "@/components/dataTableToolbar";
import { useCardReasons, useDeleteCardReason } from "@/features/cardReasons/hooks/useCardReasons";
import type { CardReason } from "@/features/cardReasons/api/cardReasonsApi";
import { type CardReason, resolveCardReasonTitle } from "@/features/cardReasons/api/cardReasonsApi";
// ─── CardReasonsListPage ───────────────────────────────────────────────────────
@@ -68,7 +68,7 @@ export function CardReasonsListPage() {
accessorKey: "title",
id: "name",
header: t("cardReasons.fields.name", "ADY").toUpperCase(),
cell: ({ row }) => <span className="text-sm text-foreground">{row.original.title[lang]}</span>,
cell: ({ row }) => <span className="text-sm text-foreground">{resolveCardReasonTitle(row.original.title, lang)}</span>,
},
{
accessorKey: "price",
@@ -4,6 +4,7 @@ import { ActiveStatusCell } from "@/constants";
import { Skeleton } from "@/components/ui/skeleton";
import { Section, InfoRow, MultiLangRow, ViewActions } from "@/components/viewPageComponents";
import { useCardReasonById, useDeleteCardReason } from "@/features/cardReasons/hooks/useCardReasons";
import { resolveCardReasonTitle } from "@/features/cardReasons/api/cardReasonsApi";
// ─── CardReasonViewPage ────────────────────────────────────────────────────────
@@ -23,7 +24,9 @@ export function CardReasonViewPage() {
<div className="flex items-start justify-between mb-6">
<div>
<h1 className="text-2xl font-bold text-foreground">
{isLoading ? "..." : `${t("cardReasons.viewTitle", "Kartyň çykarylmagynyň sebäbi giňişleýin")}: ${data?.title[lang] ?? ""}`}
{isLoading
? "..."
: `${t("cardReasons.viewTitle", "Kartyň çykarylmagynyň sebäbi giňişleýin")}: ${resolveCardReasonTitle(data?.title, lang)}`}
</h1>
</div>
+4 -4
View File
@@ -10,7 +10,7 @@ import { TableSearchInput } from "@/components/tableSearch";
import { CreateButton } from "@/components/createButton";
import { TableActions } from "@/components/tableActions";
import { useGetLoanTypes, useDeleteLoanType } from "@/features/loanTypes/hooks/useLoanTypes";
import type { LoanType } from "@/features/loanTypes/api/loanTypesApi";
import { type LoanType, resolveLoanText } from "@/features/loanTypes/api/loanTypesApi";
import { DeleteDialog } from "@/components/deleteDialog";
// ─── Column definitions ───────────────────────────────────────────────────────
@@ -33,7 +33,7 @@ function useLoanTypeColumns(
{
accessorKey: "title",
header: t("loanTypes.columns.name", "ADY"),
cell: ({ row }) => <span className="text-sm text-foreground">{row.original.title[lang]}</span>,
cell: ({ row }) => <span className="text-sm text-foreground">{resolveLoanText(row.original.title, lang)}</span>,
},
{
accessorKey: "tax",
@@ -51,8 +51,8 @@ function useLoanTypeColumns(
accessorKey: "content",
header: t("loanTypes.columns.notes", "BELLIKLER"),
cell: ({ row }) => {
const content = row.original.content;
return <span className="text-sm text-foreground">{content ? content[lang] || "—" : "—"}</span>;
const content = resolveLoanText(row.original.content, lang);
return <span className="text-sm text-foreground">{content || "—"}</span>;
},
},
{
@@ -6,6 +6,7 @@ import { ActiveStatusCell } from "@/constants";
import { Skeleton } from "@/components/ui/skeleton";
import { Section, InfoRow, MultiLangRow, ViewActions } from "@/components/viewPageComponents";
import { useGetLoanTypeById, useDeleteLoanType } from "@/features/loanTypes/hooks/useLoanTypes";
import { resolveLoanText } from "@/features/loanTypes/api/loanTypesApi";
// ─── LoanTypeViewPage ─────────────────────────────────────────────────────────
@@ -59,7 +60,7 @@ export default function LoanTypeViewPage() {
{/* Page header */}
<div className="flex items-start justify-between mb-5">
<h1 className="text-xl font-semibold text-foreground">
{t("loanTypes.viewTitle", "Karz görnüşi giňişleýin")}: {data.title[lang]}
{t("loanTypes.viewTitle", "Karz görnüşi giňişleýin")}: {resolveLoanText(data.title, lang)}
</h1>
<div className="flex items-center gap-2">
<ViewActions
@@ -88,7 +89,7 @@ export default function LoanTypeViewPage() {
<div className="flex flex-col sm:grid sm:grid-cols-[minmax(0,42%)_minmax(0,58%)] items-start sm:items-center py-2.5 px-4 border-b border-border gap-0.5 sm:gap-0">
<span className="text-xs sm:text-sm text-muted-foreground leading-snug">{t("loanTypes.fields.notes", "Bellikler")}</span>
<span className="text-sm text-foreground break-words min-w-0">{data.content ? data.content[lang] || "—" : "—"}</span>
<span className="text-sm text-foreground break-words min-w-0">{resolveLoanText(data.content, lang) || "—"}</span>
</div>
<div className="flex flex-col sm:grid sm:grid-cols-[minmax(0,42%)_minmax(0,58%)] items-start sm:items-center py-2.5 px-4 border-b border-border last:border-0 gap-1 sm:gap-0">
@@ -11,7 +11,7 @@ import { CreateButton } from "@/components/createButton";
import { TableActions } from "@/components/tableActions";
import type { FilterField, ActiveFilter } from "@/components/dataTableToolbar";
import { useBranches, useDeleteBranch, useInfiniteProvinces } from "@/features/branches/hooks/useBranches";
import type { Branch } from "@/features/branches/api/branchesApi";
import { type Branch, resolveLocalizedName } from "@/features/branches/api/branchesApi";
export function BranchesListPage() {
const { t, i18n } = useTranslation();
@@ -70,7 +70,7 @@ export function BranchesListPage() {
(provincesInfiniteData?.pages ?? []).flatMap((page) =>
(page?.provinces ?? []).map((p) => ({
value: String(p.id),
label: p.name[lang],
label: resolveLocalizedName(p.name, lang),
})),
),
[provincesInfiniteData, lang],
@@ -133,13 +133,13 @@ export function BranchesListPage() {
accessorKey: "name",
id: "name",
header: t("branches.fields.name", "ADY").toUpperCase(),
cell: ({ row }) => <span className="text-sm text-foreground">{row.original.name[lang]}</span>,
cell: ({ row }) => <span className="text-sm text-foreground">{resolveLocalizedName(row.original.name, lang)}</span>,
},
{
accessorKey: "provinceName",
id: "provinceName",
header: t("branches.fields.district", "ETRAP").toUpperCase(),
cell: ({ row }) => <span className="text-sm text-muted-foreground">{row.original.provinceName[lang]}</span>,
cell: ({ row }) => <span className="text-sm text-muted-foreground">{resolveLocalizedName(row.original.provinceName, lang)}</span>,
},
{
accessorKey: "phoneNumbers",
@@ -4,6 +4,7 @@ import { ActiveStatusCell } from "@/constants";
import { Skeleton } from "@/components/ui/skeleton";
import { Section, InfoRow, MultiLangRow, ViewActions } from "@/components/viewPageComponents";
import { useBranchById, useDeleteBranch } from "@/features/branches/hooks/useBranches";
import { resolveLocalizedName } from "@/features/branches/api/branchesApi";
export function BranchViewPage() {
const { id } = useParams<{ id: string }>();
@@ -22,7 +23,7 @@ export function BranchViewPage() {
<div className="flex items-start justify-between mb-6">
<div>
<h1 className="text-2xl font-bold text-foreground">
{isLoading ? "..." : `${t("branches.viewTitle", "Şahamça giňişleýin")}: ${data?.name[lang] ?? ""}`}
{isLoading ? "..." : `${t("branches.viewTitle", "Şahamça giňişleýin")}: ${resolveLocalizedName(data?.name, lang)}`}
</h1>
</div>
@@ -11,7 +11,7 @@ import { CreateButton } from "@/components/createButton";
import { TableActions } from "@/components/tableActions";
import type { FilterField, ActiveFilter } from "@/components/dataTableToolbar";
import { useDistricts, useDeleteDistrict } from "@/features/districts/hooks/useDistricts";
import type { District } from "@/features/districts/api/districtsApi";
import { type District, resolveDistrictName } from "@/features/districts/api/districtsApi";
export function DistrictsListPage() {
const { t, i18n } = useTranslation();
@@ -64,13 +64,13 @@ export function DistrictsListPage() {
accessorKey: "name",
id: "name",
header: t("districts.fields.name", "ADY").toUpperCase(),
cell: ({ row }) => <span className="text-sm text-foreground">{row.original.name[lang]}</span>,
cell: ({ row }) => <span className="text-sm text-foreground">{resolveDistrictName(row.original.name, lang)}</span>,
},
{
accessorKey: "region",
id: "region",
header: t("districts.fields.region", "REGION").toUpperCase(),
cell: ({ row }) => <span className="text-sm text-muted-foreground">{row.original.region[lang] ?? "—"}</span>,
cell: ({ row }) => <span className="text-sm text-muted-foreground">{resolveDistrictName(row.original.region, lang) || "—"}</span>,
},
{
accessorKey: "active",
@@ -4,6 +4,7 @@ import { ActiveStatusCell } from "@/constants";
import { Skeleton } from "@/components/ui/skeleton";
import { Section, InfoRow, MultiLangRow, ViewActions } from "@/components/viewPageComponents";
import { useDistrictById, useDeleteDistrict } from "@/features/districts/hooks/useDistricts";
import { resolveDistrictName } from "@/features/districts/api/districtsApi";
export function DistrictViewPage() {
const { id } = useParams<{ id: string }>();
@@ -22,7 +23,7 @@ export function DistrictViewPage() {
<div className="flex items-start justify-between mb-6">
<div>
<h1 className="text-2xl font-bold text-foreground">
{isLoading ? "..." : `${t("districts.viewTitle", "Etrap giňişleýin")}: ${data?.name[lang] ?? ""}`}
{isLoading ? "..." : `${t("districts.viewTitle", "Etrap giňişleýin")}: ${resolveDistrictName(data?.name, lang)}`}
</h1>
</div>