changes some status
This commit is contained in:
60
src/constants/enumLabels.ts
Normal file
60
src/constants/enumLabels.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import type { TFunction } from "i18next";
|
||||
import type { SelectOption } from "@/components/formInput";
|
||||
|
||||
/**
|
||||
* Shared helpers for enum-like backend values (status, paid flag, education,
|
||||
* marriage, order type …). The enum itself lives in `constants/`, the
|
||||
* localized text lives in `lib/i18n/locales/{en,ru,tk}.json`.
|
||||
*/
|
||||
export type TranslateFn = TFunction | ((key: string, fallback?: string) => string);
|
||||
|
||||
export interface EnumConfig<T extends string> {
|
||||
/** Allowed values as sent by the backend. */
|
||||
values: readonly T[];
|
||||
/** English fallback labels, used when the locale key is missing. */
|
||||
labels: Record<T, string>;
|
||||
/** i18n key prefix, e.g. "onlinePayments.gatewayStatus". */
|
||||
prefix: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Language-neutral fallback for a backend value we have no translation for:
|
||||
* "gateway_reference" → "gateway reference". Never invents a word, so an
|
||||
* unmapped enum can not leak English into the Turkish/Russian UI.
|
||||
*/
|
||||
export function rawEnumKey(key: string): string {
|
||||
return String(key ?? "")
|
||||
.replace(/[_-]+/g, " ")
|
||||
.trim();
|
||||
}
|
||||
|
||||
export function isEnumValue<T extends string>(values: readonly T[], key: string): key is T {
|
||||
return values.includes(
|
||||
String(key ?? "")
|
||||
.trim()
|
||||
.toLowerCase() as T,
|
||||
);
|
||||
}
|
||||
|
||||
/** Normalizes a backend key so "MARRIED" and "married" resolve to the same enum value. */
|
||||
function normalize<T extends string>(values: readonly T[], key: string): T | undefined {
|
||||
const needle = String(key ?? "")
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
return values.find((value) => value.toLowerCase() === needle);
|
||||
}
|
||||
|
||||
/** Select options for an enum, localized when `t` is given. */
|
||||
export function buildEnumOptions<T extends string>(config: EnumConfig<T>, t?: TranslateFn): SelectOption[] {
|
||||
return config.values.map((value) => ({
|
||||
value,
|
||||
label: t ? t(`${config.prefix}.${value}`, config.labels[value]) : config.labels[value],
|
||||
}));
|
||||
}
|
||||
|
||||
/** Localized label for one enum value; unknown keys fall back to the raw backend value. */
|
||||
export function getEnumLabel<T extends string>(config: EnumConfig<T>, key: string, t?: TranslateFn): string {
|
||||
const value = normalize(config.values, key);
|
||||
if (!value) return rawEnumKey(key);
|
||||
return t ? t(`${config.prefix}.${value}`, config.labels[value]) : config.labels[value];
|
||||
}
|
||||
@@ -1,23 +1,79 @@
|
||||
import type { SelectOption } from "@/components/formInput";
|
||||
import { buildEnumOptions, getEnumLabel, type EnumConfig, type TranslateFn } from "@/constants/enumLabels";
|
||||
|
||||
export const EDUCATION_OPTIONS: SelectOption[] = [
|
||||
{ value: "high", label: "Ýokary bilim" },
|
||||
{ value: "unfinished_high", label: "Gutarylmadyk ýokary bilim" },
|
||||
{ value: "masters", label: "Magistr" },
|
||||
{ value: "phd", label: "Ylymlaryň doktory" },
|
||||
{ value: "middle", label: "Orta mekdep" },
|
||||
{ value: "school", label: "Orta bilim" },
|
||||
{ value: "school_dropout", label: "Gutarylmadyk orta bilim" },
|
||||
];
|
||||
// ─── Education level ──────────────────────────────────────────────────────────
|
||||
|
||||
export const MARRIAGE_OPTIONS: SelectOption[] = [
|
||||
{ value: "MARRIED", label: "Öýlenen / Durmuşa çykan" },
|
||||
{ value: "SINGLE", label: "Öýlenmedik / Durmuşa çykmadyk" },
|
||||
{ value: "DIVORCED", label: "Aýrylşan" },
|
||||
{ value: "WIDOW", label: "Adamsy ýa-da aýaly aradan çykan" },
|
||||
{ value: "LEGAL", label: "Raýat nika" },
|
||||
];
|
||||
export const EDUCATION_VALUES = [
|
||||
"high",
|
||||
"higher",
|
||||
"unfinished_high",
|
||||
"masters",
|
||||
"phd",
|
||||
"middle",
|
||||
"secondary",
|
||||
"school",
|
||||
"school_dropout",
|
||||
] as const;
|
||||
|
||||
export type EducationValue = (typeof EDUCATION_VALUES)[number];
|
||||
|
||||
export const EDUCATION_LABELS: Record<EducationValue, string> = {
|
||||
high: "Higher secondary",
|
||||
higher: "Higher education",
|
||||
unfinished_high: "Incomplete higher secondary",
|
||||
masters: "Master's degree",
|
||||
phd: "Doctor of science",
|
||||
middle: "Secondary school",
|
||||
secondary: "Secondary education",
|
||||
school: "Secondary education",
|
||||
school_dropout: "Incomplete secondary education",
|
||||
};
|
||||
|
||||
const EDUCATION_ENUM: EnumConfig<EducationValue> = {
|
||||
values: EDUCATION_VALUES,
|
||||
labels: EDUCATION_LABELS,
|
||||
prefix: "options.education",
|
||||
};
|
||||
|
||||
// ─── Marital status ───────────────────────────────────────────────────────────
|
||||
|
||||
export const MARRIAGE_VALUES = ["MARRIED", "SINGLE", "DIVORCED", "WIDOW", "LEGAL"] as const;
|
||||
|
||||
export type MarriageValue = (typeof MARRIAGE_VALUES)[number];
|
||||
|
||||
export const MARRIAGE_LABELS: Record<MarriageValue, string> = {
|
||||
MARRIED: "Married",
|
||||
SINGLE: "Single",
|
||||
DIVORCED: "Divorced",
|
||||
WIDOW: "Widowed",
|
||||
LEGAL: "Not married / legally single",
|
||||
};
|
||||
|
||||
const MARRIAGE_ENUM: EnumConfig<MarriageValue> = {
|
||||
values: MARRIAGE_VALUES,
|
||||
labels: MARRIAGE_LABELS,
|
||||
prefix: "options.marriage",
|
||||
};
|
||||
|
||||
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
||||
|
||||
export function getEducationOptions(t?: TranslateFn): SelectOption[] {
|
||||
return buildEnumOptions(EDUCATION_ENUM, t);
|
||||
}
|
||||
|
||||
export function getEducationLabel(value: string, t?: TranslateFn): string {
|
||||
return getEnumLabel(EDUCATION_ENUM, value, t);
|
||||
}
|
||||
|
||||
export function getMarriageOptions(t?: TranslateFn): SelectOption[] {
|
||||
return buildEnumOptions(MARRIAGE_ENUM, t);
|
||||
}
|
||||
|
||||
export function getMarriageLabel(value: string, t?: TranslateFn): string {
|
||||
return getEnumLabel(MARRIAGE_ENUM, value, t);
|
||||
}
|
||||
|
||||
/** Month options for date pickers, "01" … "12". */
|
||||
export const MONTH_OPTIONS: SelectOption[] = Array.from({ length: 12 }, (_, i) => {
|
||||
const val = String(i + 1).padStart(2, "0");
|
||||
return { value: val, label: val };
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
export * from "./enumLabels";
|
||||
export * from "./formOptions";
|
||||
export * from "./orderTypes";
|
||||
export * from "./passportSeries";
|
||||
export * from "./paymentStatus";
|
||||
export * from "./regionCodes";
|
||||
export * from "./statusOptions";
|
||||
export * from "./statusCells";
|
||||
|
||||
29
src/constants/orderTypes.ts
Normal file
29
src/constants/orderTypes.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { buildEnumOptions, getEnumLabel, type EnumConfig, type TranslateFn } from "@/constants/enumLabels";
|
||||
|
||||
/** Order kinds returned by the analytics endpoints (`orderType` field). */
|
||||
export const ORDER_TYPE_VALUES = ["loan", "loan_paid_off_letter", "card", "card_pin", "card_rekwizit", "visa_master"] as const;
|
||||
|
||||
export type OrderTypeValue = (typeof ORDER_TYPE_VALUES)[number];
|
||||
|
||||
export const ORDER_TYPE_LABELS: Record<OrderTypeValue, string> = {
|
||||
loan: "Loan orders",
|
||||
loan_paid_off_letter: "Loan paid-off letter",
|
||||
card: "New card",
|
||||
card_pin: "Card PIN",
|
||||
card_rekwizit: "Card requisites",
|
||||
visa_master: "Visa / Master",
|
||||
};
|
||||
|
||||
const ORDER_TYPE_ENUM: EnumConfig<OrderTypeValue> = {
|
||||
values: ORDER_TYPE_VALUES,
|
||||
labels: ORDER_TYPE_LABELS,
|
||||
prefix: "analytics.orderType",
|
||||
};
|
||||
|
||||
export function getOrderTypeLabel(type: string, t?: TranslateFn, prefix?: string): string {
|
||||
return getEnumLabel(prefix ? { ...ORDER_TYPE_ENUM, prefix } : ORDER_TYPE_ENUM, type, t);
|
||||
}
|
||||
|
||||
export function getOrderTypeOptions(t?: TranslateFn) {
|
||||
return buildEnumOptions(ORDER_TYPE_ENUM, t);
|
||||
}
|
||||
91
src/constants/paymentStatus.ts
Normal file
91
src/constants/paymentStatus.ts
Normal file
@@ -0,0 +1,91 @@
|
||||
import type { ComponentType } from "react";
|
||||
import { AlertCircle, CheckCircle2, Clock, XCircle } from "lucide-react";
|
||||
import type { SelectOption } from "@/components/formInput";
|
||||
import type { StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { buildEnumOptions, getEnumLabel, isEnumValue, type EnumConfig, type TranslateFn } from "@/constants/enumLabels";
|
||||
|
||||
// ─── Gateway status ───────────────────────────────────────────────────────────
|
||||
|
||||
export const GATEWAY_STATUS_VALUES = ["pending", "paid", "unpaid", "failed"] as const;
|
||||
|
||||
export type GatewayStatusValue = (typeof GATEWAY_STATUS_VALUES)[number];
|
||||
|
||||
export const GATEWAY_STATUS_LABELS: Record<GatewayStatusValue, string> = {
|
||||
pending: "Pending",
|
||||
paid: "Paid",
|
||||
unpaid: "Unpaid",
|
||||
failed: "Failed",
|
||||
};
|
||||
|
||||
const GATEWAY_STATUS_ENUM: EnumConfig<GatewayStatusValue> = {
|
||||
values: GATEWAY_STATUS_VALUES,
|
||||
labels: GATEWAY_STATUS_LABELS,
|
||||
prefix: "onlinePayments.gatewayStatus",
|
||||
};
|
||||
|
||||
export const GATEWAY_STATUS_BADGE_VARIANTS: Record<GatewayStatusValue, StatusBadgeVariant> = {
|
||||
pending: "warning",
|
||||
paid: "success",
|
||||
unpaid: "default",
|
||||
failed: "error",
|
||||
};
|
||||
|
||||
export const GATEWAY_STATUS_ICONS: Record<GatewayStatusValue, ComponentType> = {
|
||||
pending: AlertCircle,
|
||||
paid: CheckCircle2,
|
||||
unpaid: Clock,
|
||||
failed: XCircle,
|
||||
};
|
||||
|
||||
// ─── Paid flag ────────────────────────────────────────────────────────────────
|
||||
|
||||
export const PAID_VALUES = ["paid", "unpaid"] as const;
|
||||
|
||||
export type PaidValue = (typeof PAID_VALUES)[number];
|
||||
|
||||
export const PAID_LABELS: Record<PaidValue, string> = {
|
||||
paid: "Paid",
|
||||
unpaid: "Unpaid",
|
||||
};
|
||||
|
||||
const PAID_ENUM: EnumConfig<PaidValue> = {
|
||||
values: PAID_VALUES,
|
||||
labels: PAID_LABELS,
|
||||
prefix: "onlinePayments.paid",
|
||||
};
|
||||
|
||||
export const PAID_BADGE_VARIANTS: Record<PaidValue, StatusBadgeVariant> = {
|
||||
paid: "success",
|
||||
unpaid: "error",
|
||||
};
|
||||
|
||||
export const PAID_ICONS: Record<PaidValue, ComponentType> = {
|
||||
paid: CheckCircle2,
|
||||
unpaid: XCircle,
|
||||
};
|
||||
|
||||
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
||||
|
||||
function withPrefix<T extends string>(config: EnumConfig<T>, prefix?: string): EnumConfig<T> {
|
||||
return prefix ? { ...config, prefix } : config;
|
||||
}
|
||||
|
||||
export function isGatewayStatusValue(status: string): status is GatewayStatusValue {
|
||||
return isEnumValue(GATEWAY_STATUS_VALUES, status);
|
||||
}
|
||||
|
||||
export function getGatewayStatusLabel(status: string, t?: TranslateFn, prefix?: string): string {
|
||||
return getEnumLabel(withPrefix(GATEWAY_STATUS_ENUM, prefix), status, t);
|
||||
}
|
||||
|
||||
export function getGatewayStatusOptions(t?: TranslateFn, prefix?: string): SelectOption[] {
|
||||
return buildEnumOptions(withPrefix(GATEWAY_STATUS_ENUM, prefix), t);
|
||||
}
|
||||
|
||||
export function toPaidValue(paid: boolean): PaidValue {
|
||||
return paid ? "paid" : "unpaid";
|
||||
}
|
||||
|
||||
export function getPaidLabel(paid: boolean, t?: TranslateFn, prefix?: string): string {
|
||||
return getEnumLabel(withPrefix(PAID_ENUM, prefix), toPaidValue(paid), t);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { useCallback } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { TFunction } from "i18next";
|
||||
import { REGION_LABELS } from "@/constants/regionCodes";
|
||||
import { getOrderTypeLabel } from "@/constants/orderTypes";
|
||||
import type { LocalizedName, OrderType } from "@/features/dashboard/api/analyticsApi";
|
||||
|
||||
// ─── Formatting ───────────────────────────────────────────────────────────────
|
||||
@@ -39,15 +40,7 @@ export function useLocalizedName() {
|
||||
}
|
||||
|
||||
export function orderTypeLabel(type: OrderType | string, t: TFunction): string {
|
||||
const fallback: Record<string, string> = {
|
||||
loan: "Karz sargytlary",
|
||||
loan_paid_off_letter: "Karzyň ýapylandygy",
|
||||
card: "Täze kart",
|
||||
card_pin: "Kart pin",
|
||||
card_rekwizit: "Kart rekwizit",
|
||||
visa_master: "Visa/Master",
|
||||
};
|
||||
return t(`analytics.orderType.${type}`, fallback[type] ?? type);
|
||||
return getOrderTypeLabel(type, t);
|
||||
}
|
||||
|
||||
export function regionLabel(code: string, t: TFunction): string {
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { TFunction } from "i18next";
|
||||
import { Info } from "lucide-react";
|
||||
import { Cell, Pie, PieChart } from "recharts";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { getEducationLabel, getMarriageLabel } from "@/constants/formOptions";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { ChartContainer, ChartTooltip, ChartTooltipContent } from "@/components/ui/chart";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
@@ -299,11 +300,10 @@ export function CustomersSection({ data, isLoading, isError, onRetry }: QueryPro
|
||||
}
|
||||
|
||||
const unknown = t("analytics.unknown", "Näbelli");
|
||||
const humanize = (k: string) => k.charAt(0).toUpperCase() + k.slice(1).toLowerCase().replace(/_/g, " ");
|
||||
const ageLabel = (k: string) =>
|
||||
k === "under25" ? t("analytics.age.under25", "25 ýaşdan kiçi") : k === "unknown" ? unknown : `${k} ${t("analytics.age.years", "ýaş")}`;
|
||||
const educationLabel = (k: string) => (k === "unknown" ? unknown : t(`options.education.${k}`, humanize(k)));
|
||||
const marriageLabel = (k: string) => (k === "unknown" ? unknown : t(`options.marriage.${k}`, humanize(k)));
|
||||
const educationLabel = (k: string) => (k === "unknown" ? unknown : getEducationLabel(k, t));
|
||||
const marriageLabel = (k: string) => (k === "unknown" ? unknown : getMarriageLabel(k, t));
|
||||
const guarantorLabel = (k: string) =>
|
||||
({
|
||||
none: t("analytics.guarantors.none", "Zamunsyz"),
|
||||
|
||||
@@ -34,8 +34,8 @@ import {
|
||||
PASSPORT_SERIES_OPTIONS,
|
||||
getStatusOptions,
|
||||
getRegionOptions,
|
||||
EDUCATION_OPTIONS,
|
||||
MARRIAGE_OPTIONS,
|
||||
getEducationOptions,
|
||||
getMarriageOptions,
|
||||
MONTH_OPTIONS,
|
||||
YEAR_OPTIONS,
|
||||
} from "@/constants";
|
||||
@@ -323,6 +323,8 @@ function StepPersonal({
|
||||
userName,
|
||||
}: StepContentProps & { initialData?: LoanOrderMobile; userLocked?: boolean; selfUserId?: string; userName?: string }) {
|
||||
const { data: requiredDocsData } = useGetRequiredDocuments({ page: 1, limit: 100 });
|
||||
const educationOptions = useMemo(() => getEducationOptions(t), [t]);
|
||||
const marriageOptions = useMemo(() => getMarriageOptions(t), [t]);
|
||||
|
||||
const [clientSearch, setClientSearch] = useState("");
|
||||
const clientsQuery = useInfiniteClients(clientSearch, !userLocked);
|
||||
@@ -417,7 +419,7 @@ function StepPersonal({
|
||||
required
|
||||
value={form.education}
|
||||
onChange={(v) => set("education", v)}
|
||||
options={EDUCATION_OPTIONS}
|
||||
options={educationOptions}
|
||||
placeholder={t("loanOrderForm.placeholders.select") || "Saýlaň"}
|
||||
error={errors.education}
|
||||
/>
|
||||
@@ -427,7 +429,7 @@ function StepPersonal({
|
||||
required
|
||||
value={form.marriageStatus}
|
||||
onChange={(v) => set("marriageStatus", v)}
|
||||
options={MARRIAGE_OPTIONS}
|
||||
options={marriageOptions}
|
||||
placeholder={t("loanOrderForm.placeholders.select") || "Saýlaň"}
|
||||
error={errors.marriageStatus}
|
||||
/>
|
||||
|
||||
@@ -26,8 +26,8 @@ import {
|
||||
PASSPORT_SERIES_OPTIONS,
|
||||
getStatusOptions,
|
||||
getRegionOptions,
|
||||
EDUCATION_OPTIONS,
|
||||
MARRIAGE_OPTIONS,
|
||||
getEducationOptions,
|
||||
getMarriageOptions,
|
||||
MONTH_OPTIONS,
|
||||
YEAR_OPTIONS,
|
||||
} from "@/constants";
|
||||
@@ -391,6 +391,8 @@ function StepPersonal({
|
||||
}: StepContentProps & { initialData?: LoanOrder; userLocked?: boolean; selfUserId?: string; userName?: string }) {
|
||||
const [clientSearch, setClientSearch] = useState("");
|
||||
const clientsQuery = useInfiniteClients(clientSearch, !userLocked);
|
||||
const educationOptions = useMemo(() => getEducationOptions(t), [t]);
|
||||
const marriageOptions = useMemo(() => getMarriageOptions(t), [t]);
|
||||
|
||||
const clientOptions: InfiniteSelectOption[] = useMemo(() => {
|
||||
const opts: InfiniteSelectOption[] = (clientsQuery.data?.pages ?? [])
|
||||
@@ -473,7 +475,7 @@ function StepPersonal({
|
||||
required
|
||||
value={form.education}
|
||||
onChange={(v) => set("education", v)}
|
||||
options={EDUCATION_OPTIONS}
|
||||
options={educationOptions}
|
||||
placeholder={t("loanOrderForm.placeholders.select") || "Saýlaň"}
|
||||
error={errors.education}
|
||||
/>
|
||||
@@ -483,7 +485,7 @@ function StepPersonal({
|
||||
required
|
||||
value={form.marriageStatus}
|
||||
onChange={(v) => set("marriageStatus", v)}
|
||||
options={MARRIAGE_OPTIONS}
|
||||
options={marriageOptions}
|
||||
placeholder={t("loanOrderForm.placeholders.select") || "Saýlaň"}
|
||||
error={errors.marriageStatus}
|
||||
/>
|
||||
|
||||
@@ -1,58 +1,45 @@
|
||||
// features/onlinePaymentHistory/components/PaymentStatusBadge.tsx
|
||||
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, Clock, Loader2, XCircle } from "lucide-react";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
interface StatusConfig {
|
||||
label: string;
|
||||
variant: StatusBadgeVariant;
|
||||
icon: React.ElementType;
|
||||
}
|
||||
|
||||
const STATUS_CONFIG: Record<string, StatusConfig> = {
|
||||
success: {
|
||||
label: "Success",
|
||||
variant: "success",
|
||||
icon: CheckCircle2,
|
||||
},
|
||||
failed: {
|
||||
label: "Failed",
|
||||
variant: "error",
|
||||
icon: XCircle,
|
||||
},
|
||||
pending: {
|
||||
label: "Pending",
|
||||
variant: "warning",
|
||||
icon: AlertCircle,
|
||||
},
|
||||
processing: {
|
||||
label: "Processing",
|
||||
variant: "warning",
|
||||
icon: Loader2,
|
||||
},
|
||||
// paid boolean fallback rendered as separate PaidBadge below
|
||||
};
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Clock } from "lucide-react";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import {
|
||||
GATEWAY_STATUS_BADGE_VARIANTS,
|
||||
GATEWAY_STATUS_ICONS,
|
||||
PAID_BADGE_VARIANTS,
|
||||
PAID_ICONS,
|
||||
getGatewayStatusLabel,
|
||||
getPaidLabel,
|
||||
isGatewayStatusValue,
|
||||
toPaidValue,
|
||||
} from "@/constants/paymentStatus";
|
||||
|
||||
// ─── GatewayStatusBadge ───────────────────────────────────────────────────────
|
||||
|
||||
export function GatewayStatusBadge({ status }: { status: string }) {
|
||||
const cfg = STATUS_CONFIG[status?.toLowerCase()];
|
||||
if (!cfg) {
|
||||
return <StatusBadge label={status ?? "—"} variant="default" icon={Clock} />;
|
||||
const { t } = useTranslation();
|
||||
const value = status?.toLowerCase() ?? "";
|
||||
|
||||
if (!isGatewayStatusValue(value)) {
|
||||
return <StatusBadge label={getGatewayStatusLabel(status, t) || "—"} variant="default" icon={Clock} />;
|
||||
}
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />;
|
||||
|
||||
return (
|
||||
<StatusBadge
|
||||
label={getGatewayStatusLabel(value, t)}
|
||||
variant={GATEWAY_STATUS_BADGE_VARIANTS[value]}
|
||||
icon={GATEWAY_STATUS_ICONS[value]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// ─── PaidBadge ────────────────────────────────────────────────────────────────
|
||||
|
||||
export function PaidBadge({ paid }: { paid: boolean }) {
|
||||
return paid ? (
|
||||
<StatusBadge label="Paid" variant="success" icon={CheckCircle2} />
|
||||
) : (
|
||||
<StatusBadge label="Unpaid" variant="error" icon={XCircle} />
|
||||
);
|
||||
const { t } = useTranslation();
|
||||
const value = toPaidValue(paid);
|
||||
|
||||
return <StatusBadge label={getPaidLabel(paid, t)} variant={PAID_BADGE_VARIANTS[value]} icon={PAID_ICONS[value]} />;
|
||||
}
|
||||
|
||||
// ─── Legacy alias — kept so the detail page import doesn't break ──────────────
|
||||
|
||||
@@ -1580,6 +1580,53 @@
|
||||
"visaMasterSberSettings.createTitle": "Create setting",
|
||||
"visaMasterSberSettings.editTitle": "Edit setting",
|
||||
"onlinePayments.viewTitle": "Payment detail",
|
||||
"onlinePayments.columns.id": "ID",
|
||||
"onlinePayments.columns.orderId": "ORDER ID",
|
||||
"onlinePayments.columns.type": "TYPE",
|
||||
"onlinePayments.columns.branch": "BRANCH",
|
||||
"onlinePayments.columns.passport": "PASSPORT",
|
||||
"onlinePayments.columns.totalAmount": "TOTAL (TMT)",
|
||||
"onlinePayments.columns.gatewayStatus": "GATEWAY STATUS",
|
||||
"onlinePayments.columns.paid": "PAID",
|
||||
"onlinePayments.filters.status": "Status",
|
||||
"onlinePayments.filters.branch": "Branch",
|
||||
"onlinePayments.filters.orderId": "Order ID",
|
||||
"onlinePayments.filters.userId": "User ID",
|
||||
"onlinePayments.gatewayStatus.pending": "Pending",
|
||||
"onlinePayments.gatewayStatus.paid": "Paid",
|
||||
"onlinePayments.gatewayStatus.unpaid": "Unpaid",
|
||||
"onlinePayments.gatewayStatus.failed": "Failed",
|
||||
"onlinePayments.paid.paid": "Paid",
|
||||
"onlinePayments.paid.unpaid": "Unpaid",
|
||||
"onlinePayments.detail.stepsCount": "Steps",
|
||||
"onlinePayments.noHistory": "No payment history found",
|
||||
"onlinePayments.detailKeys.order_id": "Order ID",
|
||||
"onlinePayments.detailKeys.order_unique_id": "Unique order ID",
|
||||
"onlinePayments.detailKeys.type": "Type",
|
||||
"onlinePayments.detailKeys.branch": "Branch",
|
||||
"onlinePayments.detailKeys.passport": "Passport",
|
||||
"onlinePayments.detailKeys.passport_id": "Passport ID",
|
||||
"onlinePayments.detailKeys.user_id": "User ID",
|
||||
"onlinePayments.detailKeys.paid": "Paid",
|
||||
"onlinePayments.detailKeys.amount": "Amount",
|
||||
"onlinePayments.detailKeys.amount_tmt": "Amount (TMT)",
|
||||
"onlinePayments.detailKeys.bank_fee_tmt": "Bank fee (TMT)",
|
||||
"onlinePayments.detailKeys.gbus_fee_tmt": "GBUS fee (TMT)",
|
||||
"onlinePayments.detailKeys.total_amount_tmt": "Total (TMT)",
|
||||
"onlinePayments.detailKeys.exchange_rate_usd": "USD exchange rate",
|
||||
"onlinePayments.detailKeys.payment_period": "Payment period",
|
||||
"onlinePayments.detailKeys.gateway_status": "Gateway status",
|
||||
"onlinePayments.detailKeys.gateway_reference": "Gateway reference",
|
||||
"onlinePayments.detailKeys.card": "Card",
|
||||
"onlinePayments.detailKeys.masked_card": "Card number",
|
||||
"onlinePayments.detailKeys.transaction_id": "Transaction ID",
|
||||
"onlinePayments.detailKeys.currency": "Currency",
|
||||
"onlinePayments.detailKeys.error": "Error",
|
||||
"onlinePayments.detailKeys.error_message": "Error message",
|
||||
"onlinePayments.detailKeys.message": "Message",
|
||||
"onlinePayments.detailKeys.ip": "IP address",
|
||||
"onlinePayments.detailKeys.created_by": "Created by",
|
||||
"onlinePayments.detailKeys.created_at": "Created at",
|
||||
"cardTypes.viewTitle": "Card type detail",
|
||||
"profile.title": "My Profile",
|
||||
"profile.actions.assignRole": "Assign role",
|
||||
@@ -1695,6 +1742,31 @@
|
||||
"analytics.guarantors.none": "No guarantor",
|
||||
"analytics.guarantors.one": "1 guarantor",
|
||||
"analytics.guarantors.two": "2 guarantors",
|
||||
"options.education.high": "Higher secondary",
|
||||
"options.education.unfinished_high": "Incomplete higher secondary",
|
||||
"options.education.masters": "Master's degree",
|
||||
"options.education.phd": "Doctor of science",
|
||||
"options.education.middle": "Secondary school",
|
||||
"options.education.school": "Secondary education",
|
||||
"options.education.school_dropout": "Incomplete secondary education",
|
||||
"options.education.higher": "Higher education",
|
||||
"options.education.secondary": "Secondary education",
|
||||
"options.marriage.MARRIED": "Married",
|
||||
"options.marriage.SINGLE": "Single",
|
||||
"options.marriage.DIVORCED": "Divorced",
|
||||
"options.marriage.WIDOW": "Widowed",
|
||||
"options.marriage.LEGAL": "Not married (legal)",
|
||||
"analytics.orderType.loan": "Loan orders",
|
||||
"analytics.orderType.loan_paid_off_letter": "Loan paid-off letter",
|
||||
"analytics.orderType.card": "New card",
|
||||
"analytics.orderType.card_pin": "Card PIN",
|
||||
"analytics.orderType.card_rekwizit": "Card requisites",
|
||||
"analytics.orderType.visa_master": "Visa / Master",
|
||||
"table.filters": "Filters",
|
||||
"table.search": "Search...",
|
||||
"table.toggleColumns": "Toggle columns",
|
||||
"table.perPage": "Per page",
|
||||
"table.reset": "Reset",
|
||||
"dashboard.errorTitle": "Failed to load data",
|
||||
"dashboard.errorMessage": "A connection error occurred with the server.",
|
||||
"common.retry": "Try again",
|
||||
|
||||
@@ -1581,6 +1581,53 @@
|
||||
"visaMasterSberSettings.createTitle": "Создать настройку",
|
||||
"visaMasterSberSettings.editTitle": "Редактировать настройку",
|
||||
"onlinePayments.viewTitle": "Детали платежа",
|
||||
"onlinePayments.columns.id": "ID",
|
||||
"onlinePayments.columns.orderId": "BELGI ORDER",
|
||||
"onlinePayments.columns.type": "ТИП",
|
||||
"onlinePayments.columns.branch": "ФИЛИАЛ",
|
||||
"onlinePayments.columns.passport": "ПАСПОРТ",
|
||||
"onlinePayments.columns.totalAmount": "ИТОГО (TMT)",
|
||||
"onlinePayments.columns.gatewayStatus": "СТАТУС ШЛЮЗА",
|
||||
"onlinePayments.columns.paid": "ОПЛАЧЕНО",
|
||||
"onlinePayments.filters.status": "Статус",
|
||||
"onlinePayments.filters.branch": "Филиал",
|
||||
"onlinePayments.filters.orderId": "ID заказа",
|
||||
"onlinePayments.filters.userId": "ID пользователя",
|
||||
"onlinePayments.gatewayStatus.pending": "Ожидание",
|
||||
"onlinePayments.gatewayStatus.paid": "Оплачено",
|
||||
"onlinePayments.gatewayStatus.unpaid": "Не оплачено",
|
||||
"onlinePayments.gatewayStatus.failed": "Ошибка",
|
||||
"onlinePayments.paid.paid": "Оплачено",
|
||||
"onlinePayments.paid.unpaid": "Не оплачено",
|
||||
"onlinePayments.detail.stepsCount": "Шаги",
|
||||
"onlinePayments.noHistory": "История платежа не найдена",
|
||||
"onlinePayments.detailKeys.order_id": "ID заказа",
|
||||
"onlinePayments.detailKeys.order_unique_id": "Уникальный ID заказа",
|
||||
"onlinePayments.detailKeys.type": "Тип",
|
||||
"onlinePayments.detailKeys.branch": "Филиал",
|
||||
"onlinePayments.detailKeys.passport": "Паспорт",
|
||||
"onlinePayments.detailKeys.passport_id": "ID паспорта",
|
||||
"onlinePayments.detailKeys.user_id": "ID пользователя",
|
||||
"onlinePayments.detailKeys.paid": "Оплачено",
|
||||
"onlinePayments.detailKeys.amount": "Сумма",
|
||||
"onlinePayments.detailKeys.amount_tmt": "Сумма (TMT)",
|
||||
"onlinePayments.detailKeys.bank_fee_tmt": "Комиссия банка (TMT)",
|
||||
"onlinePayments.detailKeys.gbus_fee_tmt": "Комиссия GBUS (TMT)",
|
||||
"onlinePayments.detailKeys.total_amount_tmt": "Итого (TMT)",
|
||||
"onlinePayments.detailKeys.exchange_rate_usd": "Курс USD",
|
||||
"onlinePayments.detailKeys.payment_period": "Период платежа",
|
||||
"onlinePayments.detailKeys.gateway_status": "Статус шлюза",
|
||||
"onlinePayments.detailKeys.gateway_reference": "Референс шлюза",
|
||||
"onlinePayments.detailKeys.card": "Карта",
|
||||
"onlinePayments.detailKeys.masked_card": "Номер карты",
|
||||
"onlinePayments.detailKeys.transaction_id": "ID транзакции",
|
||||
"onlinePayments.detailKeys.currency": "Валюта",
|
||||
"onlinePayments.detailKeys.error": "Ошибка",
|
||||
"onlinePayments.detailKeys.error_message": "Текст ошибки",
|
||||
"onlinePayments.detailKeys.message": "Сообщение",
|
||||
"onlinePayments.detailKeys.ip": "IP-адрес",
|
||||
"onlinePayments.detailKeys.created_by": "Создал",
|
||||
"onlinePayments.detailKeys.created_at": "Дата создания",
|
||||
"cardTypes.viewTitle": "Детали типа карты",
|
||||
"profile.title": "Мой профиль",
|
||||
"profile.actions.assignRole": "Назначить роль",
|
||||
@@ -1696,6 +1743,31 @@
|
||||
"analytics.guarantors.none": "Без поручителя",
|
||||
"analytics.guarantors.one": "1 поручитель",
|
||||
"analytics.guarantors.two": "2 поручителя",
|
||||
"options.education.high": "Высшее образование",
|
||||
"options.education.unfinished_high": "Незаконченное высшее",
|
||||
"options.education.masters": "Магистр",
|
||||
"options.education.phd": "Доктор наук",
|
||||
"options.education.middle": "Средняя школа",
|
||||
"options.education.school": "Среднее образование",
|
||||
"options.education.school_dropout": "Незаконченное среднее",
|
||||
"options.education.higher": "Высшее образование",
|
||||
"options.education.secondary": "Среднее образование",
|
||||
"options.marriage.MARRIED": "Женат / Замужем",
|
||||
"options.marriage.SINGLE": "Не женат / Не замужем",
|
||||
"options.marriage.DIVORCED": "Развод",
|
||||
"options.marriage.WIDOW": "Вдовец / Вдова",
|
||||
"options.marriage.LEGAL": "Не состоит в браке",
|
||||
"analytics.orderType.loan": "Заявки на кредит",
|
||||
"analytics.orderType.loan_paid_off_letter": "Справка о погашении кредита",
|
||||
"analytics.orderType.card": "Новая карта",
|
||||
"analytics.orderType.card_pin": "ПИН карты",
|
||||
"analytics.orderType.card_rekwizit": "Реквизиты карты",
|
||||
"analytics.orderType.visa_master": "Visa / Master",
|
||||
"table.filters": "Фильтры",
|
||||
"table.search": "Поиск...",
|
||||
"table.toggleColumns": "Столбцы",
|
||||
"table.perPage": "На странице",
|
||||
"table.reset": "Сбросить",
|
||||
"dashboard.errorTitle": "Не удалось загрузить данные",
|
||||
"dashboard.errorMessage": "Произошла ошибка при подключении к серверу.",
|
||||
"common.retry": "Повторить",
|
||||
|
||||
@@ -1579,6 +1579,53 @@
|
||||
"visaMasterSberSettings.createTitle": "Sazlama döretmek",
|
||||
"visaMasterSberSettings.editTitle": "Sazlama üýtgetmek",
|
||||
"onlinePayments.viewTitle": "Töleg giňišleýin",
|
||||
"onlinePayments.columns.id": "ID",
|
||||
"onlinePayments.columns.orderId": "ORDER BELGISI",
|
||||
"onlinePayments.columns.type": "GÖRNÜŞI",
|
||||
"onlinePayments.columns.branch": "ŞAHAMÇA",
|
||||
"onlinePayments.columns.passport": "PASPORT",
|
||||
"onlinePayments.columns.totalAmount": "JEMI (TMT)",
|
||||
"onlinePayments.columns.gatewayStatus": "GATEWAY STATUSY",
|
||||
"onlinePayments.columns.paid": "TÖLENDI",
|
||||
"onlinePayments.filters.status": "Status",
|
||||
"onlinePayments.filters.branch": "Şahamça",
|
||||
"onlinePayments.filters.orderId": "Order ID",
|
||||
"onlinePayments.filters.userId": "Ulanyjy ID",
|
||||
"onlinePayments.gatewayStatus.pending": "Garaşylýar",
|
||||
"onlinePayments.gatewayStatus.paid": "Tölendi",
|
||||
"onlinePayments.gatewayStatus.unpaid": "Tölenmedi",
|
||||
"onlinePayments.gatewayStatus.failed": "Ýalňyşlyk",
|
||||
"onlinePayments.paid.paid": "Tölendi",
|
||||
"onlinePayments.paid.unpaid": "Tölenmedi",
|
||||
"onlinePayments.detail.stepsCount": "Ädimler",
|
||||
"onlinePayments.noHistory": "Töleg taryhy tapylmady",
|
||||
"onlinePayments.detailKeys.order_id": "Order ID",
|
||||
"onlinePayments.detailKeys.order_unique_id": "Unikal order ID",
|
||||
"onlinePayments.detailKeys.type": "Görnüşi",
|
||||
"onlinePayments.detailKeys.branch": "Şahamça",
|
||||
"onlinePayments.detailKeys.passport": "Pasport",
|
||||
"onlinePayments.detailKeys.passport_id": "Pasport ID",
|
||||
"onlinePayments.detailKeys.user_id": "Ulanyjy ID",
|
||||
"onlinePayments.detailKeys.paid": "Tölendi",
|
||||
"onlinePayments.detailKeys.amount": "Möçberi",
|
||||
"onlinePayments.detailKeys.amount_tmt": "Möçberi (TMT)",
|
||||
"onlinePayments.detailKeys.bank_fee_tmt": "Bank komissiýasy (TMT)",
|
||||
"onlinePayments.detailKeys.gbus_fee_tmt": "GBUS komissiýasy (TMT)",
|
||||
"onlinePayments.detailKeys.total_amount_tmt": "Jemi (TMT)",
|
||||
"onlinePayments.detailKeys.exchange_rate_usd": "USD awtomatik bahasy",
|
||||
"onlinePayments.detailKeys.payment_period": "Töleg möhleti",
|
||||
"onlinePayments.detailKeys.gateway_status": "Gateway statusy",
|
||||
"onlinePayments.detailKeys.gateway_reference": "Gateway referansi",
|
||||
"onlinePayments.detailKeys.card": "Kart",
|
||||
"onlinePayments.detailKeys.masked_card": "Kart belgisi",
|
||||
"onlinePayments.detailKeys.transaction_id": "Tranzaksiýa ID",
|
||||
"onlinePayments.detailKeys.currency": "Pul birligi",
|
||||
"onlinePayments.detailKeys.error": "Ýalňyşlyk",
|
||||
"onlinePayments.detailKeys.error_message": "Ýalňyşlyk teksti",
|
||||
"onlinePayments.detailKeys.message": "Habar",
|
||||
"onlinePayments.detailKeys.ip": "IP salgysy",
|
||||
"onlinePayments.detailKeys.created_by": "Döreden",
|
||||
"onlinePayments.detailKeys.created_at": "Döredilen wagty",
|
||||
"cardTypes.viewTitle": "Kart görnüşi giňişleýin",
|
||||
"profile.title": "Meniň profilim",
|
||||
"profile.actions.assignRole": "Rol birikdiriň",
|
||||
@@ -1694,6 +1741,31 @@
|
||||
"analytics.guarantors.none": "Zamunsyz",
|
||||
"analytics.guarantors.one": "1 zamun",
|
||||
"analytics.guarantors.two": "2 zamun",
|
||||
"options.education.high": "Ýokary bilim",
|
||||
"options.education.unfinished_high": "Gutarylmadyk ýokary bilim",
|
||||
"options.education.masters": "Magistr",
|
||||
"options.education.phd": "Ylymlaryň doktory",
|
||||
"options.education.middle": "Orta mekdep",
|
||||
"options.education.school": "Orta bilim",
|
||||
"options.education.school_dropout": "Gutarylmadyk orta bilim",
|
||||
"options.education.higher": "Ýokary bilim",
|
||||
"options.education.secondary": "Orta bilim",
|
||||
"options.marriage.MARRIED": "Öýlenen / Durmuşa çykan",
|
||||
"options.marriage.SINGLE": "Öýlenmedik / Durmuşa çykmadyk",
|
||||
"options.marriage.DIVORCED": "Aýrylşan",
|
||||
"options.marriage.WIDOW": "Adamsy ýa-da aýaly aradan çykan",
|
||||
"options.marriage.LEGAL": "Raýat nika",
|
||||
"analytics.orderType.loan": "Karz sargytlary",
|
||||
"analytics.orderType.loan_paid_off_letter": "Karzyň ýapylandygy",
|
||||
"analytics.orderType.card": "Täze kart",
|
||||
"analytics.orderType.card_pin": "Kart pin",
|
||||
"analytics.orderType.card_rekwizit": "Kart rekwizit",
|
||||
"analytics.orderType.visa_master": "Visa/Master",
|
||||
"table.filters": "Filterler",
|
||||
"table.search": "Gözlemek...",
|
||||
"table.toggleColumns": "Sütünler",
|
||||
"table.perPage": "Sahypa başyna",
|
||||
"table.reset": "Arassala",
|
||||
"dashboard.errorTitle": "Maglumatlary ýükläp bolmady",
|
||||
"dashboard.errorMessage": "Serwer bilen baglanyşykda säwlik ýüze çykdy.",
|
||||
"common.retry": "Täzeden synanyş",
|
||||
|
||||
@@ -11,6 +11,7 @@ import type { VisibilityState } from "@tanstack/react-table";
|
||||
import { useGetOnlinePayments } from "@/features/onlinePaymentHistory/hooks/useOnlinePaymentsHistory";
|
||||
import type { OnlinePayment } from "@/features/onlinePaymentHistory/api/onlinePaymentsHistoryApi";
|
||||
import { GatewayStatusBadge, PaidBadge } from "../../features/onlinePaymentHistory/components/PaymentStatusBadge";
|
||||
import { getGatewayStatusOptions } from "@/constants/paymentStatus";
|
||||
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
|
||||
|
||||
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
||||
@@ -50,13 +51,18 @@ const DEFAULT_VISIBILITY: VisibilityState = {
|
||||
|
||||
const DEFAULT_ORDER = [...COLUMN_IDS, "actions"];
|
||||
|
||||
/** Gateway status options for the filter dropdown. */
|
||||
const GATEWAY_STATUS_OPTIONS = [
|
||||
{ value: "success", label: "Success" },
|
||||
{ value: "failed", label: "Failed" },
|
||||
{ value: "pending", label: "Pending" },
|
||||
{ value: "processing", label: "Processing" },
|
||||
];
|
||||
/** Column id → i18n key, shared by the table headers and the column-toggle list. */
|
||||
const COLUMN_LABEL_KEYS: Record<(typeof COLUMN_IDS)[number], string> = {
|
||||
id: "onlinePayments.columns.id",
|
||||
orderId: "onlinePayments.columns.orderId",
|
||||
type: "onlinePayments.columns.type",
|
||||
branchName: "onlinePayments.columns.branch",
|
||||
passport: "onlinePayments.columns.passport",
|
||||
totalAmountTmt: "onlinePayments.columns.totalAmount",
|
||||
gatewayStatus: "onlinePayments.columns.gatewayStatus",
|
||||
paid: "onlinePayments.columns.paid",
|
||||
createdAt: "onlinePayments.columns.createdAt",
|
||||
};
|
||||
|
||||
// ─── OnlinePaymentHistoryPage ─────────────────────────────────────────────────
|
||||
|
||||
@@ -109,6 +115,8 @@ export default function OnlinePaymentHistoryPage() {
|
||||
// ─── Derive query params from active filters
|
||||
const filterMap = useMemo(() => Object.fromEntries(activeFilters.map((f) => [f.fieldId, f.value])), [activeFilters]);
|
||||
|
||||
const gatewayStatusOptions = useMemo(() => getGatewayStatusOptions(t), [t]);
|
||||
|
||||
const queryParams = useMemo(
|
||||
() => ({
|
||||
page,
|
||||
@@ -147,7 +155,7 @@ export default function OnlinePaymentHistoryPage() {
|
||||
id: "status",
|
||||
label: t("onlinePayments.filters.status", "Status"),
|
||||
type: "select",
|
||||
options: GATEWAY_STATUS_OPTIONS,
|
||||
options: gatewayStatusOptions,
|
||||
},
|
||||
{
|
||||
id: "branchId",
|
||||
@@ -172,7 +180,7 @@ export default function OnlinePaymentHistoryPage() {
|
||||
type: "text",
|
||||
},
|
||||
],
|
||||
[t, branchOptions, isBranchesLoading, isFetchingNextBranches, hasNextBranches, branchSearch],
|
||||
[t, branchOptions, isBranchesLoading, isFetchingNextBranches, hasNextBranches, branchSearch, gatewayStatusOptions],
|
||||
);
|
||||
|
||||
// ─── Columns
|
||||
@@ -181,28 +189,28 @@ export default function OnlinePaymentHistoryPage() {
|
||||
{
|
||||
id: "id",
|
||||
accessorKey: "id",
|
||||
header: t("onlinePayments.columns.id", "ID"),
|
||||
header: t(COLUMN_LABEL_KEYS.id, "ID"),
|
||||
cell: ({ row }) => <span className="tabular-nums text-foreground font-medium">{row.original.id}</span>,
|
||||
size: 50,
|
||||
},
|
||||
{
|
||||
id: "orderId",
|
||||
accessorKey: "orderId",
|
||||
header: t("onlinePayments.columns.orderId", "ORDER ID"),
|
||||
header: t(COLUMN_LABEL_KEYS.orderId, "ORDER ID"),
|
||||
cell: ({ row }) => <span className="tabular-nums text-foreground font-medium">{row.original.orderId}</span>,
|
||||
size: 90,
|
||||
},
|
||||
{
|
||||
id: "type",
|
||||
accessorKey: "type",
|
||||
header: t("onlinePayments.columns.type", "TYPE"),
|
||||
header: t(COLUMN_LABEL_KEYS.type, "TYPE"),
|
||||
cell: ({ row }) => <span className="text-xs font-semibold uppercase tracking-wide text-foreground">{row.original.type}</span>,
|
||||
size: 80,
|
||||
},
|
||||
{
|
||||
id: "branchName",
|
||||
accessorKey: "branchName",
|
||||
header: t("onlinePayments.columns.branch", "BRANCH"),
|
||||
header: t(COLUMN_LABEL_KEYS.branchName, "BRANCH"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground truncate max-w-[200px] block">
|
||||
{row.original.branchName?.[lang] ?? row.original.branchName?.en ?? "—"}
|
||||
@@ -213,7 +221,7 @@ export default function OnlinePaymentHistoryPage() {
|
||||
{
|
||||
id: "passport",
|
||||
accessorKey: "passport",
|
||||
header: t("onlinePayments.columns.passport", "PASSPORT"),
|
||||
header: t(COLUMN_LABEL_KEYS.passport, "PASSPORT"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground">
|
||||
{row.original.passportName} {row.original.passportSurname}
|
||||
@@ -224,28 +232,28 @@ export default function OnlinePaymentHistoryPage() {
|
||||
{
|
||||
id: "totalAmountTmt",
|
||||
accessorKey: "totalAmountTmt",
|
||||
header: t("onlinePayments.columns.totalAmount", "TOTAL (TMT)"),
|
||||
header: t(COLUMN_LABEL_KEYS.totalAmountTmt, "TOTAL (TMT)"),
|
||||
cell: ({ row }) => <span className="tabular-nums text-foreground font-medium">{row.original.totalAmountTmt.toLocaleString()}</span>,
|
||||
size: 110,
|
||||
},
|
||||
{
|
||||
id: "gatewayStatus",
|
||||
accessorKey: "gatewayStatus",
|
||||
header: t("onlinePayments.columns.gatewayStatus", "GATEWAY STATUS"),
|
||||
header: t(COLUMN_LABEL_KEYS.gatewayStatus, "GATEWAY STATUS"),
|
||||
cell: ({ row }) => <GatewayStatusBadge status={row.original.gatewayStatus} />,
|
||||
size: 140,
|
||||
},
|
||||
{
|
||||
id: "paid",
|
||||
accessorKey: "paid",
|
||||
header: t("onlinePayments.columns.paid", "PAID"),
|
||||
header: t(COLUMN_LABEL_KEYS.paid, "PAID"),
|
||||
cell: ({ row }) => <PaidBadge paid={row.original.paid} />,
|
||||
size: 90,
|
||||
},
|
||||
{
|
||||
id: "createdAt",
|
||||
accessorKey: "createdAt",
|
||||
header: t("onlinePayments.columns.createdAt", "CREATED AT"),
|
||||
header: t(COLUMN_LABEL_KEYS.createdAt, "CREATED AT"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-muted-foreground text-xs whitespace-nowrap">{formatDateTime(row.original.createdAt)}</span>
|
||||
),
|
||||
@@ -275,7 +283,7 @@ export default function OnlinePaymentHistoryPage() {
|
||||
[t, navigate, lang],
|
||||
);
|
||||
|
||||
const toggleableColumns = useMemo(() => COLUMN_IDS.map((id) => ({ id, label: t(`onlinePayments.columns.${id}`, id) })), [t]);
|
||||
const toggleableColumns = useMemo(() => COLUMN_IDS.map((id) => ({ id, label: t(COLUMN_LABEL_KEYS[id], id) })), [t]);
|
||||
|
||||
// ─── Derived pagination
|
||||
const totalCount = data?.count ?? 0;
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useGetOnlinePaymentById } from "@/features/onlinePaymentHistory/hooks/u
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import type { PaymentHistoryStep } from "@/features/onlinePaymentHistory/api/onlinePaymentsHistoryApi";
|
||||
import { GatewayStatusBadge } from "@/features/onlinePaymentHistory/components/PaymentStatusBadge";
|
||||
import { rawEnumKey, type TranslateFn } from "@/constants/enumLabels";
|
||||
|
||||
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -20,9 +21,15 @@ function formatDateTime(iso: string): string {
|
||||
return `${hh}:${mm}, ${dd}.${mo}.${yy}`;
|
||||
}
|
||||
|
||||
/** Backend sends raw keys like "gateway_reference" — look them up under `onlinePayments.detailKeys`. */
|
||||
function detailKeyLabel(key: string, t: TranslateFn): string {
|
||||
return t(`onlinePayments.detailKeys.${key}`, rawEnumKey(key));
|
||||
}
|
||||
|
||||
// ─── StepRow ──────────────────────────────────────────────────────────────────
|
||||
|
||||
function StepRow({ step }: { step: PaymentHistoryStep }) {
|
||||
const { t } = useTranslation();
|
||||
const detailEntries = Object.entries(step.detail ?? {});
|
||||
|
||||
return (
|
||||
@@ -45,7 +52,7 @@ function StepRow({ step }: { step: PaymentHistoryStep }) {
|
||||
<div className="mt-2 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-[120px]">{key}</span>
|
||||
<span className="text-muted-foreground font-medium min-w-[120px]">{detailKeyLabel(key, t)}</span>
|
||||
<span className="text-foreground break-all">{String(value)}</span>
|
||||
</div>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user