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
@@ -105,6 +105,8 @@ const DistrictsViewPage = lazy(() => import("@/pages/settings/location/districts
|
|||||||
const DistrictEditPage = lazy(() => import("@/pages/settings/location/districtsEdit"));
|
const DistrictEditPage = lazy(() => import("@/pages/settings/location/districtsEdit"));
|
||||||
const BranchesPage = lazy(() => import("@/pages/settings/location/branches"));
|
const BranchesPage = lazy(() => import("@/pages/settings/location/branches"));
|
||||||
const BackupsPage = lazy(() => import("@/pages/backups"));
|
const BackupsPage = lazy(() => import("@/pages/backups"));
|
||||||
|
const ActivityLogsPage = lazy(() => import("@/pages/logs"));
|
||||||
|
const ActivityLogViewPage = lazy(() => import("@/pages/logs/view"));
|
||||||
const BranchCreatePage = lazy(() => import("@/pages/settings/location/branchesCreate"));
|
const BranchCreatePage = lazy(() => import("@/pages/settings/location/branchesCreate"));
|
||||||
const BranchesViewPage = lazy(() => import("@/pages/settings/location/branchesView"));
|
const BranchesViewPage = lazy(() => import("@/pages/settings/location/branchesView"));
|
||||||
const BranchEditPage = lazy(() => import("@/pages/settings/location/branchesEdit"));
|
const BranchEditPage = lazy(() => import("@/pages/settings/location/branchesEdit"));
|
||||||
@@ -587,6 +589,19 @@ const routes: AppRoute[] = [
|
|||||||
element: page(BackupsPage),
|
element: page(BackupsPage),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ── LOGLAR ──────────────────────────────────────────────────────
|
||||||
|
{
|
||||||
|
...bc((t) => t("logs.title", "Loglar"), "/logs"),
|
||||||
|
children: [
|
||||||
|
{ path: "/logs", element: page(ActivityLogsPage) },
|
||||||
|
{
|
||||||
|
path: "/logs/:id",
|
||||||
|
handle: { title: (t) => t("logs.viewTitle", "Log giňişleýin") },
|
||||||
|
element: page(ActivityLogViewPage),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
// ── SAZLAMALAR > ULANYJYLAR ───────────────────────────────────────
|
// ── SAZLAMALAR > ULANYJYLAR ───────────────────────────────────────
|
||||||
{
|
{
|
||||||
...bc((t) => t("nav.settings", "Sazlamalar")),
|
...bc((t) => t("nav.settings", "Sazlamalar")),
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import apiClient from "@/lib/api/client";
|
||||||
|
|
||||||
|
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export interface ActivityLogUser {
|
||||||
|
id: number;
|
||||||
|
username: string;
|
||||||
|
role: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ActivityLog {
|
||||||
|
id: number;
|
||||||
|
userId: number;
|
||||||
|
user: ActivityLogUser;
|
||||||
|
method: string;
|
||||||
|
path: string;
|
||||||
|
module: string;
|
||||||
|
action: string;
|
||||||
|
statusCode: number;
|
||||||
|
requestBody: Record<string, unknown> | null;
|
||||||
|
ip: string;
|
||||||
|
createdAt: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ActivityLogsResponse {
|
||||||
|
count: number;
|
||||||
|
logs: ActivityLog[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ActivityLogsParams {
|
||||||
|
page?: number;
|
||||||
|
limit?: number;
|
||||||
|
user_id?: number;
|
||||||
|
module?: string;
|
||||||
|
action?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── API Functions ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export const activityLogsApi = {
|
||||||
|
getActivityLogs: async (params: ActivityLogsParams = {}, signal?: AbortSignal): Promise<ActivityLogsResponse> => {
|
||||||
|
const { page, limit, user_id, module, action } = params;
|
||||||
|
const { data } = await apiClient.get<ActivityLogsResponse>("/activity-logs", {
|
||||||
|
params: { page, limit, user_id, module, action },
|
||||||
|
signal,
|
||||||
|
});
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
|
||||||
|
getActivityLogById: async (id: number): Promise<ActivityLog> => {
|
||||||
|
const { data } = await apiClient.get<ActivityLog>(`/activity-logs/${id}`);
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { activityLogsApi, type ActivityLogsParams } from "../api/activityLogsApi";
|
||||||
|
|
||||||
|
// ─── Query Keys ───────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export const activityLogKeys = {
|
||||||
|
all: ["activityLogs"] as const,
|
||||||
|
lists: () => [...activityLogKeys.all, "list"] as const,
|
||||||
|
list: (params: ActivityLogsParams) => [...activityLogKeys.lists(), params] as const,
|
||||||
|
details: () => [...activityLogKeys.all, "detail"] as const,
|
||||||
|
detail: (id: number) => [...activityLogKeys.details(), id] as const,
|
||||||
|
};
|
||||||
|
|
||||||
|
// ─── useActivityLogs ──────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export function useActivityLogs(params: ActivityLogsParams = {}) {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: activityLogKeys.list(params),
|
||||||
|
queryFn: ({ signal }) => activityLogsApi.getActivityLogs(params, signal),
|
||||||
|
placeholderData: (prev) => prev,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── useActivityLog ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export function useActivityLog(id: number) {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: activityLogKeys.detail(id),
|
||||||
|
queryFn: () => activityLogsApi.getActivityLogById(id),
|
||||||
|
enabled: !!id,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
import apiClient from "@/lib/api/client";
|
import apiClient from "@/lib/api/client";
|
||||||
|
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||||
|
|
||||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export interface CardPinOrder {
|
export interface CardPinOrder {
|
||||||
id: number;
|
id: number;
|
||||||
uniqueId: string;
|
uniqueId: string;
|
||||||
userId: number;
|
user: { id: number; name: string; username: string; phone: string; email: string } | null;
|
||||||
cardTypeId: number;
|
cardType: { id: number; name: LocalizedText | string } | null;
|
||||||
cardNumber: string;
|
cardNumber: string;
|
||||||
region: string;
|
region: string;
|
||||||
branchId: number;
|
branch: { id: number; name: LocalizedText | string } | null;
|
||||||
customerName: string;
|
customerName: string;
|
||||||
customerSurname: string;
|
customerSurname: string;
|
||||||
customerPatronicName: string | null;
|
customerPatronicName: string | null;
|
||||||
|
|||||||
@@ -206,8 +206,8 @@ function StepPersonal({ form, errors, set, t, initialData }: StepContentProps &
|
|||||||
label: u.name || `${u.firstName || ""} ${u.lastName || ""}`.trim() || u.username || String(u.id),
|
label: u.name || `${u.firstName || ""} ${u.lastName || ""}`.trim() || u.username || String(u.id),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (initialData?.userId && !opts.some((o) => o.value === String(initialData.userId))) {
|
if (initialData?.user?.id && !opts.some((o) => o.value === String(initialData.user!.id))) {
|
||||||
opts.unshift({ value: String(initialData.userId), label: String(initialData.userId) });
|
opts.unshift({ value: String(initialData.user!.id), label: initialData.user!.name || String(initialData.user!.id) });
|
||||||
}
|
}
|
||||||
return opts;
|
return opts;
|
||||||
}, [clientsQuery.data, initialData]);
|
}, [clientsQuery.data, initialData]);
|
||||||
@@ -579,9 +579,9 @@ function mapInitial(data: CardPinOrder): Partial<CardPinFormData> {
|
|||||||
uniqueId: data.uniqueId ?? "",
|
uniqueId: data.uniqueId ?? "",
|
||||||
status: data.status ?? "",
|
status: data.status ?? "",
|
||||||
cardNumber: data.cardNumber ?? "",
|
cardNumber: data.cardNumber ?? "",
|
||||||
cardTypeId: String(data.cardTypeId ?? ""),
|
cardTypeId: String(data.cardType?.id ?? ""),
|
||||||
region: data.region ?? "",
|
region: data.region ?? "",
|
||||||
branchId: String(data.branchId ?? ""),
|
branchId: String(data.branch?.id ?? ""),
|
||||||
customerName: data.customerName ?? "",
|
customerName: data.customerName ?? "",
|
||||||
customerSurname: data.customerSurname ?? "",
|
customerSurname: data.customerSurname ?? "",
|
||||||
customerPatronicName: data.customerPatronicName ?? "",
|
customerPatronicName: data.customerPatronicName ?? "",
|
||||||
@@ -593,7 +593,7 @@ function mapInitial(data: CardPinOrder): Partial<CardPinFormData> {
|
|||||||
passportTwo: data.passportTwo ?? "",
|
passportTwo: data.passportTwo ?? "",
|
||||||
passportThree: data.passportThree ?? "",
|
passportThree: data.passportThree ?? "",
|
||||||
passportFour: data.passportFour ?? "",
|
passportFour: data.passportFour ?? "",
|
||||||
userId: String(data.userId ?? ""),
|
userId: String(data.user?.id ?? ""),
|
||||||
notes: data.notes ?? "",
|
notes: data.notes ?? "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ import apiClient from "@/lib/api/client";
|
|||||||
|
|
||||||
export interface Card {
|
export interface Card {
|
||||||
id: number;
|
id: number;
|
||||||
userId: number;
|
user: { id: number; name: string; username: string; phone: string; email: string } | null;
|
||||||
number: string;
|
number: string;
|
||||||
name: string;
|
name: string;
|
||||||
month: string;
|
month: string;
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ export function CardTransactionForm({ mode, initialData }: CardTransactionFormPr
|
|||||||
label: u.name || `${u.firstName || ""} ${u.lastName || ""}`.trim() || u.username || String(u.id),
|
label: u.name || `${u.firstName || ""} ${u.lastName || ""}`.trim() || u.username || String(u.id),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (initialData?.userId && !opts.some((o) => o.value === String(initialData.userId))) {
|
if (initialData?.user?.id && !opts.some((o) => o.value === String(initialData.user!.id))) {
|
||||||
opts.unshift({ value: String(initialData.userId), label: String(initialData.userId) });
|
opts.unshift({ value: String(initialData.user!.id), label: initialData.user!.name || String(initialData.user!.id) });
|
||||||
}
|
}
|
||||||
return opts;
|
return opts;
|
||||||
}, [clientsQuery.data, initialData]);
|
}, [clientsQuery.data, initialData]);
|
||||||
@@ -100,7 +100,7 @@ export function CardTransactionForm({ mode, initialData }: CardTransactionFormPr
|
|||||||
type: initialData.type,
|
type: initialData.type,
|
||||||
month: initialData.month,
|
month: initialData.month,
|
||||||
year: initialData.year,
|
year: initialData.year,
|
||||||
userId: String(initialData.userId),
|
userId: String(initialData.user?.id ?? ""),
|
||||||
}
|
}
|
||||||
: DEFAULT_FORM_VALUES,
|
: DEFAULT_FORM_VALUES,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -185,13 +185,16 @@ export interface LoanOrderPayload {
|
|||||||
|
|
||||||
// ─── Backend types ─────────────────────────────────────────────────────────────
|
// ─── Backend types ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
type NestedLocalized = { id: number; name: LocalizedText | string };
|
||||||
|
|
||||||
interface BackendLoanOrder {
|
interface BackendLoanOrder {
|
||||||
id?: number | string;
|
id?: number | string;
|
||||||
uniqueId?: string | null;
|
uniqueId?: string | null;
|
||||||
region?: string | null;
|
region?: string | null;
|
||||||
branchId?: number | null;
|
branchId?: number | null;
|
||||||
|
branch?: NestedLocalized | number | string | null;
|
||||||
branchName?: LocalizedText | string | null;
|
branchName?: LocalizedText | string | null;
|
||||||
loanType?: number | string | null;
|
loanType?: NestedLocalized | number | string | null;
|
||||||
loanTypeName?: LocalizedText | string | null;
|
loanTypeName?: LocalizedText | string | null;
|
||||||
userId?: number | null;
|
userId?: number | null;
|
||||||
userName?: string | null;
|
userName?: string | null;
|
||||||
@@ -277,6 +280,27 @@ function resolveLocalizedName(name: LocalizedText | string | null | undefined):
|
|||||||
return name[key as keyof LocalizedText] ?? name.tm ?? name.en ?? name.ru ?? "";
|
return name[key as keyof LocalizedText] ?? name.tm ?? name.en ?? name.ru ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Extract a display name from a nested `{id, name}` object, a `LocalizedText`, or a plain string/number. */
|
||||||
|
function resolveNestedName(value: NestedLocalized | LocalizedText | string | number | null | undefined): string {
|
||||||
|
if (value === null || value === undefined || value === "") return "";
|
||||||
|
if (typeof value === "string") return value;
|
||||||
|
if (typeof value === "number") return "";
|
||||||
|
if ("name" in value) return resolveLocalizedName(value.name);
|
||||||
|
return resolveLocalizedName(value as LocalizedText);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Extract a numeric ID from a nested `{id}` object, a number, or a string. */
|
||||||
|
function resolveNestedId(value: NestedLocalized | number | string | null | undefined): number | null {
|
||||||
|
if (value === null || value === undefined || value === "") return null;
|
||||||
|
if (typeof value === "number") return value;
|
||||||
|
if (typeof value === "string") {
|
||||||
|
const n = Number(value);
|
||||||
|
return Number.isNaN(n) ? null : n;
|
||||||
|
}
|
||||||
|
if ("id" in value) return value.id ?? null;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
function toNum(value: string | number | null | undefined): number | null {
|
function toNum(value: string | number | null | undefined): number | null {
|
||||||
if (value === null || value === undefined || value === "") return null;
|
if (value === null || value === undefined || value === "") return null;
|
||||||
const n = Number(value);
|
const n = Number(value);
|
||||||
@@ -289,12 +313,12 @@ function mapBackendToUI(order: BackendLoanOrder): LoanOrder {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
id: String(order.id ?? order.uniqueId ?? ""),
|
id: String(order.id ?? order.uniqueId ?? ""),
|
||||||
loanType: resolveLocalizedName(order.loanTypeName) || (order.loanType != null ? String(order.loanType) : ""),
|
loanType: resolveNestedName(order.loanType) || resolveLocalizedName(order.loanTypeName),
|
||||||
createdAt: order.createdAt ?? "",
|
createdAt: order.createdAt ?? "",
|
||||||
region: order.region ?? "",
|
region: order.region ?? "",
|
||||||
branch: resolveLocalizedName(order.branchName),
|
branch: resolveNestedName(order.branch) || resolveLocalizedName(order.branchName),
|
||||||
branchId: order.branchId ?? undefined,
|
branchId: resolveNestedId(order.branch) ?? order.branchId ?? undefined,
|
||||||
loanTypeId: order.loanType ?? undefined,
|
loanTypeId: resolveNestedId(order.loanType) ?? undefined,
|
||||||
workCityId: order.workProvinceId ?? undefined,
|
workCityId: order.workProvinceId ?? undefined,
|
||||||
createdById: order.userId ?? undefined,
|
createdById: order.userId ?? undefined,
|
||||||
firstName: order.customerName ?? "",
|
firstName: order.customerName ?? "",
|
||||||
|
|||||||
@@ -9,10 +9,23 @@ export interface LoanPaidOffLetter {
|
|||||||
id: number;
|
id: number;
|
||||||
uniqueId: string;
|
uniqueId: string;
|
||||||
region: string;
|
region: string;
|
||||||
branchId: number | null;
|
regionName: LocalizedText | null;
|
||||||
branchName?: LocalizedText | string | null;
|
branch: {
|
||||||
userId: number | null;
|
id: number;
|
||||||
userName?: string | null;
|
name: LocalizedText | string;
|
||||||
|
uniqueCode: string;
|
||||||
|
} | null;
|
||||||
|
province: {
|
||||||
|
id: number;
|
||||||
|
name: LocalizedText | string;
|
||||||
|
} | null;
|
||||||
|
user: {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
username: string;
|
||||||
|
phone: string;
|
||||||
|
email: string;
|
||||||
|
} | null;
|
||||||
customerName: string;
|
customerName: string;
|
||||||
customerSurname: string;
|
customerSurname: string;
|
||||||
customerPatronicName: string;
|
customerPatronicName: string;
|
||||||
|
|||||||
@@ -351,10 +351,10 @@ export function LoanPaidOffLetterForm({ mode, initialData }: LoanPaidOffLetterFo
|
|||||||
label: resolveLocalizedName(b.name, lang) || b.uniqueCode || String(b.id),
|
label: resolveLocalizedName(b.name, lang) || b.uniqueCode || String(b.id),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (initialData?.branchId) {
|
if (initialData?.branch?.id) {
|
||||||
const bId = String(initialData.branchId);
|
const bId = String(initialData.branch.id);
|
||||||
if (!opts.some((o) => o.value === bId)) {
|
if (!opts.some((o) => o.value === bId)) {
|
||||||
const initialBranchName = resolveLocalizedName(initialData.branchName, lang) || bId;
|
const initialBranchName = resolveLocalizedName(initialData.branch.name, lang) || bId;
|
||||||
opts.unshift({ value: bId, label: initialBranchName });
|
opts.unshift({ value: bId, label: initialBranchName });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -385,10 +385,10 @@ export function LoanPaidOffLetterForm({ mode, initialData }: LoanPaidOffLetterFo
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
if (initialData?.userId) {
|
if (initialData?.user?.id) {
|
||||||
const uId = String(initialData.userId);
|
const uId = String(initialData.user.id);
|
||||||
if (!opts.some((o) => o.value === uId)) {
|
if (!opts.some((o) => o.value === uId)) {
|
||||||
const initialUserName = initialData.userName || uId;
|
const initialUserName = initialData.user.name || uId;
|
||||||
opts.unshift({ value: uId, label: initialUserName });
|
opts.unshift({ value: uId, label: initialUserName });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,8 +148,8 @@ export function mapInitial(data: LoanPaidOffLetter): LoanPaidOffLetterFormData {
|
|||||||
passportSerie: data.passportSerie ?? "",
|
passportSerie: data.passportSerie ?? "",
|
||||||
passportId: data.passportId ?? "",
|
passportId: data.passportId ?? "",
|
||||||
region: data.region ?? "",
|
region: data.region ?? "",
|
||||||
branchId: data.branchId != null ? String(data.branchId) : "",
|
branchId: data.branch?.id != null ? String(data.branch.id) : "",
|
||||||
userId: data.userId != null ? String(data.userId) : "",
|
userId: data.user?.id != null ? String(data.user.id) : "",
|
||||||
status: data.status ?? "pending",
|
status: data.status ?? "pending",
|
||||||
notes: data.notes ?? "",
|
notes: data.notes ?? "",
|
||||||
loanContractNumber: data.loanContractNumber ?? "",
|
loanContractNumber: data.loanContractNumber ?? "",
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
import apiClient from "@/lib/api/client";
|
import apiClient from "@/lib/api/client";
|
||||||
|
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||||
|
|
||||||
// ─── Card Order ───────────────────────────────────────────────────────────────
|
// ─── Card Order ───────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export interface CardOrder {
|
export interface CardOrder {
|
||||||
id: number;
|
id: number;
|
||||||
uniqueId: string;
|
uniqueId: string;
|
||||||
cardStateId: number;
|
cardState: { id: number; name: LocalizedText | string } | null;
|
||||||
cardTypeId: number;
|
cardType: { id: number; name: LocalizedText | string } | null;
|
||||||
region: string;
|
region: string;
|
||||||
branchId: number;
|
branch: { id: number; name: LocalizedText | string } | null;
|
||||||
|
user: { id: number; name: string; username: string; phone: string; email: string } | null;
|
||||||
customerName: string;
|
customerName: string;
|
||||||
customerSurname: string;
|
customerSurname: string;
|
||||||
customerPatronicName: string;
|
customerPatronicName: string;
|
||||||
@@ -31,7 +33,6 @@ export interface CardOrder {
|
|||||||
passportThree: string;
|
passportThree: string;
|
||||||
passportFour: string;
|
passportFour: string;
|
||||||
notes: string;
|
notes: string;
|
||||||
userId: number;
|
|
||||||
paid: boolean;
|
paid: boolean;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
|
|||||||
@@ -431,12 +431,12 @@ function StepContact({ form, errors, set, t, initialData }: StepContentProps & {
|
|||||||
label: u.name || `${u.firstName || ""} ${u.lastName || ""}`.trim() || u.username || String(u.id),
|
label: u.name || `${u.firstName || ""} ${u.lastName || ""}`.trim() || u.username || String(u.id),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (initialData?.userId && !opts.some((o) => o.value === String(initialData.userId))) {
|
if (initialData?.user?.id && !opts.some((o) => o.value === String(initialData.user!.id))) {
|
||||||
opts.unshift({
|
opts.unshift({
|
||||||
value: String(initialData.userId),
|
value: String(initialData.user!.id),
|
||||||
label: initialData.customerName
|
label: initialData.customerName
|
||||||
? `${initialData.customerName} ${initialData.customerSurname || ""}`.trim()
|
? `${initialData.customerName} ${initialData.customerSurname || ""}`.trim()
|
||||||
: String(initialData.userId),
|
: String(initialData.user!.id),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return opts;
|
return opts;
|
||||||
@@ -732,10 +732,10 @@ function mapInitial(data: CardOrder): Partial<OrderNewCardFormData> {
|
|||||||
uniqueId: data.uniqueId,
|
uniqueId: data.uniqueId,
|
||||||
status: data.status,
|
status: data.status,
|
||||||
paid: data.paid,
|
paid: data.paid,
|
||||||
cardStateId: String(data.cardStateId ?? ""),
|
cardStateId: String(data.cardState?.id ?? ""),
|
||||||
cardTypeId: String(data.cardTypeId ?? ""),
|
cardTypeId: String(data.cardType?.id ?? ""),
|
||||||
region: data.region ?? "",
|
region: data.region ?? "",
|
||||||
branchId: String(data.branchId ?? ""),
|
branchId: String(data.branch?.id ?? ""),
|
||||||
customerName: data.customerName,
|
customerName: data.customerName,
|
||||||
customerSurname: data.customerSurname,
|
customerSurname: data.customerSurname,
|
||||||
customerPatronicName: data.customerPatronicName ?? "",
|
customerPatronicName: data.customerPatronicName ?? "",
|
||||||
@@ -756,7 +756,7 @@ function mapInitial(data: CardOrder): Partial<OrderNewCardFormData> {
|
|||||||
passportAddress: data.passportAddress ?? "",
|
passportAddress: data.passportAddress ?? "",
|
||||||
realAddress: data.realAddress ?? "",
|
realAddress: data.realAddress ?? "",
|
||||||
jobLocation: data.jobLocation ?? "",
|
jobLocation: data.jobLocation ?? "",
|
||||||
userId: String(data.userId ?? ""),
|
userId: String(data.user?.id ?? ""),
|
||||||
notes: data.notes ?? "",
|
notes: data.notes ?? "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -4,12 +4,33 @@ import { isStatusValue } from "@/constants";
|
|||||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||||
import { postFile, buildFileUrl } from "@/features/shared/api/sharedApi";
|
import { postFile, buildFileUrl } from "@/features/shared/api/sharedApi";
|
||||||
|
|
||||||
// ─── Types (UI-facing) ────────────────────────────────────────────────────────
|
// ─── Shared types ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export type IntlPaymentStatus = "pending" | "approved" | "rejected";
|
export type IntlPaymentStatus = "pending" | "approved" | "rejected";
|
||||||
export type CurrencyType = "visa" | "mastercard";
|
export type CurrencyType = "visa" | "mastercard";
|
||||||
|
|
||||||
export interface IntlPaymentItem {
|
/** Kabul ediji + Upgradyý resminamalar (15 sany) — hem UI hem Payload ortak */
|
||||||
|
export interface IntlPaymentDocs {
|
||||||
|
doc_sberbank_account: string | null;
|
||||||
|
doc_school_enrollment: string | null;
|
||||||
|
doc_summons: string | null;
|
||||||
|
doc_passport_tm: string | null;
|
||||||
|
doc_foreign_passport: string | null;
|
||||||
|
doc_foreign_passport_copy: string | null;
|
||||||
|
doc_exit_permission: string | null;
|
||||||
|
doc_school_foreign_info: string | null;
|
||||||
|
doc_school_departure_info: string | null;
|
||||||
|
upd_doc_passport_tm: string | null;
|
||||||
|
upd_doc_foreign_passport: string | null;
|
||||||
|
upd_doc_visa: string | null;
|
||||||
|
upd_doc_acceptance_letter: string | null;
|
||||||
|
upd_doc_passport_biometric: string | null;
|
||||||
|
upd_doc_passport_old: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── UI-facing types ──────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export interface IntlPaymentItem extends IntlPaymentDocs {
|
||||||
id: string;
|
id: string;
|
||||||
client_id: string;
|
client_id: string;
|
||||||
client_label: string;
|
client_label: string;
|
||||||
@@ -39,25 +60,6 @@ export interface IntlPaymentItem {
|
|||||||
// Töleg kabul edijiniň maglumatlary
|
// Töleg kabul edijiniň maglumatlary
|
||||||
receiver_info: string;
|
receiver_info: string;
|
||||||
|
|
||||||
// Kabul ediji talyp boyunca resminamalar (9 sany)
|
|
||||||
doc_sberbank_account: string | null; // file url
|
|
||||||
doc_school_enrollment: string | null;
|
|
||||||
doc_summons: string | null;
|
|
||||||
doc_passport_tm: string | null;
|
|
||||||
doc_foreign_passport: string | null;
|
|
||||||
doc_foreign_passport_copy: string | null;
|
|
||||||
doc_exit_permission: string | null;
|
|
||||||
doc_school_foreign_info: string | null;
|
|
||||||
doc_school_departure_info: string | null;
|
|
||||||
|
|
||||||
// Upgradyý boyunca resminamalar (6 sany)
|
|
||||||
upd_doc_passport_tm: string | null;
|
|
||||||
upd_doc_foreign_passport: string | null;
|
|
||||||
upd_doc_visa: string | null;
|
|
||||||
upd_doc_acceptance_letter: string | null;
|
|
||||||
upd_doc_passport_biometric: string | null;
|
|
||||||
upd_doc_passport_old: string | null;
|
|
||||||
|
|
||||||
created_by: string;
|
created_by: string;
|
||||||
created_by_label: string;
|
created_by_label: string;
|
||||||
}
|
}
|
||||||
@@ -85,7 +87,7 @@ export interface IntlPaymentListResponse {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export type IntlPaymentCreatePayload = {
|
export type IntlPaymentCreatePayload = IntlPaymentDocs & {
|
||||||
client_id: string;
|
client_id: string;
|
||||||
status: string;
|
status: string;
|
||||||
note: string;
|
note: string;
|
||||||
@@ -105,25 +107,6 @@ export type IntlPaymentCreatePayload = {
|
|||||||
payer_account_number: string;
|
payer_account_number: string;
|
||||||
|
|
||||||
receiver_info: string;
|
receiver_info: string;
|
||||||
|
|
||||||
// kabul ediji docs (uploaded URL strings, same as DocumentUpload in loan orders)
|
|
||||||
doc_sberbank_account: string | null;
|
|
||||||
doc_school_enrollment: string | null;
|
|
||||||
doc_summons: string | null;
|
|
||||||
doc_passport_tm: string | null;
|
|
||||||
doc_foreign_passport: string | null;
|
|
||||||
doc_foreign_passport_copy: string | null;
|
|
||||||
doc_exit_permission: string | null;
|
|
||||||
doc_school_foreign_info: string | null;
|
|
||||||
doc_school_departure_info: string | null;
|
|
||||||
|
|
||||||
// upgradyý docs (uploaded URL strings)
|
|
||||||
upd_doc_passport_tm: string | null;
|
|
||||||
upd_doc_foreign_passport: string | null;
|
|
||||||
upd_doc_visa: string | null;
|
|
||||||
upd_doc_acceptance_letter: string | null;
|
|
||||||
upd_doc_passport_biometric: string | null;
|
|
||||||
upd_doc_passport_old: string | null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type IntlPaymentUpdatePayload = Partial<IntlPaymentCreatePayload>;
|
export type IntlPaymentUpdatePayload = Partial<IntlPaymentCreatePayload>;
|
||||||
@@ -140,7 +123,6 @@ interface BackendIntlPayment {
|
|||||||
email?: string | null;
|
email?: string | null;
|
||||||
region?: string | null;
|
region?: string | null;
|
||||||
regionName?: LocalizedText | string | null;
|
regionName?: LocalizedText | string | null;
|
||||||
branchId?: number | null;
|
|
||||||
branch?: {
|
branch?: {
|
||||||
id: number;
|
id: number;
|
||||||
uniqueCode: string;
|
uniqueCode: string;
|
||||||
@@ -149,8 +131,9 @@ interface BackendIntlPayment {
|
|||||||
provinceId: number;
|
provinceId: number;
|
||||||
provinceName?: LocalizedText;
|
provinceName?: LocalizedText;
|
||||||
} | null;
|
} | null;
|
||||||
userId?: number | null;
|
branchId?: number | null;
|
||||||
user?: { id: number; name: string; username: string; phone: string; email: string } | null;
|
user?: { id: number; name: string; username: string; phone: string; email: string } | null;
|
||||||
|
userId?: number | null;
|
||||||
address?: string | null;
|
address?: string | null;
|
||||||
senderDatas?: { fullName?: string; passportSerie?: string; passportNumber?: string; depositAccount?: string } | null;
|
senderDatas?: { fullName?: string; passportSerie?: string; passportNumber?: string; depositAccount?: string } | null;
|
||||||
paymentReciever?: Array<{ fullName?: string; passportSerie?: string; passportNumber?: string; depositAccount?: string }> | null;
|
paymentReciever?: Array<{ fullName?: string; passportSerie?: string; passportNumber?: string; depositAccount?: string }> | null;
|
||||||
@@ -199,55 +182,6 @@ function firstFileUrl(arr?: string[] | null): string | null {
|
|||||||
return toFileUrl(arr[0]);
|
return toFileUrl(arr[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapBackendToUI(o: BackendIntlPayment): IntlPaymentItem {
|
|
||||||
const status: IntlPaymentStatus = isStatusValue(o.status ?? "") ? (o.status as IntlPaymentStatus) : "pending";
|
|
||||||
const d = o.documents ?? {};
|
|
||||||
|
|
||||||
return {
|
|
||||||
id: String(o.id ?? o.uniqueId ?? ""),
|
|
||||||
client_id: o.userId != null ? String(o.userId) : (o.uniqueId ?? String(o.id ?? "")),
|
|
||||||
client_label: o.user?.name ?? o.uniqueId ?? String(o.id ?? ""),
|
|
||||||
currency_type: (o.type as CurrencyType) ?? "visa",
|
|
||||||
currency_type_label: o.type ?? "",
|
|
||||||
created_at: o.createdAt ?? "",
|
|
||||||
province: o.region ?? "",
|
|
||||||
province_label: resolveLocalizedName(o.regionName) || o.region || "",
|
|
||||||
branch: o.branchId != null ? String(o.branchId) : "",
|
|
||||||
branch_label: o.branch?.name ? resolveLocalizedName(o.branch.name) : "",
|
|
||||||
status,
|
|
||||||
note: o.notes ?? "",
|
|
||||||
passport_first_name: o.passportName ?? "",
|
|
||||||
passport_last_name: o.passportSurname ?? "",
|
|
||||||
phone: formatFromApiPhone(o.phone),
|
|
||||||
email: o.email ?? "",
|
|
||||||
home_address: o.address ?? "",
|
|
||||||
passport_series: o.senderDatas?.passportSerie ?? o.senderPassportSerie ?? o.paymentReciever?.[0]?.passportSerie ?? "",
|
|
||||||
passport_number: o.senderDatas?.passportNumber ?? o.senderPassportNumber ?? o.paymentReciever?.[0]?.passportNumber ?? "",
|
|
||||||
payer_full_name: o.senderFullName ?? o.senderDatas?.fullName ?? "",
|
|
||||||
payer_account_number: o.senderDepositAccount ?? o.senderDatas?.depositAccount ?? "",
|
|
||||||
receiver_info: o.recieverFullName ?? o.paymentReciever?.[0]?.fullName ?? "",
|
|
||||||
|
|
||||||
doc_sberbank_account: firstFileUrl(d.student_visa_card_details),
|
|
||||||
doc_school_enrollment: firstFileUrl(d.student_enrollment_certificate),
|
|
||||||
doc_summons: firstFileUrl(d.student_ticket_copy),
|
|
||||||
doc_passport_tm: firstFileUrl(d.student_internal_passport),
|
|
||||||
doc_foreign_passport: firstFileUrl(d.student_foreign_passport),
|
|
||||||
doc_foreign_passport_copy: firstFileUrl(d.student_visa_page),
|
|
||||||
doc_exit_permission: firstFileUrl(d.student_stamp_page),
|
|
||||||
doc_school_foreign_info: firstFileUrl(d.student_enrollment_clarification),
|
|
||||||
doc_school_departure_info: firstFileUrl(d.sender_internal_passport),
|
|
||||||
upd_doc_passport_tm: firstFileUrl(d.sender_foreign_passport),
|
|
||||||
upd_doc_foreign_passport: firstFileUrl(d.sender_stamp_page),
|
|
||||||
upd_doc_visa: firstFileUrl(d.kinship_documents),
|
|
||||||
upd_doc_acceptance_letter: firstFileUrl(d.first_passport_series_info),
|
|
||||||
upd_doc_passport_biometric: firstFileUrl(d.police_passport_series_info),
|
|
||||||
upd_doc_passport_old: null,
|
|
||||||
|
|
||||||
created_by: o.userId != null ? String(o.userId) : "",
|
|
||||||
created_by_label: o.user?.name ?? "",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Form doc field -> backend documents key
|
// Form doc field -> backend documents key
|
||||||
const DOC_FILE_TO_KEY: Record<string, string> = {
|
const DOC_FILE_TO_KEY: Record<string, string> = {
|
||||||
doc_sberbank_account: "student_visa_card_details",
|
doc_sberbank_account: "student_visa_card_details",
|
||||||
@@ -266,22 +200,78 @@ const DOC_FILE_TO_KEY: Record<string, string> = {
|
|||||||
upd_doc_passport_biometric: "police_passport_series_info",
|
upd_doc_passport_biometric: "police_passport_series_info",
|
||||||
};
|
};
|
||||||
|
|
||||||
async function mapPayloadToBackend(
|
function mapDocs(d: Record<string, string[]>): IntlPaymentDocs {
|
||||||
payload: IntlPaymentCreatePayload | Partial<IntlPaymentCreatePayload>,
|
return {
|
||||||
): Promise<Record<string, unknown>> {
|
doc_sberbank_account: firstFileUrl(d.student_visa_card_details),
|
||||||
const documents: Record<string, string[]> = {};
|
doc_school_enrollment: firstFileUrl(d.student_enrollment_certificate),
|
||||||
|
doc_summons: firstFileUrl(d.student_ticket_copy),
|
||||||
|
doc_passport_tm: firstFileUrl(d.student_internal_passport),
|
||||||
|
doc_foreign_passport: firstFileUrl(d.student_foreign_passport),
|
||||||
|
doc_foreign_passport_copy: firstFileUrl(d.student_visa_page),
|
||||||
|
doc_exit_permission: firstFileUrl(d.student_stamp_page),
|
||||||
|
doc_school_foreign_info: firstFileUrl(d.student_enrollment_clarification),
|
||||||
|
doc_school_departure_info: firstFileUrl(d.sender_internal_passport),
|
||||||
|
upd_doc_passport_tm: firstFileUrl(d.sender_foreign_passport),
|
||||||
|
upd_doc_foreign_passport: firstFileUrl(d.sender_stamp_page),
|
||||||
|
upd_doc_visa: firstFileUrl(d.kinship_documents),
|
||||||
|
upd_doc_acceptance_letter: firstFileUrl(d.first_passport_series_info),
|
||||||
|
upd_doc_passport_biometric: firstFileUrl(d.police_passport_series_info),
|
||||||
|
upd_doc_passport_old: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapBackendToUI(o: BackendIntlPayment): IntlPaymentItem {
|
||||||
|
const status: IntlPaymentStatus = isStatusValue(o.status ?? "") ? (o.status as IntlPaymentStatus) : "pending";
|
||||||
|
|
||||||
|
return {
|
||||||
|
...mapDocs(o.documents ?? {}),
|
||||||
|
id: String(o.id ?? o.uniqueId ?? ""),
|
||||||
|
client_id: o.user?.id != null ? String(o.user.id) : o.userId != null ? String(o.userId) : o.uniqueId || String(o.id ?? ""),
|
||||||
|
client_label: o.user?.name ?? o.uniqueId ?? String(o.id ?? ""),
|
||||||
|
currency_type: (o.type as CurrencyType) ?? "visa",
|
||||||
|
currency_type_label: o.type ?? "",
|
||||||
|
created_at: o.createdAt ?? "",
|
||||||
|
province: o.region ?? "",
|
||||||
|
province_label: resolveLocalizedName(o.regionName) || o.region || "",
|
||||||
|
branch: o.branch?.id != null ? String(o.branch.id) : o.branchId != null ? String(o.branchId) : "",
|
||||||
|
branch_label: o.branch?.name ? resolveLocalizedName(o.branch.name) : "",
|
||||||
|
status,
|
||||||
|
note: o.notes ?? "",
|
||||||
|
passport_first_name: o.passportName ?? "",
|
||||||
|
passport_last_name: o.passportSurname ?? "",
|
||||||
|
phone: formatFromApiPhone(o.phone),
|
||||||
|
email: o.email ?? "",
|
||||||
|
home_address: o.address ?? "",
|
||||||
|
passport_series: o.senderDatas?.passportSerie ?? o.senderPassportSerie ?? o.paymentReciever?.[0]?.passportSerie ?? "",
|
||||||
|
passport_number: o.senderDatas?.passportNumber ?? o.senderPassportNumber ?? o.paymentReciever?.[0]?.passportNumber ?? "",
|
||||||
|
payer_full_name: o.senderFullName ?? o.senderDatas?.fullName ?? "",
|
||||||
|
payer_account_number: o.senderDepositAccount ?? o.senderDatas?.depositAccount ?? "",
|
||||||
|
receiver_info: o.recieverFullName ?? o.paymentReciever?.[0]?.fullName ?? "",
|
||||||
|
created_by: o.user?.id != null ? String(o.user.id) : o.userId != null ? String(o.userId) : "",
|
||||||
|
created_by_label: o.user?.name ?? "",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async function mapFileDocsToBackend(docs: IntlPaymentDocs): Promise<Record<string, string[]>> {
|
||||||
|
const result: Record<string, string[]> = {};
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
Object.entries(DOC_FILE_TO_KEY).map(async ([field, key]) => {
|
Object.entries(DOC_FILE_TO_KEY).map(async ([field, key]) => {
|
||||||
const value = payload[field as keyof IntlPaymentCreatePayload] as File | string | null | undefined;
|
const value = docs[field as keyof IntlPaymentDocs] as File | string | null | undefined;
|
||||||
if (value instanceof File) {
|
if (value instanceof File) {
|
||||||
const filename = await postFile(value);
|
const filename = await postFile(value);
|
||||||
documents[key] = [filename];
|
result[key] = [filename];
|
||||||
} else if (typeof value === "string" && value) {
|
} else if (typeof value === "string" && value) {
|
||||||
documents[key] = [value];
|
result[key] = [value];
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function mapPayloadToBackend(
|
||||||
|
payload: IntlPaymentCreatePayload | Partial<IntlPaymentCreatePayload>,
|
||||||
|
): Promise<Record<string, unknown>> {
|
||||||
|
const documents = await mapFileDocsToBackend(payload as IntlPaymentDocs);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
address: payload.home_address ?? "",
|
address: payload.home_address ?? "",
|
||||||
|
|||||||
@@ -457,6 +457,7 @@
|
|||||||
"loanPaidOffLetters.fields.loanReason": "Loan reason",
|
"loanPaidOffLetters.fields.loanReason": "Loan reason",
|
||||||
"loanPaidOffLetters.fields.loanFile": "File",
|
"loanPaidOffLetters.fields.loanFile": "File",
|
||||||
"loanPaidOffLetters.fields.region": "Region",
|
"loanPaidOffLetters.fields.region": "Region",
|
||||||
|
"loanPaidOffLetters.fields.provinceName": "Province",
|
||||||
"loanPaidOffLetters.fields.branchId": "Branch ID",
|
"loanPaidOffLetters.fields.branchId": "Branch ID",
|
||||||
"loanPaidOffLetters.fields.userId": "User ID",
|
"loanPaidOffLetters.fields.userId": "User ID",
|
||||||
"loanPaidOffLetters.fields.status": "Status",
|
"loanPaidOffLetters.fields.status": "Status",
|
||||||
|
|||||||
@@ -457,6 +457,7 @@
|
|||||||
"loanPaidOffLetters.fields.loanReason": "Причина кредита",
|
"loanPaidOffLetters.fields.loanReason": "Причина кредита",
|
||||||
"loanPaidOffLetters.fields.loanFile": "Файл",
|
"loanPaidOffLetters.fields.loanFile": "Файл",
|
||||||
"loanPaidOffLetters.fields.region": "Регион",
|
"loanPaidOffLetters.fields.region": "Регион",
|
||||||
|
"loanPaidOffLetters.fields.provinceName": "Область",
|
||||||
"loanPaidOffLetters.fields.branchId": "ID филиала",
|
"loanPaidOffLetters.fields.branchId": "ID филиала",
|
||||||
"loanPaidOffLetters.fields.branchName": "Название филиала",
|
"loanPaidOffLetters.fields.branchName": "Название филиала",
|
||||||
"loanPaidOffLetters.fields.userId": "ID пользователя",
|
"loanPaidOffLetters.fields.userId": "ID пользователя",
|
||||||
|
|||||||
@@ -457,6 +457,7 @@
|
|||||||
"loanPaidOffLetters.fields.loanReason": "Karz sebäbi",
|
"loanPaidOffLetters.fields.loanReason": "Karz sebäbi",
|
||||||
"loanPaidOffLetters.fields.loanFile": "Faýl",
|
"loanPaidOffLetters.fields.loanFile": "Faýl",
|
||||||
"loanPaidOffLetters.fields.region": "Sebit",
|
"loanPaidOffLetters.fields.region": "Sebit",
|
||||||
|
"loanPaidOffLetters.fields.provinceName": "Welaýat",
|
||||||
"loanPaidOffLetters.fields.branchId": "Şahamça ID",
|
"loanPaidOffLetters.fields.branchId": "Şahamça ID",
|
||||||
"loanPaidOffLetters.fields.branchName": "Şahamça ady",
|
"loanPaidOffLetters.fields.branchName": "Şahamça ady",
|
||||||
"loanPaidOffLetters.fields.userId": "Ulanyjy ID",
|
"loanPaidOffLetters.fields.userId": "Ulanyjy ID",
|
||||||
|
|||||||
@@ -20,6 +20,15 @@ import {
|
|||||||
} from "@/components/ui/alert-dialog";
|
} from "@/components/ui/alert-dialog";
|
||||||
import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents";
|
import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents";
|
||||||
import { getStatusLabel, isStatusValue, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
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 ─────────────────────────────────────────────────────────────
|
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -72,7 +81,7 @@ function CardPinViewSkeleton() {
|
|||||||
export default function CardPinViewPage() {
|
export default function CardPinViewPage() {
|
||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { t } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
|
|
||||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||||
|
|
||||||
@@ -153,14 +162,29 @@ export default function CardPinViewPage() {
|
|||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t("cardPin.cardSection", "Kart")}>
|
<BentoCard title={t("cardPin.cardSection", "Kart")}>
|
||||||
<InfoRow label={t("cardPin.field.cardNumber", "Kart belgisi")} value={data.cardNumber} />
|
<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
|
||||||
|
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>
|
||||||
|
|
||||||
<BentoCard title={t("cardPin.locationSection", "Lokasiýa")}>
|
<BentoCard title={t("cardPin.locationSection", "Lokasiýa")}>
|
||||||
<InfoRow label={t("cardPin.field.region", "Sebit")} value={data.region || undefined} />
|
<InfoRow label={t("cardPin.field.region", "Sebit")} value={data.region || "—"} />
|
||||||
<InfoRow label={t("cardPin.field.branchId", "Şahamça ID")} value={data.branchId} />
|
<InfoRow
|
||||||
<InfoRow label={t("cardPin.field.userId", "Ulanyjy ID")} value={data.userId} />
|
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>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
|
|
||||||
|
|||||||
@@ -76,11 +76,19 @@ export default function CardTransactionsPage() {
|
|||||||
size: 100,
|
size: 100,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "userId",
|
id: "user",
|
||||||
accessorKey: "userId",
|
accessorFn: (row) => row.user?.name ?? "",
|
||||||
header: t("cardTransaction.col.userId", "Ulanyjy ID"),
|
header: t("cardTransaction.col.user", "Ulanyjy"),
|
||||||
cell: ({ row }) => <span className="text-sm text-muted-foreground">{row.original.userId}</span>,
|
cell: ({ row }) => {
|
||||||
size: 110,
|
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",
|
id: "createdAt",
|
||||||
|
|||||||
@@ -90,7 +90,12 @@ export default function CardTransactionViewPage() {
|
|||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t("cardTransaction.section.meta", "Belligi")}>
|
<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
|
<InfoRow
|
||||||
label={t("cardTransaction.col.createdAt", "Döredilen wagty")}
|
label={t("cardTransaction.col.createdAt", "Döredilen wagty")}
|
||||||
value={data.createdAt ? new Date(data.createdAt).toLocaleString() : "—"}
|
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 { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||||
import { getStatusLabel, isStatusValue, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
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 ─────────────────────────────────────────────────────────────
|
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -71,7 +80,7 @@ function DetailSkeleton() {
|
|||||||
export default function CardOrderDetailPage() {
|
export default function CardOrderDetailPage() {
|
||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { t } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
|
|
||||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||||
|
|
||||||
@@ -145,14 +154,30 @@ export default function CardOrderDetailPage() {
|
|||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t("cardOrder.section.card", "Kart")}>
|
<BentoCard title={t("cardOrder.section.card", "Kart")}>
|
||||||
<InfoRow label={t("cardOrder.field.cardTypeId", "Kart görnüşi ID")} value={order.cardTypeId} />
|
<InfoRow
|
||||||
<InfoRow label={t("cardOrder.field.cardStateId", "Kart ýagdaýy ID")} value={order.cardStateId} />
|
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>
|
||||||
|
|
||||||
<BentoCard title={t("cardOrder.section.location", "Lokasiýa")}>
|
<BentoCard title={t("cardOrder.section.location", "Lokasiýa")}>
|
||||||
<InfoRow label={t("cardOrder.field.region", "Sebit")} value={order.region} />
|
<InfoRow label={t("cardOrder.field.region", "Sebit")} value={order.region || "—"} />
|
||||||
<InfoRow label={t("cardOrder.field.branchId", "Şahamça ID")} value={order.branchId} />
|
<InfoRow
|
||||||
<InfoRow label={t("cardOrder.field.userId", "Ulanyjy ID")} value={order.userId} />
|
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>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
|
|
||||||
|
|||||||
@@ -191,7 +191,12 @@ export default function IntlPaymentViewPage() {
|
|||||||
{/* ── Row 1: Meta + Ýüztuman + Lokasiýa ───────────────────────────── */}
|
{/* ── Row 1: Meta + Ýüztuman + Lokasiýa ───────────────────────────── */}
|
||||||
<BentoGrid cols={3}>
|
<BentoGrid cols={3}>
|
||||||
<BentoCard title={t("intlPayment.statusSection", "Esasy maglumatlar")}>
|
<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("common.id", "ID")} value={data.id} />
|
||||||
<InfoRow label={t("intlPayment.status", "Status")}>
|
<InfoRow label={t("intlPayment.status", "Status")}>
|
||||||
<PaymentStatusBadge status={data.status} />
|
<PaymentStatusBadge status={data.status} />
|
||||||
@@ -206,7 +211,12 @@ export default function IntlPaymentViewPage() {
|
|||||||
|
|
||||||
<BentoCard title={t("intlPayment.locationSection", "Lokasiýa")}>
|
<BentoCard title={t("intlPayment.locationSection", "Lokasiýa")}>
|
||||||
<InfoRow label={t("intlPayment.province", "Welaýat")} value={data.province_label} />
|
<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>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents";
|
|||||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||||
import { STATUS_BADGE_VARIANTS } from "@/constants";
|
import { STATUS_BADGE_VARIANTS } from "@/constants";
|
||||||
import { buildFileUrl } from "@/features/shared/api/sharedApi";
|
import { buildFileUrl } from "@/features/shared/api/sharedApi";
|
||||||
|
|
||||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||||
|
|
||||||
function formatDate(value: string | null | undefined): string {
|
function formatDate(value: string | null | undefined): string {
|
||||||
@@ -17,7 +16,7 @@ function formatDate(value: string | null | undefined): string {
|
|||||||
return value.slice(0, 10);
|
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 (!name) return "";
|
||||||
if (typeof name === "string") return name;
|
if (typeof name === "string") return name;
|
||||||
return name[lang as keyof LocalizedText] ?? name.tm ?? name.en ?? name.ru ?? "";
|
return name[lang as keyof LocalizedText] ?? name.tm ?? name.en ?? name.ru ?? "";
|
||||||
@@ -145,18 +144,25 @@ export default function LoanPaidOffLettersViewPage() {
|
|||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t("loanPaidOffLetters.sections.additional", "Goşmaça")}>
|
<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
|
<InfoRow
|
||||||
label={t("loanPaidOffLetters.fields.branchName", "Şahamça")}
|
label={t("loanPaidOffLetters.fields.branchName", "Şahamça")}
|
||||||
value={resolveLocalizedName(record.branchName, i18n.language) || (record.branchId != null ? String(record.branchId) : "—")}
|
value={resolveLocalizedName(record.branch?.name, i18n.language) || record.branch?.uniqueCode || "—"}
|
||||||
isLink={Boolean(record.branchId)}
|
isLink={Boolean(record.branch?.id)}
|
||||||
href={record.branchId ? `/settings/location/branches/${record.branchId}` : undefined}
|
href={record.branch?.id ? `/settings/location/branches/${record.branch.id}` : undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t("loanPaidOffLetters.fields.userName", "Ulanyjy ady")}
|
label={t("loanPaidOffLetters.fields.userName", "Ulanyjy ady")}
|
||||||
value={record.userName || (record.userId != null ? String(record.userId) : "—")}
|
value={record.user?.name || "—"}
|
||||||
isLink={Boolean(record.userId)}
|
isLink={Boolean(record.user?.id)}
|
||||||
href={record.userId ? `/all-users/${record.userId}` : undefined}
|
href={record.user?.id ? `/all-users/${record.user.id}` : undefined}
|
||||||
/>
|
/>
|
||||||
<InfoRow label={t("loanPaidOffLetters.fields.notes", "Bellikler")} value={record.notes || "—"} />
|
<InfoRow label={t("loanPaidOffLetters.fields.notes", "Bellikler")} value={record.notes || "—"} />
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|||||||
Reference in new issue
Block a user