changes some status
This commit is contained in:
1 parent
cbd17608c1
commit
6e626482f6
15 files changed
+553
-99
No files matched your search
@@ -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