connected with loan order api
This commit is contained in:
@@ -145,7 +145,7 @@ export default function LoanOrderViewPage() {
|
||||
|
||||
{/* Location */}
|
||||
<BentoCard title={t("loanOrders.sections.location", "Lokasiýa")}>
|
||||
<InfoRow label={t("loanOrders.columns.region", "Welaýat")} value={order.region} />
|
||||
<InfoRow label={t("loanOrders.columns.region", "Welaýat")} value={t(`loanOrders.regions.${order.region}`, order.region)} />
|
||||
<InfoRow
|
||||
label={t("loanOrders.columns.branch", "Şahamça")}
|
||||
value={order.branch}
|
||||
|
||||
@@ -37,14 +37,7 @@ const COLUMN_IDS = ["id", "loanType", "createdAt", "region", "branch", "firstNam
|
||||
|
||||
// ─── Filter fields ────────────────────────────────────────────────────────────
|
||||
|
||||
const REGION_OPTIONS = [
|
||||
{ value: "Balkan", label: "Balkan" },
|
||||
{ value: "Ahal", label: "Ahal" },
|
||||
{ value: "Daşoguz", label: "Daşoguz" },
|
||||
{ value: "Lebap", label: "Lebap" },
|
||||
{ value: "Mary", label: "Mary" },
|
||||
{ value: "Aşgabat", label: "Aşgabat" },
|
||||
];
|
||||
const REGION_CODES = ["AG", "AH", "BN", "DZ", "LB", "MR"] as const;
|
||||
|
||||
// ─── Page Component ───────────────────────────────────────────────────────────
|
||||
|
||||
@@ -82,6 +75,8 @@ export default function LoanOrdersPage() {
|
||||
const { data, isLoading } = useLoanOrders(queryParams);
|
||||
const totalPages = data ? Math.ceil(data.total / perPage) : 1;
|
||||
|
||||
const regionOptions = useMemo(() => REGION_CODES.map((code) => ({ value: code, label: t(`loanOrders.regions.${code}`, code) })), [t]);
|
||||
|
||||
const handleFilterChange = useCallback((fieldId: string, value: string) => {
|
||||
setActiveFilters((prev) => prev.map((f) => (f.fieldId === fieldId ? { ...f, value } : f)));
|
||||
setPage(1);
|
||||
@@ -128,7 +123,9 @@ export default function LoanOrdersPage() {
|
||||
id: "region",
|
||||
accessorKey: "region",
|
||||
header: t("Region", "WELAÝAT"),
|
||||
cell: ({ row }) => <span className="text-sm text-foreground">{row.original.region}</span>,
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground">{t(`loanOrders.regions.${row.original.region}`, row.original.region)}</span>
|
||||
),
|
||||
size: 100,
|
||||
},
|
||||
{
|
||||
@@ -191,7 +188,7 @@ export default function LoanOrdersPage() {
|
||||
{
|
||||
id: "region",
|
||||
label: t("Region", "WELAÝAT"),
|
||||
options: REGION_OPTIONS,
|
||||
options: regionOptions,
|
||||
},
|
||||
{
|
||||
id: "status",
|
||||
@@ -212,7 +209,7 @@ export default function LoanOrdersPage() {
|
||||
],
|
||||
},
|
||||
],
|
||||
[t],
|
||||
[t, regionOptions],
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -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}
|
||||
/>
|
||||
|
||||
@@ -79,6 +79,12 @@ export default function LoanRemainingViewPage() {
|
||||
<Section title={t("loanRemaining.sections.info", "Esasy maglumatlar")}>
|
||||
<InfoRow label={t("common.id", "ID")} value={String(record.id)} />
|
||||
<InfoRow label={t("loanRemaining.columns.userId", "Ulanyjy ID")} value={String(record.userId)} />
|
||||
<InfoRow
|
||||
label={t("loanRemaining.columns.userName", "Ulanyjy ady")}
|
||||
isLink
|
||||
href={`/all-users/${record.userId}`}
|
||||
value={String(record.userName)}
|
||||
/>
|
||||
<InfoRow label={t("loanRemaining.columns.passportSerie", "Pasport seriýasy")} value={record.passportSerie} />
|
||||
<InfoRow label={t("loanRemaining.columns.passportId", "Pasport belgisi")} value={record.passportId} />
|
||||
<InfoRow label={t("loanRemaining.columns.accountNumber", "Karz hasaby")} value={record.accountNumber} />
|
||||
|
||||
Reference in New Issue
Block a user