added lang param to api
This commit is contained in:
@@ -102,11 +102,12 @@ export function InfoRow({ label, value, children, isLink, href }: InfoRowProps)
|
||||
|
||||
export interface MultiLangRowProps {
|
||||
label: string;
|
||||
value?: { tm?: string; tk?: string; ru?: string; en?: string } | null;
|
||||
value?: { tm?: string; tk?: string; ru?: string; en?: string } | string | null;
|
||||
}
|
||||
|
||||
export function MultiLangRow({ label, value }: MultiLangRowProps) {
|
||||
if (!value) return <InfoRow label={label} value="—" />;
|
||||
if (typeof value === "string") return <InfoRow label={label} value={value} />;
|
||||
|
||||
const langs = [
|
||||
{ code: "TK", val: value.tm ?? value.tk },
|
||||
|
||||
@@ -2,6 +2,12 @@ import { useTranslation } from "react-i18next";
|
||||
import { CheckCircle2, XCircle } from "lucide-react";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { STATUS_ICONS, STATUS_BADGE_VARIANTS, isStatusValue, getStatusLabel } from "@/constants/statusOptions";
|
||||
import {
|
||||
GATEWAY_STATUS_BADGE_VARIANTS,
|
||||
GATEWAY_STATUS_ICONS,
|
||||
getGatewayStatusLabel,
|
||||
isGatewayStatusValue,
|
||||
} from "@/constants/paymentStatus";
|
||||
|
||||
interface StatusCellProps {
|
||||
status: string;
|
||||
@@ -40,3 +46,24 @@ export function ActiveStatusCell({ active, status, labelActive, labelInactive }:
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
interface GatewayStatusCellProps {
|
||||
status?: string | null;
|
||||
}
|
||||
|
||||
export function GatewayStatusCell({ status }: GatewayStatusCellProps) {
|
||||
const { t } = useTranslation();
|
||||
const normalizedStatus = status || "unknown";
|
||||
|
||||
if (isGatewayStatusValue(normalizedStatus)) {
|
||||
return (
|
||||
<StatusBadge
|
||||
label={getGatewayStatusLabel(normalizedStatus, t)}
|
||||
variant={GATEWAY_STATUS_BADGE_VARIANTS[normalizedStatus]}
|
||||
icon={GATEWAY_STATUS_ICONS[normalizedStatus]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return <StatusBadge label={normalizedStatus} variant="default" />;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,11 @@ import { useCreateCardPin, useUpdateCardPin } from "@/features/cardPins/hooks/us
|
||||
import { validateStep, DEFAULT_FORM_VALUES, buildPayload } from "@/features/cardPins/schemas/cardPin.schema";
|
||||
import type { CardPinFormData } from "@/features/cardPins/schemas/cardPin.schema";
|
||||
import { useCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
|
||||
import { resolveCardTypeTitle } from "@/features/cardTypes/api/cardTypesApi";
|
||||
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 { PASSPORT_SERIES_OPTIONS, getStatusOptions } from "@/constants";
|
||||
import { DocumentUpload } from "@/components/documentUpload";
|
||||
import { InfiniteSelect, type InfiniteSelectOption } from "@/components/infiniteSelect";
|
||||
@@ -396,7 +399,7 @@ export function CardPinForm({ mode, initialData }: CardPinFormProps) {
|
||||
() =>
|
||||
(cardTypesData?.paymentCards ?? []).map((ct) => ({
|
||||
value: String(ct.id),
|
||||
label: ct.title[lang] || ct.title.tm,
|
||||
label: resolveCardTypeTitle(ct.title, lang),
|
||||
})),
|
||||
[cardTypesData, lang],
|
||||
);
|
||||
@@ -405,7 +408,7 @@ export function CardPinForm({ mode, initialData }: CardPinFormProps) {
|
||||
() =>
|
||||
(branchesData?.branches ?? []).map((b) => ({
|
||||
value: String(b.id),
|
||||
label: b.name[lang] || b.name.tm,
|
||||
label: resolveLocalizedName(b.name, lang),
|
||||
})),
|
||||
[branchesData, lang],
|
||||
);
|
||||
@@ -413,8 +416,8 @@ export function CardPinForm({ mode, initialData }: CardPinFormProps) {
|
||||
const districtOptions = useMemo(
|
||||
() =>
|
||||
(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),
|
||||
})),
|
||||
[districtsData, lang],
|
||||
);
|
||||
|
||||
@@ -3,14 +3,23 @@ import apiClient from "@/lib/api/client";
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
|
||||
export interface LocalizedTitle {
|
||||
tm: string;
|
||||
ru: string;
|
||||
en: string;
|
||||
tm?: string;
|
||||
ru?: string;
|
||||
en?: string;
|
||||
}
|
||||
|
||||
export type LocalizedReasonTitle = string | LocalizedTitle;
|
||||
|
||||
export function resolveCardReasonTitle(val: LocalizedReasonTitle | null | undefined, lang = "tm"): string {
|
||||
if (!val) return "";
|
||||
if (typeof val === "string") return val;
|
||||
const key = (lang === "tk" ? "tm" : lang) as keyof LocalizedTitle;
|
||||
return val[key] ?? val.tm ?? val.en ?? val.ru ?? "";
|
||||
}
|
||||
|
||||
export interface CardReason {
|
||||
id: number;
|
||||
title: LocalizedTitle;
|
||||
title: LocalizedReasonTitle;
|
||||
price: string;
|
||||
notes: string;
|
||||
active: boolean;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { z } from "zod";
|
||||
import type { CardReason, CreateCardReasonPayload } from "../api/cardReasonsApi";
|
||||
import { resolveCardReasonTitle, type CardReason, type CreateCardReasonPayload } from "../api/cardReasonsApi";
|
||||
|
||||
export function createCardReasonFormSchema(t: (key: string, fallback?: string) => string) {
|
||||
return z.object({
|
||||
@@ -36,9 +36,9 @@ export function buildPayload(data: CardReasonFormData): CreateCardReasonPayload
|
||||
|
||||
export function mapInitial(data: CardReason): CardReasonFormData {
|
||||
return {
|
||||
nameTk: data.title.tm,
|
||||
nameRu: data.title.ru,
|
||||
nameEn: data.title.en,
|
||||
nameTk: resolveCardReasonTitle(data.title, "tm"),
|
||||
nameRu: resolveCardReasonTitle(data.title, "ru"),
|
||||
nameEn: resolveCardReasonTitle(data.title, "en"),
|
||||
price: data.price,
|
||||
notes: data.notes ?? "",
|
||||
active: data.active,
|
||||
|
||||
@@ -3,15 +3,16 @@ import apiClient from "@/lib/api/client";
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
|
||||
export interface LocalizedText {
|
||||
tm: string;
|
||||
ru: string;
|
||||
en: string;
|
||||
tm?: string;
|
||||
ru?: string;
|
||||
en?: string;
|
||||
}
|
||||
|
||||
export function resolveLocalizedName(name: LocalizedText | string | null | undefined, lang = "en"): string {
|
||||
if (!name) return "";
|
||||
if (typeof name === "string") return name;
|
||||
return name[lang as keyof LocalizedText] ?? name.tm ?? name.en ?? name.ru ?? "";
|
||||
const key = (lang === "tk" ? "tm" : lang) as keyof LocalizedText;
|
||||
return name[key] ?? name.tm ?? name.en ?? name.ru ?? "";
|
||||
}
|
||||
|
||||
export type CardRequisiteStatus = "pending" | "approved" | "rejected";
|
||||
@@ -26,12 +27,12 @@ export interface CardRequisiteUser {
|
||||
|
||||
export interface CardRequisiteCardType {
|
||||
id: number;
|
||||
name: LocalizedText;
|
||||
name: LocalizedText | string;
|
||||
}
|
||||
|
||||
export interface CardRequisiteBranch {
|
||||
id: number;
|
||||
name: LocalizedText;
|
||||
name: LocalizedText | string;
|
||||
}
|
||||
|
||||
/** Raw backend entity (GET responses mirror this shape). */
|
||||
|
||||
@@ -11,7 +11,7 @@ import { useCreateCardTransaction, useUpdateCardTransaction } from "../hooks/use
|
||||
import { useInfiniteClients } from "@/features/clients/hooks/useClients";
|
||||
import { useWebSelfLock } from "@/features/shared/hooks/useWebSelfLock";
|
||||
import { useCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
|
||||
import type { LocalizedTitle } from "@/features/cardTypes/api/cardTypesApi";
|
||||
import { resolveCardTypeTitle, type LocalizedTitle } from "@/features/cardTypes/api/cardTypesApi";
|
||||
import { cardTransactionFormSchema, DEFAULT_FORM_VALUES, buildPayload } from "../schemas/cardTransaction.schema";
|
||||
import type { CardTransactionFormData } from "../schemas/cardTransaction.schema";
|
||||
import { MONTH_OPTIONS, CARD_YEAR_OPTIONS } from "@/constants";
|
||||
@@ -74,7 +74,7 @@ export function CardTransactionForm({ mode, initialData }: CardTransactionFormPr
|
||||
const cardTypeOptions = useMemo(() => {
|
||||
const opts = (cardTypesData?.paymentCards ?? []).map((ct) => ({
|
||||
value: String(ct.id),
|
||||
label: ct.title[lang] || ct.title.tm,
|
||||
label: resolveCardTypeTitle(ct.title, lang),
|
||||
}));
|
||||
|
||||
if (initialData?.type && !opts.some((o) => o.value === initialData.type)) {
|
||||
|
||||
@@ -3,15 +3,24 @@ import apiClient from "@/lib/api/client";
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
|
||||
export interface LocalizedTitle {
|
||||
tm: string;
|
||||
ru: string;
|
||||
en: string;
|
||||
tm?: string;
|
||||
ru?: string;
|
||||
en?: string;
|
||||
}
|
||||
|
||||
export type LocalizedCardTypeTitle = string | LocalizedTitle;
|
||||
|
||||
export function resolveCardTypeTitle(val: LocalizedCardTypeTitle | null | undefined, lang = "tm"): string {
|
||||
if (!val) return "";
|
||||
if (typeof val === "string") return val;
|
||||
const key = (lang === "tk" ? "tm" : lang) as keyof LocalizedTitle;
|
||||
return val[key] ?? val.tm ?? val.en ?? val.ru ?? "";
|
||||
}
|
||||
|
||||
export interface CardType {
|
||||
id: number;
|
||||
price: string;
|
||||
title: LocalizedTitle;
|
||||
title: LocalizedCardTypeTitle;
|
||||
notes: string;
|
||||
active: boolean;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { z } from "zod";
|
||||
import type { CardType, CreateCardTypePayload } from "../api/cardTypesApi";
|
||||
import { resolveCardTypeTitle, type CardType, type CreateCardTypePayload } from "../api/cardTypesApi";
|
||||
|
||||
export function createCardTypeFormSchema(t: (key: string, fallback?: string) => string) {
|
||||
return z.object({
|
||||
@@ -36,9 +36,9 @@ export function buildPayload(data: CardTypeFormData): CreateCardTypePayload {
|
||||
|
||||
export function mapInitial(data: CardType): CardTypeFormData {
|
||||
return {
|
||||
nameTk: data.title.tm,
|
||||
nameRu: data.title.ru,
|
||||
nameEn: data.title.en,
|
||||
nameTk: resolveCardTypeTitle(data.title, "tm"),
|
||||
nameRu: resolveCardTypeTitle(data.title, "ru"),
|
||||
nameEn: resolveCardTypeTitle(data.title, "en"),
|
||||
price: data.price,
|
||||
notes: data.notes ?? "",
|
||||
active: data.active,
|
||||
|
||||
@@ -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 LocalizedDistrictField = string | LocalizedText;
|
||||
|
||||
export function resolveDistrictName(val: LocalizedDistrictField | 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 ?? "";
|
||||
}
|
||||
|
||||
// ─── District (Province) ──────────────────────────────────────────────────────
|
||||
|
||||
export interface District {
|
||||
id: number;
|
||||
name: LocalizedText;
|
||||
region: LocalizedText;
|
||||
name: LocalizedDistrictField;
|
||||
region: LocalizedDistrictField;
|
||||
active: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { FormActions } from "@/components/formActions";
|
||||
import { MultiLangInput } from "@/components/multiLangInput";
|
||||
import { BentoGrid, BentoCard } from "@/components/bento";
|
||||
import type { District } from "../api/districtsApi";
|
||||
import { resolveDistrictName, type District } from "../api/districtsApi";
|
||||
import { useCreateDistrict, useUpdateDistrict } from "../hooks/useDistricts";
|
||||
import { createDistrictFormSchema, DEFAULT_FORM_VALUES, buildPayload } from "../schemas/district.schema";
|
||||
import type { DistrictFormData } from "../schemas/district.schema";
|
||||
@@ -30,12 +30,12 @@ export interface DistrictFormProps {
|
||||
|
||||
function mapInitial(data: District): DistrictFormData {
|
||||
return {
|
||||
nameTk: data.name.tm,
|
||||
nameRu: data.name.ru,
|
||||
nameEn: data.name.en,
|
||||
regionTk: data.region.tm,
|
||||
regionRu: data.region.ru,
|
||||
regionEn: data.region.en,
|
||||
nameTk: resolveDistrictName(data.name, "tm"),
|
||||
nameRu: resolveDistrictName(data.name, "ru"),
|
||||
nameEn: resolveDistrictName(data.name, "en"),
|
||||
regionTk: resolveDistrictName(data.region, "tm"),
|
||||
regionRu: resolveDistrictName(data.region, "ru"),
|
||||
regionEn: resolveDistrictName(data.region, "en"),
|
||||
isActive: data.active,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,19 +3,28 @@ 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 LocalizedLoanField = string | LocalizedText;
|
||||
|
||||
export function resolveLoanText(val: LocalizedLoanField | 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 ?? "";
|
||||
}
|
||||
|
||||
// ─── Loan Type ────────────────────────────────────────────────────────────────
|
||||
|
||||
export interface LoanType {
|
||||
id: number;
|
||||
title: LocalizedText;
|
||||
title: LocalizedLoanField;
|
||||
tax: number;
|
||||
loanTerm: string;
|
||||
content: LocalizedText;
|
||||
content: LocalizedLoanField;
|
||||
active: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
|
||||
@@ -10,7 +10,7 @@ import { MultiLangInput } from "@/components/multiLangInput";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { BentoGrid, BentoCard } from "@/components/bento";
|
||||
import { useCreateLoanType, useUpdateLoanType } from "../hooks/useLoanTypes";
|
||||
import type { LoanType } from "../api/loanTypesApi";
|
||||
import { resolveLoanText, type LoanType } from "../api/loanTypesApi";
|
||||
import { createLoanTypeFormSchema, DEFAULT_FORM_VALUES, buildPayload } from "../schemas/loanType.schema";
|
||||
import type { LoanTypeFormData } from "../schemas/loanType.schema";
|
||||
|
||||
@@ -36,12 +36,12 @@ function flattenErrors(errors: Record<string, { message?: string } | undefined>)
|
||||
|
||||
function mapInitial(data: LoanType): LoanTypeFormData {
|
||||
return {
|
||||
nameTk: data.title.tm,
|
||||
nameRu: data.title.ru,
|
||||
nameEn: data.title.en,
|
||||
notesTk: data.content.tm ?? "",
|
||||
notesRu: data.content.ru ?? "",
|
||||
notesEn: data.content.en ?? "",
|
||||
nameTk: resolveLoanText(data.title, "tm"),
|
||||
nameRu: resolveLoanText(data.title, "ru"),
|
||||
nameEn: resolveLoanText(data.title, "en"),
|
||||
notesTk: resolveLoanText(data.content, "tm"),
|
||||
notesRu: resolveLoanText(data.content, "ru"),
|
||||
notesEn: resolveLoanText(data.content, "en"),
|
||||
tax: String(data.tax),
|
||||
loanTerm: data.loanTerm,
|
||||
isActive: data.active,
|
||||
|
||||
@@ -67,6 +67,32 @@ export interface OnlinePaymentListResponse {
|
||||
export interface GatewayResponse {
|
||||
errorCode?: string;
|
||||
errorMessage?: string;
|
||||
actionCode?: number;
|
||||
actionCodeDescription?: string;
|
||||
orderStatus?: number;
|
||||
currency?: string;
|
||||
amount?: number;
|
||||
date?: number;
|
||||
ip?: string;
|
||||
terminalId?: string;
|
||||
orderNumber?: string;
|
||||
bankInfo?: {
|
||||
bankCountryCode?: string;
|
||||
bankCountryName?: string;
|
||||
};
|
||||
cardAuthInfo?: {
|
||||
pan?: string;
|
||||
expiration?: string;
|
||||
approvalCode?: string;
|
||||
cardholderName?: string;
|
||||
};
|
||||
paymentAmountInfo?: {
|
||||
paymentState?: string;
|
||||
approvedAmount?: number;
|
||||
refundedAmount?: number;
|
||||
depositedAmount?: number;
|
||||
};
|
||||
attributes?: Array<{ name?: string; value?: string }>;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
@@ -89,10 +115,18 @@ export interface OnlinePaymentDetail {
|
||||
amountMinor?: number;
|
||||
amountUsd?: number;
|
||||
exchangeRateUsd?: number;
|
||||
cardholderName?: string;
|
||||
paymentPeriod?: string;
|
||||
gatewayStatus: string;
|
||||
gatewayReference?: string;
|
||||
apiClient?: string;
|
||||
apiClientName?: string;
|
||||
description?: string;
|
||||
maskedPan?: string;
|
||||
callbackStatus?: string;
|
||||
callbackAt?: string;
|
||||
formUrl?: string;
|
||||
successUrl?: string;
|
||||
createdById?: number;
|
||||
createdByName?: string;
|
||||
createdAt: string;
|
||||
@@ -142,9 +176,13 @@ export async function fetchOnlinePayments(params: OnlinePaymentListParams = {}):
|
||||
* GET /payment-history/:id
|
||||
* Returns the step-by-step history log for a single payment order.
|
||||
*/
|
||||
export async function fetchOnlinePaymentById(id: number): Promise<PaymentHistoryStep[]> {
|
||||
const { data } = await apiClient.get<PaymentHistoryStep[]>(`/payment-history/${id}`);
|
||||
return data;
|
||||
export async function fetchOnlinePaymentById(id: number): Promise<any[]> {
|
||||
const { data } = await apiClient.get<any>(`/payment-history/${id}`);
|
||||
if (Array.isArray(data)) return data;
|
||||
if (data && Array.isArray(data.data)) return data.data;
|
||||
if (data && Array.isArray(data.items)) return data.items;
|
||||
if (data && typeof data === "object") return [data];
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,13 +201,14 @@ export async function fetchOnlinePaymentDetail(id: number | string): Promise<Onl
|
||||
*/
|
||||
export async function fetchOrderPaymentHistory(
|
||||
orderId: number | string,
|
||||
params: { page?: number; limit?: number } = {},
|
||||
params: { page?: number; limit?: number; lang?: string } = {},
|
||||
): Promise<OnlinePaymentListResponse> {
|
||||
const { page, limit } = params;
|
||||
const { page, limit, lang } = params;
|
||||
const { data } = await apiClient.get<any>(`/payment-history/${orderId}`, {
|
||||
params: {
|
||||
page: page ?? 1,
|
||||
limit: limit ?? 25,
|
||||
...(page !== undefined ? { page } : {}),
|
||||
...(limit !== undefined ? { limit } : {}),
|
||||
lang: lang ?? "tm",
|
||||
},
|
||||
});
|
||||
|
||||
@@ -179,6 +218,9 @@ export async function fetchOrderPaymentHistory(
|
||||
if (data && Array.isArray(data.items)) {
|
||||
return { count: data.count ?? data.items.length, items: data.items };
|
||||
}
|
||||
if (data && Array.isArray(data.data)) {
|
||||
return { count: data.data.length, items: data.data };
|
||||
}
|
||||
return { count: 0, items: [] };
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,10 @@ export function useGetOnlinePaymentDetail(id: number | string) {
|
||||
/**
|
||||
* Fetches the paginated payment history for a specific order /payment-history/:id
|
||||
*/
|
||||
export function useGetOrderPaymentHistory(orderId: number | string | undefined, params: { page?: number; limit?: number } = {}) {
|
||||
export function useGetOrderPaymentHistory(
|
||||
orderId: number | string | undefined,
|
||||
params: { page?: number; limit?: number; lang?: string } = {},
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: onlinePaymentKeys.orderHistory(orderId ?? "", params),
|
||||
queryFn: () => fetchOrderPaymentHistory(orderId!, params),
|
||||
|
||||
@@ -18,9 +18,13 @@ import { useCreateCard, useUpdateCard } from "../hooks/useOrderNewCard";
|
||||
import { validateStep, DEFAULT_FORM_VALUES, buildPayload } from "../schemas/orderNewCard.schema";
|
||||
import type { OrderNewCardFormData } from "../schemas/orderNewCard.schema";
|
||||
import { useCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
|
||||
import { resolveCardTypeTitle } from "@/features/cardTypes/api/cardTypesApi";
|
||||
import { useCardReasons } from "@/features/cardReasons/hooks/useCardReasons";
|
||||
import { resolveCardReasonTitle } from "@/features/cardReasons/api/cardReasonsApi";
|
||||
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 { useInfiniteClients } from "@/features/clients/hooks/useClients";
|
||||
import { useWebSelfLock } from "@/features/shared/hooks/useWebSelfLock";
|
||||
import { PASSPORT_SERIES_OPTIONS, getStatusOptions } from "@/constants";
|
||||
@@ -530,7 +534,7 @@ export function CardOrderForm({ mode, initialData }: CardOrderFormProps) {
|
||||
() =>
|
||||
(cardTypesData?.paymentCards ?? []).map((ct) => ({
|
||||
value: String(ct.id),
|
||||
label: ct.title[lang] || ct.title.tm,
|
||||
label: resolveCardTypeTitle(ct.title, lang),
|
||||
})),
|
||||
[cardTypesData, lang],
|
||||
);
|
||||
@@ -539,7 +543,7 @@ export function CardOrderForm({ mode, initialData }: CardOrderFormProps) {
|
||||
() =>
|
||||
(cardReasonsData?.reasonCards ?? []).map((cr) => ({
|
||||
value: String(cr.id),
|
||||
label: cr.title[lang] || cr.title.tm,
|
||||
label: resolveCardReasonTitle(cr.title, lang),
|
||||
})),
|
||||
[cardReasonsData, lang],
|
||||
);
|
||||
@@ -548,7 +552,7 @@ export function CardOrderForm({ mode, initialData }: CardOrderFormProps) {
|
||||
() =>
|
||||
(branchesData?.branches ?? []).map((b) => ({
|
||||
value: String(b.id),
|
||||
label: b.name[lang] || b.name.tm,
|
||||
label: resolveLocalizedName(b.name, lang),
|
||||
})),
|
||||
[branchesData, lang],
|
||||
);
|
||||
@@ -556,8 +560,8 @@ export function CardOrderForm({ mode, initialData }: CardOrderFormProps) {
|
||||
const districtOptions = useMemo(
|
||||
() =>
|
||||
(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),
|
||||
})),
|
||||
[districtsData, lang],
|
||||
);
|
||||
|
||||
@@ -15,7 +15,7 @@ import { useInfiniteUsers } from "@/features/allUsers/hooks/useAllUsers";
|
||||
import { useInfiniteRoles } from "@/features/roles/hooks/useRoles";
|
||||
import { useInfiniteBranches } from "@/features/shared/hooks/useSharedBranchUsers";
|
||||
import { useAssignRoleToUser, useAssignBranchToUser } from "@/features/shared/hooks/useSharedUserAssignments";
|
||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||
import { resolveLocalizedName } from "@/features/branches/api/branchesApi";
|
||||
|
||||
export type AssignDialogKind = "role" | "branch";
|
||||
|
||||
@@ -39,7 +39,7 @@ const ASSIGN_DIALOG_FIELD_LABELS: Record<AssignDialogKind, string> = {
|
||||
|
||||
export function AssignDialog({ kind, onClose, targetUserId, targetUserName, onAssigned }: AssignDialogProps) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const lang = (i18n.language === "ru" ? "ru" : i18n.language === "en" ? "en" : "tm") as keyof LocalizedText;
|
||||
const lang = (i18n.language === "ru" ? "ru" : i18n.language === "en" ? "en" : "tm") as "tm" | "ru" | "en";
|
||||
const [targetSearch, setTargetSearch] = useState("");
|
||||
const [targetValue, setTargetValue] = useState(() => (targetUserId ? String(targetUserId) : ""));
|
||||
const [resourceSearch, setResourceSearch] = useState("");
|
||||
@@ -76,7 +76,7 @@ export function AssignDialog({ kind, onClose, targetUserId, targetUserName, onAs
|
||||
.flatMap((page) => page?.branches ?? [])
|
||||
.map((branch) => ({
|
||||
value: String(branch.id),
|
||||
label: branch.name?.[lang] || branch.name?.tm || branch.name?.en || branch.name?.ru || branch.uniqueCode || String(branch.id),
|
||||
label: resolveLocalizedName(branch.name, lang) || branch.uniqueCode || String(branch.id),
|
||||
}));
|
||||
}, [kind, rolesQuery.data, branchesQuery.data, lang]);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type React from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Database, AlertTriangle, Eye } from "lucide-react";
|
||||
import { Database, AlertTriangle, Eye, ExternalLink } from "lucide-react";
|
||||
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from "@/components/ui/dialog";
|
||||
@@ -28,20 +29,18 @@ export function PaymentDetailDialog({ paymentId, open, onOpenChange }: PaymentDe
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="sm:max-w-2xl max-h-[85vh] overflow-y-auto">
|
||||
<DialogContent className="sm:max-w-lg max-h-[85vh] overflow-y-auto">
|
||||
<DialogHeader>
|
||||
<div className="flex items-center justify-between gap-3 pr-6">
|
||||
<div className="flex items-center gap-2">
|
||||
<Database className="size-5 text-primary" />
|
||||
<DialogTitle className="text-base font-semibold">
|
||||
{t("onlinePayments.paymentViewTitle", "Töleg maglumaty")}: #{paymentId}
|
||||
</DialogTitle>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 pr-6 flex-wrap">
|
||||
<Database className="size-5 text-primary shrink-0" />
|
||||
<DialogTitle className="text-base font-semibold">
|
||||
{t("onlinePayments.paymentViewTitle", "Töleg maglumaty")}: #{paymentId}
|
||||
</DialogTitle>
|
||||
{data && (
|
||||
<div className="flex items-center gap-2">
|
||||
<>
|
||||
<GatewayStatusBadge status={data.gatewayStatus} />
|
||||
<PaidBadge paid={data.paid} />
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{data?.orderNumber && (
|
||||
@@ -52,21 +51,19 @@ export function PaymentDetailDialog({ paymentId, open, onOpenChange }: PaymentDe
|
||||
</DialogHeader>
|
||||
|
||||
{isLoading ? (
|
||||
<div className="space-y-4 py-2">
|
||||
<Skeleton className="h-6 w-1/2" />
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<Skeleton className="h-24 w-full rounded-lg" />
|
||||
<Skeleton className="h-24 w-full rounded-lg" />
|
||||
</div>
|
||||
<div className="space-y-3 py-2">
|
||||
<Skeleton className="h-6 w-1/3" />
|
||||
<Skeleton className="h-4 w-1/2" />
|
||||
<Skeleton className="h-28 w-full rounded-lg" />
|
||||
<Skeleton className="h-28 w-full rounded-lg" />
|
||||
</div>
|
||||
) : isError || !data ? (
|
||||
<div className="py-8 text-center text-sm text-destructive">{t("common.error", "Maglumat ýüklenende ýalňyşlyk ýüze çykdy")}</div>
|
||||
) : (
|
||||
<div className="space-y-4 text-xs">
|
||||
{/* Gateway Response Alert if Error */}
|
||||
<div className="space-y-3 text-xs">
|
||||
{/* Gateway error alert */}
|
||||
{data.gatewayResponse && (data.gatewayResponse.errorCode || data.gatewayResponse.errorMessage) && (
|
||||
<div className="flex items-start gap-2.5 p-3 rounded-lg border border-destructive/30 bg-destructive/10 text-destructive text-xs">
|
||||
<div className="flex items-start gap-2.5 p-3 rounded-lg border border-destructive/30 bg-destructive/10 text-destructive">
|
||||
<AlertTriangle className="size-4 shrink-0 mt-0.5" />
|
||||
<div className="space-y-0.5">
|
||||
<div className="font-semibold">
|
||||
@@ -77,122 +74,105 @@ export function PaymentDetailDialog({ paymentId, open, onOpenChange }: PaymentDe
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Grid 1: General Info */}
|
||||
{/* Section 1: General */}
|
||||
<div className="rounded-lg border border-border p-3 space-y-2 bg-muted/10">
|
||||
<p className="font-semibold text-muted-foreground uppercase text-[11px] tracking-wide">
|
||||
{t("onlinePayments.sectionGeneral", "Esasy maglumatlar")}
|
||||
</p>
|
||||
<div className="grid grid-cols-2 gap-x-4 gap-y-2">
|
||||
<div>
|
||||
<span className="text-muted-foreground block">{t("common.id", "ID")}</span>
|
||||
<span className="font-mono font-medium text-foreground">{data.id}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-muted-foreground block">{t("onlinePayments.columns.orderId", "Sargyt ID")}</span>
|
||||
<div className="space-y-1.5">
|
||||
<Row label={t("common.id", "ID")}>
|
||||
<span className="font-mono font-medium">{data.id}</span>
|
||||
</Row>
|
||||
<Row label={t("onlinePayments.columns.orderId", "Sargyt ID")}>
|
||||
<Link to={`/visa-master/${data.orderId}`} className="font-mono text-primary hover:underline">
|
||||
#{data.orderId}
|
||||
</Link>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-muted-foreground block">{t("onlinePayments.columns.orderNumber", "Sargyt belgisi")}</span>
|
||||
<span className="font-mono text-foreground">{data.orderNumber || "—"}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-muted-foreground block">{t("onlinePayments.columns.type", "Görnüşi")}</span>
|
||||
<span className="uppercase font-medium text-foreground">{data.type}</span>
|
||||
</div>
|
||||
</Row>
|
||||
<Row label={t("onlinePayments.columns.orderNumber", "Sargyt belgisi")}>
|
||||
<span className="font-mono">{data.orderNumber || "—"}</span>
|
||||
</Row>
|
||||
<Row label={t("onlinePayments.columns.type", "Görnüşi")}>
|
||||
<span className="uppercase font-medium">{data.type}</span>
|
||||
</Row>
|
||||
{data.description && (
|
||||
<div className="col-span-2">
|
||||
<span className="text-muted-foreground block">{t("onlinePayments.columns.description", "Düşündiriş")}</span>
|
||||
<span className="text-foreground">{data.description}</span>
|
||||
</div>
|
||||
<Row label={t("onlinePayments.columns.description", "Düşündiriş")}>
|
||||
<span>{data.description}</span>
|
||||
</Row>
|
||||
)}
|
||||
<div>
|
||||
<span className="text-muted-foreground block">{t("onlinePayments.columns.createdAt", "Döredilen wagty")}</span>
|
||||
<span className="text-foreground">{formatFromApiDate(data.createdAt)}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-muted-foreground block">{t("onlinePayments.columns.updatedAt", "Täzelenen wagty")}</span>
|
||||
<span className="text-foreground">{formatFromApiDate(data.updatedAt)}</span>
|
||||
</div>
|
||||
<Row label={t("onlinePayments.columns.createdAt", "Döredilen wagty")}>
|
||||
<span>{formatFromApiDate(data.createdAt)}</span>
|
||||
</Row>
|
||||
<Row label={t("onlinePayments.columns.updatedAt", "Täzelenen wagty")}>
|
||||
<span>{formatFromApiDate(data.updatedAt)}</span>
|
||||
</Row>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Grid 2: Financial Info */}
|
||||
{/* Section 2: Financial */}
|
||||
<div className="rounded-lg border border-border p-3 space-y-2 bg-muted/10">
|
||||
<p className="font-semibold text-muted-foreground uppercase text-[11px] tracking-wide">
|
||||
{t("onlinePayments.sectionFinancial", "Maliýe maglumatlary")}
|
||||
</p>
|
||||
<div className="grid grid-cols-2 gap-x-4 gap-y-2">
|
||||
<div>
|
||||
<span className="text-muted-foreground block">{t("onlinePayments.columns.amountTmt", "Töleg möçberi")}</span>
|
||||
<span className="font-medium text-foreground">{data.amountTmt?.toLocaleString?.() ?? data.amountTmt} TMT</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-muted-foreground block">{t("onlinePayments.columns.totalAmount", "Jemi töleg möçberi")}</span>
|
||||
<div className="space-y-1.5">
|
||||
<Row label={t("onlinePayments.columns.amountTmt", "Töleg möçberi")}>
|
||||
<span className="font-medium">{data.amountTmt?.toLocaleString?.() ?? data.amountTmt} TMT</span>
|
||||
</Row>
|
||||
<Row label={t("onlinePayments.columns.totalAmount", "Jemi töleg möçberi")}>
|
||||
<span className="font-semibold text-primary">{data.totalAmountTmt?.toLocaleString?.() ?? data.totalAmountTmt} TMT</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-muted-foreground block">{t("onlinePayments.columns.bankFeeTmt", "Bank komissiýasy")}</span>
|
||||
<span className="text-foreground">{data.bankFeeTmt?.toLocaleString?.() ?? data.bankFeeTmt} TMT</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-muted-foreground block">{t("onlinePayments.columns.gbusFeeTmt", "GBUS komissiýasy")}</span>
|
||||
<span className="text-foreground">{data.gbusFeeTmt?.toLocaleString?.() ?? data.gbusFeeTmt} TMT</span>
|
||||
</div>
|
||||
</Row>
|
||||
<Row label={t("onlinePayments.columns.bankFeeTmt", "Bank komissiýasy")}>
|
||||
<span>{data.bankFeeTmt?.toLocaleString?.() ?? data.bankFeeTmt} TMT</span>
|
||||
</Row>
|
||||
<Row label={t("onlinePayments.columns.gbusFeeTmt", "GBUS komissiýasy")}>
|
||||
<span>{data.gbusFeeTmt?.toLocaleString?.() ?? data.gbusFeeTmt} TMT</span>
|
||||
</Row>
|
||||
{data.amountUsd != null && (
|
||||
<div>
|
||||
<span className="text-muted-foreground block">{t("onlinePayments.columns.amountUsd", "Möçber (USD)")}</span>
|
||||
<span className="text-foreground">{data.amountUsd} $</span>
|
||||
</div>
|
||||
<Row label={t("onlinePayments.columns.amountUsd", "Möçber (USD)")}>
|
||||
<span>{data.amountUsd} $</span>
|
||||
</Row>
|
||||
)}
|
||||
{data.exchangeRateUsd != null && (
|
||||
<div>
|
||||
<span className="text-muted-foreground block">{t("onlinePayments.columns.exchangeRateUsd", "Hümmet (USD)")}</span>
|
||||
<span className="text-foreground">{data.exchangeRateUsd} TMT</span>
|
||||
</div>
|
||||
<Row label={t("onlinePayments.columns.exchangeRateUsd", "Hümmet (USD)")}>
|
||||
<span>{data.exchangeRateUsd} TMT</span>
|
||||
</Row>
|
||||
)}
|
||||
{data.paymentPeriod && (
|
||||
<div>
|
||||
<span className="text-muted-foreground block">{t("onlinePayments.columns.paymentPeriod", "Töleg döwri")}</span>
|
||||
<span className="text-foreground">{formatFromApiDate(data.paymentPeriod)}</span>
|
||||
</div>
|
||||
<Row label={t("onlinePayments.columns.paymentPeriod", "Töleg döwri")}>
|
||||
<span>{formatFromApiDate(data.paymentPeriod)}</span>
|
||||
</Row>
|
||||
)}
|
||||
{data.apiClient && (
|
||||
<div>
|
||||
<span className="text-muted-foreground block">{t("onlinePayments.columns.apiClient", "API Client")}</span>
|
||||
<span className="font-mono text-foreground">{data.apiClient}</span>
|
||||
</div>
|
||||
<Row label={t("onlinePayments.columns.apiClient", "API Client")}>
|
||||
<span className="font-mono">{data.apiClient}</span>
|
||||
</Row>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Grid 3: Customer & Branch */}
|
||||
{/* Section 3: Customer & Branch */}
|
||||
<div className="rounded-lg border border-border p-3 space-y-2 bg-muted/10">
|
||||
<p className="font-semibold text-muted-foreground uppercase text-[11px] tracking-wide">
|
||||
{t("onlinePayments.sectionCustomer", "Müşderi we Şahamça")}
|
||||
</p>
|
||||
<div className="grid grid-cols-2 gap-x-4 gap-y-2">
|
||||
<div>
|
||||
<span className="text-muted-foreground block">{t("onlinePayments.columns.passport", "Müşderi")}</span>
|
||||
<span className="font-medium text-foreground">
|
||||
{[data.passportName, data.passportSurname].filter(Boolean).join(" ") || "—"}
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-muted-foreground block">{t("onlinePayments.columns.userId", "Ulanyjy ID")}</span>
|
||||
<div className="space-y-1.5">
|
||||
<Row label={t("onlinePayments.columns.passport", "Müşderi")}>
|
||||
<span className="font-medium">{[data.passportName, data.passportSurname].filter(Boolean).join(" ") || "—"}</span>
|
||||
</Row>
|
||||
<Row label={t("onlinePayments.columns.userId", "Ulanyjy ID")}>
|
||||
<Link to={`/all-users/${data.userId}`} className="font-mono text-primary hover:underline">
|
||||
#{data.userId}
|
||||
</Link>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-muted-foreground block">{t("onlinePayments.columns.branch", "Şahamça")}</span>
|
||||
<span className="text-foreground">{data.branchName?.[lang] || data.branchName?.tm || data.branchName?.en || "—"}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-muted-foreground block">{t("onlinePayments.columns.createdByName", "Döreden işgär")}</span>
|
||||
<span className="text-foreground">{data.createdByName || "—"}</span>
|
||||
</div>
|
||||
</Row>
|
||||
<Row label={t("onlinePayments.columns.branch", "Şahamça")}>
|
||||
<span>
|
||||
{(typeof data.branchName === "string"
|
||||
? data.branchName
|
||||
: data.branchName?.[lang] || data.branchName?.tm || data.branchName?.en) || "—"}
|
||||
</span>
|
||||
</Row>
|
||||
<Row label={t("onlinePayments.columns.createdByName", "Döreden işgär")}>
|
||||
<span>{data.createdByName || "—"}</span>
|
||||
</Row>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -202,57 +182,276 @@ export function PaymentDetailDialog({ paymentId, open, onOpenChange }: PaymentDe
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Shared Row helper ────────────────────────────────────────────────────────
|
||||
|
||||
function Row({ label, children }: { label: string; children: React.ReactNode }) {
|
||||
return (
|
||||
<div className="flex gap-2 text-xs">
|
||||
<span className="text-muted-foreground font-medium min-w-[130px] shrink-0">{label}</span>
|
||||
<span className="text-foreground break-all">{children}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ─── LastStepDialog ───────────────────────────────────────────────────────────
|
||||
|
||||
interface LastStepDialogProps {
|
||||
/** The order ID (row.original.orderId) used to fetch the step history. */
|
||||
export interface LastStepDialogProps {
|
||||
/** The ID used to fetch the step history from /payment-history/:id. */
|
||||
orderId: number | null;
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a dialog showing only the most recent payment history step
|
||||
* Opens a dialog showing only the most recent payment history step / operation
|
||||
* for the given order. Used by the Eye icon in PaymentHistoryTable.
|
||||
* Fetches its own data independently via useGetOnlinePaymentById (/payment-history/:id).
|
||||
*/
|
||||
export function LastStepDialog({ orderId, open, onOpenChange }: LastStepDialogProps) {
|
||||
const { t } = useTranslation();
|
||||
const { data: steps, isLoading } = useGetOnlinePaymentById(orderId ?? 0);
|
||||
const { t, i18n } = useTranslation();
|
||||
const lang = resolveLang(i18n.language);
|
||||
const { data: rawSteps, isLoading, isError } = useGetOnlinePaymentById(orderId ?? 0);
|
||||
|
||||
// The "last" step is the one with the highest createdAt (or last element if already sorted desc).
|
||||
const lastStep = steps?.length ? [...steps].sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())[0] : null;
|
||||
const steps: any[] = Array.isArray(rawSteps)
|
||||
? rawSteps
|
||||
: (rawSteps as any)?.data && Array.isArray((rawSteps as any).data)
|
||||
? (rawSteps as any).data
|
||||
: (rawSteps as any)?.items && Array.isArray((rawSteps as any).items)
|
||||
? (rawSteps as any).items
|
||||
: rawSteps && typeof rawSteps === "object" && (rawSteps as any).id
|
||||
? [rawSteps]
|
||||
: [];
|
||||
|
||||
const lastStep = steps.length
|
||||
? [...steps].sort((a, b) => new Date(b.createdAt || 0).getTime() - new Date(a.createdAt || 0).getTime())[0]
|
||||
: null;
|
||||
|
||||
const branchDisplay =
|
||||
typeof lastStep?.branchName === "string"
|
||||
? lastStep.branchName
|
||||
: lastStep?.branchName?.[lang] || lastStep?.branchName?.tm || lastStep?.branchName?.en || null;
|
||||
|
||||
const fullName = [lastStep?.passportName, lastStep?.passportSurname].filter(Boolean).join(" ");
|
||||
const detailEntries = Object.entries(lastStep?.detail ?? {});
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="sm:max-w-lg max-h-[80vh] overflow-y-auto">
|
||||
<DialogContent className="sm:max-w-lg max-h-[85vh] overflow-y-auto">
|
||||
<DialogHeader>
|
||||
<div className="flex items-center gap-2">
|
||||
<Eye className="size-5 text-primary" />
|
||||
<div className="flex items-center gap-2 pr-6 flex-wrap">
|
||||
<Eye className="size-5 text-primary shrink-0" />
|
||||
<DialogTitle className="text-base font-semibold">{t("onlinePayments.lastStep.title", "Iň soňky işlem")}</DialogTitle>
|
||||
{lastStep && (
|
||||
<>
|
||||
{(lastStep.gatewayStatus || lastStep.step) && <GatewayStatusBadge status={lastStep.gatewayStatus || lastStep.step} />}
|
||||
{typeof lastStep.paid === "boolean" && <PaidBadge paid={lastStep.paid} />}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{orderId && <DialogDescription className="text-xs">Order #{orderId}</DialogDescription>}
|
||||
{(lastStep?.orderNumber || lastStep?.orderId || orderId) && (
|
||||
<DialogDescription className="text-xs">
|
||||
{t("onlinePayments.columns.orderNumber", "Sargyt belgisi")}:{" "}
|
||||
{lastStep?.orderNumber || `Order #${lastStep?.orderId || orderId}`}
|
||||
</DialogDescription>
|
||||
)}
|
||||
</DialogHeader>
|
||||
|
||||
{isLoading ? (
|
||||
<div className="space-y-3 py-2">
|
||||
<Skeleton className="h-6 w-1/3" />
|
||||
<Skeleton className="h-4 w-1/2" />
|
||||
<Skeleton className="h-24 w-full rounded-lg" />
|
||||
<Skeleton className="h-28 w-full rounded-lg" />
|
||||
<Skeleton className="h-28 w-full rounded-lg" />
|
||||
</div>
|
||||
) : !lastStep ? (
|
||||
) : isError || !lastStep ? (
|
||||
<div className="py-8 text-center text-sm text-muted-foreground">{t("onlinePayments.noHistory", "Töleg taryhy tapylmady")}</div>
|
||||
) : (
|
||||
<div className="space-y-4 text-xs">
|
||||
{/* Step header: status badge + time + operator */}
|
||||
<div className="flex flex-wrap items-center gap-3 px-1">
|
||||
<GatewayStatusBadge status={lastStep.step} />
|
||||
<span className="text-muted-foreground whitespace-nowrap">{formatFromApiDate(lastStep.createdAt)}</span>
|
||||
{lastStep.createdByName && <span className="text-muted-foreground">{lastStep.createdByName}</span>}
|
||||
<div className="space-y-3 text-xs">
|
||||
{/* Section 1: General */}
|
||||
<div className="rounded-lg border border-border p-3 space-y-2 bg-muted/10">
|
||||
<p className="font-semibold text-muted-foreground uppercase text-[11px] tracking-wide">
|
||||
{t("onlinePayments.sectionGeneral", "Esasy maglumatlar")}
|
||||
</p>
|
||||
<div className="space-y-1.5">
|
||||
{lastStep.id != null && (
|
||||
<Row label={t("common.id", "ID")}>
|
||||
<span className="font-mono font-medium">{lastStep.id}</span>
|
||||
</Row>
|
||||
)}
|
||||
{lastStep.orderId != null && (
|
||||
<Row label={t("onlinePayments.columns.orderId", "Sargyt ID")}>
|
||||
<Link to={`/visa-master/${lastStep.orderId}`} className="font-mono text-primary hover:underline">
|
||||
#{lastStep.orderId}
|
||||
</Link>
|
||||
</Row>
|
||||
)}
|
||||
{lastStep.orderNumber && (
|
||||
<Row label={t("onlinePayments.columns.orderNumber", "Sargyt belgisi")}>
|
||||
<span className="font-mono">{lastStep.orderNumber}</span>
|
||||
</Row>
|
||||
)}
|
||||
{lastStep.type && (
|
||||
<Row label={t("onlinePayments.columns.type", "Görnüşi")}>
|
||||
<span className="uppercase font-medium">{lastStep.type}</span>
|
||||
</Row>
|
||||
)}
|
||||
{lastStep.description && (
|
||||
<Row label={t("onlinePayments.columns.description", "Düşündiriş")}>
|
||||
<span>{lastStep.description}</span>
|
||||
</Row>
|
||||
)}
|
||||
{lastStep.gatewayReference && (
|
||||
<Row label={t("onlinePayments.columns.gatewayReference", "Gateway Ref")}>
|
||||
<span className="font-mono text-[11px] break-all">{lastStep.gatewayReference}</span>
|
||||
</Row>
|
||||
)}
|
||||
{(lastStep.apiClientName || lastStep.apiClient) && (
|
||||
<Row label={t("onlinePayments.columns.apiClient", "API Client")}>
|
||||
<span className="font-mono">{lastStep.apiClientName || lastStep.apiClient}</span>
|
||||
</Row>
|
||||
)}
|
||||
{lastStep.callbackStatus && (
|
||||
<Row label={t("onlinePayments.columns.callbackStatus", "Callback ýagdaýy")}>
|
||||
<span className="uppercase font-medium">{lastStep.callbackStatus}</span>
|
||||
</Row>
|
||||
)}
|
||||
{lastStep.createdAt && (
|
||||
<Row label={t("onlinePayments.columns.createdAt", "Döredilen wagty")}>
|
||||
<span>{formatFromApiDate(lastStep.createdAt)}</span>
|
||||
</Row>
|
||||
)}
|
||||
{lastStep.callbackAt && (
|
||||
<Row label={t("onlinePayments.columns.callbackAt", "Callback wagty")}>
|
||||
<span>{formatFromApiDate(lastStep.callbackAt)}</span>
|
||||
</Row>
|
||||
)}
|
||||
{lastStep.updatedAt && (
|
||||
<Row label={t("onlinePayments.columns.updatedAt", "Täzelenen wagty")}>
|
||||
<span>{formatFromApiDate(lastStep.updatedAt)}</span>
|
||||
</Row>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Detail key-value grid */}
|
||||
{/* Section 2: Financial */}
|
||||
{(lastStep.amountTmt != null || lastStep.totalAmountTmt != null || lastStep.amountUsd != null) && (
|
||||
<div className="rounded-lg border border-border p-3 space-y-2 bg-muted/10">
|
||||
<p className="font-semibold text-muted-foreground uppercase text-[11px] tracking-wide">
|
||||
{t("onlinePayments.sectionFinancial", "Maliýe maglumatlary")}
|
||||
</p>
|
||||
<div className="space-y-1.5">
|
||||
{lastStep.totalAmountTmt != null && (
|
||||
<Row label={t("onlinePayments.columns.totalAmount", "Jemi töleg möçberi")}>
|
||||
<span className="font-semibold text-primary">
|
||||
{lastStep.totalAmountTmt?.toLocaleString?.() ?? lastStep.totalAmountTmt} TMT
|
||||
</span>
|
||||
</Row>
|
||||
)}
|
||||
{lastStep.amountTmt != null && (
|
||||
<Row label={t("onlinePayments.columns.amountTmt", "Töleg möçberi")}>
|
||||
<span className="font-medium">{lastStep.amountTmt?.toLocaleString?.() ?? lastStep.amountTmt} TMT</span>
|
||||
</Row>
|
||||
)}
|
||||
{lastStep.bankFeeTmt != null && (
|
||||
<Row label={t("onlinePayments.columns.bankFeeTmt", "Bank komissiýasy")}>
|
||||
<span>{lastStep.bankFeeTmt?.toLocaleString?.() ?? lastStep.bankFeeTmt} TMT</span>
|
||||
</Row>
|
||||
)}
|
||||
{lastStep.gbusFeeTmt != null && (
|
||||
<Row label={t("onlinePayments.columns.gbusFeeTmt", "GBUS komissiýasy")}>
|
||||
<span>{lastStep.gbusFeeTmt?.toLocaleString?.() ?? lastStep.gbusFeeTmt} TMT</span>
|
||||
</Row>
|
||||
)}
|
||||
{lastStep.amountUsd != null && (
|
||||
<Row label={t("onlinePayments.columns.amountUsd", "Möçber (USD)")}>
|
||||
<span>{lastStep.amountUsd} $</span>
|
||||
</Row>
|
||||
)}
|
||||
{lastStep.exchangeRateUsd != null && (
|
||||
<Row label={t("onlinePayments.columns.exchangeRateUsd", "Hümmet (USD)")}>
|
||||
<span>{lastStep.exchangeRateUsd} TMT</span>
|
||||
</Row>
|
||||
)}
|
||||
{lastStep.paymentPeriod && (
|
||||
<Row label={t("onlinePayments.columns.paymentPeriod", "Töleg döwri")}>
|
||||
<span>{formatFromApiDate(lastStep.paymentPeriod)}</span>
|
||||
</Row>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Section 3: Customer & Branch */}
|
||||
{(fullName || lastStep.branchName || lastStep.createdByName || lastStep.userId) && (
|
||||
<div className="rounded-lg border border-border p-3 space-y-2 bg-muted/10">
|
||||
<p className="font-semibold text-muted-foreground uppercase text-[11px] tracking-wide">
|
||||
{t("onlinePayments.sectionCustomer", "Müşderi we Şahamça")}
|
||||
</p>
|
||||
<div className="space-y-1.5">
|
||||
{fullName && (
|
||||
<Row label={t("onlinePayments.columns.passport", "Müşderi")}>
|
||||
<span className="font-medium">{fullName}</span>
|
||||
</Row>
|
||||
)}
|
||||
{lastStep.userId != null && (
|
||||
<Row label={t("onlinePayments.columns.userId", "Ulanyjy ID")}>
|
||||
<Link to={`/all-users/${lastStep.userId}`} className="font-mono text-primary hover:underline">
|
||||
#{lastStep.userId}
|
||||
</Link>
|
||||
</Row>
|
||||
)}
|
||||
{branchDisplay && (
|
||||
<Row label={t("onlinePayments.columns.branch", "Şahamça")}>
|
||||
<span>{branchDisplay}</span>
|
||||
</Row>
|
||||
)}
|
||||
{lastStep.createdByName && (
|
||||
<Row label={t("onlinePayments.columns.createdByName", "Döreden işgär")}>
|
||||
<span>{lastStep.createdByName}</span>
|
||||
</Row>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Section 4: External URLs */}
|
||||
{(lastStep.formUrl || lastStep.successUrl) && (
|
||||
<div className="rounded-lg border border-border p-3 space-y-2 bg-muted/10">
|
||||
<p className="font-semibold text-muted-foreground uppercase text-[11px] tracking-wide">
|
||||
{t("onlinePayments.sectionUrls", "Baglanyşyklar")}
|
||||
</p>
|
||||
<div className="space-y-1.5">
|
||||
{lastStep.formUrl && (
|
||||
<Row label={t("onlinePayments.columns.formUrl", "Töleg Form URL")}>
|
||||
<a
|
||||
href={lastStep.formUrl}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="inline-flex items-center gap-1 text-primary hover:underline break-all"
|
||||
>
|
||||
<ExternalLink className="size-3 shrink-0" />
|
||||
<span className="truncate max-w-[260px]">{lastStep.formUrl}</span>
|
||||
</a>
|
||||
</Row>
|
||||
)}
|
||||
{lastStep.successUrl && (
|
||||
<Row label={t("onlinePayments.columns.successUrl", "Success URL")}>
|
||||
<a
|
||||
href={lastStep.successUrl}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="inline-flex items-center gap-1 text-primary hover:underline break-all"
|
||||
>
|
||||
<ExternalLink className="size-3 shrink-0" />
|
||||
<span className="truncate max-w-[260px]">{lastStep.successUrl}</span>
|
||||
</a>
|
||||
</Row>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Legacy detail entries if present */}
|
||||
{detailEntries.length > 0 && (
|
||||
<div className="rounded-lg border border-border p-3 space-y-2 bg-muted/10">
|
||||
<p className="font-semibold text-muted-foreground uppercase text-[11px] tracking-wide">
|
||||
@@ -260,21 +459,13 @@ export function LastStepDialog({ orderId, open, onOpenChange }: LastStepDialogPr
|
||||
</p>
|
||||
<div className="space-y-1.5">
|
||||
{detailEntries.map(([key, value]) => (
|
||||
<div key={key} className="flex gap-2">
|
||||
<span className="text-muted-foreground font-medium min-w-[130px] shrink-0">
|
||||
{t(`onlinePayments.detailKeys.${key}`, rawEnumKey(key))}
|
||||
</span>
|
||||
<span className="text-foreground break-all">{String(value)}</span>
|
||||
</div>
|
||||
<Row key={key} label={t(`onlinePayments.detailKeys.${key}`, rawEnumKey(key))}>
|
||||
<span>{String(value)}</span>
|
||||
</Row>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Step ID */}
|
||||
<p className="text-muted-foreground text-[11px] px-1">
|
||||
Step ID: <span className="font-mono">{lastStep.id}</span>
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</DialogContent>
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { useState, useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Eye } from "lucide-react";
|
||||
import { ScanLine, Eye } from "lucide-react";
|
||||
import type { VisibilityState } from "@tanstack/react-table";
|
||||
|
||||
import { DataTable, type ColumnDef, type SortingState } from "@/components/dataTable";
|
||||
import { DataTableToolbar, type ColumnMeta } from "@/components/dataTableToolbar";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useGetPaymentGateway } from "@/features/onlinePaymentHistory/hooks/useOnlinePaymentsHistory";
|
||||
import { ActiveStatusCell } from "@/constants/statusCells";
|
||||
import { useGetOrderPaymentHistory } from "@/features/onlinePaymentHistory/hooks/useOnlinePaymentsHistory";
|
||||
import { GatewayStatusCell } from "@/constants/statusCells";
|
||||
import { PaidBadge } from "@/features/onlinePaymentHistory/components/PaymentStatusBadge";
|
||||
import { formatFromApiDate } from "@/lib/utils/dateUtils";
|
||||
import { PaymentDetailDialog, LastStepDialog } from "./PaymentDetailDialog";
|
||||
|
||||
@@ -78,27 +79,15 @@ function isPaid(row: any): boolean {
|
||||
return Boolean(row.paid ?? (row.detail?.paid === "true" || row.detail?.paid === true));
|
||||
}
|
||||
|
||||
function isSynced(row: any): boolean {
|
||||
if (row.gatewayResponse?.orderStatus === 0 || row.gatewayResponse?.errorMessage === "Успешно") return true;
|
||||
return Boolean(
|
||||
row.synced ??
|
||||
row.isSynced ??
|
||||
row.systemSynced ??
|
||||
row.syncedWithSystem ??
|
||||
(row.detail?.synced === "true" || row.detail?.synced === true),
|
||||
);
|
||||
}
|
||||
|
||||
const PER_PAGE = 25;
|
||||
|
||||
// ─── Main Component ───────────────────────────────────────────────────────────
|
||||
|
||||
interface PaymentHistoryTableProps {
|
||||
orderId?: string | number;
|
||||
paymentId?: string | number;
|
||||
}
|
||||
|
||||
export function PaymentHistoryTable({ orderId, paymentId }: PaymentHistoryTableProps = {}) {
|
||||
export function PaymentHistoryTable({ orderId }: PaymentHistoryTableProps = {}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
// ─── Dialog State ──────────────────────────────────────────────────────────
|
||||
@@ -117,19 +106,11 @@ export function PaymentHistoryTable({ orderId, paymentId }: PaymentHistoryTableP
|
||||
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
|
||||
const [columnOrder, setColumnOrder] = useState<string[]>([]);
|
||||
|
||||
// ─── Query: /payment-history/payments/:id/gateway ──────────────────────────
|
||||
const effectiveId = paymentId || orderId;
|
||||
const { data: rawData, isLoading } = useGetPaymentGateway(effectiveId);
|
||||
// ─── Query: /payment-history/:id?lang=tm ───────────────────────────────────
|
||||
const { data: historyData, isLoading } = useGetOrderPaymentHistory(orderId, { lang: "tm" });
|
||||
|
||||
const items = useMemo(() => {
|
||||
let list: any[] = [];
|
||||
if (Array.isArray(rawData)) {
|
||||
list = rawData;
|
||||
} else if (rawData && typeof rawData === "object" && (rawData as any).id) {
|
||||
list = [rawData];
|
||||
} else if (rawData && Array.isArray((rawData as any).items)) {
|
||||
list = (rawData as any).items;
|
||||
}
|
||||
const list = historyData?.items ?? [];
|
||||
|
||||
if (!search.trim()) return list;
|
||||
const q = search.trim().toLowerCase();
|
||||
@@ -137,13 +118,11 @@ export function PaymentHistoryTable({ orderId, paymentId }: PaymentHistoryTableP
|
||||
const haystack = [r.id, getPayerFullName(r), getMaskedCard(r), getReference(r), r.orderId].join(" ").toLowerCase();
|
||||
return haystack.includes(q);
|
||||
});
|
||||
}, [rawData, search]);
|
||||
}, [historyData, search]);
|
||||
|
||||
const totalCount = useMemo(() => {
|
||||
if (Array.isArray(rawData)) return rawData.length;
|
||||
if (rawData && typeof (rawData as any).count === "number") return (rawData as any).count;
|
||||
return items.length;
|
||||
}, [rawData, items]);
|
||||
return historyData?.count ?? items.length;
|
||||
}, [historyData, items]);
|
||||
|
||||
const totalPages = Math.ceil(totalCount / perPage) || 1;
|
||||
|
||||
@@ -234,21 +213,14 @@ export function PaymentHistoryTable({ orderId, paymentId }: PaymentHistoryTableP
|
||||
{
|
||||
id: "isPaid",
|
||||
header: t("intlPayment.historyColumns.isPaid", "Tölenen"),
|
||||
cell: ({ row }) => (
|
||||
<ActiveStatusCell
|
||||
active={isPaid(row.original)}
|
||||
labelActive={t("onlinePayments.statuses.paid", "Tölendi")}
|
||||
labelInactive={t("onlinePayments.statuses.unpaid", "Tölenmedi")}
|
||||
/>
|
||||
),
|
||||
cell: ({ row }) => <PaidBadge paid={isPaid(row.original)} />,
|
||||
size: 110,
|
||||
},
|
||||
{
|
||||
id: "isSynced",
|
||||
header: t("intlPayment.historyColumns.isSynced", "Ulgam bn birikdirilen"),
|
||||
cell: ({ row }) => (
|
||||
<ActiveStatusCell active={isSynced(row.original)} labelActive={t("common.yes", "Hawa")} labelInactive={t("common.no", "Ýok")} />
|
||||
),
|
||||
id: "gatewayStatus",
|
||||
accessorKey: "gatewayStatus",
|
||||
header: t("onlinePayments.columns.gatewayStatus", "Gateway statusy"),
|
||||
cell: ({ row }) => <GatewayStatusCell status={row.original.gatewayStatus} />,
|
||||
size: 130,
|
||||
},
|
||||
{
|
||||
@@ -257,7 +229,7 @@ export function PaymentHistoryTable({ orderId, paymentId }: PaymentHistoryTableP
|
||||
cell: ({ row }) => (
|
||||
<div className="flex items-center justify-end gap-1">
|
||||
{/* Storage (Database) icon: opens payment detail dialog */}
|
||||
{/* <Button
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="size-8 text-muted-foreground hover:text-foreground cursor-pointer"
|
||||
@@ -267,8 +239,8 @@ export function PaymentHistoryTable({ orderId, paymentId }: PaymentHistoryTableP
|
||||
setSelectedPaymentId(row.original.id);
|
||||
}}
|
||||
>
|
||||
<Database className="size-4" />
|
||||
</Button> */}
|
||||
<ScanLine className="size-4" />
|
||||
</Button>
|
||||
|
||||
{/* Eye icon: opens last-step dialog */}
|
||||
<Button
|
||||
@@ -278,7 +250,7 @@ export function PaymentHistoryTable({ orderId, paymentId }: PaymentHistoryTableP
|
||||
title={t("onlinePayments.lastStep.title", "Iň soňky işlem")}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setSelectedOrderId(row.original.orderId || row.original.id);
|
||||
setSelectedOrderId(row.original.orderId ?? row.original.id);
|
||||
}}
|
||||
>
|
||||
<Eye className="size-4" />
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
import apiClient from "@/lib/api/client";
|
||||
|
||||
export interface PaymentTextI18n {
|
||||
en: string;
|
||||
ru: string;
|
||||
tm: string;
|
||||
en?: string;
|
||||
ru?: string;
|
||||
tm?: string;
|
||||
}
|
||||
|
||||
export type LocalizedPaymentText = string | PaymentTextI18n;
|
||||
|
||||
export function resolveVisaMasterText(text: LocalizedPaymentText | null | undefined, lang = "tm"): string {
|
||||
if (!text) return "";
|
||||
if (typeof text === "string") return text;
|
||||
const key = (lang === "tk" ? "tm" : lang) as keyof PaymentTextI18n;
|
||||
return text[key] ?? text.tm ?? text.ru ?? text.en ?? "";
|
||||
}
|
||||
|
||||
export interface VisaMasterSetting {
|
||||
@@ -11,7 +20,7 @@ export interface VisaMasterSetting {
|
||||
id: number;
|
||||
isActive: boolean;
|
||||
name: string;
|
||||
text: PaymentTextI18n;
|
||||
text: LocalizedPaymentText;
|
||||
updatedAt: string;
|
||||
updatedById: number;
|
||||
updatedByName: string;
|
||||
|
||||
@@ -25,13 +25,15 @@ export interface VisaMasterSettingFormProps {
|
||||
}
|
||||
|
||||
function mapInitial(data: VisaMasterSetting): VisaMasterSettingFormData {
|
||||
const textVal = data.text;
|
||||
const isStr = typeof textVal === "string";
|
||||
return {
|
||||
code: data.code,
|
||||
name: data.name,
|
||||
isActive: data.isActive,
|
||||
textTm: data.text?.tm ?? "",
|
||||
textRu: data.text?.ru ?? "",
|
||||
textEn: data.text?.en ?? "",
|
||||
textTm: isStr ? textVal : ((textVal as any)?.tm ?? ""),
|
||||
textRu: isStr ? textVal : ((textVal as any)?.ru ?? ""),
|
||||
textEn: isStr ? textVal : ((textVal as any)?.en ?? ""),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -547,7 +547,7 @@ function DashboardHeader() {
|
||||
const languages = [
|
||||
{ code: "en", label: "English" },
|
||||
{ code: "ru", label: "Русский" },
|
||||
{ code: "tk", label: "Türkmençe" },
|
||||
{ code: "tm", label: "Türkmençe" },
|
||||
] as const;
|
||||
|
||||
// ── Breadcrumbs ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import axios, { type AxiosError, type InternalAxiosRequestConfig } from "axios";
|
||||
import { useAuthStore } from "@/app/store/authStore";
|
||||
import i18n from "@/lib/i18n";
|
||||
|
||||
// ---- API Envelope Types ----
|
||||
export interface ApiSuccessResponse<T> {
|
||||
@@ -46,6 +47,12 @@ apiClient.interceptors.request.use(
|
||||
if (token && config.headers) {
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
|
||||
// Inject the current UI language as a query param so the backend
|
||||
// returns localized content (e.g. branch names, district names).
|
||||
const lang = i18n.language || "tm";
|
||||
config.params = { lang, ...config.params };
|
||||
|
||||
return config;
|
||||
},
|
||||
(error) => Promise.reject(error),
|
||||
|
||||
@@ -3,9 +3,9 @@ import { initReactI18next } from "react-i18next";
|
||||
|
||||
import en from "./locales/en.json";
|
||||
import ru from "./locales/ru.json";
|
||||
import tk from "./locales/tk.json";
|
||||
import tm from "./locales/tk.json";
|
||||
|
||||
export const SUPPORTED_LANGUAGES = ["en", "ru", "tk"] as const;
|
||||
export const SUPPORTED_LANGUAGES = ["en", "ru", "tm"] as const;
|
||||
export type SupportedLanguage = (typeof SUPPORTED_LANGUAGES)[number];
|
||||
|
||||
const savedStorage = localStorage.getItem("tbbank-lang");
|
||||
@@ -28,10 +28,10 @@ i18n.use(initReactI18next).init({
|
||||
resources: {
|
||||
en: { translation: en },
|
||||
ru: { translation: ru },
|
||||
tk: { translation: tk },
|
||||
tm: { translation: tm },
|
||||
},
|
||||
lng: defaultLang,
|
||||
fallbackLng: "tk",
|
||||
fallbackLng: "tm",
|
||||
interpolation: {
|
||||
escapeValue: false,
|
||||
},
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
"Born place (passport)": "Born place (passport)",
|
||||
"Branch": "Branch",
|
||||
"Branches": "Branches",
|
||||
"Language": "Language",
|
||||
"Payment settings": "Payment settings",
|
||||
"Cancelled": "Cancelled",
|
||||
"Card": "Card",
|
||||
"Card balance": "Card balance",
|
||||
@@ -1643,6 +1645,31 @@
|
||||
"onlinePayments.detailKeys.ip": "IP address",
|
||||
"onlinePayments.detailKeys.created_by": "Created by",
|
||||
"onlinePayments.detailKeys.created_at": "Created at",
|
||||
"onlinePayments.gatewaySection": "Gateway details",
|
||||
"onlinePayments.gatewayCardSection": "Card and bank details",
|
||||
"onlinePayments.callbackSection": "Callback and connection",
|
||||
"onlinePayments.gatewayErrorTitle": "Gateway error",
|
||||
"onlinePayments.gateway.orderStatus": "Gateway order status",
|
||||
"onlinePayments.gateway.errorCode": "Error code",
|
||||
"onlinePayments.gateway.errorMessage": "Gateway response",
|
||||
"onlinePayments.gateway.actionCode": "Action code",
|
||||
"onlinePayments.gateway.actionDescription": "Action description",
|
||||
"onlinePayments.gateway.terminal": "Terminal",
|
||||
"onlinePayments.gateway.ip": "IP address",
|
||||
"onlinePayments.gateway.expiration": "Expiration date",
|
||||
"onlinePayments.gateway.approvalCode": "Approval code",
|
||||
"onlinePayments.gateway.bankCountry": "Bank country",
|
||||
"onlinePayments.gateway.currency": "Currency",
|
||||
"onlinePayments.gateway.paymentState": "Payment state",
|
||||
"onlinePayments.gateway.approvedAmount": "Approved amount",
|
||||
"onlinePayments.columns.cardholderName": "Cardholder",
|
||||
"onlinePayments.columns.maskedPan": "Card number",
|
||||
"onlinePayments.columns.gatewayReference": "Gateway reference",
|
||||
"onlinePayments.columns.callbackStatus": "Callback status",
|
||||
"onlinePayments.columns.callbackAt": "Callback time",
|
||||
"onlinePayments.columns.apiClientName": "API client",
|
||||
"onlinePayments.columns.formUrl": "Form URL",
|
||||
"onlinePayments.columns.successUrl": "Success URL",
|
||||
"cardTypes.viewTitle": "Card type detail",
|
||||
"profile.title": "My Profile",
|
||||
"profile.actions.assignRole": "Assign role",
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
"Born place (passport)": "Место рождения (паспорт)",
|
||||
"Branch": "Филиал",
|
||||
"Branches": "Филиалы",
|
||||
"Language": "Язык",
|
||||
"Payment settings": "Настройки платежа",
|
||||
"Cancelled": "Отменено",
|
||||
"Card": "Карта",
|
||||
"Cancel": "Отменить",
|
||||
@@ -1644,6 +1646,31 @@
|
||||
"onlinePayments.detailKeys.ip": "IP-адрес",
|
||||
"onlinePayments.detailKeys.created_by": "Создал",
|
||||
"onlinePayments.detailKeys.created_at": "Дата создания",
|
||||
"onlinePayments.gatewaySection": "Данные шлюза",
|
||||
"onlinePayments.gatewayCardSection": "Данные карты и банка",
|
||||
"onlinePayments.callbackSection": "Callback и соединение",
|
||||
"onlinePayments.gatewayErrorTitle": "Ошибка шлюза",
|
||||
"onlinePayments.gateway.orderStatus": "Статус заказа в шлюзе",
|
||||
"onlinePayments.gateway.errorCode": "Код ошибки",
|
||||
"onlinePayments.gateway.errorMessage": "Ответ шлюза",
|
||||
"onlinePayments.gateway.actionCode": "Код действия",
|
||||
"onlinePayments.gateway.actionDescription": "Описание действия",
|
||||
"onlinePayments.gateway.terminal": "Терминал",
|
||||
"onlinePayments.gateway.ip": "IP-адрес",
|
||||
"onlinePayments.gateway.expiration": "Срок действия",
|
||||
"onlinePayments.gateway.approvalCode": "Код подтверждения",
|
||||
"onlinePayments.gateway.bankCountry": "Страна банка",
|
||||
"onlinePayments.gateway.currency": "Валюта",
|
||||
"onlinePayments.gateway.paymentState": "Состояние платежа",
|
||||
"onlinePayments.gateway.approvedAmount": "Подтверждённая сумма",
|
||||
"onlinePayments.columns.cardholderName": "Держатель карты",
|
||||
"onlinePayments.columns.maskedPan": "Номер карты",
|
||||
"onlinePayments.columns.gatewayReference": "Референс шлюза",
|
||||
"onlinePayments.columns.callbackStatus": "Статус callback",
|
||||
"onlinePayments.columns.callbackAt": "Время callback",
|
||||
"onlinePayments.columns.apiClientName": "API-клиент",
|
||||
"onlinePayments.columns.formUrl": "URL формы",
|
||||
"onlinePayments.columns.successUrl": "URL успешного перехода",
|
||||
"cardTypes.viewTitle": "Детали типа карты",
|
||||
"profile.title": "Мой профиль",
|
||||
"profile.actions.assignRole": "Назначить роль",
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
"Born place (passport)": "Doglan ýeri (pasport)",
|
||||
"Branch": "Şahamça",
|
||||
"Branches": "Şahamçalar",
|
||||
"Language": "Dil",
|
||||
"Payment settings": "Töleg sazlamalary",
|
||||
"Cancelled": "Ýatyrylan",
|
||||
"Card": "Kart",
|
||||
"Cancel": "Ýatyrmak",
|
||||
@@ -1642,6 +1644,31 @@
|
||||
"onlinePayments.detailKeys.ip": "IP salgysy",
|
||||
"onlinePayments.detailKeys.created_by": "Döreden",
|
||||
"onlinePayments.detailKeys.created_at": "Döredilen wagty",
|
||||
"onlinePayments.gatewaySection": "Gateway maglumatlary",
|
||||
"onlinePayments.gatewayCardSection": "Kart we bank maglumatlary",
|
||||
"onlinePayments.callbackSection": "Callback we baglanyşyk",
|
||||
"onlinePayments.gatewayErrorTitle": "Gateway ýalňyşlygy",
|
||||
"onlinePayments.gateway.orderStatus": "Gateway sargyt statusy",
|
||||
"onlinePayments.gateway.errorCode": "Ýalňyşlyk kody",
|
||||
"onlinePayments.gateway.errorMessage": "Gateway jogaby",
|
||||
"onlinePayments.gateway.actionCode": "Hereket kody",
|
||||
"onlinePayments.gateway.actionDescription": "Hereket düşündirişi",
|
||||
"onlinePayments.gateway.terminal": "Terminal",
|
||||
"onlinePayments.gateway.ip": "IP salgysy",
|
||||
"onlinePayments.gateway.expiration": "Möhletiniň gutarýan wagty",
|
||||
"onlinePayments.gateway.approvalCode": "Tassyklama kody",
|
||||
"onlinePayments.gateway.bankCountry": "Bank döwleti",
|
||||
"onlinePayments.gateway.currency": "Pul birligi",
|
||||
"onlinePayments.gateway.paymentState": "Töleg ýagdaýy",
|
||||
"onlinePayments.gateway.approvedAmount": "Tassyklanan möçber",
|
||||
"onlinePayments.columns.cardholderName": "Kart eýesi",
|
||||
"onlinePayments.columns.maskedPan": "Kart belgisi",
|
||||
"onlinePayments.columns.gatewayReference": "Gateway referensi",
|
||||
"onlinePayments.columns.callbackStatus": "Callback statusy",
|
||||
"onlinePayments.columns.callbackAt": "Callback wagty",
|
||||
"onlinePayments.columns.apiClientName": "API müşderisi",
|
||||
"onlinePayments.columns.formUrl": "Form URL-si",
|
||||
"onlinePayments.columns.successUrl": "Üstünlik URL-si",
|
||||
"cardTypes.viewTitle": "Kart görnüşi giňişleýin",
|
||||
"profile.title": "Meniň profilim",
|
||||
"profile.actions.assignRole": "Rol birikdiriň",
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user