changes some status
This commit is contained in:
@@ -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 ──────────────
|
||||
|
||||
Reference in New Issue
Block a user