fixed some types, add some labels
This commit is contained in:
1 parent
62b6489abf
commit
1a7dd954e2
23 files changed
+379
-168
No files matched your search
@@ -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>
|
||||
|
||||
|
||||
Reference in new issue
Block a user