started connect with api
This commit is contained in:
1 parent
0ca218505d
commit
6da59f42d9
112 files changed
+7091
-6989
No files matched your search
@@ -2,21 +2,36 @@ import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil } from "lucide-react";
|
||||
import {
|
||||
useLoanPaidOffLetterById,
|
||||
useDeleteLoanPaidOffLetter,
|
||||
} from "@/features/loanPaidOffLetters/hooks/useLoanPaidOffLetters";
|
||||
import { useLoanPaidOffLetterById, useDeleteLoanPaidOffLetter } from "@/features/loanPaidOffLetters/hooks/useLoanPaidOffLetters";
|
||||
import type { StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { InfoRow, Section } from "@/components/viewPageComponents";
|
||||
import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
const STATUS_VARIANT: Record<string, StatusBadgeVariant> = {
|
||||
pending: "warning",
|
||||
approved: "success",
|
||||
rejected: "error",
|
||||
};
|
||||
|
||||
function formatDate(value: string | null | undefined): string {
|
||||
if (!value) return "—";
|
||||
return value.slice(0, 10);
|
||||
}
|
||||
|
||||
function LoanPaidOffLetterViewSkeleton() {
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<Skeleton className="h-7 w-64" />
|
||||
<div className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3">
|
||||
{[...Array(5)].map((_, j) => (
|
||||
<Skeleton key={j} className="h-4 w-full" />
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
{[...Array(4)].map((_, i) => (
|
||||
<div key={i} className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3">
|
||||
<Skeleton className="h-3 w-24 mb-1" />
|
||||
{[...Array(4)].map((_, j) => (
|
||||
<Skeleton key={j} className="h-4 w-full" />
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -41,19 +56,17 @@ export default function LoanPaidOffLettersViewPage() {
|
||||
if (isLoading) return <LoanPaidOffLetterViewSkeleton />;
|
||||
|
||||
if (!record) {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-64 text-muted-foreground text-sm">
|
||||
{t("common.notFound", "Tapylmady")}
|
||||
</div>
|
||||
);
|
||||
return <div className="flex items-center justify-center h-64 text-muted-foreground text-sm">{t("common.notFound", "Tapylmady")}</div>;
|
||||
}
|
||||
|
||||
const fullName = [record.customerSurname, record.customerName, record.customerPatronicName].filter(Boolean).join(" ");
|
||||
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<div className="flex items-center justify-between mb-5">
|
||||
<div className="flex flex-col gap-6">
|
||||
{/* ── Page header ──────────────────────────────────────────────────── */}
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t("loanPaidOffLetters.view.title", "Güwanama maglumaty")}:{" "}
|
||||
{record.id}
|
||||
{t("loanPaidOffLetters.view.title", "Güwanama maglumaty")}: {record.uniqueId}
|
||||
</h1>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<button
|
||||
@@ -74,25 +87,62 @@ export default function LoanPaidOffLettersViewPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Section title={t("loanPaidOffLetters.sections.info", "Esasy maglumatlar")}>
|
||||
<InfoRow label={t("common.id", "ID")} value={String(record.id)} />
|
||||
<InfoRow
|
||||
label={t("loanPaidOffLetters.columns.passportSeries", "Pasport seriýasy")}
|
||||
value={record.passportSeries}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanPaidOffLetters.columns.passportNumber", "Pasport belgisi")}
|
||||
value={record.passportNumber}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanPaidOffLetters.columns.loanAccount", "Karz hasaby")}
|
||||
value={record.loanAccount}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanPaidOffLetters.columns.issuedAt", "Berlen wagty")}
|
||||
value={record.issuedAt}
|
||||
/>
|
||||
</Section>
|
||||
{/* ── Row 1: Esasy maglumatlar + Müşderi maglumatlary ───────────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("loanPaidOffLetters.sections.info", "Esasy maglumatlar")}>
|
||||
<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_VARIANT[record.status] ?? "default"}
|
||||
/>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("loanPaidOffLetters.fields.createdAt", "Döredilen wagty")} value={formatDate(record.createdAt)} />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("loanPaidOffLetters.sections.customer", "Müşderi maglumatlary")}>
|
||||
<InfoRow label={t("loanPaidOffLetters.fields.customerName", "Ady")} value={fullName || "—"} />
|
||||
<InfoRow label={t("loanPaidOffLetters.fields.bornAt", "Doglan senesi")} value={formatDate(record.bornAt)} />
|
||||
<InfoRow label={t("loanPaidOffLetters.fields.phone", "Telefon")} value={record.phone || "—"} />
|
||||
<InfoRow label={t("loanPaidOffLetters.fields.passportSerie", "Pasport seriýasy")} value={record.passportSerie || "—"} />
|
||||
<InfoRow label={t("loanPaidOffLetters.fields.passportId", "Pasport belgisi")} value={record.passportId || "—"} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 2: Karz maglumatlary + Goşmaça ───────────────────────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("loanPaidOffLetters.sections.loan", "Karz maglumatlary")}>
|
||||
<InfoRow
|
||||
label={t("loanPaidOffLetters.fields.loanContractNumber", "Karz şertnamasy belgisi")}
|
||||
value={record.loanContractNumber || "—"}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanPaidOffLetters.fields.loanContractDate", "Karz şertnamasy senesi")}
|
||||
value={formatDate(record.loanContractDate)}
|
||||
/>
|
||||
<InfoRow label={t("loanPaidOffLetters.fields.loanAmount", "Karz möçberi")} value={record.loanAmount || "—"} />
|
||||
<InfoRow label={t("loanPaidOffLetters.fields.loanReason", "Karz sebäbi")} value={record.loanReason || "—"} />
|
||||
<InfoRow label={t("loanPaidOffLetters.fields.loanFile", "Faýl")} value={record.loanFile || "—"} />
|
||||
</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.branchId", "Şahamça ID")}
|
||||
value={record.branchId != null ? String(record.branchId) : "—"}
|
||||
isLink={Boolean(record.branchId)}
|
||||
href={record.branchId ? `/settings/location/branches/${record.branchId}` : undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanPaidOffLetters.fields.userId", "Ulanyjy ID")}
|
||||
value={record.userId != null ? String(record.userId) : "—"}
|
||||
isLink={Boolean(record.userId)}
|
||||
href={record.userId ? `/all-users/${record.userId}` : undefined}
|
||||
/>
|
||||
<InfoRow label={t("loanPaidOffLetters.fields.notes", "Bellikler")} value={record.notes || "—"} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
<ConfirmDialog
|
||||
open={showDeleteDialog}
|
||||
|
||||
Reference in new issue
Block a user