fixed some types, add some labels

This commit is contained in:
Jelaletdin12
2026-08-26 23:20:09 +05:00
parent 62b6489abf
commit 1a7dd954e2
23 changed files with 379 additions and 168 deletions

View File

@@ -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;
},
};

View File

@@ -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,
});
}

View File

@@ -1,15 +1,16 @@
import apiClient from "@/lib/api/client";
import type { LocalizedText } from "@/features/branches/api/branchesApi";
// ─── Types ────────────────────────────────────────────────────────────────────
export interface CardPinOrder {
id: number;
uniqueId: string;
userId: number;
cardTypeId: number;
user: { id: number; name: string; username: string; phone: string; email: string } | null;
cardType: { id: number; name: LocalizedText | string } | null;
cardNumber: string;
region: string;
branchId: number;
branch: { id: number; name: LocalizedText | string } | null;
customerName: string;
customerSurname: string;
customerPatronicName: string | null;

View File

@@ -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),
}));
if (initialData?.userId && !opts.some((o) => o.value === String(initialData.userId))) {
opts.unshift({ value: String(initialData.userId), label: String(initialData.userId) });
if (initialData?.user?.id && !opts.some((o) => o.value === String(initialData.user!.id))) {
opts.unshift({ value: String(initialData.user!.id), label: initialData.user!.name || String(initialData.user!.id) });
}
return opts;
}, [clientsQuery.data, initialData]);
@@ -579,9 +579,9 @@ function mapInitial(data: CardPinOrder): Partial<CardPinFormData> {
uniqueId: data.uniqueId ?? "",
status: data.status ?? "",
cardNumber: data.cardNumber ?? "",
cardTypeId: String(data.cardTypeId ?? ""),
cardTypeId: String(data.cardType?.id ?? ""),
region: data.region ?? "",
branchId: String(data.branchId ?? ""),
branchId: String(data.branch?.id ?? ""),
customerName: data.customerName ?? "",
customerSurname: data.customerSurname ?? "",
customerPatronicName: data.customerPatronicName ?? "",
@@ -593,7 +593,7 @@ function mapInitial(data: CardPinOrder): Partial<CardPinFormData> {
passportTwo: data.passportTwo ?? "",
passportThree: data.passportThree ?? "",
passportFour: data.passportFour ?? "",
userId: String(data.userId ?? ""),
userId: String(data.user?.id ?? ""),
notes: data.notes ?? "",
};
}

View File

@@ -4,7 +4,7 @@ import apiClient from "@/lib/api/client";
export interface Card {
id: number;
userId: number;
user: { id: number; name: string; username: string; phone: string; email: string } | null;
number: string;
name: string;
month: string;

View File

@@ -66,8 +66,8 @@ export function CardTransactionForm({ mode, initialData }: CardTransactionFormPr
label: u.name || `${u.firstName || ""} ${u.lastName || ""}`.trim() || u.username || String(u.id),
}));
if (initialData?.userId && !opts.some((o) => o.value === String(initialData.userId))) {
opts.unshift({ value: String(initialData.userId), label: String(initialData.userId) });
if (initialData?.user?.id && !opts.some((o) => o.value === String(initialData.user!.id))) {
opts.unshift({ value: String(initialData.user!.id), label: initialData.user!.name || String(initialData.user!.id) });
}
return opts;
}, [clientsQuery.data, initialData]);
@@ -100,7 +100,7 @@ export function CardTransactionForm({ mode, initialData }: CardTransactionFormPr
type: initialData.type,
month: initialData.month,
year: initialData.year,
userId: String(initialData.userId),
userId: String(initialData.user?.id ?? ""),
}
: DEFAULT_FORM_VALUES,
});

View File

@@ -185,13 +185,16 @@ export interface LoanOrderPayload {
// ─── Backend types ─────────────────────────────────────────────────────────────
type NestedLocalized = { id: number; name: LocalizedText | string };
interface BackendLoanOrder {
id?: number | string;
uniqueId?: string | null;
region?: string | null;
branchId?: number | null;
branch?: NestedLocalized | number | string | null;
branchName?: LocalizedText | string | null;
loanType?: number | string | null;
loanType?: NestedLocalized | number | string | null;
loanTypeName?: LocalizedText | string | null;
userId?: number | 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 ?? "";
}
/** 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 {
if (value === null || value === undefined || value === "") return null;
const n = Number(value);
@@ -289,12 +313,12 @@ function mapBackendToUI(order: BackendLoanOrder): LoanOrder {
return {
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 ?? "",
region: order.region ?? "",
branch: resolveLocalizedName(order.branchName),
branchId: order.branchId ?? undefined,
loanTypeId: order.loanType ?? undefined,
branch: resolveNestedName(order.branch) || resolveLocalizedName(order.branchName),
branchId: resolveNestedId(order.branch) ?? order.branchId ?? undefined,
loanTypeId: resolveNestedId(order.loanType) ?? undefined,
workCityId: order.workProvinceId ?? undefined,
createdById: order.userId ?? undefined,
firstName: order.customerName ?? "",

View File

@@ -9,10 +9,23 @@ export interface LoanPaidOffLetter {
id: number;
uniqueId: string;
region: string;
branchId: number | null;
branchName?: LocalizedText | string | null;
userId: number | null;
userName?: string | null;
regionName: LocalizedText | null;
branch: {
id: number;
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;
customerSurname: string;
customerPatronicName: string;

View File

@@ -351,10 +351,10 @@ export function LoanPaidOffLetterForm({ mode, initialData }: LoanPaidOffLetterFo
label: resolveLocalizedName(b.name, lang) || b.uniqueCode || String(b.id),
}));
if (initialData?.branchId) {
const bId = String(initialData.branchId);
if (initialData?.branch?.id) {
const bId = String(initialData.branch.id);
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 });
}
}
@@ -385,10 +385,10 @@ export function LoanPaidOffLetterForm({ mode, initialData }: LoanPaidOffLetterFo
};
});
if (initialData?.userId) {
const uId = String(initialData.userId);
if (initialData?.user?.id) {
const uId = String(initialData.user.id);
if (!opts.some((o) => o.value === uId)) {
const initialUserName = initialData.userName || uId;
const initialUserName = initialData.user.name || uId;
opts.unshift({ value: uId, label: initialUserName });
}
}

View File

@@ -148,8 +148,8 @@ export function mapInitial(data: LoanPaidOffLetter): LoanPaidOffLetterFormData {
passportSerie: data.passportSerie ?? "",
passportId: data.passportId ?? "",
region: data.region ?? "",
branchId: data.branchId != null ? String(data.branchId) : "",
userId: data.userId != null ? String(data.userId) : "",
branchId: data.branch?.id != null ? String(data.branch.id) : "",
userId: data.user?.id != null ? String(data.user.id) : "",
status: data.status ?? "pending",
notes: data.notes ?? "",
loanContractNumber: data.loanContractNumber ?? "",

View File

@@ -1,14 +1,16 @@
import apiClient from "@/lib/api/client";
import type { LocalizedText } from "@/features/branches/api/branchesApi";
// ─── Card Order ───────────────────────────────────────────────────────────────
export interface CardOrder {
id: number;
uniqueId: string;
cardStateId: number;
cardTypeId: number;
cardState: { id: number; name: LocalizedText | string } | null;
cardType: { id: number; name: LocalizedText | string } | null;
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;
customerSurname: string;
customerPatronicName: string;
@@ -31,7 +33,6 @@ export interface CardOrder {
passportThree: string;
passportFour: string;
notes: string;
userId: number;
paid: boolean;
createdAt: string;
updatedAt: string;

View File

@@ -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),
}));
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),
value: String(initialData.user!.id),
label: initialData.customerName
? `${initialData.customerName} ${initialData.customerSurname || ""}`.trim()
: String(initialData.userId),
: String(initialData.user!.id),
});
}
return opts;
@@ -732,10 +732,10 @@ function mapInitial(data: CardOrder): Partial<OrderNewCardFormData> {
uniqueId: data.uniqueId,
status: data.status,
paid: data.paid,
cardStateId: String(data.cardStateId ?? ""),
cardTypeId: String(data.cardTypeId ?? ""),
cardStateId: String(data.cardState?.id ?? ""),
cardTypeId: String(data.cardType?.id ?? ""),
region: data.region ?? "",
branchId: String(data.branchId ?? ""),
branchId: String(data.branch?.id ?? ""),
customerName: data.customerName,
customerSurname: data.customerSurname,
customerPatronicName: data.customerPatronicName ?? "",
@@ -756,7 +756,7 @@ function mapInitial(data: CardOrder): Partial<OrderNewCardFormData> {
passportAddress: data.passportAddress ?? "",
realAddress: data.realAddress ?? "",
jobLocation: data.jobLocation ?? "",
userId: String(data.userId ?? ""),
userId: String(data.user?.id ?? ""),
notes: data.notes ?? "",
};
}

View File

@@ -4,12 +4,33 @@ import { isStatusValue } from "@/constants";
import type { LocalizedText } from "@/features/branches/api/branchesApi";
import { postFile, buildFileUrl } from "@/features/shared/api/sharedApi";
// ─── Types (UI-facing) ────────────────────────────────────────────────────────
// ─── Shared types ─────────────────────────────────────────────────────────────
export type IntlPaymentStatus = "pending" | "approved" | "rejected";
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;
client_id: string;
client_label: string;
@@ -39,25 +60,6 @@ export interface IntlPaymentItem {
// Töleg kabul edijiniň maglumatlary
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_label: string;
}
@@ -85,7 +87,7 @@ export interface IntlPaymentListResponse {
};
}
export type IntlPaymentCreatePayload = {
export type IntlPaymentCreatePayload = IntlPaymentDocs & {
client_id: string;
status: string;
note: string;
@@ -105,25 +107,6 @@ export type IntlPaymentCreatePayload = {
payer_account_number: 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>;
@@ -140,7 +123,6 @@ interface BackendIntlPayment {
email?: string | null;
region?: string | null;
regionName?: LocalizedText | string | null;
branchId?: number | null;
branch?: {
id: number;
uniqueCode: string;
@@ -149,8 +131,9 @@ interface BackendIntlPayment {
provinceId: number;
provinceName?: LocalizedText;
} | null;
userId?: number | null;
branchId?: number | null;
user?: { id: number; name: string; username: string; phone: string; email: string } | null;
userId?: number | null;
address?: string | null;
senderDatas?: { 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]);
}
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
const DOC_FILE_TO_KEY: Record<string, string> = {
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",
};
async function mapPayloadToBackend(
payload: IntlPaymentCreatePayload | Partial<IntlPaymentCreatePayload>,
): Promise<Record<string, unknown>> {
const documents: Record<string, string[]> = {};
function mapDocs(d: Record<string, string[]>): IntlPaymentDocs {
return {
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,
};
}
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(
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) {
const filename = await postFile(value);
documents[key] = [filename];
result[key] = [filename];
} 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 {
address: payload.home_address ?? "",