connected with loan order api
This commit is contained in:
1 parent
7bb37f9b43
commit
73142c1fcf
19 files changed
+1234
-476
No files matched your search
@@ -1,19 +1,28 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil } from "lucide-react";
|
||||
import { Trash2, Pencil, 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 } 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 {
|
||||
if (!value) return "—";
|
||||
return value.slice(0, 10);
|
||||
}
|
||||
|
||||
function resolveLocalizedName(name: LocalizedText | string | undefined | null, lang = "en"): string {
|
||||
if (!name) return "";
|
||||
if (typeof name === "string") return name;
|
||||
return name[lang as keyof LocalizedText] ?? name.tm ?? name.en ?? name.ru ?? "";
|
||||
}
|
||||
|
||||
function LoanPaidOffLetterViewSkeleton() {
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
@@ -33,7 +42,7 @@ function LoanPaidOffLetterViewSkeleton() {
|
||||
}
|
||||
|
||||
export default function LoanPaidOffLettersViewPage() {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const deleteMutation = useDeleteLoanPaidOffLetter();
|
||||
@@ -117,20 +126,35 @@ export default function LoanPaidOffLettersViewPage() {
|
||||
/>
|
||||
<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 || "—"} />
|
||||
<InfoRow label={t("loanPaidOffLetters.fields.loanFile", "Faýl")}>
|
||||
{record.loanFile ? (
|
||||
<a
|
||||
href={record.loanFile.startsWith("http") ? record.loanFile : buildFileUrl(record.loanFile)}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-primary/10 text-primary text-xs font-medium hover:bg-primary/20 transition-colors"
|
||||
>
|
||||
<FileText size={14} />
|
||||
<span className="truncate max-w-[220px]">{decodeURIComponent(record.loanFile.split("/").pop() || record.loanFile)}</span>
|
||||
<ExternalLink size={12} className="ml-1 opacity-70 shrink-0" />
|
||||
</a>
|
||||
) : (
|
||||
<span className="text-muted-foreground">—</span>
|
||||
)}
|
||||
</InfoRow>
|
||||
</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) : "—"}
|
||||
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}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanPaidOffLetters.fields.userId", "Ulanyjy ID")}
|
||||
value={record.userId != null ? String(record.userId) : "—"}
|
||||
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}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user