fixed some types, add some labels
This commit is contained in:
@@ -20,6 +20,15 @@ import {
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents";
|
||||
import { getStatusLabel, isStatusValue, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||
|
||||
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
||||
|
||||
function resolveLocalizedName(name: LocalizedText | string | null | undefined, lang = "en"): string {
|
||||
if (!name) return "";
|
||||
if (typeof name === "string") return name;
|
||||
return name[lang as keyof LocalizedText] ?? name.tm ?? name.en ?? name.ru ?? "";
|
||||
}
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -72,7 +81,7 @@ function CardPinViewSkeleton() {
|
||||
export default function CardPinViewPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
@@ -153,14 +162,29 @@ export default function CardPinViewPage() {
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("cardPin.cardSection", "Kart")}>
|
||||
<InfoRow label={t("cardPin.field.cardNumber", "Kart belgisi")} value={data.cardNumber} />
|
||||
<InfoRow label={t("cardPin.field.cardTypeId", "Kart görnüşi ID")} value={data.cardTypeId} />
|
||||
<InfoRow label={t("cardPin.field.cardNumber", "Kart belgisi")} value={data.cardNumber || "—"} />
|
||||
<InfoRow
|
||||
isLink={Boolean(data.cardType?.id)}
|
||||
href={data.cardType?.id ? `/settings/card/card-types/${data.cardType.id}` : undefined}
|
||||
label={t("cardPin.field.cardType", "Kart görnüşi")}
|
||||
value={resolveLocalizedName(data.cardType?.name, i18n.language) || "—"}
|
||||
/>
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("cardPin.locationSection", "Lokasiýa")}>
|
||||
<InfoRow label={t("cardPin.field.region", "Sebit")} value={data.region || undefined} />
|
||||
<InfoRow label={t("cardPin.field.branchId", "Şahamça ID")} value={data.branchId} />
|
||||
<InfoRow label={t("cardPin.field.userId", "Ulanyjy ID")} value={data.userId} />
|
||||
<InfoRow label={t("cardPin.field.region", "Sebit")} value={data.region || "—"} />
|
||||
<InfoRow
|
||||
label={t("cardPin.field.branch", "Şahamça")}
|
||||
value={resolveLocalizedName(data.branch?.name, i18n.language) || "—"}
|
||||
isLink={Boolean(data.branch?.id)}
|
||||
href={data.branch?.id ? `/settings/location/branches/${data.branch.id}` : undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("cardPin.field.user", "Ulanyjy")}
|
||||
value={data.user?.name || "—"}
|
||||
isLink={Boolean(data.user?.id)}
|
||||
href={data.user?.id ? `/all-users/${data.user.id}` : undefined}
|
||||
/>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
|
||||
@@ -76,11 +76,19 @@ export default function CardTransactionsPage() {
|
||||
size: 100,
|
||||
},
|
||||
{
|
||||
id: "userId",
|
||||
accessorKey: "userId",
|
||||
header: t("cardTransaction.col.userId", "Ulanyjy ID"),
|
||||
cell: ({ row }) => <span className="text-sm text-muted-foreground">{row.original.userId}</span>,
|
||||
size: 110,
|
||||
id: "user",
|
||||
accessorFn: (row) => row.user?.name ?? "",
|
||||
header: t("cardTransaction.col.user", "Ulanyjy"),
|
||||
cell: ({ row }) => {
|
||||
const user = row.original.user;
|
||||
if (!user) return <span className="text-sm text-muted-foreground">—</span>;
|
||||
return (
|
||||
<button className="text-sm text-primary hover:underline text-left" onClick={() => navigate(`/all-users/${user.id}`)}>
|
||||
{user.name}
|
||||
</button>
|
||||
);
|
||||
},
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
id: "createdAt",
|
||||
|
||||
@@ -90,7 +90,12 @@ export default function CardTransactionViewPage() {
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("cardTransaction.section.meta", "Belligi")}>
|
||||
<InfoRow label={t("cardTransaction.col.userId", "Ulanyjy ID")} value={data.userId} />
|
||||
<InfoRow
|
||||
label={t("cardTransaction.col.user", "Ulanyjy")}
|
||||
value={data.user?.name || "—"}
|
||||
isLink={Boolean(data.user?.id)}
|
||||
href={data.user?.id ? `/all-users/${data.user.id}` : undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("cardTransaction.col.createdAt", "Döredilen wagty")}
|
||||
value={data.createdAt ? new Date(data.createdAt).toLocaleString() : "—"}
|
||||
|
||||
@@ -19,6 +19,15 @@ import { BentoGrid, BentoCard, InfoRow, PassportImage } from "@/components/viewP
|
||||
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 type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||
|
||||
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
||||
|
||||
function resolveLocalizedName(name: LocalizedText | string | null | undefined, lang = "en"): string {
|
||||
if (!name) return "";
|
||||
if (typeof name === "string") return name;
|
||||
return name[lang as keyof LocalizedText] ?? name.tm ?? name.en ?? name.ru ?? "";
|
||||
}
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -71,7 +80,7 @@ function DetailSkeleton() {
|
||||
export default function CardOrderDetailPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
@@ -145,14 +154,30 @@ export default function CardOrderDetailPage() {
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("cardOrder.section.card", "Kart")}>
|
||||
<InfoRow label={t("cardOrder.field.cardTypeId", "Kart görnüşi ID")} value={order.cardTypeId} />
|
||||
<InfoRow label={t("cardOrder.field.cardStateId", "Kart ýagdaýy ID")} value={order.cardStateId} />
|
||||
<InfoRow
|
||||
label={t("cardOrder.field.cardType", "Kart görnüşi")}
|
||||
value={resolveLocalizedName(order.cardType?.name, i18n.language) || "—"}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("cardOrder.field.cardState", "Kart ýagdaýy")}
|
||||
value={resolveLocalizedName(order.cardState?.name, i18n.language) || "—"}
|
||||
/>
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("cardOrder.section.location", "Lokasiýa")}>
|
||||
<InfoRow label={t("cardOrder.field.region", "Sebit")} value={order.region} />
|
||||
<InfoRow label={t("cardOrder.field.branchId", "Şahamça ID")} value={order.branchId} />
|
||||
<InfoRow label={t("cardOrder.field.userId", "Ulanyjy ID")} value={order.userId} />
|
||||
<InfoRow label={t("cardOrder.field.region", "Sebit")} value={order.region || "—"} />
|
||||
<InfoRow
|
||||
label={t("cardOrder.field.branch", "Şahamça")}
|
||||
value={resolveLocalizedName(order.branch?.name, i18n.language) || "—"}
|
||||
isLink={Boolean(order.branch?.id)}
|
||||
href={order.branch?.id ? `/settings/location/branches/${order.branch.id}` : undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("cardOrder.field.user", "Ulanyjy")}
|
||||
value={order.user?.name || "—"}
|
||||
isLink={Boolean(order.user?.id)}
|
||||
href={order.user?.id ? `/all-users/${order.user.id}` : undefined}
|
||||
/>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
|
||||
@@ -191,7 +191,12 @@ export default function IntlPaymentViewPage() {
|
||||
{/* ── Row 1: Meta + Ýüztuman + Lokasiýa ───────────────────────────── */}
|
||||
<BentoGrid cols={3}>
|
||||
<BentoCard title={t("intlPayment.statusSection", "Esasy maglumatlar")}>
|
||||
<InfoRow label={t("intlPayment.client", "Ulanyjy")} value={data.client_label} isLink />
|
||||
<InfoRow
|
||||
label={t("intlPayment.client", "Ulanyjy")}
|
||||
value={data.client_label}
|
||||
isLink={Boolean(data.client_id)}
|
||||
href={data.client_id ? `/all-users/${data.client_id}` : undefined}
|
||||
/>
|
||||
<InfoRow label={t("common.id", "ID")} value={data.id} />
|
||||
<InfoRow label={t("intlPayment.status", "Status")}>
|
||||
<PaymentStatusBadge status={data.status} />
|
||||
@@ -206,7 +211,12 @@ export default function IntlPaymentViewPage() {
|
||||
|
||||
<BentoCard title={t("intlPayment.locationSection", "Lokasiýa")}>
|
||||
<InfoRow label={t("intlPayment.province", "Welaýat")} value={data.province_label} />
|
||||
<InfoRow label={t("intlPayment.branch", "Şahamça")} value={data.branch_label} isLink />
|
||||
<InfoRow
|
||||
label={t("intlPayment.branch", "Şahamça")}
|
||||
value={data.branch_label}
|
||||
isLink={Boolean(data.branch)}
|
||||
href={data.branch ? `/settings/location/branches/${data.branch}` : undefined}
|
||||
/>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
import { STATUS_BADGE_VARIANTS } from "@/constants";
|
||||
import { buildFileUrl } from "@/features/shared/api/sharedApi";
|
||||
|
||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||
|
||||
function formatDate(value: string | null | undefined): string {
|
||||
@@ -17,7 +16,7 @@ function formatDate(value: string | null | undefined): string {
|
||||
return value.slice(0, 10);
|
||||
}
|
||||
|
||||
function resolveLocalizedName(name: LocalizedText | string | undefined | null, lang = "en"): string {
|
||||
function resolveLocalizedName(name: LocalizedText | string | null | undefined, lang = "en"): string {
|
||||
if (!name) return "";
|
||||
if (typeof name === "string") return name;
|
||||
return name[lang as keyof LocalizedText] ?? name.tm ?? name.en ?? name.ru ?? "";
|
||||
@@ -145,18 +144,25 @@ export default function LoanPaidOffLettersViewPage() {
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("loanPaidOffLetters.sections.additional", "Goşmaça")}>
|
||||
<InfoRow label={t("loanPaidOffLetters.fields.region", "Sebit")} value={record.region || "—"} />
|
||||
<InfoRow
|
||||
label={t("loanPaidOffLetters.fields.region", "Sebit")}
|
||||
value={resolveLocalizedName(record.regionName, i18n.language) || record.region || "—"}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanPaidOffLetters.fields.provinceName", "Welaýat")}
|
||||
value={resolveLocalizedName(record.province?.name, i18n.language) || "—"}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanPaidOffLetters.fields.branchName", "Şahamça")}
|
||||
value={resolveLocalizedName(record.branchName, i18n.language) || (record.branchId != null ? String(record.branchId) : "—")}
|
||||
isLink={Boolean(record.branchId)}
|
||||
href={record.branchId ? `/settings/location/branches/${record.branchId}` : undefined}
|
||||
value={resolveLocalizedName(record.branch?.name, i18n.language) || record.branch?.uniqueCode || "—"}
|
||||
isLink={Boolean(record.branch?.id)}
|
||||
href={record.branch?.id ? `/settings/location/branches/${record.branch.id}` : undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanPaidOffLetters.fields.userName", "Ulanyjy ady")}
|
||||
value={record.userName || (record.userId != null ? String(record.userId) : "—")}
|
||||
isLink={Boolean(record.userId)}
|
||||
href={record.userId ? `/all-users/${record.userId}` : undefined}
|
||||
value={record.user?.name || "—"}
|
||||
isLink={Boolean(record.user?.id)}
|
||||
href={record.user?.id ? `/all-users/${record.user.id}` : undefined}
|
||||
/>
|
||||
<InfoRow label={t("loanPaidOffLetters.fields.notes", "Bellikler")} value={record.notes || "—"} />
|
||||
</BentoCard>
|
||||
|
||||
Reference in New Issue
Block a user