refactored code
This commit is contained in:
@@ -2,3 +2,4 @@ export * from "./formOptions";
|
||||
export * from "./passportSeries";
|
||||
export * from "./regionCodes";
|
||||
export * from "./statusOptions";
|
||||
export * from "./statusCells";
|
||||
|
||||
41
src/constants/statusCells.tsx
Normal file
41
src/constants/statusCells.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Clock, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { STATUS_BADGE_VARIANTS, isStatusValue, getStatusLabel, type StatusValue } from "@/constants/statusOptions";
|
||||
|
||||
export const STATUS_ICONS: Record<StatusValue, React.ElementType> = {
|
||||
pending: Clock,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
};
|
||||
|
||||
interface StatusCellProps {
|
||||
status: string;
|
||||
prefix?: string;
|
||||
fallbackLabels?: Record<string, string>;
|
||||
fallbackVariants?: Record<string, StatusBadgeVariant>;
|
||||
}
|
||||
|
||||
export function StatusCell({ status, prefix = "status", fallbackLabels, fallbackVariants }: StatusCellProps) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
if (isStatusValue(status)) {
|
||||
return <StatusBadge label={getStatusLabel(status, t, prefix)} variant={STATUS_BADGE_VARIANTS[status]} icon={STATUS_ICONS[status]} />;
|
||||
}
|
||||
|
||||
const label = (fallbackLabels && fallbackLabels[status]) ?? status;
|
||||
const variant = (fallbackVariants && fallbackVariants[status]) ?? "default";
|
||||
return <StatusBadge label={label} variant={variant} />;
|
||||
}
|
||||
|
||||
export function ActiveStatusCell({ active }: { active: boolean }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<StatusBadge
|
||||
label={active ? t("common.active", "Işjeň") : t("common.inactive", "Işjeň däl")}
|
||||
variant={active ? "success" : "default"}
|
||||
icon={active ? CheckCircle2 : XCircle}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -485,7 +485,8 @@ export function BranchForm({ mode, initialData }: BranchFormProps) {
|
||||
onPrev={currentStep > 0 ? handleBack : undefined}
|
||||
onNext={!isLastStep ? handleNext : undefined}
|
||||
showSubmit={isLastStep}
|
||||
onSubmit={isLastStep ? doSubmit : undefined}
|
||||
saveOnEveryStep={mode === "edit"}
|
||||
onSubmit={doSubmit}
|
||||
submitLabel={mode === "create" ? t("branches.actions.create", "Şahamça döret") : t("branches.actions.update", "Täzelemek")}
|
||||
className="px-5 py-3.5 border-t border-border bg-muted/30"
|
||||
/>
|
||||
|
||||
@@ -588,7 +588,8 @@ export function CardPinForm({ mode, initialData }: CardPinFormProps) {
|
||||
onNext={!isLastStep ? handleNext : undefined}
|
||||
nextLabel={t("common.next", "Indiki")}
|
||||
showSubmit={isLastStep}
|
||||
onSubmit={isLastStep ? handleSubmit : undefined}
|
||||
saveOnEveryStep={mode === "edit"}
|
||||
onSubmit={handleSubmit}
|
||||
submitLabel={
|
||||
mode === "create" ? t("cardPin.createBtn", "Kart pin bukja dörediň") : t("cardPin.editBtn", "Kart pin bukja redaktirläň")
|
||||
}
|
||||
|
||||
@@ -752,7 +752,8 @@ export function CardOrderForm({ mode, initialData }: CardOrderFormProps) {
|
||||
onPrev={currentStep > 0 ? handleBack : undefined}
|
||||
onNext={!isLastStep ? handleNext : undefined}
|
||||
showSubmit={isLastStep}
|
||||
onSubmit={isLastStep ? doSubmit : undefined}
|
||||
saveOnEveryStep={mode === "edit"}
|
||||
onSubmit={doSubmit}
|
||||
submitLabel={mode === "create" ? t("cardOrder.submit", "Kart sargyt dörediň") : t("common.save", "Ýatda sakla")}
|
||||
loadingLabel={t("common.saving", "Ýüklenilýär...")}
|
||||
cancelLabel={t("common.cancel", "Ýatyr")}
|
||||
|
||||
@@ -624,7 +624,8 @@ export function SberPaymentForm({ mode, initialData }: SberPaymentFormProps) {
|
||||
onPrev={currentStep > 0 ? handleBack : undefined}
|
||||
onNext={!isLastStep ? handleNext : undefined}
|
||||
showSubmit={isLastStep}
|
||||
onSubmit={isLastStep ? doSubmit : undefined}
|
||||
saveOnEveryStep={mode === "edit"}
|
||||
onSubmit={doSubmit}
|
||||
submitLabel={
|
||||
mode === "create"
|
||||
? t("sberPayments.buttons.create", "Sber töleg (talyplar üçin) dörediň")
|
||||
|
||||
@@ -673,7 +673,8 @@ export function IntlPaymentForm({ mode, initialData }: IntlPaymentFormProps) {
|
||||
onPrev={currentStep > 0 ? handleBack : undefined}
|
||||
onNext={!isLastStep ? handleNext : undefined}
|
||||
showSubmit={isLastStep}
|
||||
onSubmit={isLastStep ? doSubmit : undefined}
|
||||
saveOnEveryStep={mode === "edit"}
|
||||
onSubmit={doSubmit}
|
||||
submitLabel={mode === "create" ? t("intlPayment.createBtn", "Dörediň") : t("intlPayment.editBtn", "Redaktirläň")}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -898,7 +898,7 @@
|
||||
"sberPayments.status.approved": "Tassyklandy",
|
||||
"sberPayments.status.rejected": "Ýatyryldy",
|
||||
"sberPayments.paidStatus.paid": "Tölendi",
|
||||
"sberPayments.paidStatus.unpaid": "Tölmedi",
|
||||
"sberPayments.paidStatus.unpaid": "Tölenmedi",
|
||||
"sberPayments.view.sections.main": "Esasy maglumatlar",
|
||||
"sberPayments.view.sections.location": "Lokasiýa",
|
||||
"sberPayments.view.sections.personal": "Şahsy maglumatlar",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState, useMemo, useCallback } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Download, Database, CheckCircle2, XCircle, Clock, AlertCircle } from "lucide-react";
|
||||
import { Download, Database } from "lucide-react";
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
@@ -10,27 +10,11 @@ import { DataTable } from "@/components/dataTable";
|
||||
import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
||||
import { TableSearchInput } from "@/components/tableSearch";
|
||||
import { CreateButton } from "@/components/createButton";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { StatusCell } from "@/constants";
|
||||
import { useBackups, useCreateBackup, useDeleteBackup, useDownloadBackup } from "@/features/backups/hooks/useBackups";
|
||||
import type { Backup, BackupStatus } from "@/features/backups/api/backupsApi";
|
||||
import type { Backup } from "@/features/backups/api/backupsApi";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
|
||||
// ─── Status Badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_CONFIG: Record<BackupStatus, { labelKey: string; fallback: string; variant: StatusBadgeVariant; icon: React.ElementType }> = {
|
||||
pending: { labelKey: "backups.status.pending", fallback: "Garaşylýar", variant: "warning", icon: AlertCircle },
|
||||
in_progress: { labelKey: "backups.status.inProgress", fallback: "Dowam edýär", variant: "warning", icon: Clock },
|
||||
completed: { labelKey: "backups.status.completed", fallback: "Tamamlandy", variant: "success", icon: CheckCircle2 },
|
||||
failed: { labelKey: "backups.status.failed", fallback: "Şowsuz", variant: "error", icon: XCircle },
|
||||
};
|
||||
|
||||
function BackupStatusBadge({ status }: { status: string }) {
|
||||
const { t } = useTranslation();
|
||||
const cfg = STATUS_CONFIG[status as BackupStatus];
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={t(cfg.labelKey, cfg.fallback)} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
|
||||
// ─── Column meta for toggle dropdown ─────────────────────────────────────────
|
||||
|
||||
const COLUMN_IDS = ["id", "fileName", "size", "status", "createdBy", "createdAt"] as const;
|
||||
@@ -129,7 +113,14 @@ export default function BackupsPage() {
|
||||
id: "status",
|
||||
accessorKey: "status",
|
||||
header: t("backups.col.status", "Status"),
|
||||
cell: ({ row }) => <BackupStatusBadge status={row.original.status} />,
|
||||
cell: ({ row }) => (
|
||||
<StatusCell
|
||||
status={row.original.status}
|
||||
prefix="backups.status"
|
||||
fallbackLabels={{ pending: "Garaşylýar", in_progress: "Dowam edýär", completed: "Tamamlandy", failed: "Şowsuz" }}
|
||||
fallbackVariants={{ pending: "warning", in_progress: "warning", completed: "success", failed: "error" }}
|
||||
/>
|
||||
),
|
||||
size: 140,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,30 +1,13 @@
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Download, Database, CheckCircle2, XCircle, Clock, AlertCircle } from "lucide-react";
|
||||
import { Download, Database } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { useBackup, useDeleteBackup, useDownloadBackup } from "@/features/backups/hooks/useBackups";
|
||||
import { InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import type { BackupStatus } from "@/features/backups/api/backupsApi";
|
||||
import { StatusCell } from "@/constants";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
|
||||
// ─── Status Badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_CONFIG: Record<BackupStatus, { labelKey: string; fallback: string; variant: StatusBadgeVariant; icon: React.ElementType }> = {
|
||||
pending: { labelKey: "backups.status.pending", fallback: "Garaşylýar", variant: "warning", icon: AlertCircle },
|
||||
in_progress: { labelKey: "backups.status.inProgress", fallback: "Dowam edýär", variant: "warning", icon: Clock },
|
||||
completed: { labelKey: "backups.status.completed", fallback: "Tamamlandy", variant: "success", icon: CheckCircle2 },
|
||||
failed: { labelKey: "backups.status.failed", fallback: "Şowsuz", variant: "error", icon: XCircle },
|
||||
};
|
||||
|
||||
function BackupStatusBadge({ status }: { status: string }) {
|
||||
const { t } = useTranslation();
|
||||
const cfg = STATUS_CONFIG[status as BackupStatus];
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={t(cfg.labelKey, cfg.fallback)} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function BackupViewPage() {
|
||||
@@ -93,7 +76,12 @@ export default function BackupViewPage() {
|
||||
<InfoRow label={t("backups.col.fileName", "Faýl ady")} value={data.fileName} />
|
||||
<InfoRow label={t("backups.col.fileSize", "Ölçegi")} value={`${data.size} (${data.sizeBytes} bytes)`} />
|
||||
<InfoRow label={t("backups.col.status", "Status")}>
|
||||
<BackupStatusBadge status={data.status} />
|
||||
<StatusCell
|
||||
status={data.status}
|
||||
prefix="backups.status"
|
||||
fallbackLabels={{ pending: "Garaşylýar", in_progress: "Dowam edýär", completed: "Tamamlandy", failed: "Şowsuz" }}
|
||||
fallbackVariants={{ pending: "warning", in_progress: "warning", completed: "success", failed: "error" }}
|
||||
/>
|
||||
</InfoRow>
|
||||
<InfoRow
|
||||
label={t("backups.col.createdBy", "Döreden")}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState, useMemo, useCallback } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
@@ -9,30 +9,12 @@ import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/compone
|
||||
import { TableSearchInput } from "@/components/tableSearch";
|
||||
import { CreateButton } from "@/components/createButton";
|
||||
import { TableActions } from "@/components/tableActions";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { StatusCell } from "@/constants";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { useCardBalances, useDeleteCardBalance } from "@/features/cardBalance/hooks/useCardBalance";
|
||||
import type { CardBalance, CardBalanceStatus } from "@/features/cardBalance/api/cardBalanceApi";
|
||||
import type { CardBalance } from "@/features/cardBalance/api/cardBalanceApi";
|
||||
import { useInfiniteUsers } from "@/features/allUsers/hooks/useAllUsers";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
// ─── Status Badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_CONFIG: Record<
|
||||
CardBalanceStatus,
|
||||
{ labelKey: string; fallback: string; variant: StatusBadgeVariant; icon: React.ElementType }
|
||||
> = {
|
||||
pending: { labelKey: "cardBalance.status.pending", fallback: "Garaşylýar", variant: "warning", icon: AlertCircle },
|
||||
approved: { labelKey: "cardBalance.status.approved", fallback: "Tassyklanan", variant: "success", icon: CheckCircle2 },
|
||||
rejected: { labelKey: "cardBalance.status.rejected", fallback: "Ret edilen", variant: "error", icon: XCircle },
|
||||
};
|
||||
|
||||
function CardBalanceStatusBadge({ status }: { status: string }) {
|
||||
const { t } = useTranslation();
|
||||
const cfg = STATUS_CONFIG[status as CardBalanceStatus];
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={t(cfg.labelKey, cfg.fallback)} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
|
||||
// ─── Column meta for toggle dropdown ─────────────────────────────────────────
|
||||
|
||||
const COLUMN_IDS = ["id", "passportNumber", "cardLast4", "expiry", "balance", "status", "createdBy", "createdAt"] as const;
|
||||
@@ -176,7 +158,14 @@ export default function CardBalancesPage() {
|
||||
id: "status",
|
||||
accessorKey: "status",
|
||||
header: t("Status", "STATUS"),
|
||||
cell: ({ row }) => <CardBalanceStatusBadge status={row.original.status} />,
|
||||
cell: ({ row }) => (
|
||||
<StatusCell
|
||||
status={row.original.status}
|
||||
prefix="cardBalance.status"
|
||||
fallbackLabels={{ pending: "Garaşylýar", approved: "Tassyklanan", rejected: "Ret edilen" }}
|
||||
fallbackVariants={{ pending: "warning", approved: "success", rejected: "error" }}
|
||||
/>
|
||||
),
|
||||
size: 140,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,29 +1,10 @@
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { useCardBalance, useDeleteCardBalance } from "@/features/cardBalance/hooks/useCardBalance";
|
||||
import { InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import type { CardBalanceStatus } from "@/features/cardBalance/api/cardBalanceApi";
|
||||
import { StatusCell } from "@/constants";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
// ─── Status Badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_CONFIG: Record<
|
||||
CardBalanceStatus,
|
||||
{ labelKey: string; fallback: string; variant: StatusBadgeVariant; icon: React.ElementType }
|
||||
> = {
|
||||
pending: { labelKey: "cardBalance.status.pending", fallback: "Garaşylýar", variant: "warning", icon: AlertCircle },
|
||||
approved: { labelKey: "cardBalance.status.approved", fallback: "Tassyklanan", variant: "success", icon: CheckCircle2 },
|
||||
rejected: { labelKey: "cardBalance.status.rejected", fallback: "Ret edilen", variant: "error", icon: XCircle },
|
||||
};
|
||||
|
||||
function CardBalanceStatusBadge({ status }: { status: string }) {
|
||||
const { t } = useTranslation();
|
||||
const cfg = STATUS_CONFIG[status as CardBalanceStatus];
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={t(cfg.labelKey, cfg.fallback)} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -86,7 +67,12 @@ export default function CardBalanceViewPage() {
|
||||
<InfoRow label={t("Card expiry", "Kart möhleti")} value={`${String(data.expiryMonth).padStart(2, "0")}/${data.expiryYear}`} />
|
||||
<InfoRow label={t("Balance amount", "Galyndy möçberi")} value={`${data.balanceAmount} ${data.balanceCurrency}`} />
|
||||
<InfoRow label={t("Status", "Status")}>
|
||||
<CardBalanceStatusBadge status={data.status} />
|
||||
<StatusCell
|
||||
status={data.status}
|
||||
prefix="cardBalance.status"
|
||||
fallbackLabels={{ pending: "Garaşylýar", approved: "Tassyklanan", rejected: "Ret edilen" }}
|
||||
fallbackVariants={{ pending: "warning", approved: "success", rejected: "error" }}
|
||||
/>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("Checked at", "Barlan wagty")} value={formatFromApiDate(data.checkedAt)} />
|
||||
<InfoRow
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useState, useCallback, useMemo } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { TFunction } from "i18next";
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
import { DataTableToolbar, type ColumnMeta, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
||||
@@ -11,13 +10,12 @@ import { TableActions } from "@/components/tableActions";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
|
||||
import { useCardPins, useDeleteCardPin } from "@/features/cardPins/hooks/useCardPins";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
|
||||
import type { CardPinOrder } from "@/features/cardPins/api/cardPinApi";
|
||||
import { useBranches } from "@/features/branches/hooks/useBranches";
|
||||
import { useDistricts } from "@/features/districts/hooks/useDistricts";
|
||||
import { useCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
|
||||
import { getStatusLabel, getStatusOptions, isStatusValue, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
import { getStatusOptions, StatusCell } from "@/constants";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
// ─── Filter field IDs ──────────────────────────────────────────────────────────
|
||||
|
||||
@@ -26,29 +24,6 @@ type FilterId = (typeof FILTER_IDS)[number];
|
||||
|
||||
const INITIAL_FILTERS: ActiveFilter[] = FILTER_IDS.map((fieldId) => ({ fieldId, value: "" }));
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_ICONS: Record<StatusValue, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
};
|
||||
|
||||
function statusConfig(status: string, t: TFunction): { label: string; variant: StatusBadgeVariant; icon?: React.ElementType } {
|
||||
const key = status.trim().toLowerCase();
|
||||
if (isStatusValue(key)) {
|
||||
return { label: getStatusLabel(key, t, "cardPin.status"), variant: STATUS_BADGE_VARIANTS[key], icon: STATUS_ICONS[key] };
|
||||
}
|
||||
return { label: status, variant: "default" };
|
||||
}
|
||||
|
||||
function StatusCell({ status }: { status: string }) {
|
||||
const { t } = useTranslation();
|
||||
const cfg = statusConfig(status, t);
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
const PER_PAGE = 25;
|
||||
@@ -144,7 +119,7 @@ export default function CardPinsPage() {
|
||||
id: "status",
|
||||
accessorKey: "status",
|
||||
header: t("cardPin.col.status", "Statusy"),
|
||||
cell: ({ row }) => <StatusCell status={row.original.status} />,
|
||||
cell: ({ row }) => <StatusCell status={row.original.status} prefix="cardPin.status" />,
|
||||
},
|
||||
{
|
||||
id: "createdAt",
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useCardPin, useDeleteCardPin } from "@/features/cardPins/hooks/useCardPins";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage, ViewActions } from "@/components/viewPageComponents";
|
||||
import { getStatusLabel, isStatusValue, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
import { StatusCell } from "@/constants";
|
||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
|
||||
@@ -17,32 +15,6 @@ function resolveLocalizedName(name: LocalizedText | string | null | undefined, l
|
||||
return name[lang as keyof LocalizedText] ?? name.tm ?? name.en ?? name.ru ?? "";
|
||||
}
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_ICONS: Record<StatusValue, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
};
|
||||
|
||||
function statusConfig(
|
||||
status: string,
|
||||
t: (key: string, fallback?: string) => string,
|
||||
): { label: string; variant: StatusBadgeVariant; icon?: React.ElementType } {
|
||||
const key = status.trim().toLowerCase();
|
||||
if (isStatusValue(key)) {
|
||||
return { label: getStatusLabel(key, t, "cardPin.status"), variant: STATUS_BADGE_VARIANTS[key], icon: STATUS_ICONS[key] };
|
||||
}
|
||||
return { label: status, variant: "default" };
|
||||
}
|
||||
|
||||
function CardPinStatusBadge({ status }: { status: string }) {
|
||||
const { t } = useTranslation();
|
||||
const cfg = statusConfig(status, (key, fallback) => t(key, fallback ?? key));
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
|
||||
function CardPinViewSkeleton() {
|
||||
@@ -102,7 +74,7 @@ export default function CardPinViewPage() {
|
||||
<InfoRow label={t("common.id", "ID")} value={data.id} />
|
||||
<InfoRow label={t("cardPin.field.uniqueId", "Sargyt belgisi")} value={data.uniqueId} />
|
||||
<InfoRow label={t("cardPin.field.status", "Status")}>
|
||||
<CardPinStatusBadge status={data.status} />
|
||||
<StatusCell status={data.status} prefix="cardPin.status" />
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.field.notes", "Bellik")} value={data.notes || undefined} />
|
||||
<InfoRow label={t("cardPin.col.createdAt", "Döredilen wagty")} value={data.createdAt ? formatFromApiDate(data.createdAt) : "—"} />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState, useMemo, useCallback } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
@@ -9,33 +9,15 @@ import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/compone
|
||||
import { TableSearchInput } from "@/components/tableSearch";
|
||||
import { CreateButton } from "@/components/createButton";
|
||||
import { TableActions } from "@/components/tableActions";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { useCardRequisites, useDeleteCardRequisite } from "@/features/cardRequisites/hooks/useCardRequisites";
|
||||
import type { CardRequisite, CardRequisiteStatus } from "@/features/cardRequisites/api/cardRequisitesApi";
|
||||
import type { CardRequisite } from "@/features/cardRequisites/api/cardRequisitesApi";
|
||||
import { resolveLocalizedName } from "@/features/cardRequisites/api/cardRequisitesApi";
|
||||
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
|
||||
import { useInfiniteCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
|
||||
import { useInfiniteClients } from "@/features/clients/hooks/useClients";
|
||||
import { getRegionOptions } from "@/constants";
|
||||
|
||||
// ─── Status Badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_CONFIG: Record<
|
||||
CardRequisiteStatus,
|
||||
{ labelKey: string; fallback: string; variant: StatusBadgeVariant; icon: React.ElementType }
|
||||
> = {
|
||||
pending: { labelKey: "cardRequisites.status.pending", fallback: "Garaşylýar", variant: "warning", icon: AlertCircle },
|
||||
approved: { labelKey: "cardRequisites.status.approved", fallback: "Tassyklanan", variant: "success", icon: CheckCircle2 },
|
||||
rejected: { labelKey: "cardRequisites.status.rejected", fallback: "Ret edilen", variant: "error", icon: XCircle },
|
||||
};
|
||||
|
||||
function CardRequisiteStatusBadge({ status }: { status: string }) {
|
||||
const { t } = useTranslation();
|
||||
const cfg = STATUS_CONFIG[status as CardRequisiteStatus];
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={t(cfg.labelKey, cfg.fallback)} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
import { getRegionOptions, StatusCell } from "@/constants";
|
||||
|
||||
// ─── Column meta for toggle dropdown ─────────────────────────────────────────
|
||||
|
||||
@@ -246,7 +228,14 @@ export default function CardRequisitesPage() {
|
||||
id: "status",
|
||||
accessorKey: "status",
|
||||
header: t("Status", "STATUS"),
|
||||
cell: ({ row }) => <CardRequisiteStatusBadge status={row.original.status} />,
|
||||
cell: ({ row }) => (
|
||||
<StatusCell
|
||||
status={row.original.status}
|
||||
prefix="cardRequisites.status"
|
||||
fallbackLabels={{ pending: "Garaşylýar", approved: "Tassyklanan", rejected: "Ret edilen" }}
|
||||
fallbackVariants={{ pending: "warning", approved: "success", rejected: "error" }}
|
||||
/>
|
||||
),
|
||||
size: 140,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -4,36 +4,11 @@ import { ArrowLeft } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { useCardRequisite, useDeleteCardRequisite } from "@/features/cardRequisites/hooks/useCardRequisites";
|
||||
import type { CardRequisiteStatus } from "@/features/cardRequisites/api/cardRequisitesApi";
|
||||
import { resolveLocalizedName } from "@/features/cardRequisites/api/cardRequisitesApi";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage, ViewActions } from "@/components/viewPageComponents";
|
||||
import { StatusCell } from "@/constants";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_VARIANT: Record<CardRequisiteStatus, StatusBadgeVariant> = {
|
||||
pending: "warning",
|
||||
approved: "success",
|
||||
rejected: "error",
|
||||
};
|
||||
|
||||
const STATUS_ICON: Record<CardRequisiteStatus, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
};
|
||||
|
||||
function CardRequisiteStatusBadge({ status }: { status: string }) {
|
||||
const { t } = useTranslation();
|
||||
const key = status as CardRequisiteStatus;
|
||||
const variant = STATUS_VARIANT[key];
|
||||
const Icon = STATUS_ICON[key];
|
||||
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={t(`cardRequisite.status.${key}`)} variant={variant} icon={Icon} />;
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
|
||||
function CardRequisiteViewSkeleton() {
|
||||
@@ -103,7 +78,12 @@ export default function CardRequisiteViewPage() {
|
||||
<InfoRow label={t("Unique ID", "Unikal ID")} value={data.uniqueId || undefined} />
|
||||
<InfoRow label={t("cardRequisite.createdAt", "Döredilen wagty")} value={formatFromApiDate(data.createdAt)} />
|
||||
<InfoRow label={t("cardRequisite.status", "Status")}>
|
||||
<CardRequisiteStatusBadge status={data.status} />
|
||||
<StatusCell
|
||||
status={data.status}
|
||||
prefix="cardRequisite.status"
|
||||
fallbackLabels={{ pending: "Garaşylýar", approved: "Tassyklanan", rejected: "Ret edilen" }}
|
||||
fallbackVariants={{ pending: "warning", approved: "success", rejected: "error" }}
|
||||
/>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardRequisite.note", "Bellik")} value={data.notes || undefined} />
|
||||
</BentoCard>
|
||||
|
||||
@@ -3,45 +3,22 @@ import { useNavigate, Link } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
import { DataTableToolbar, type ColumnMeta, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
||||
import { TableSearchInput } from "@/components/tableSearch";
|
||||
import { CreateButton } from "@/components/createButton";
|
||||
import { TableActions } from "@/components/tableActions";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { useCards, useDeleteCard } from "@/features/orderNewCard/hooks/useOrderNewCard";
|
||||
import type { CardOrder } from "@/features/orderNewCard/api/orderNewCardApi";
|
||||
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
|
||||
import { useInfiniteDistricts } from "@/features/districts/hooks/useDistricts";
|
||||
import { useInfiniteCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
|
||||
import { getStatusLabel, getStatusOptions, isStatusValue, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
import { getStatusOptions, StatusCell, ActiveStatusCell } from "@/constants";
|
||||
import { formatFromApiDate } from "@/lib/utils/dateUtils";
|
||||
|
||||
const PER_PAGE = 25;
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_ICONS: Record<StatusValue, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
};
|
||||
|
||||
function CardOrderStatusBadge({ status }: { status: string }) {
|
||||
const { t } = useTranslation();
|
||||
const key = (status || "").trim().toLowerCase();
|
||||
const isKnown = isStatusValue(key);
|
||||
const variant: StatusBadgeVariant = isKnown ? STATUS_BADGE_VARIANTS[key] : "default";
|
||||
const icon = isKnown ? STATUS_ICONS[key] : undefined;
|
||||
const label = isKnown ? getStatusLabel(key, t, "cardOrder.status") : status;
|
||||
|
||||
return <StatusBadge label={label} variant={variant} icon={icon} />;
|
||||
}
|
||||
|
||||
// ─── Filter field IDs ──────────────────────────────────────────────────────────
|
||||
|
||||
const FILTER_IDS = ["status", "branch_id", "user_id", "card_state_id", "card_type_id", "region"] as const;
|
||||
@@ -157,18 +134,13 @@ export default function CardOrdersPage() {
|
||||
id: "status",
|
||||
accessorKey: "status",
|
||||
header: t("cardOrder.col.status", "Statusy"),
|
||||
cell: ({ row }) => <CardOrderStatusBadge status={row.original.status} />,
|
||||
cell: ({ row }) => <StatusCell status={row.original.status} prefix="cardOrder.status" />,
|
||||
},
|
||||
{
|
||||
id: "paid",
|
||||
accessorKey: "paid",
|
||||
header: t("cardOrder.col.paid", "Tölegli"),
|
||||
cell: ({ row }) => (
|
||||
<StatusBadge
|
||||
label={row.original.paid ? t("common.yes", "Hawa") : t("common.no", "Ýok")}
|
||||
variant={row.original.paid ? "success" : "error"}
|
||||
/>
|
||||
),
|
||||
cell: ({ row }) => <ActiveStatusCell active={row.original.paid} />,
|
||||
size: 90,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -3,9 +3,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { useCardById, useDeleteCard } from "@/features/orderNewCard/hooks/useOrderNewCard";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage, ViewActions } from "@/components/viewPageComponents";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import { getStatusLabel, isStatusValue, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
import { StatusCell, ActiveStatusCell } from "@/constants";
|
||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
|
||||
@@ -17,32 +15,6 @@ function resolveLocalizedName(name: LocalizedText | string | null | undefined, l
|
||||
return name[lang as keyof LocalizedText] ?? name.tm ?? name.en ?? name.ru ?? "";
|
||||
}
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_ICONS: Record<StatusValue, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
};
|
||||
|
||||
function statusConfig(
|
||||
status: string,
|
||||
t: (key: string, fallback?: string) => string,
|
||||
): { label: string; variant: StatusBadgeVariant; icon?: React.ElementType } {
|
||||
const key = status.trim().toLowerCase();
|
||||
if (isStatusValue(key)) {
|
||||
return { label: getStatusLabel(key, t, "cardOrder.status"), variant: STATUS_BADGE_VARIANTS[key], icon: STATUS_ICONS[key] };
|
||||
}
|
||||
return { label: status, variant: "default" };
|
||||
}
|
||||
|
||||
function CardOrderStatusBadge({ status }: { status: string }) {
|
||||
const { t } = useTranslation();
|
||||
const cfg = statusConfig(status, (key, fallback) => t(key, fallback ?? key));
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
|
||||
function DetailSkeleton() {
|
||||
@@ -107,14 +79,10 @@ export default function CardOrderDetailPage() {
|
||||
<InfoRow label={t("common.id", "ID")} value={order.id} />
|
||||
<InfoRow label={t("cardOrder.field.uniqueId", "Sargyt belgisi")} value={order.uniqueId} />
|
||||
<InfoRow label={t("cardOrder.field.status", "Status")}>
|
||||
<CardOrderStatusBadge status={order.status} />
|
||||
<StatusCell status={order.status} prefix="cardOrder.status" />
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.paid", "Tölenen")}>
|
||||
<span
|
||||
className={`inline-flex items-center justify-center w-5 h-5 rounded-full text-xs font-bold ${order.paid ? "bg-emerald-500/15 text-emerald-400" : "bg-red-500/15 text-red-400"}`}
|
||||
>
|
||||
{order.paid ? "✓" : "✕"}
|
||||
</span>
|
||||
<ActiveStatusCell active={order.paid} />
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.notes", "Bellik")} value={order.notes ?? undefined} />
|
||||
<InfoRow
|
||||
|
||||
@@ -11,65 +11,9 @@ import { CreateButton } from "@/components/createButton";
|
||||
import { TableActions } from "@/components/tableActions";
|
||||
import { MonthSelect } from "@/components/monthSelect";
|
||||
import { useSberPaymentOrders, useDeleteSberPayment } from "@/features/sberPayments/hooks/useSberPayments";
|
||||
import {
|
||||
type SberPaymentOrder,
|
||||
WELAYATLAR,
|
||||
STATUSES,
|
||||
type PaymentStatus,
|
||||
type PaymentPaidStatus,
|
||||
} from "@/features/sberPayments/api/sberPaymentsApi";
|
||||
import { type SberPaymentOrder, WELAYATLAR, STATUSES } from "@/features/sberPayments/api/sberPaymentsApi";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
function getStatusConfig(t: (key: string, fallback?: string) => string) {
|
||||
return {
|
||||
GARASYLYYAR: {
|
||||
label: t("sberPayments.status.pending", "Garaşylýar"),
|
||||
variant: "warning" as StatusBadgeVariant,
|
||||
icon: AlertCircle,
|
||||
},
|
||||
KANAGATLANDYRYLAN: {
|
||||
label: t("sberPayments.status.approved", "Tassyklandy"),
|
||||
variant: "success" as StatusBadgeVariant,
|
||||
icon: CheckCircle2,
|
||||
},
|
||||
RET_EDILEN: {
|
||||
label: t("sberPayments.status.rejected", "Ýatyryldy"),
|
||||
variant: "error" as StatusBadgeVariant,
|
||||
icon: XCircle,
|
||||
},
|
||||
} satisfies Record<PaymentStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }>;
|
||||
}
|
||||
|
||||
function getPaidStatusConfig(t: (key: string, fallback?: string) => string) {
|
||||
return {
|
||||
Tolenmedik: {
|
||||
label: t("sberPayments.paidStatus.unpaid", "Tölmedi"),
|
||||
variant: "error" as StatusBadgeVariant,
|
||||
icon: XCircle,
|
||||
},
|
||||
Tolendi: {
|
||||
label: t("sberPayments.paidStatus.paid", "Tölendi"),
|
||||
variant: "success" as StatusBadgeVariant,
|
||||
icon: CheckCircle2,
|
||||
},
|
||||
} satisfies Record<PaymentPaidStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }>;
|
||||
}
|
||||
|
||||
function PaymentPaidStatusBadge({ status, t }: { status: PaymentPaidStatus; t: (key: string, fallback?: string) => string }) {
|
||||
const cfg = getPaidStatusConfig(t)[status];
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{String(status)}</span>;
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
|
||||
function PaymentStatusBadge({ status, t }: { status: PaymentStatus; t: (key: string, fallback?: string) => string }) {
|
||||
const cfg = getStatusConfig(t)[status];
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{String(status)}</span>;
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
import { StatusCell } from "@/constants";
|
||||
|
||||
// ─── Column Definitions ───────────────────────────────────────────────────────
|
||||
|
||||
@@ -200,12 +144,31 @@ export default function SberPaymentsListPage() {
|
||||
<ArrowUpDown size={12} />
|
||||
</button>
|
||||
),
|
||||
cell: ({ row }) => <PaymentStatusBadge status={row.getValue("status")} t={t} />,
|
||||
cell: ({ row }) => (
|
||||
<StatusCell
|
||||
status={row.getValue("status") as string}
|
||||
fallbackLabels={{
|
||||
GARASYLYYAR: t("sberPayments.status.pending", "Garaşylýar"),
|
||||
KANAGATLANDYRYLAN: t("sberPayments.status.approved", "Tassyklandy"),
|
||||
RET_EDILEN: t("sberPayments.status.rejected", "Ýatyryldy"),
|
||||
}}
|
||||
fallbackVariants={{ GARASYLYYAR: "warning", KANAGATLANDYRYLAN: "success", RET_EDILEN: "error" }}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "paidStatus",
|
||||
header: paidStatusLabel,
|
||||
cell: ({ row }) => <PaymentPaidStatusBadge status={row.getValue("paidStatus")} t={t} />,
|
||||
cell: ({ row }) => (
|
||||
<StatusCell
|
||||
status={row.getValue("paidStatus") as string}
|
||||
fallbackLabels={{
|
||||
Tolenmedik: t("sberPayments.paidStatus.unpaid", "Tölenmedi"),
|
||||
Tolendi: t("sberPayments.paidStatus.paid", "Tölendi"),
|
||||
}}
|
||||
fallbackVariants={{ Tolenmedik: "error", Tolendi: "success" }}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
|
||||
@@ -1,65 +1,13 @@
|
||||
import { format } from "date-fns";
|
||||
import { Search, Download, XCircle, CheckCircle2, AlertCircle } from "lucide-react";
|
||||
import { Search, Download } from "lucide-react";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { StatusCell } from "@/constants";
|
||||
import { BentoGrid, BentoCard, InfoRow, AuditLog, ViewActions, type AuditRowProps } from "@/components/viewPageComponents";
|
||||
import { useSberPaymentOrder, useDeleteSberPayment } from "@/features/sberPayments/hooks/useSberPayments";
|
||||
import type { PaymentPaidStatus, PaymentStatus } from "@/features/sberPayments/api/sberPaymentsApi";
|
||||
import { useState } from "react";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_VARIANT: Record<PaymentStatus, StatusBadgeVariant> = {
|
||||
GARASYLYYAR: "warning",
|
||||
KANAGATLANDYRYLAN: "success",
|
||||
RET_EDILEN: "error",
|
||||
};
|
||||
|
||||
const STATUS_ICON: Record<PaymentStatus, React.ElementType> = {
|
||||
GARASYLYYAR: AlertCircle,
|
||||
KANAGATLANDYRYLAN: CheckCircle2,
|
||||
RET_EDILEN: XCircle,
|
||||
};
|
||||
|
||||
const STATUS_KEY_MAP: Record<PaymentStatus, string> = {
|
||||
GARASYLYYAR: "pending",
|
||||
KANAGATLANDYRYLAN: "approved",
|
||||
RET_EDILEN: "rejected",
|
||||
};
|
||||
|
||||
const PAID_STATUS_VARIANT: Record<PaymentPaidStatus, StatusBadgeVariant> = {
|
||||
Tolenmedik: "error",
|
||||
Tolendi: "success",
|
||||
};
|
||||
|
||||
const PAID_STATUS_ICON: Record<PaymentPaidStatus, React.ElementType> = {
|
||||
Tolenmedik: XCircle,
|
||||
Tolendi: CheckCircle2,
|
||||
};
|
||||
|
||||
const PAID_STATUS_KEY_MAP: Record<PaymentPaidStatus, string> = {
|
||||
Tolenmedik: "unpaid",
|
||||
Tolendi: "paid",
|
||||
};
|
||||
|
||||
function PaymentStatusBadge({ status }: { status: PaymentStatus }) {
|
||||
const { t } = useTranslation();
|
||||
const variant = STATUS_VARIANT[status];
|
||||
const Icon = STATUS_ICON[status];
|
||||
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={t(`sberPayments.status.${STATUS_KEY_MAP[status]}`)} variant={variant} icon={Icon} />;
|
||||
}
|
||||
|
||||
function PaymentPaidStatusBadge({ status }: { status: PaymentPaidStatus }) {
|
||||
const { t } = useTranslation();
|
||||
const variant = PAID_STATUS_VARIANT[status];
|
||||
const Icon = PAID_STATUS_ICON[status];
|
||||
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={t(`sberPayments.paidStatus.${PAID_STATUS_KEY_MAP[status]}`)} variant={variant} icon={Icon} />;
|
||||
}
|
||||
|
||||
// ─── Document row ─────────────────────────────────────────────────────────────
|
||||
|
||||
function DocumentRow({ label, fileName, fileUrl }: { label: string; fileName: string | null; fileUrl: string | null }) {
|
||||
@@ -173,10 +121,25 @@ export default function SberPaymentViewPage() {
|
||||
<BentoCard title={t("sberPayments.view.sections.main", "Esasy maglumatlar")}>
|
||||
<InfoRow label={t("common.id", "ID")} value={order.id} />
|
||||
<InfoRow label={t("Status", "Status")}>
|
||||
<PaymentStatusBadge status={order.status} />
|
||||
<StatusCell
|
||||
status={order.status}
|
||||
fallbackLabels={{
|
||||
GARASYLYYAR: t("sberPayments.status.pending", "Garaşylýar"),
|
||||
KANAGATLANDYRYLAN: t("sberPayments.status.approved", "Tassyklandy"),
|
||||
RET_EDILEN: t("sberPayments.status.rejected", "Ýatyryldy"),
|
||||
}}
|
||||
fallbackVariants={{ GARASYLYYAR: "warning", KANAGATLANDYRYLAN: "success", RET_EDILEN: "error" }}
|
||||
/>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("sberPayments.columns.paidStatus", "Tölenen (şul aý)")}>
|
||||
<PaymentPaidStatusBadge status={order.paidStatus} />
|
||||
<StatusCell
|
||||
status={order.paidStatus}
|
||||
fallbackLabels={{
|
||||
Tolenmedik: t("sberPayments.paidStatus.unpaid", "Tölenmedi"),
|
||||
Tolendi: t("sberPayments.paidStatus.paid", "Tölendi"),
|
||||
}}
|
||||
fallbackVariants={{ Tolenmedik: "error", Tolendi: "success" }}
|
||||
/>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("sberPayments.cards.bellik", "Bellik")} value={order.bellik} />
|
||||
</BentoCard>
|
||||
|
||||
@@ -10,14 +10,12 @@ import { TableActions } from "@/components/tableActions";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { MonthSelect } from "@/components/monthSelect";
|
||||
import { InfiniteSelect } from "@/components/infiniteSelect";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { REGION_CODES, REGION_LABELS, StatusCell } from "@/constants";
|
||||
import { useIntlPayments, useDeleteIntlPayment } from "@/features/visaMasterPayments/hooks/useVisaMasterPayments";
|
||||
import type { IntlPaymentStatus, IntlPaymentItem } from "@/features/visaMasterPayments/api/visaMasterPaymentsApi";
|
||||
import { useInfiniteBranches } from "@/features/shared/hooks/useSharedBranchUsers";
|
||||
import { useInfiniteUsers } from "@/features/allUsers/hooks/useAllUsers";
|
||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||
import { REGION_CODES, REGION_LABELS } from "@/constants";
|
||||
import { formatFromApiDate } from "@/lib/utils/dateUtils";
|
||||
|
||||
// ─── Constants ────────────────────────────────────────────────────────────────
|
||||
@@ -81,17 +79,6 @@ export default function IntlPaymentsPage() {
|
||||
});
|
||||
const { mutate: deletePayment, isPending: isDeleting } = useDeleteIntlPayment();
|
||||
|
||||
function IntlPaymentStatusBadge({ status }: { status: IntlPaymentStatus }) {
|
||||
const STATUS_CONFIG = {
|
||||
pending: { label: t("intlPayment.status.pending", "Garaşylýar"), variant: "warning" as StatusBadgeVariant, icon: AlertCircle },
|
||||
approved: { label: t("intlPayment.status.approved", "Tassyklandy"), variant: "success" as StatusBadgeVariant, icon: CheckCircle2 },
|
||||
rejected: { label: t("intlPayment.status.rejected", "Ret edildi"), variant: "error" as StatusBadgeVariant, icon: XCircle },
|
||||
};
|
||||
const cfg = STATUS_CONFIG[status];
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
|
||||
const columns: ColumnDef<IntlPaymentItem>[] = [
|
||||
{
|
||||
accessorKey: "id",
|
||||
@@ -135,7 +122,14 @@ export default function IntlPaymentsPage() {
|
||||
{
|
||||
accessorKey: "status",
|
||||
header: t("intlPayment.status", "Status"),
|
||||
cell: ({ row }) => <IntlPaymentStatusBadge status={row.original.status} />,
|
||||
cell: ({ row }) => (
|
||||
<StatusCell
|
||||
status={row.original.status}
|
||||
prefix="intlPayment.status"
|
||||
fallbackLabels={{ pending: "Garaşylýar", approved: "Tassyklandy", rejected: "Ret edildi" }}
|
||||
fallbackVariants={{ pending: "warning", approved: "success", rejected: "error" }}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
|
||||
@@ -1,35 +1,13 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Download, Search, AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { Download, Search } from "lucide-react";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { StatusCell } from "@/constants";
|
||||
import { BentoGrid, BentoCard, InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { useIntlPayment, useDeleteIntlPayment } from "@/features/visaMasterPayments/hooks/useVisaMasterPayments";
|
||||
import type { IntlPaymentStatus } from "@/features/visaMasterPayments/api/visaMasterPaymentsApi";
|
||||
import { formatFromApiDate } from "@/lib/utils/dateUtils";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_VARIANT: Record<IntlPaymentStatus, StatusBadgeVariant> = {
|
||||
pending: "warning",
|
||||
approved: "success",
|
||||
rejected: "error",
|
||||
};
|
||||
|
||||
const STATUS_ICON: Record<IntlPaymentStatus, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
};
|
||||
|
||||
function PaymentStatusBadge({ status }: { status: IntlPaymentStatus }) {
|
||||
const { t } = useTranslation();
|
||||
const variant = STATUS_VARIANT[status] ?? STATUS_VARIANT.pending;
|
||||
const Icon = STATUS_ICON[status] ?? STATUS_ICON.pending;
|
||||
return <StatusBadge label={t(`intlPayment.status.${status}`)} variant={variant} icon={Icon} />;
|
||||
}
|
||||
|
||||
// ─── DocFile row ──────────────────────────────────────────────────────────────
|
||||
|
||||
function DocFileRow({ label, url }: { label: string; url: string | null }) {
|
||||
@@ -192,7 +170,12 @@ export default function IntlPaymentViewPage() {
|
||||
/>
|
||||
<InfoRow label={t("common.id", "ID")} value={data.id} />
|
||||
<InfoRow label={t("intlPayment.status", "Status")}>
|
||||
<PaymentStatusBadge status={data.status} />
|
||||
<StatusCell
|
||||
status={data.status}
|
||||
prefix="intlPayment.status"
|
||||
fallbackLabels={{ pending: "Garaşylýar", approved: "Tassyklandy", rejected: "Ret edildi" }}
|
||||
fallbackVariants={{ pending: "warning", approved: "success", rejected: "error" }}
|
||||
/>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("intlPayment.tilowanMonth", "Tölewan (Aý/aý)")} value={formatFromApiDate(data.created_at)} />
|
||||
<InfoRow label={t("intlPayment.note", "Bellik")} value={data.note} />
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useState, useMemo, useCallback } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
@@ -9,29 +8,12 @@ import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/compone
|
||||
import { TableSearchInput } from "@/components/tableSearch";
|
||||
import { CreateButton } from "@/components/createButton";
|
||||
import { TableActions } from "@/components/tableActions";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
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 { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { getStatusLabel, getStatusOptions, getRegionOptions, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
import { getStatusOptions, getRegionOptions, StatusCell } from "@/constants";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
// ─── Status Badge (inline) ────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_ICONS: Record<StatusValue, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
};
|
||||
|
||||
function LoanOrderStatusBadge({ status }: { status: LoanOrderMobileStatus }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<StatusBadge label={getStatusLabel(status, t, "loanOrderStatus")} variant={STATUS_BADGE_VARIANTS[status]} icon={STATUS_ICONS[status]} />
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Column meta for toggle dropdown ─────────────────────────────────────────
|
||||
|
||||
const COLUMN_IDS = ["id", "loanType", "createdAt", "region", "branch", "firstName", "lastName", "phone", "status"] as const;
|
||||
@@ -180,7 +162,7 @@ export default function LoanOrderMobilesPage() {
|
||||
id: "status",
|
||||
accessorKey: "status",
|
||||
header: t("Status", "STATUS"),
|
||||
cell: ({ row }) => <LoanOrderStatusBadge status={row.original.status} />,
|
||||
cell: ({ row }) => <StatusCell status={row.original.status} prefix="loanOrderStatus" />,
|
||||
size: 180,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -3,29 +3,10 @@ import { useTranslation } from "react-i18next";
|
||||
import { useLoanOrderMobileById, useDeleteLoanOrderMobile } from "@/features/loanOrderMobiles/hooks/useLoanOrderMobiles";
|
||||
import { CreditCardVisual } from "@/components/creditCardVisual";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import type { LoanOrderMobileStatus } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage, AuditLog, ViewActions, type AuditRowProps } from "@/components/viewPageComponents";
|
||||
import { getStatusLabel, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
import { StatusCell } from "@/constants";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_ICON: Record<StatusValue, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
};
|
||||
|
||||
function LoanOrderMobileStatusBadge({ status }: { status: LoanOrderMobileStatus }) {
|
||||
const { t } = useTranslation();
|
||||
const variant = STATUS_BADGE_VARIANTS[status];
|
||||
const Icon = STATUS_ICON[status];
|
||||
return <StatusBadge label={getStatusLabel(status, t, "loanOrderStatus")} variant={variant} icon={Icon} />;
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
|
||||
function LoanOrderMobilesViewSkeleton() {
|
||||
@@ -107,7 +88,7 @@ export default function LoanOrderMobilesViewPage() {
|
||||
<InfoRow label={t("common.id", "ID")} value={order.id} />
|
||||
<InfoRow label={t("loanOrders.fields.uniqueId", "Ýeke-täk ID")} value={order.uniqueId || undefined} />
|
||||
<InfoRow label={t("loanOrders.columns.status", "Status")}>
|
||||
<LoanOrderMobileStatusBadge status={order.status} />
|
||||
<StatusCell status={order.status} prefix="loanOrderStatus" />
|
||||
</InfoRow>
|
||||
<InfoRow label={t("loanOrders.columns.createdAt", "Döredilen wagty")} value={formatFromApiDate(order.createdAt)} />
|
||||
<InfoRow label={t("loanOrders.fields.updatedAt", "Üýtgedilen wagty")} value={formatFromApiDate(order.updatedAt) || undefined} />
|
||||
|
||||
@@ -2,29 +2,10 @@ import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useLoanOrderById, useDeleteLoanOrder } from "@/features/loanOrders/hooks/useLoanOrders";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import type { LoanOrderStatus } from "@/features/loanOrders/api/loanOrdersApi";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage, AuditLog, ViewActions, type AuditRowProps } from "@/components/viewPageComponents";
|
||||
import { getStatusLabel, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
import { StatusCell } from "@/constants";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_ICON: Record<StatusValue, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
};
|
||||
|
||||
function LoanOrderMobileStatusBadge({ status }: { status: LoanOrderStatus }) {
|
||||
const { t } = useTranslation();
|
||||
const variant = STATUS_BADGE_VARIANTS[status];
|
||||
const Icon = STATUS_ICON[status];
|
||||
return <StatusBadge label={getStatusLabel(status, t, "loanOrderStatus")} variant={variant} icon={Icon} />;
|
||||
}
|
||||
|
||||
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
||||
|
||||
/** Combine expiry month/year into a single "MM/YYYY" string, or undefined if both are empty. */
|
||||
@@ -117,7 +98,7 @@ export default function LoanOrderViewPage() {
|
||||
<InfoRow label={t("loanOrders.columns.createdAt", "Döredilen wagty")} value={formatFromApiDate(order.createdAt) || undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.updatedAt", "Üýtgedilen wagty")} value={formatFromApiDate(order.updatedAt) || undefined} />
|
||||
<InfoRow label={t("loanOrders.columns.status", "Status")}>
|
||||
<LoanOrderMobileStatusBadge status={order.status} />
|
||||
<StatusCell status={order.status} prefix="loanOrderStatus" />
|
||||
</InfoRow>
|
||||
<InfoRow label={t("loanOrders.fields.source", "Çeşme")} value={order.source ?? undefined} />
|
||||
<InfoRow
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useState, useMemo, useCallback } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
@@ -9,29 +8,12 @@ import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/compone
|
||||
import { TableSearchInput } from "@/components/tableSearch";
|
||||
import { CreateButton } from "@/components/createButton";
|
||||
import { TableActions } from "@/components/tableActions";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
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 { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { getStatusLabel, getStatusOptions, getRegionOptions, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
import { getStatusOptions, getRegionOptions, StatusCell } from "@/constants";
|
||||
import { formatFromApiDate } from "@/lib/utils";
|
||||
// ─── Status Badge (inline) ────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_ICONS: Record<StatusValue, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
};
|
||||
|
||||
function LoanOrderStatusBadge({ status }: { status: LoanOrderStatus }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<StatusBadge label={getStatusLabel(status, t, "loanOrderStatus")} variant={STATUS_BADGE_VARIANTS[status]} icon={STATUS_ICONS[status]} />
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Column meta for toggle dropdown ─────────────────────────────────────────
|
||||
|
||||
const COLUMN_IDS = ["id", "loanType", "createdAt", "region", "branch", "firstName", "lastName", "phone", "status"] as const;
|
||||
@@ -178,7 +160,7 @@ export default function LoanOrdersPage() {
|
||||
id: "status",
|
||||
accessorKey: "status",
|
||||
header: t("Status", "STATUS"),
|
||||
cell: ({ row }) => <LoanOrderStatusBadge status={row.original.status} />,
|
||||
cell: ({ row }) => <StatusCell status={row.original.status} prefix="loanOrderStatus" />,
|
||||
size: 180,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -9,13 +9,12 @@ import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/compone
|
||||
import { TableSearchInput } from "@/components/tableSearch";
|
||||
import { CreateButton } from "@/components/createButton";
|
||||
import { TableActions } from "@/components/tableActions";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { useLoanPaidOffLetters, useDeleteLoanPaidOffLetter } from "@/features/loanPaidOffLetters/hooks/useLoanPaidOffLetters";
|
||||
import type { LoanPaidOffLetter } from "@/features/loanPaidOffLetters/api/loanPaidOffLettersApi";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
|
||||
import { useInfiniteDistricts } from "@/features/districts/hooks/useDistricts";
|
||||
import { getStatusOptions, STATUS_BADGE_VARIANTS } from "@/constants";
|
||||
import { getStatusOptions, StatusCell } from "@/constants";
|
||||
|
||||
// ─── Column IDs ────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -250,12 +249,7 @@ export default function LoanPaidOffLettersPage() {
|
||||
id: "status",
|
||||
accessorKey: "status",
|
||||
header: t("loanPaidOffLetters.columns.status", "STATUS"),
|
||||
cell: ({ row }) => {
|
||||
const status = row.original.status;
|
||||
return (
|
||||
<StatusBadge label={t(`loanPaidOffLetters.status.${status}`, status)} variant={STATUS_BADGE_VARIANTS[status] ?? "default"} />
|
||||
);
|
||||
},
|
||||
cell: ({ row }) => <StatusCell status={row.original.status} prefix="loanPaidOffLetters.status" />,
|
||||
size: 120,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -2,10 +2,9 @@ import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FileText, ExternalLink } from "lucide-react";
|
||||
import { useLoanPaidOffLetterById, useDeleteLoanPaidOffLetter } from "@/features/loanPaidOffLetters/hooks/useLoanPaidOffLetters";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { BentoGrid, BentoCard, InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { STATUS_BADGE_VARIANTS } from "@/constants";
|
||||
import { StatusCell } from "@/constants";
|
||||
import { buildFileUrl } from "@/features/shared/api/sharedApi";
|
||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||
|
||||
@@ -83,10 +82,7 @@ export default function LoanPaidOffLettersViewPage() {
|
||||
<InfoRow label={t("common.id", "ID")} value={String(record.id)} />
|
||||
<InfoRow label={t("loanPaidOffLetters.fields.uniqueId", "Unikal ID")} value={record.uniqueId || "—"} />
|
||||
<InfoRow label={t("loanPaidOffLetters.fields.status", "Status")}>
|
||||
<StatusBadge
|
||||
label={t(`loanPaidOffLetters.status.${record.status}`, record.status)}
|
||||
variant={STATUS_BADGE_VARIANTS[record.status] ?? "default"}
|
||||
/>
|
||||
<StatusCell status={record.status} prefix="loanPaidOffLetters.status" />
|
||||
</InfoRow>
|
||||
<InfoRow label={t("loanPaidOffLetters.fields.createdAt", "Döredilen wagty")} value={formatDate(record.createdAt)} />
|
||||
</BentoCard>
|
||||
|
||||
@@ -9,7 +9,7 @@ import { TableSearchInput } from "@/components/tableSearch";
|
||||
import { CreateButton } from "@/components/createButton";
|
||||
import { TableActions } from "@/components/tableActions";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
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";
|
||||
@@ -94,11 +94,7 @@ export function CardTypesListPage() {
|
||||
onCheckedChange={() => handleToggleActive(row.original)}
|
||||
disabled={activeMutation.isPending}
|
||||
/>
|
||||
{row.original.active ? (
|
||||
<StatusBadge label={t("common.active", "Işjeň")} variant="success" />
|
||||
) : (
|
||||
<StatusBadge label={t("common.inactive", "Işjeň däl")} variant="default" />
|
||||
)}
|
||||
<ActiveStatusCell active={row.original.active} />
|
||||
</div>
|
||||
),
|
||||
size: 150,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Section, InfoRow, MultiLangRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { ActiveStatusCell } from "@/constants";
|
||||
import { useCardTypeById, useDeleteCardType } from "@/features/cardTypes/hooks/useCardTypes";
|
||||
|
||||
export function CardTypeViewPage() {
|
||||
@@ -59,11 +59,7 @@ export function CardTypeViewPage() {
|
||||
|
||||
<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 gap-1 sm:gap-0">
|
||||
<span className="text-xs sm:text-sm text-muted-foreground leading-snug">{t("cardTypes.fields.isActive", "Işjeň")}</span>
|
||||
{data.active ? (
|
||||
<StatusBadge label={t("common.active", "Işjeň")} variant="success" />
|
||||
) : (
|
||||
<StatusBadge label={t("common.inactive", "Işjeň däl")} variant="default" />
|
||||
)}
|
||||
<ActiveStatusCell active={data.active} />
|
||||
</div>
|
||||
</Section>
|
||||
) : (
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
import { CheckCircle2, XCircle } from "lucide-react";
|
||||
import { ActiveStatusCell } from "@/constants";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||
@@ -85,8 +85,7 @@ export function CardReasonsListPage() {
|
||||
accessorKey: "active",
|
||||
id: "isActive",
|
||||
header: t("cardReasons.fields.isActive", "IŞJEŇ").toUpperCase(),
|
||||
cell: ({ row }) =>
|
||||
row.original.active ? <CheckCircle2 size={18} className="text-emerald-500" /> : <XCircle size={18} className="text-destructive" />,
|
||||
cell: ({ row }) => <ActiveStatusCell active={row.original.active} />,
|
||||
size: 100,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { CheckCircle2, XCircle } from "lucide-react";
|
||||
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";
|
||||
@@ -63,7 +63,7 @@ export function CardReasonViewPage() {
|
||||
{/* isActive custom row */}
|
||||
<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 gap-1 sm:gap-0">
|
||||
<span className="text-xs sm:text-sm text-muted-foreground leading-snug">{t("cardReasons.fields.isActive", "Işjeň")}</span>
|
||||
{data.active ? <CheckCircle2 size={18} className="text-emerald-500" /> : <XCircle size={18} className="text-destructive" />}
|
||||
<ActiveStatusCell active={data.active} />
|
||||
</div>
|
||||
</Section>
|
||||
) : (
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { CheckCircle2, XCircle } from "lucide-react";
|
||||
import { ActiveStatusCell } from "@/constants";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||
import { TableSearchInput } from "@/components/tableSearch";
|
||||
@@ -59,8 +59,7 @@ function useLoanTypeColumns(
|
||||
accessorKey: "active",
|
||||
header: t("loanTypes.columns.isActive", "IŞJEŇ"),
|
||||
size: 80,
|
||||
cell: ({ row }) =>
|
||||
row.original.active ? <CheckCircle2 size={18} className="text-emerald-500" /> : <XCircle size={18} className="text-red-500" />,
|
||||
cell: ({ row }) => <ActiveStatusCell active={row.original.active} />,
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { CheckCircle2, XCircle } from "lucide-react";
|
||||
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";
|
||||
@@ -93,7 +93,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 last:border-0 gap-1 sm:gap-0">
|
||||
<span className="text-xs sm:text-sm text-muted-foreground leading-snug">{t("loanTypes.fields.isActive", "Işjeň")}</span>
|
||||
{data.active ? <CheckCircle2 size={20} className="text-emerald-500" /> : <XCircle size={20} className="text-muted-foreground" />}
|
||||
<ActiveStatusCell active={data.active} />
|
||||
</div>
|
||||
</Section>
|
||||
</div>
|
||||
|
||||
@@ -7,7 +7,7 @@ import { TableSearchInput } from "@/components/tableSearch";
|
||||
import { CreateButton } from "@/components/createButton";
|
||||
import { TableActions } from "@/components/tableActions";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { ActiveStatusCell } from "@/constants";
|
||||
import {
|
||||
useGetRequiredDocuments,
|
||||
useDeleteRequiredDocument,
|
||||
@@ -89,11 +89,7 @@ export default function RequiredDocumentsListPage() {
|
||||
onCheckedChange={() => handleToggleActive(row.original)}
|
||||
disabled={activeMutation.isPending}
|
||||
/>
|
||||
{row.original.active ? (
|
||||
<StatusBadge label={t("common.active", "Işjeň")} variant="success" />
|
||||
) : (
|
||||
<StatusBadge label={t("common.inactive", "Işjeň däl")} variant="default" />
|
||||
)}
|
||||
<ActiveStatusCell active={row.original.active} />
|
||||
</div>
|
||||
),
|
||||
},
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Section, InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { ActiveStatusCell } from "@/constants";
|
||||
import { useGetRequiredDocumentById, useDeleteRequiredDocument } from "@/features/requiredDocuments/hooks/useRequiredDocuments";
|
||||
|
||||
export default function RequiredDocumentsViewPage() {
|
||||
@@ -59,11 +59,7 @@ export default function RequiredDocumentsViewPage() {
|
||||
|
||||
<div className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4">
|
||||
<span className="text-sm text-muted-foreground">{t("loanDocuments.fields.isActive", "Işjeň")}</span>
|
||||
{data.active ? (
|
||||
<StatusBadge label={t("common.active", "Işjeň")} variant="success" />
|
||||
) : (
|
||||
<StatusBadge label={t("common.inactive", "Işjeň däl")} variant="default" />
|
||||
)}
|
||||
<ActiveStatusCell active={data.active} />
|
||||
</div>
|
||||
</Section>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useState, useMemo } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
import { CheckCircle2, XCircle } from "lucide-react";
|
||||
import { ActiveStatusCell } from "@/constants";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||
@@ -148,8 +148,7 @@ export function BranchesListPage() {
|
||||
accessorKey: "active",
|
||||
id: "isActive",
|
||||
header: t("branches.fields.isActive", "IŞJEŇ").toUpperCase(),
|
||||
cell: ({ row }) =>
|
||||
row.original.active ? <CheckCircle2 size={18} className="text-emerald-500" /> : <XCircle size={18} className="text-destructive" />,
|
||||
cell: ({ row }) => <ActiveStatusCell active={row.original.active} />,
|
||||
size: 100,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { CheckCircle2, XCircle } from "lucide-react";
|
||||
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";
|
||||
@@ -61,7 +61,7 @@ export function BranchViewPage() {
|
||||
|
||||
<div className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4">
|
||||
<span className="text-sm text-muted-foreground">{t("branches.fields.isActive", "Işjeň")}</span>
|
||||
{data.active ? <CheckCircle2 size={18} className="text-emerald-500" /> : <XCircle size={18} className="text-destructive" />}
|
||||
<ActiveStatusCell active={data.active} />
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
import { CheckCircle2, XCircle } from "lucide-react";
|
||||
import { ActiveStatusCell } from "@/constants";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||
@@ -76,8 +76,7 @@ export function DistrictsListPage() {
|
||||
accessorKey: "active",
|
||||
id: "isActive",
|
||||
header: t("districts.fields.isActive", "IŞJEŇ").toUpperCase(),
|
||||
cell: ({ row }) =>
|
||||
row.original.active ? <CheckCircle2 size={18} className="text-emerald-500" /> : <XCircle size={18} className="text-destructive" />,
|
||||
cell: ({ row }) => <ActiveStatusCell active={row.original.active} />,
|
||||
size: 100,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { CheckCircle2, XCircle } from "lucide-react";
|
||||
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";
|
||||
@@ -57,7 +57,7 @@ export function DistrictViewPage() {
|
||||
|
||||
<div className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4">
|
||||
<span className="text-sm text-muted-foreground">{t("districts.fields.isActive", "Işjeň")}</span>
|
||||
{data.active ? <CheckCircle2 size={18} className="text-emerald-500" /> : <XCircle size={18} className="text-destructive" />}
|
||||
<ActiveStatusCell active={data.active} />
|
||||
</div>
|
||||
</Section>
|
||||
) : (
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { CheckCircle2, XCircle } from "lucide-react";
|
||||
import { ActiveStatusCell } from "@/constants";
|
||||
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { DataTableToolbar, type ActiveFilter } from "@/components/dataTableToolbar";
|
||||
@@ -107,8 +107,7 @@ export default function UsersListPage() {
|
||||
accessorKey: "active",
|
||||
header: t("users.fields.isActive", "IŞJEŇ"),
|
||||
size: 80,
|
||||
cell: ({ row }) =>
|
||||
row.original.active ? <CheckCircle2 size={18} className="text-emerald-500" /> : <XCircle size={18} className="text-destructive" />,
|
||||
cell: ({ row }) => <ActiveStatusCell active={row.original.active} />,
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { XCircle, CheckCircle2, UserRound, Link2 } from "lucide-react";
|
||||
import { UserRound, Link2 } from "lucide-react";
|
||||
import { ActiveStatusCell } from "@/constants";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { BentoGrid, BentoCard, InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { useUser, useDeleteUser } from "@/features/allUsers/hooks/useAllUsers";
|
||||
|
||||
// ─── ActiveIndicator ──────────────────────────────────────────────────────────
|
||||
|
||||
function ActiveIndicator({ active }: { active: boolean }) {
|
||||
return active ? <CheckCircle2 size={18} className="text-emerald-500" /> : <XCircle size={18} className="text-destructive" />;
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function UserViewPage() {
|
||||
@@ -107,7 +102,7 @@ export default function UserViewPage() {
|
||||
/>
|
||||
|
||||
<InfoRow label={t("users.fields.isActive", "Işjeň")}>
|
||||
<ActiveIndicator active={user.active} />
|
||||
<ActiveStatusCell active={user.active} />
|
||||
</InfoRow>
|
||||
</BentoCard>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { CheckCircle2, XCircle } from "lucide-react";
|
||||
import { ActiveStatusCell } from "@/constants";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||
@@ -73,8 +73,7 @@ export default function ClientsPage() {
|
||||
{
|
||||
accessorKey: "active",
|
||||
header: t("clients.fields.isActive", "IŞJEŇ"),
|
||||
cell: ({ row }) =>
|
||||
row.original.active ? <CheckCircle2 size={18} className="text-emerald-500" /> : <XCircle size={18} className="text-destructive" />,
|
||||
cell: ({ row }) => <ActiveStatusCell active={row.original.active} />,
|
||||
size: 80,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useParams, useNavigate, Link } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { XCircle, CheckCircle2, UserRound } from "lucide-react";
|
||||
import { UserRound } from "lucide-react";
|
||||
import { ActiveStatusCell } from "@/constants";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { BentoGrid, BentoCard, InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
@@ -16,12 +17,6 @@ function resolveLocalizedName(name: LocalizedText | string | undefined | null, l
|
||||
return name[lang as keyof LocalizedText] ?? name.en ?? name.tm ?? name.ru ?? "";
|
||||
}
|
||||
|
||||
// ─── ActiveIndicator ──────────────────────────────────────────────────────────
|
||||
|
||||
function ActiveIndicator({ active }: { active: boolean }) {
|
||||
return active ? <CheckCircle2 size={18} className="text-emerald-500" /> : <XCircle size={18} className="text-destructive" />;
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function ClientDetailPage() {
|
||||
@@ -112,7 +107,7 @@ export default function ClientDetailPage() {
|
||||
href={roles[0]?.id ? `/settings/users/roles/${roles[0].id}` : "/settings/users/roles"}
|
||||
/>
|
||||
<InfoRow label={t("clients.fields.isActive", "Işjeň")}>
|
||||
<ActiveIndicator active={client.active} />
|
||||
<ActiveStatusCell active={client.active} />
|
||||
</InfoRow>
|
||||
<InfoRow label={t("users.fields.createdAt", "Döredilen wagty")} value={formatFromApiDate(client.createdAt) || "—"} />
|
||||
<InfoRow label={t("users.fields.updatedAt", "Täzelenen wagty")} value={formatFromApiDate(client.updatedAt) || "—"} />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { CheckCircle2, XCircle } from "lucide-react";
|
||||
import { ActiveStatusCell } from "@/constants";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||
@@ -84,8 +84,7 @@ export default function OperatorsPage() {
|
||||
{
|
||||
accessorKey: "active",
|
||||
header: t("operators.fields.isActive", "IŞJEŇ"),
|
||||
cell: ({ row }) =>
|
||||
row.original.active ? <CheckCircle2 size={18} className="text-emerald-500" /> : <XCircle size={18} className="text-destructive" />,
|
||||
cell: ({ row }) => <ActiveStatusCell active={row.original.active} />,
|
||||
size: 80,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useParams, useNavigate, Link } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { CheckCircle2, XCircle, UserRound } from "lucide-react";
|
||||
import { UserRound } from "lucide-react";
|
||||
import { ActiveStatusCell } from "@/constants";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { BentoGrid, BentoCard, InfoRow, ViewActions } from "@/components/viewPageComponents";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
@@ -15,12 +16,6 @@ function resolveLocalizedName(name: LocalizedText | string, lang = "en"): string
|
||||
return name[lang as keyof LocalizedText] ?? name.en ?? "";
|
||||
}
|
||||
|
||||
// ─── ActiveIndicator ──────────────────────────────────────────────────────────
|
||||
|
||||
function ActiveIndicator({ active }: { active: boolean }) {
|
||||
return active ? <CheckCircle2 size={18} className="text-emerald-500" /> : <XCircle size={18} className="text-destructive" />;
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function OperatorDetailPage() {
|
||||
@@ -111,7 +106,7 @@ export default function OperatorDetailPage() {
|
||||
href={roles[0]?.id ? `/settings/users/roles/${roles[0].id}` : "/settings/users/roles"}
|
||||
/>
|
||||
<InfoRow label={t("operators.fields.isActive", "Işjeň")}>
|
||||
<ActiveIndicator active={operator.active} />
|
||||
<ActiveStatusCell active={operator.active} />
|
||||
</InfoRow>
|
||||
<InfoRow label={t("users.fields.createdAt", "Döredilen wagty")} value={formatFromApiDate(operator.createdAt) || "—"} />
|
||||
<InfoRow label={t("users.fields.updatedAt", "Täzelenen wagty")} value={formatFromApiDate(operator.updatedAt) || "—"} />
|
||||
|
||||
Reference in New Issue
Block a user