fixed some missed data, added role based function(user)
This commit is contained in:
1 parent
5884ec831c
commit
9ad86634dd
31 files changed
+1276
-977
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
import { lazy, Suspense } from "react";
|
import { lazy, Suspense } from "react";
|
||||||
import { createBrowserRouter, Navigate, Outlet } from "react-router-dom";
|
import { createBrowserRouter, Navigate, Outlet } from "react-router-dom";
|
||||||
import type { RouteObject } from "react-router-dom";
|
import type { RouteObject } from "react-router-dom";
|
||||||
import { useAuthStore } from "../store/authStore";
|
import { useAuthStore, getHomePath } from "../store/authStore";
|
||||||
import { Spinner } from "@/components/ui/spinner";
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
import { DashboardLayout } from "@/layouts/DashboardLayout";
|
import { DashboardLayout } from "@/layouts/DashboardLayout";
|
||||||
import { AuthLayout } from "@/layouts/AuthLayout";
|
import { AuthLayout } from "@/layouts/AuthLayout";
|
||||||
@@ -123,7 +123,14 @@ function AuthGuard() {
|
|||||||
|
|
||||||
function PublicGuard() {
|
function PublicGuard() {
|
||||||
const isAuthenticated = useAuthStore((s) => s.isAuthenticated);
|
const isAuthenticated = useAuthStore((s) => s.isAuthenticated);
|
||||||
if (isAuthenticated) return <Navigate to="/dashboard" replace />;
|
if (isAuthenticated) return <Navigate to={getHomePath()} replace />;
|
||||||
|
return <Outlet />;
|
||||||
|
}
|
||||||
|
|
||||||
|
function DashboardGuard() {
|
||||||
|
const user = useAuthStore((s) => s.user);
|
||||||
|
const isAdmin = user?.role?.code === "admin";
|
||||||
|
if (!isAdmin) return <Navigate to="/loan-orders" replace />;
|
||||||
return <Outlet />;
|
return <Outlet />;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,12 +199,17 @@ const routes: AppRoute[] = [
|
|||||||
element: <DashboardLayout />,
|
element: <DashboardLayout />,
|
||||||
errorElement: <PageErrorFallback />,
|
errorElement: <PageErrorFallback />,
|
||||||
children: [
|
children: [
|
||||||
{ path: "/", element: <Navigate to="/dashboard" replace /> },
|
{ path: "/", element: <Navigate to={getHomePath()} replace /> },
|
||||||
|
|
||||||
{
|
{
|
||||||
path: "/dashboard",
|
element: <DashboardGuard />,
|
||||||
handle: { title: (t) => t("nav.dashboard", "Baş sahypa") },
|
children: [
|
||||||
element: page(DashboardPage),
|
{
|
||||||
|
path: "/dashboard",
|
||||||
|
handle: { title: (t) => t("nav.dashboard", "Baş sahypa") },
|
||||||
|
element: page(DashboardPage),
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
// ── KARZ SARGYTLARY ───────────────────────────────────────────────
|
// ── KARZ SARGYTLARY ───────────────────────────────────────────────
|
||||||
|
|||||||
@@ -36,6 +36,13 @@ export interface AuthUser {
|
|||||||
createdAt?: string;
|
createdAt?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns the role-appropriate landing page for the current user. */
|
||||||
|
export function getHomePath(): string {
|
||||||
|
const user = useAuthStore.getState().user;
|
||||||
|
const isAdmin = user?.role?.code === "admin";
|
||||||
|
return isAdmin ? "/dashboard" : "/loan-orders";
|
||||||
|
}
|
||||||
|
|
||||||
interface AuthState {
|
interface AuthState {
|
||||||
token: string | null;
|
token: string | null;
|
||||||
refreshTokenValue: string | null;
|
refreshTokenValue: string | null;
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import type { SelectOption } from "@/components/formInput";
|
||||||
|
|
||||||
|
export const EDUCATION_OPTIONS: SelectOption[] = [
|
||||||
|
{ value: "high", label: "Ýokary bilim" },
|
||||||
|
{ value: "unfinished_high", label: "Gutarylmadyk ýokary bilim" },
|
||||||
|
{ value: "masters", label: "Magistr" },
|
||||||
|
{ value: "phd", label: "Ylymlaryň doktory" },
|
||||||
|
{ value: "middle", label: "Orta mekdep" },
|
||||||
|
{ value: "school", label: "Orta bilim" },
|
||||||
|
{ value: "school_dropout", label: "Gutarylmadyk orta bilim" },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const MARRIAGE_OPTIONS: SelectOption[] = [
|
||||||
|
{ value: "MARRIED", label: "Öýlenen / Durmuşa çykan" },
|
||||||
|
{ value: "SINGLE", label: "Öýlenmedik / Durmuşa çykmadyk" },
|
||||||
|
{ value: "DIVORCED", label: "Aýrylşan" },
|
||||||
|
{ value: "WIDOW", label: "Adamsy ýa-da aýaly aradan çykan" },
|
||||||
|
{ value: "LEGAL", label: "Raýat nika" },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const MONTH_OPTIONS: SelectOption[] = Array.from({ length: 12 }, (_, i) => {
|
||||||
|
const val = String(i + 1).padStart(2, "0");
|
||||||
|
return { value: val, label: val };
|
||||||
|
});
|
||||||
|
|
||||||
|
export const YEAR_OPTIONS: SelectOption[] = Array.from({ length: 15 }, (_, i) => {
|
||||||
|
const year = String(new Date().getFullYear() + i);
|
||||||
|
return { value: year, label: year };
|
||||||
|
});
|
||||||
|
|
||||||
|
/** Longer expiry range used by card balance / requisites / transaction forms. */
|
||||||
|
export const CARD_YEAR_OPTIONS: SelectOption[] = Array.from({ length: 20 }, (_, i) => {
|
||||||
|
const year = String(new Date().getFullYear() + i);
|
||||||
|
return { value: year, label: year };
|
||||||
|
});
|
||||||
@@ -1,2 +1,4 @@
|
|||||||
|
export * from "./formOptions";
|
||||||
export * from "./passportSeries";
|
export * from "./passportSeries";
|
||||||
|
export * from "./regionCodes";
|
||||||
export * from "./statusOptions";
|
export * from "./statusOptions";
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import type { TFunction } from "i18next";
|
||||||
|
import type { SelectOption } from "@/components/formInput";
|
||||||
|
|
||||||
|
export const REGION_CODES = ["AG", "AH", "BN", "DZ", "LB", "MR"] as const;
|
||||||
|
|
||||||
|
export type RegionCode = (typeof REGION_CODES)[number];
|
||||||
|
|
||||||
|
/** Distinct region set used by loan paid-off letters. */
|
||||||
|
export const LOAN_PAID_OFF_REGION_CODES = ["AG", "AH", "BA", "DA", "LE", "MA"] as const;
|
||||||
|
|
||||||
|
export type LoanPaidOffRegionCode = (typeof LOAN_PAID_OFF_REGION_CODES)[number];
|
||||||
|
|
||||||
|
export const REGION_LABELS: Record<string, string> = {
|
||||||
|
AG: "Aşgabat",
|
||||||
|
AH: "Ahal",
|
||||||
|
BN: "Balkan",
|
||||||
|
DZ: "Daşoguz",
|
||||||
|
LB: "Lebap",
|
||||||
|
MR: "Mary",
|
||||||
|
};
|
||||||
|
|
||||||
|
type TranslateFn = TFunction | ((key: string, fallback?: string) => string);
|
||||||
|
|
||||||
|
export function getRegionOptions(
|
||||||
|
t: TranslateFn,
|
||||||
|
prefix = "loanOrders",
|
||||||
|
codes: readonly string[] = REGION_CODES,
|
||||||
|
labels?: Record<string, string>,
|
||||||
|
): SelectOption[] {
|
||||||
|
return codes.map((code) => ({
|
||||||
|
value: code,
|
||||||
|
label: t(`${prefix}.regions.${code}`, labels?.[code] ?? code),
|
||||||
|
}));
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { useAuthStore } from "@/app/store/authStore";
|
import { useAuthStore, getHomePath } from "@/app/store/authStore";
|
||||||
import { extractErrorMessage } from "@/lib/api/client";
|
import { extractErrorMessage } from "@/lib/api/client";
|
||||||
import { loginApi, getProfileApi, updateProfileApi, type LoginRequest, type UpdateProfileRequest } from "../api/authApi";
|
import { loginApi, getProfileApi, updateProfileApi, type LoginRequest, type UpdateProfileRequest } from "../api/authApi";
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ export function useLogin() {
|
|||||||
setUser(profile);
|
setUser(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
navigate("/dashboard", { replace: true });
|
navigate(getHomePath(), { replace: true });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { useCreateCardBalance, useUpdateCardBalance } from "@/features/cardBalan
|
|||||||
import { cardBalanceFormSchema, DEFAULT_FORM_VALUES, mapInitial, buildPayload } from "@/features/cardBalance/schemas/cardBalance.schema";
|
import { cardBalanceFormSchema, DEFAULT_FORM_VALUES, mapInitial, buildPayload } from "@/features/cardBalance/schemas/cardBalance.schema";
|
||||||
import type { CardBalanceFormData } from "@/features/cardBalance/schemas/cardBalance.schema";
|
import type { CardBalanceFormData } from "@/features/cardBalance/schemas/cardBalance.schema";
|
||||||
import { useInfiniteUsers } from "@/features/allUsers/hooks/useAllUsers";
|
import { useInfiniteUsers } from "@/features/allUsers/hooks/useAllUsers";
|
||||||
|
import { MONTH_OPTIONS, CARD_YEAR_OPTIONS } from "@/constants";
|
||||||
|
|
||||||
interface CardBalanceFormProps {
|
interface CardBalanceFormProps {
|
||||||
mode: "create" | "edit";
|
mode: "create" | "edit";
|
||||||
@@ -42,16 +43,6 @@ const CURRENCY_OPTIONS: SelectOption[] = [
|
|||||||
{ value: "EUR", label: "EUR" },
|
{ value: "EUR", label: "EUR" },
|
||||||
];
|
];
|
||||||
|
|
||||||
const MONTH_OPTIONS: SelectOption[] = Array.from({ length: 12 }, (_, i) => {
|
|
||||||
const val = String(i + 1).padStart(2, "0");
|
|
||||||
return { value: val, label: val };
|
|
||||||
});
|
|
||||||
|
|
||||||
const YEAR_OPTIONS: SelectOption[] = Array.from({ length: 20 }, (_, i) => {
|
|
||||||
const year = String(new Date().getFullYear() + i);
|
|
||||||
return { value: year, label: year };
|
|
||||||
});
|
|
||||||
|
|
||||||
// ─── Component ────────────────────────────────────────────────────────────────
|
// ─── Component ────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export function CardBalanceForm({ mode, initialData }: CardBalanceFormProps) {
|
export function CardBalanceForm({ mode, initialData }: CardBalanceFormProps) {
|
||||||
@@ -182,7 +173,7 @@ export function CardBalanceForm({ mode, initialData }: CardBalanceFormProps) {
|
|||||||
label={t("Card expiry year", "Kart Möhleti (ýyl)")}
|
label={t("Card expiry year", "Kart Möhleti (ýyl)")}
|
||||||
value={form.expiryYear}
|
value={form.expiryYear}
|
||||||
onChange={setString("expiryYear")}
|
onChange={setString("expiryYear")}
|
||||||
options={YEAR_OPTIONS}
|
options={CARD_YEAR_OPTIONS}
|
||||||
placeholder={t("Select", "Saýlamak üçin basyň")}
|
placeholder={t("Select", "Saýlamak üçin basyň")}
|
||||||
error={errMsg(errors.expiryYear)}
|
error={errMsg(errors.expiryYear)}
|
||||||
required
|
required
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import { useInfiniteCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
|
|||||||
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
|
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
|
||||||
import { useInfiniteClients } from "@/features/clients/hooks/useClients";
|
import { useInfiniteClients } from "@/features/clients/hooks/useClients";
|
||||||
import { resolveLocalizedName } from "@/features/loanOrders/api/loanOrdersApi";
|
import { resolveLocalizedName } from "@/features/loanOrders/api/loanOrdersApi";
|
||||||
|
import { getRegionOptions, MONTH_OPTIONS, CARD_YEAR_OPTIONS } from "@/constants";
|
||||||
|
|
||||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -48,15 +49,6 @@ const STATUS_OPTIONS: SelectOption[] = [
|
|||||||
{ value: "rejected", label: "Ret edilen" },
|
{ value: "rejected", label: "Ret edilen" },
|
||||||
];
|
];
|
||||||
|
|
||||||
const REGION_CODES = ["AG", "AH", "BN", "DZ", "LB", "MR"] as const;
|
|
||||||
|
|
||||||
function getRegionOptions(t: TFunction): SelectOption[] {
|
|
||||||
return REGION_CODES.map((code) => ({
|
|
||||||
value: code,
|
|
||||||
label: t(`cardRequisites.regions.${code}`, code),
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
const PASSPORT_SERIES_OPTIONS = [
|
const PASSPORT_SERIES_OPTIONS = [
|
||||||
{ value: "I-MR", label: "I-MR" },
|
{ value: "I-MR", label: "I-MR" },
|
||||||
{ value: "II-MR", label: "II-MR" },
|
{ value: "II-MR", label: "II-MR" },
|
||||||
@@ -67,16 +59,6 @@ const PASSPORT_SERIES_OPTIONS = [
|
|||||||
{ value: "B", label: "B" },
|
{ value: "B", label: "B" },
|
||||||
];
|
];
|
||||||
|
|
||||||
const MONTH_OPTIONS: SelectOption[] = Array.from({ length: 12 }, (_, i) => {
|
|
||||||
const val = String(i + 1).padStart(2, "0");
|
|
||||||
return { value: val, label: val };
|
|
||||||
});
|
|
||||||
|
|
||||||
const YEAR_OPTIONS: SelectOption[] = Array.from({ length: 20 }, (_, i) => {
|
|
||||||
const year = String(new Date().getFullYear() + i);
|
|
||||||
return { value: year, label: year };
|
|
||||||
});
|
|
||||||
|
|
||||||
function mapInitial(data: CardRequisite): CardRequisiteFormData {
|
function mapInitial(data: CardRequisite): CardRequisiteFormData {
|
||||||
return {
|
return {
|
||||||
status: data.status ?? "pending",
|
status: data.status ?? "pending",
|
||||||
@@ -166,7 +148,7 @@ function StepCard({ form, errors, set, t, initialData }: StepContentProps) {
|
|||||||
const branchQuery = useInfiniteBranches(branchSearch);
|
const branchQuery = useInfiniteBranches(branchSearch);
|
||||||
const clientQuery = useInfiniteClients(clientSearch);
|
const clientQuery = useInfiniteClients(clientSearch);
|
||||||
|
|
||||||
const regionOptions = useMemo(() => getRegionOptions(t), [t]);
|
const regionOptions = useMemo(() => getRegionOptions(t, "cardRequisites"), [t]);
|
||||||
|
|
||||||
const cardTypeOptions: InfiniteSelectOption[] = useMemo(() => {
|
const cardTypeOptions: InfiniteSelectOption[] = useMemo(() => {
|
||||||
const opts: InfiniteSelectOption[] = (cardTypeQuery.data?.pages ?? [])
|
const opts: InfiniteSelectOption[] = (cardTypeQuery.data?.pages ?? [])
|
||||||
@@ -282,7 +264,7 @@ function StepCard({ form, errors, set, t, initialData }: StepContentProps) {
|
|||||||
required
|
required
|
||||||
value={form.cardYear}
|
value={form.cardYear}
|
||||||
onChange={(v) => set("cardYear", v)}
|
onChange={(v) => set("cardYear", v)}
|
||||||
options={YEAR_OPTIONS}
|
options={CARD_YEAR_OPTIONS}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
error={errors.cardYear}
|
error={errors.cardYear}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { useCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
|
|||||||
import type { LocalizedTitle } from "@/features/cardTypes/api/cardTypesApi";
|
import type { LocalizedTitle } from "@/features/cardTypes/api/cardTypesApi";
|
||||||
import { cardTransactionFormSchema, DEFAULT_FORM_VALUES, buildPayload } from "../schemas/cardTransaction.schema";
|
import { cardTransactionFormSchema, DEFAULT_FORM_VALUES, buildPayload } from "../schemas/cardTransaction.schema";
|
||||||
import type { CardTransactionFormData } from "../schemas/cardTransaction.schema";
|
import type { CardTransactionFormData } from "../schemas/cardTransaction.schema";
|
||||||
|
import { MONTH_OPTIONS, CARD_YEAR_OPTIONS } from "@/constants";
|
||||||
|
|
||||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -21,18 +22,6 @@ interface CardTransactionFormProps {
|
|||||||
initialData?: Card;
|
initialData?: Card;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Constants ────────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
const MONTH_OPTIONS = Array.from({ length: 12 }, (_, i) => {
|
|
||||||
const val = String(i + 1).padStart(2, "0");
|
|
||||||
return { value: val, label: val };
|
|
||||||
});
|
|
||||||
|
|
||||||
const YEAR_OPTIONS = Array.from({ length: 20 }, (_, i) => {
|
|
||||||
const year = String(new Date().getFullYear() + i);
|
|
||||||
return { value: year, label: year };
|
|
||||||
});
|
|
||||||
|
|
||||||
// ─── Form errors helper ───────────────────────────────────────────────────────
|
// ─── Form errors helper ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
type FlatErrors = Partial<Record<keyof CardTransactionFormData, string>>;
|
type FlatErrors = Partial<Record<keyof CardTransactionFormData, string>>;
|
||||||
@@ -224,7 +213,7 @@ export function CardTransactionForm({ mode, initialData }: CardTransactionFormPr
|
|||||||
label={t("Card expiry year", "Kart möhleti (ýyl)")}
|
label={t("Card expiry year", "Kart möhleti (ýyl)")}
|
||||||
value={form.year}
|
value={form.year}
|
||||||
onChange={setField("year")}
|
onChange={setField("year")}
|
||||||
options={YEAR_OPTIONS}
|
options={CARD_YEAR_OPTIONS}
|
||||||
placeholder={t("Select to choose", "Saýlamak üçin basyň")}
|
placeholder={t("Select to choose", "Saýlamak üçin basyň")}
|
||||||
error={errMsg(errors.year)}
|
error={errMsg(errors.year)}
|
||||||
required
|
required
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export async function createLoanOrderMobile(payload: LoanOrderPayload): Promise<
|
|||||||
// ─── Mobile-specific List API ──────────────────────────────────────────────────
|
// ─── Mobile-specific List API ──────────────────────────────────────────────────
|
||||||
|
|
||||||
export async function fetchLoanOrderMobiles(params: LoanOrdersParams = {}, signal?: AbortSignal): Promise<LoanOrdersResponse> {
|
export async function fetchLoanOrderMobiles(params: LoanOrdersParams = {}, signal?: AbortSignal): Promise<LoanOrdersResponse> {
|
||||||
const { page, perPage, limit, search, region, status, branch, branch_id, createdById, userId, user_id, archived } = params;
|
const { page, perPage, limit, search, region, status, branch, branch_id, createdById, userId, user_id } = params;
|
||||||
const branchId = branch || branch_id;
|
const branchId = branch || branch_id;
|
||||||
const uid = createdById || userId || user_id;
|
const uid = createdById || userId || user_id;
|
||||||
|
|
||||||
@@ -61,7 +61,6 @@ export async function fetchLoanOrderMobiles(params: LoanOrdersParams = {}, signa
|
|||||||
status: status || undefined,
|
status: status || undefined,
|
||||||
branch_id: branchId || undefined,
|
branch_id: branchId || undefined,
|
||||||
user_id: uid || undefined,
|
user_id: uid || undefined,
|
||||||
archived: archived || undefined,
|
|
||||||
},
|
},
|
||||||
signal,
|
signal,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -29,48 +29,17 @@ import { useInfiniteLoanTypes } from "@/features/loanTypes/hooks/useLoanTypes";
|
|||||||
import { useInfiniteClients } from "@/features/clients/hooks/useClients";
|
import { useInfiniteClients } from "@/features/clients/hooks/useClients";
|
||||||
import { useGetRequiredDocuments } from "@/features/requiredDocuments/hooks/useRequiredDocuments";
|
import { useGetRequiredDocuments } from "@/features/requiredDocuments/hooks/useRequiredDocuments";
|
||||||
|
|
||||||
import { PASSPORT_SERIES_OPTIONS, getStatusOptions } from "@/constants";
|
import {
|
||||||
|
PASSPORT_SERIES_OPTIONS,
|
||||||
|
getStatusOptions,
|
||||||
|
getRegionOptions,
|
||||||
|
EDUCATION_OPTIONS,
|
||||||
|
MARRIAGE_OPTIONS,
|
||||||
|
MONTH_OPTIONS,
|
||||||
|
YEAR_OPTIONS,
|
||||||
|
} from "@/constants";
|
||||||
import { formatFromApiDate, formatFromApiPhone } from "@/lib/utils";
|
import { formatFromApiDate, formatFromApiPhone } from "@/lib/utils";
|
||||||
|
|
||||||
// ─── Static options ───────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
const REGION_CODES = ["AG", "AH", "BN", "DZ", "LB", "MR"] as const;
|
|
||||||
|
|
||||||
function getRegionOptions(t: TFunction): SelectOption[] {
|
|
||||||
return REGION_CODES.map((code) => ({
|
|
||||||
value: code,
|
|
||||||
label: t(`loanOrders.regions.${code}`, code),
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
const EDUCATION_OPTIONS: SelectOption[] = [
|
|
||||||
{ value: "high", label: "Ýokary bilim" },
|
|
||||||
{ value: "unfinished_high", label: "Gutarylmadyk ýokary bilim" },
|
|
||||||
{ value: "masters", label: "Magistr" },
|
|
||||||
{ value: "phd", label: "Ylymlaryň doktory" },
|
|
||||||
{ value: "middle", label: "Orta mekdep" },
|
|
||||||
{ value: "school", label: "Orta bilim" },
|
|
||||||
{ value: "school_dropout", label: "Gutarylmadyk orta bilim" },
|
|
||||||
];
|
|
||||||
|
|
||||||
const MARRIAGE_OPTIONS: SelectOption[] = [
|
|
||||||
{ value: "MARRIED", label: "Öýlenen / Durmuşa çykan" },
|
|
||||||
{ value: "SINGLE", label: "Öýlenmedik / Durmuşa çykmadyk" },
|
|
||||||
{ value: "DIVORCED", label: "Aýrylşan" },
|
|
||||||
{ value: "WIDOW", label: "Adamsy ýa-da aýaly aradan çykan" },
|
|
||||||
{ value: "LEGAL", label: "Raýat nika" },
|
|
||||||
];
|
|
||||||
|
|
||||||
const MONTH_OPTIONS: SelectOption[] = Array.from({ length: 12 }, (_, i) => ({
|
|
||||||
value: String(i + 1).padStart(2, "0"),
|
|
||||||
label: String(i + 1).padStart(2, "0"),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const YEAR_OPTIONS: SelectOption[] = Array.from({ length: 15 }, (_, i) => ({
|
|
||||||
value: String(new Date().getFullYear() + i),
|
|
||||||
label: String(new Date().getFullYear() + i),
|
|
||||||
}));
|
|
||||||
|
|
||||||
// ─── Form errors helper ──────────────────────────────────────────────────────
|
// ─── Form errors helper ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
type FlatErrors = Partial<Record<keyof LoanOrderMobileFormData, string>>;
|
type FlatErrors = Partial<Record<keyof LoanOrderMobileFormData, string>>;
|
||||||
@@ -222,8 +191,8 @@ function StepStatus({ form, errors, set, t }: StepContentProps) {
|
|||||||
<FormInput
|
<FormInput
|
||||||
type="textarea"
|
type="textarea"
|
||||||
label={t("Note") || "Bellik"}
|
label={t("Note") || "Bellik"}
|
||||||
value={form.note}
|
value={form.notes}
|
||||||
onChange={(v) => set("note", v)}
|
onChange={(v) => set("notes", v)}
|
||||||
placeholder={t("loanOrderForm.placeholders.note") || "Bellik..."}
|
placeholder={t("loanOrderForm.placeholders.note") || "Bellik..."}
|
||||||
rows={3}
|
rows={3}
|
||||||
/>
|
/>
|
||||||
@@ -312,7 +281,7 @@ function StepLocation({ form, errors, set, t, initialData }: StepContentProps &
|
|||||||
value={form.region}
|
value={form.region}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
set("region", v);
|
set("region", v);
|
||||||
set("branch", "");
|
set("branchId", "");
|
||||||
}}
|
}}
|
||||||
options={regionOptions}
|
options={regionOptions}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
@@ -324,12 +293,12 @@ function StepLocation({ form, errors, set, t, initialData }: StepContentProps &
|
|||||||
<InfiniteSelect
|
<InfiniteSelect
|
||||||
label={t("Branch") || "Şahamça"}
|
label={t("Branch") || "Şahamça"}
|
||||||
required
|
required
|
||||||
value={form.branch}
|
value={form.branchId}
|
||||||
onChange={(v) => set("branch", v)}
|
onChange={(v) => set("branchId", v)}
|
||||||
options={branchOptions}
|
options={branchOptions}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
disabled={!form.region}
|
disabled={!form.region}
|
||||||
error={errors.branch}
|
error={errors.branchId}
|
||||||
loading={branchQuery.isLoading}
|
loading={branchQuery.isLoading}
|
||||||
isLoadingMore={branchQuery.isFetchingNextPage}
|
isLoadingMore={branchQuery.isFetchingNextPage}
|
||||||
hasNextPage={!!branchQuery.hasNextPage}
|
hasNextPage={!!branchQuery.hasNextPage}
|
||||||
@@ -398,25 +367,25 @@ function StepPersonal({ form, errors, set, t, initialData }: StepContentProps &
|
|||||||
type="text"
|
type="text"
|
||||||
label={t("Name") || "Ady"}
|
label={t("Name") || "Ady"}
|
||||||
required
|
required
|
||||||
value={form.firstName}
|
value={form.customerName}
|
||||||
onChange={(v) => set("firstName", v)}
|
onChange={(v) => set("customerName", v)}
|
||||||
placeholder={t("Name") || "Ady"}
|
placeholder={t("Name") || "Ady"}
|
||||||
error={errors.firstName}
|
error={errors.customerName}
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t("Surname") || "Familiýasy"}
|
label={t("Surname") || "Familiýasy"}
|
||||||
required
|
required
|
||||||
value={form.lastName}
|
value={form.customerSurname}
|
||||||
onChange={(v) => set("lastName", v)}
|
onChange={(v) => set("customerSurname", v)}
|
||||||
placeholder={t("Surname") || "Familiýasy"}
|
placeholder={t("Surname") || "Familiýasy"}
|
||||||
error={errors.lastName}
|
error={errors.customerSurname}
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t("Patronic name") || "Atasynyň ady"}
|
label={t("Patronic name") || "Atasynyň ady"}
|
||||||
value={form.patronicName}
|
value={form.customerPatronicName}
|
||||||
onChange={(v) => set("patronicName", v)}
|
onChange={(v) => set("customerPatronicName", v)}
|
||||||
placeholder={t("Patronic name") || "Atasynyň ady"}
|
placeholder={t("Patronic name") || "Atasynyň ady"}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -450,9 +419,9 @@ function StepPersonal({ form, errors, set, t, initialData }: StepContentProps &
|
|||||||
type="date"
|
type="date"
|
||||||
label={t("Date of birth") || "Doglan güni"}
|
label={t("Date of birth") || "Doglan güni"}
|
||||||
required
|
required
|
||||||
value={form.dateOfBirth}
|
value={form.bornAt}
|
||||||
onChange={(v) => set("dateOfBirth", v)}
|
onChange={(v) => set("bornAt", v)}
|
||||||
error={errors.dateOfBirth}
|
error={errors.bornAt}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
@@ -464,16 +433,16 @@ function StepPersonal({ form, errors, set, t, initialData }: StepContentProps &
|
|||||||
type="text"
|
type="text"
|
||||||
label={t("Residence (passport)") || "Ýazgy edilen salgyňyz"}
|
label={t("Residence (passport)") || "Ýazgy edilen salgyňyz"}
|
||||||
required
|
required
|
||||||
value={form.residence}
|
value={form.passportAddress}
|
||||||
onChange={(v) => set("residence", v)}
|
onChange={(v) => set("passportAddress", v)}
|
||||||
placeholder={t("loanOrderForm.placeholders.residence") || "Ýazgy edilen salgy"}
|
placeholder={t("loanOrderForm.placeholders.residence") || "Ýazgy edilen salgy"}
|
||||||
error={errors.residence}
|
error={errors.passportAddress}
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t("Current Residence") || "Häzirki ýaşaýyş ýeri"}
|
label={t("Current Residence") || "Häzirki ýaşaýyş ýeri"}
|
||||||
value={form.currentResidence}
|
value={form.realAddress}
|
||||||
onChange={(v) => set("currentResidence", v)}
|
onChange={(v) => set("realAddress", v)}
|
||||||
placeholder={t("loanOrderForm.placeholders.currentResidence") || "Häzirki ýaşaýyş ýeri"}
|
placeholder={t("loanOrderForm.placeholders.currentResidence") || "Häzirki ýaşaýyş ýeri"}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
@@ -482,8 +451,8 @@ function StepPersonal({ form, errors, set, t, initialData }: StepContentProps &
|
|||||||
<FormInput
|
<FormInput
|
||||||
type="select"
|
type="select"
|
||||||
label={t("Loan history") || "Karz taryhy"}
|
label={t("Loan history") || "Karz taryhy"}
|
||||||
value={form.loanHistory}
|
value={form.loanOrderRequiredDocId}
|
||||||
onChange={(v) => set("loanHistory", v)}
|
onChange={(v) => set("loanOrderRequiredDocId", v)}
|
||||||
options={loanHistoryOptions}
|
options={loanHistoryOptions}
|
||||||
placeholder={t("loanOrderForm.placeholders.select") || "Saýlaň"}
|
placeholder={t("loanOrderForm.placeholders.select") || "Saýlaň"}
|
||||||
/>
|
/>
|
||||||
@@ -522,21 +491,21 @@ function StepCard({ form, errors, set, t }: StepContentProps) {
|
|||||||
type="searchable-select"
|
type="searchable-select"
|
||||||
label={t("loanOrderForm.labels.cardExpMonth") || "Aý"}
|
label={t("loanOrderForm.labels.cardExpMonth") || "Aý"}
|
||||||
required
|
required
|
||||||
value={form.cardExpMonth}
|
value={form.cardMonth}
|
||||||
onChange={(v) => set("cardExpMonth", v)}
|
onChange={(v) => set("cardMonth", v)}
|
||||||
options={MONTH_OPTIONS}
|
options={MONTH_OPTIONS}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
error={errors.cardExpMonth}
|
error={errors.cardMonth}
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="searchable-select"
|
type="searchable-select"
|
||||||
label={t("loanOrderForm.labels.cardExpYear") || "Ýyl"}
|
label={t("loanOrderForm.labels.cardExpYear") || "Ýyl"}
|
||||||
required
|
required
|
||||||
value={form.cardExpYear}
|
value={form.cardYear}
|
||||||
onChange={(v) => set("cardExpYear", v)}
|
onChange={(v) => set("cardYear", v)}
|
||||||
options={YEAR_OPTIONS}
|
options={YEAR_OPTIONS}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
error={errors.cardExpYear}
|
error={errors.cardYear}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
@@ -564,10 +533,10 @@ function StepPassport({ form, errors, set, t, mode }: StepContentProps & { mode:
|
|||||||
type="text"
|
type="text"
|
||||||
label={t("Passport id") || "Pasport belgisi"}
|
label={t("Passport id") || "Pasport belgisi"}
|
||||||
required
|
required
|
||||||
value={form.passportNumber}
|
value={form.passportId}
|
||||||
onChange={(v) => set("passportNumber", v)}
|
onChange={(v) => set("passportId", v)}
|
||||||
placeholder={t("Passport id") || "Pasport belgisi"}
|
placeholder={t("Passport id") || "Pasport belgisi"}
|
||||||
error={errors.passportNumber}
|
error={errors.passportId}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
<BentoCard>
|
<BentoCard>
|
||||||
@@ -575,9 +544,9 @@ function StepPassport({ form, errors, set, t, mode }: StepContentProps & { mode:
|
|||||||
type="date"
|
type="date"
|
||||||
label={t("Passport date of issue") || "Pasport berlen senesi"}
|
label={t("Passport date of issue") || "Pasport berlen senesi"}
|
||||||
required
|
required
|
||||||
value={form.passportDateOfIssue}
|
value={form.passportGivenAt}
|
||||||
onChange={(v) => set("passportDateOfIssue", v)}
|
onChange={(v) => set("passportGivenAt", v)}
|
||||||
error={errors.passportDateOfIssue}
|
error={errors.passportGivenAt}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
@@ -692,10 +661,10 @@ function StepContact({ form, errors, set, t }: StepContentProps) {
|
|||||||
<FormInput
|
<FormInput
|
||||||
type="phone"
|
type="phone"
|
||||||
label={t("Home phone") || "Öý telefony"}
|
label={t("Home phone") || "Öý telefony"}
|
||||||
value={form.homePhone}
|
value={form.phoneHome}
|
||||||
onChange={(v) => set("homePhone", v)}
|
onChange={(v) => set("phoneHome", v)}
|
||||||
placeholder={t("loanOrderForm.placeholders.phone") || "61 097 651"}
|
placeholder={t("loanOrderForm.placeholders.phone") || "61 097 651"}
|
||||||
error={errors.homePhone}
|
error={errors.phoneHome}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
@@ -735,10 +704,10 @@ function StepJob({ form, errors, set, t, initialData }: StepContentProps & { ini
|
|||||||
<FormInput
|
<FormInput
|
||||||
type="phone"
|
type="phone"
|
||||||
label={t("HR department work number") || "Işgärler bölüminiň iş belgisi"}
|
label={t("HR department work number") || "Işgärler bölüminiň iş belgisi"}
|
||||||
value={form.workHrPhone}
|
value={form.workCompanyAccountantNumber}
|
||||||
onChange={(v) => set("workHrPhone", v)}
|
onChange={(v) => set("workCompanyAccountantNumber", v)}
|
||||||
placeholder={t("loanOrderForm.placeholders.phone") || "61 097 651"}
|
placeholder={t("loanOrderForm.placeholders.phone") || "61 097 651"}
|
||||||
error={errors.workHrPhone}
|
error={errors.workCompanyAccountantNumber}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
@@ -753,8 +722,8 @@ function StepJob({ form, errors, set, t, initialData }: StepContentProps & { ini
|
|||||||
/>
|
/>
|
||||||
<InfiniteSelect
|
<InfiniteSelect
|
||||||
label={t("Work province") || "Işleýän etrabyňyz"}
|
label={t("Work province") || "Işleýän etrabyňyz"}
|
||||||
value={form.workProvince}
|
value={form.workProvinceId}
|
||||||
onChange={(v) => set("workProvince", v)}
|
onChange={(v) => set("workProvinceId", v)}
|
||||||
options={provinceOptions}
|
options={provinceOptions}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
loading={provinceQuery.isLoading}
|
loading={provinceQuery.isLoading}
|
||||||
@@ -773,10 +742,10 @@ function StepJob({ form, errors, set, t, initialData }: StepContentProps & { ini
|
|||||||
type="text"
|
type="text"
|
||||||
label={t("Position") || "Wezipe"}
|
label={t("Position") || "Wezipe"}
|
||||||
required
|
required
|
||||||
value={form.position}
|
value={form.workPosition}
|
||||||
onChange={(v) => set("position", v)}
|
onChange={(v) => set("workPosition", v)}
|
||||||
placeholder={t("Position") || "Wezipe"}
|
placeholder={t("Position") || "Wezipe"}
|
||||||
error={errors.position}
|
error={errors.workPosition}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
<BentoCard>
|
<BentoCard>
|
||||||
@@ -784,10 +753,10 @@ function StepJob({ form, errors, set, t, initialData }: StepContentProps & { ini
|
|||||||
type="number"
|
type="number"
|
||||||
label={t("Salary") || "Zähmet haky"}
|
label={t("Salary") || "Zähmet haky"}
|
||||||
required
|
required
|
||||||
value={form.salary}
|
value={form.workSalary}
|
||||||
onChange={(v) => set("salary", v)}
|
onChange={(v) => set("workSalary", v)}
|
||||||
placeholder={t("Salary") || "Zähmet haky"}
|
placeholder={t("Salary") || "Zähmet haky"}
|
||||||
error={errors.salary}
|
error={errors.workSalary}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
<BentoCard>
|
<BentoCard>
|
||||||
@@ -814,10 +783,10 @@ function StepGuarantor({ form, errors, set, t }: StepContentProps) {
|
|||||||
type="text"
|
type="text"
|
||||||
label={t("Guarantor name") || "Zamunyň ady"}
|
label={t("Guarantor name") || "Zamunyň ady"}
|
||||||
required
|
required
|
||||||
value={form.guarantor1Name}
|
value={form.guarantorName}
|
||||||
onChange={(v) => set("guarantor1Name", v)}
|
onChange={(v) => set("guarantorName", v)}
|
||||||
placeholder={t("Guarantor name") || "Zamunyň ady"}
|
placeholder={t("Guarantor name") || "Zamunyň ady"}
|
||||||
error={errors.guarantor1Name}
|
error={errors.guarantorName}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
<BentoCard>
|
<BentoCard>
|
||||||
@@ -825,18 +794,18 @@ function StepGuarantor({ form, errors, set, t }: StepContentProps) {
|
|||||||
type="text"
|
type="text"
|
||||||
label={t("Guarantor Surname") || "Zamunyň familiýasy"}
|
label={t("Guarantor Surname") || "Zamunyň familiýasy"}
|
||||||
required
|
required
|
||||||
value={form.guarantor1Surname}
|
value={form.guarantorSurname}
|
||||||
onChange={(v) => set("guarantor1Surname", v)}
|
onChange={(v) => set("guarantorSurname", v)}
|
||||||
placeholder={t("Guarantor Surname") || "Zamunyň familiýasy"}
|
placeholder={t("Guarantor Surname") || "Zamunyň familiýasy"}
|
||||||
error={errors.guarantor1Surname}
|
error={errors.guarantorSurname}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
<BentoCard>
|
<BentoCard>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t("Guarantor Patronic name") || "Zamunyň atasynyň ady"}
|
label={t("Guarantor Patronic name") || "Zamunyň atasynyň ady"}
|
||||||
value={form.guarantor1Patronic}
|
value={form.guarantorPatronicName}
|
||||||
onChange={(v) => set("guarantor1Patronic", v)}
|
onChange={(v) => set("guarantorPatronicName", v)}
|
||||||
placeholder={t("Guarantor Patronic name") || "Zamunyň atasynyň ady"}
|
placeholder={t("Guarantor Patronic name") || "Zamunyň atasynyň ady"}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
@@ -848,11 +817,11 @@ function StepGuarantor({ form, errors, set, t }: StepContentProps) {
|
|||||||
type="searchable-select"
|
type="searchable-select"
|
||||||
label={t("Passport serie") || "Pasport seriýasy"}
|
label={t("Passport serie") || "Pasport seriýasy"}
|
||||||
required
|
required
|
||||||
value={form.guarantor1PassportSerie}
|
value={form.guarantorPassportSerie}
|
||||||
onChange={(v) => set("guarantor1PassportSerie", v)}
|
onChange={(v) => set("guarantorPassportSerie", v)}
|
||||||
options={PASSPORT_SERIES_OPTIONS}
|
options={PASSPORT_SERIES_OPTIONS}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
error={errors.guarantor1PassportSerie}
|
error={errors.guarantorPassportSerie}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
<BentoCard>
|
<BentoCard>
|
||||||
@@ -860,10 +829,10 @@ function StepGuarantor({ form, errors, set, t }: StepContentProps) {
|
|||||||
type="text"
|
type="text"
|
||||||
label={t("Passport id") || "Pasport belgisi"}
|
label={t("Passport id") || "Pasport belgisi"}
|
||||||
required
|
required
|
||||||
value={form.guarantor1PassportNumber}
|
value={form.guarantorPassportId}
|
||||||
onChange={(v) => set("guarantor1PassportNumber", v)}
|
onChange={(v) => set("guarantorPassportId", v)}
|
||||||
placeholder={t("Passport id") || "Pasport belgisi"}
|
placeholder={t("Passport id") || "Pasport belgisi"}
|
||||||
error={errors.guarantor1PassportNumber}
|
error={errors.guarantorPassportId}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
@@ -874,19 +843,19 @@ function StepGuarantor({ form, errors, set, t }: StepContentProps) {
|
|||||||
type="text"
|
type="text"
|
||||||
label={t("Card number") || "Kart belgisi"}
|
label={t("Card number") || "Kart belgisi"}
|
||||||
required
|
required
|
||||||
value={form.guarantor1CardNumber}
|
value={form.guarantorCardNumber}
|
||||||
onChange={(v) => set("guarantor1CardNumber", v)}
|
onChange={(v) => set("guarantorCardNumber", v)}
|
||||||
placeholder={t("Card number") || "Kart belgisi"}
|
placeholder={t("Card number") || "Kart belgisi"}
|
||||||
error={errors.guarantor1CardNumber}
|
error={errors.guarantorCardNumber}
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t("Name on card") || "Kartdaky ady"}
|
label={t("Name on card") || "Kartdaky ady"}
|
||||||
required
|
required
|
||||||
value={form.guarantor1CardName}
|
value={form.guarantorCardName}
|
||||||
onChange={(v) => set("guarantor1CardName", v)}
|
onChange={(v) => set("guarantorCardName", v)}
|
||||||
placeholder={t("Name on card") || "Kartdaky ady"}
|
placeholder={t("Name on card") || "Kartdaky ady"}
|
||||||
error={errors.guarantor1CardName}
|
error={errors.guarantorCardName}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
@@ -895,35 +864,21 @@ function StepGuarantor({ form, errors, set, t }: StepContentProps) {
|
|||||||
type="searchable-select"
|
type="searchable-select"
|
||||||
label={t("loanOrderForm.labels.cardExpMonth") || "Aý"}
|
label={t("loanOrderForm.labels.cardExpMonth") || "Aý"}
|
||||||
required
|
required
|
||||||
value={form.guarantor1CardExpMonth}
|
value={form.guarantorCardMonth}
|
||||||
onChange={(v) => set("guarantor1CardExpMonth", v)}
|
onChange={(v) => set("guarantorCardMonth", v)}
|
||||||
options={MONTH_OPTIONS}
|
options={MONTH_OPTIONS}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
error={errors.guarantor1CardExpMonth}
|
error={errors.guarantorCardMonth}
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="searchable-select"
|
type="searchable-select"
|
||||||
label={t("loanOrderForm.labels.cardExpYear") || "Ýyl"}
|
label={t("loanOrderForm.labels.cardExpYear") || "Ýyl"}
|
||||||
required
|
required
|
||||||
value={form.guarantor1CardExpYear}
|
value={form.guarantorCardYear}
|
||||||
onChange={(v) => set("guarantor1CardExpYear", v)}
|
onChange={(v) => set("guarantorCardYear", v)}
|
||||||
options={YEAR_OPTIONS}
|
options={YEAR_OPTIONS}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
error={errors.guarantor1CardExpYear}
|
error={errors.guarantorCardYear}
|
||||||
/>
|
|
||||||
</BentoCard>
|
|
||||||
</BentoGrid>
|
|
||||||
|
|
||||||
<BentoGrid cols={1}>
|
|
||||||
<BentoCard>
|
|
||||||
<FormInput
|
|
||||||
type="number"
|
|
||||||
label={t("Guarantor Salary") || "Zamunyň zähmet haky"}
|
|
||||||
required
|
|
||||||
value={form.guarantor1Salary}
|
|
||||||
onChange={(v) => set("guarantor1Salary", v)}
|
|
||||||
placeholder={t("Guarantor Salary") || "Zamunyň zähmet haky"}
|
|
||||||
error={errors.guarantor1Salary}
|
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
@@ -959,8 +914,8 @@ function StepGuarantor2({ form, errors, set, t }: StepContentProps) {
|
|||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t("Guarantor Patronic name") || "Zamunyň atasynyň ady"}
|
label={t("Guarantor Patronic name") || "Zamunyň atasynyň ady"}
|
||||||
value={form.guarantor2Patronic}
|
value={form.guarantor2PatronicName}
|
||||||
onChange={(v) => set("guarantor2Patronic", v)}
|
onChange={(v) => set("guarantor2PatronicName", v)}
|
||||||
placeholder={t("Guarantor Patronic name") || "Zamunyň atasynyň ady"}
|
placeholder={t("Guarantor Patronic name") || "Zamunyň atasynyň ady"}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
@@ -982,10 +937,10 @@ function StepGuarantor2({ form, errors, set, t }: StepContentProps) {
|
|||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t("Passport id") || "Pasport belgisi"}
|
label={t("Passport id") || "Pasport belgisi"}
|
||||||
value={form.guarantor2PassportNumber}
|
value={form.guarantor2PassportId}
|
||||||
onChange={(v) => set("guarantor2PassportNumber", v)}
|
onChange={(v) => set("guarantor2PassportId", v)}
|
||||||
placeholder={t("Passport id") || "Pasport belgisi"}
|
placeholder={t("Passport id") || "Pasport belgisi"}
|
||||||
error={errors.guarantor2PassportNumber}
|
error={errors.guarantor2PassportId}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
@@ -1014,20 +969,20 @@ function StepGuarantor2({ form, errors, set, t }: StepContentProps) {
|
|||||||
<FormInput
|
<FormInput
|
||||||
type="searchable-select"
|
type="searchable-select"
|
||||||
label={t("loanOrderForm.labels.cardExpMonth") || "Aý"}
|
label={t("loanOrderForm.labels.cardExpMonth") || "Aý"}
|
||||||
value={form.guarantor2CardExpMonth}
|
value={form.guarantor2CardMonth}
|
||||||
onChange={(v) => set("guarantor2CardExpMonth", v)}
|
onChange={(v) => set("guarantor2CardMonth", v)}
|
||||||
options={MONTH_OPTIONS}
|
options={MONTH_OPTIONS}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
error={errors.guarantor2CardExpMonth}
|
error={errors.guarantor2CardMonth}
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="searchable-select"
|
type="searchable-select"
|
||||||
label={t("loanOrderForm.labels.cardExpYear") || "Ýyl"}
|
label={t("loanOrderForm.labels.cardExpYear") || "Ýyl"}
|
||||||
value={form.guarantor2CardExpYear}
|
value={form.guarantor2CardYear}
|
||||||
onChange={(v) => set("guarantor2CardExpYear", v)}
|
onChange={(v) => set("guarantor2CardYear", v)}
|
||||||
options={YEAR_OPTIONS}
|
options={YEAR_OPTIONS}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
error={errors.guarantor2CardExpYear}
|
error={errors.guarantor2CardYear}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
@@ -1059,8 +1014,7 @@ export function LoanOrderMobileForm({ initialData, mode }: LoanOrderMobileFormPr
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [currentStep, setCurrentStep] = useState(0);
|
const [currentStep, setCurrentStep] = useState(0);
|
||||||
const [visited, setVisited] = useState<Set<number>>(() => new Set([0]));
|
const [visited, setVisited] = useState<Set<number>>(() => (mode === "edit" ? new Set(STEPS.map((_, i) => i)) : new Set([0])));
|
||||||
const [submittedSteps, setSubmittedSteps] = useState<Set<number>>(() => new Set());
|
|
||||||
|
|
||||||
const createMutation = useCreateLoanOrderMobile();
|
const createMutation = useCreateLoanOrderMobile();
|
||||||
const updateMutation = useUpdateLoanOrderMobile();
|
const updateMutation = useUpdateLoanOrderMobile();
|
||||||
@@ -1085,7 +1039,7 @@ export function LoanOrderMobileForm({ initialData, mode }: LoanOrderMobileFormPr
|
|||||||
(setValue as (name: K, val: LoanOrderMobileFormData[K]) => void)(k, v);
|
(setValue as (name: K, val: LoanOrderMobileFormData[K]) => void)(k, v);
|
||||||
clearErrors(k);
|
clearErrors(k);
|
||||||
},
|
},
|
||||||
[setValue, clearErrors, submittedSteps, currentStep],
|
[setValue, clearErrors],
|
||||||
);
|
);
|
||||||
|
|
||||||
const stepProps: StepContentProps = { form, errors: flatErrors, set, t };
|
const stepProps: StepContentProps = { form, errors: flatErrors, set, t };
|
||||||
@@ -1096,15 +1050,14 @@ export function LoanOrderMobileForm({ initialData, mode }: LoanOrderMobileFormPr
|
|||||||
|
|
||||||
const stepsWithErrors = useMemo(() => {
|
const stepsWithErrors = useMemo(() => {
|
||||||
const errorSet = new Set<number>();
|
const errorSet = new Set<number>();
|
||||||
submittedSteps.forEach((s) => {
|
visited.forEach((s) => {
|
||||||
const stepErrs = STEPS[s].validate(form, mode);
|
const stepErrs = STEPS[s].validate(form, mode);
|
||||||
if (Object.keys(stepErrs).length > 0) errorSet.add(s);
|
if (Object.keys(stepErrs).length > 0) errorSet.add(s);
|
||||||
});
|
});
|
||||||
return errorSet;
|
return errorSet;
|
||||||
}, [submittedSteps, form, mode]);
|
}, [visited, form, mode]);
|
||||||
|
|
||||||
const handleNext = () => {
|
const handleNext = () => {
|
||||||
setSubmittedSteps((prev) => new Set([...prev, currentStep]));
|
|
||||||
const stepErrs = STEPS[currentStep].validate(form, mode);
|
const stepErrs = STEPS[currentStep].validate(form, mode);
|
||||||
|
|
||||||
if (Object.keys(stepErrs).length > 0) {
|
if (Object.keys(stepErrs).length > 0) {
|
||||||
@@ -1139,7 +1092,6 @@ export function LoanOrderMobileForm({ initialData, mode }: LoanOrderMobileFormPr
|
|||||||
|
|
||||||
const doSubmit = () => {
|
const doSubmit = () => {
|
||||||
setVisited(new Set(STEPS.map((_, i) => i)));
|
setVisited(new Set(STEPS.map((_, i) => i)));
|
||||||
setSubmittedSteps(new Set(STEPS.map((_, i) => i)));
|
|
||||||
|
|
||||||
const allErrors: FlatErrors = {};
|
const allErrors: FlatErrors = {};
|
||||||
for (const step of STEPS) Object.assign(allErrors, step.validate(form, mode));
|
for (const step of STEPS) Object.assign(allErrors, step.validate(form, mode));
|
||||||
@@ -1240,19 +1192,19 @@ function mapInitial(order: LoanOrderMobile): Partial<LoanOrderMobileFormData> {
|
|||||||
status: order.status ?? "pending",
|
status: order.status ?? "pending",
|
||||||
loanType: order.loanTypeId != null ? String(order.loanTypeId) : "",
|
loanType: order.loanTypeId != null ? String(order.loanTypeId) : "",
|
||||||
region: order.region ?? "AG",
|
region: order.region ?? "AG",
|
||||||
branch: order.branchId != null ? String(order.branchId) : "",
|
branchId: order.branchId != null ? String(order.branchId) : "",
|
||||||
userId: order.createdById != null ? String(order.createdById) : "",
|
userId: order.createdById != null ? String(order.createdById) : "",
|
||||||
firstName: order.firstName ?? "",
|
customerName: order.customerName ?? order.firstName ?? "",
|
||||||
lastName: order.lastName ?? "",
|
customerSurname: order.customerSurname ?? order.lastName ?? "",
|
||||||
patronicName: order.patronicName ?? "",
|
customerPatronicName: order.customerPatronicName ?? "",
|
||||||
education: order.education ?? "",
|
education: order.education ?? "",
|
||||||
marriageStatus: order.marriageStatus ?? "",
|
marriageStatus: order.marriageStatus ?? "",
|
||||||
dateOfBirth: formatFromApiDate(order.dateOfBirth),
|
bornAt: formatFromApiDate(order.bornAt),
|
||||||
residence: order.residence ?? "",
|
passportAddress: order.passportAddress ?? order.residence ?? "",
|
||||||
currentResidence: order.currentResidence ?? "",
|
realAddress: order.realAddress ?? order.currentResidence ?? "",
|
||||||
passportSerie: order.passportSerie ?? "",
|
passportSerie: order.passportSerie ?? "",
|
||||||
passportNumber: order.passportNumber ?? "",
|
passportId: order.passportId ?? "",
|
||||||
passportDateOfIssue: formatFromApiDate(order.passportDateOfIssue),
|
passportGivenAt: formatFromApiDate(order.passportGivenAt),
|
||||||
passportGivenBy: order.passportGivenBy ?? "",
|
passportGivenBy: order.passportGivenBy ?? "",
|
||||||
passportOne: order.passportPage1Url ?? "",
|
passportOne: order.passportPage1Url ?? "",
|
||||||
passportTwo: order.passportPage23Url ?? "",
|
passportTwo: order.passportPage23Url ?? "",
|
||||||
@@ -1262,40 +1214,39 @@ function mapInitial(order: LoanOrderMobile): Partial<LoanOrderMobileFormData> {
|
|||||||
email: order.email ?? "",
|
email: order.email ?? "",
|
||||||
phone: formatFromApiPhone(order.phone),
|
phone: formatFromApiPhone(order.phone),
|
||||||
phoneAdditional: formatFromApiPhone(order.phoneAdditional),
|
phoneAdditional: formatFromApiPhone(order.phoneAdditional),
|
||||||
homePhone: formatFromApiPhone(order.homePhone),
|
phoneHome: formatFromApiPhone(order.phoneHome),
|
||||||
workCompany: order.workCompany ?? "",
|
workCompany: order.workCompany ?? "",
|
||||||
workHrPhone: formatFromApiPhone(order.workHrPhone),
|
workCompanyAccountantNumber: formatFromApiPhone(order.workCompanyAccountantNumber),
|
||||||
workRegion: order.workRegion ?? "AG",
|
workRegion: order.workRegion ?? "AG",
|
||||||
workProvince: order.workCityId != null ? String(order.workCityId) : "",
|
workProvinceId: order.workCityId != null ? String(order.workCityId) : "",
|
||||||
position: order.position ?? "",
|
workPosition: order.workPosition ?? "",
|
||||||
salary: order.salary != null ? String(order.salary) : "",
|
workSalary: order.workSalary != null ? String(order.workSalary) : "",
|
||||||
workStartedAt: formatFromApiDate(order.workStartedAt),
|
workStartedAt: formatFromApiDate(order.workStartedAt),
|
||||||
note: order.note ?? "",
|
notes: order.notes ?? order.note ?? "",
|
||||||
loanAmount: order.loanAmount != null ? String(order.loanAmount) : "",
|
loanAmount: order.loanAmount != null ? String(order.loanAmount) : "",
|
||||||
loanHistory: order.loanHistory ?? "",
|
loanOrderRequiredDocId: order.loanOrderRequiredDocId != null ? String(order.loanOrderRequiredDocId) : (order.loanHistory ?? ""),
|
||||||
cardNumber: order.cardNumber ?? "",
|
cardNumber: order.cardNumber ?? "",
|
||||||
cardName: order.cardName ?? "",
|
cardName: order.cardName ?? "",
|
||||||
cardExpMonth: order.cardExpMonth ?? "",
|
cardMonth: order.cardMonth ?? "",
|
||||||
cardExpYear: order.cardExpYear ?? "",
|
cardYear: order.cardYear ?? "",
|
||||||
guarantor1Name: order.guarantor1Name ?? "",
|
guarantorName: order.guarantorName ?? "",
|
||||||
guarantor1Surname: order.guarantor1Surname ?? "",
|
guarantorSurname: order.guarantorSurname ?? "",
|
||||||
guarantor1Patronic: order.guarantor1Patronic ?? "",
|
guarantorPatronicName: order.guarantorPatronicName ?? "",
|
||||||
guarantor1PassportSerie: order.guarantor1PassportSerie ?? "",
|
guarantorPassportSerie: order.guarantorPassportSerie ?? "",
|
||||||
guarantor1PassportNumber: order.guarantor1PassportNumber ?? "",
|
guarantorPassportId: order.guarantorPassportId ?? "",
|
||||||
guarantor1CardNumber: order.guarantor1CardNumber ?? "",
|
guarantorCardNumber: order.guarantorCardNumber ?? "",
|
||||||
guarantor1CardName: order.guarantor1CardName ?? "",
|
guarantorCardName: order.guarantorCardName ?? "",
|
||||||
guarantor1CardExpMonth: order.guarantor1CardExpMonth ?? "",
|
guarantorCardMonth: order.guarantorCardMonth ?? "",
|
||||||
guarantor1CardExpYear: order.guarantor1CardExpYear ?? "",
|
guarantorCardYear: order.guarantorCardYear ?? "",
|
||||||
guarantor1Salary: order.guarantor1Salary != null ? String(order.guarantor1Salary) : "",
|
|
||||||
guarantor2Name: order.guarantor2Name ?? "",
|
guarantor2Name: order.guarantor2Name ?? "",
|
||||||
guarantor2Surname: order.guarantor2Surname ?? "",
|
guarantor2Surname: order.guarantor2Surname ?? "",
|
||||||
guarantor2Patronic: order.guarantor2Patronic ?? "",
|
guarantor2PatronicName: order.guarantor2PatronicName ?? "",
|
||||||
guarantor2PassportSerie: order.guarantor2PassportSerie ?? "",
|
guarantor2PassportSerie: order.guarantor2PassportSerie ?? "",
|
||||||
guarantor2PassportNumber: order.guarantor2PassportNumber ?? "",
|
guarantor2PassportId: order.guarantor2PassportId ?? "",
|
||||||
guarantor2CardNumber: order.guarantor2CardNumber ?? "",
|
guarantor2CardNumber: order.guarantor2CardNumber ?? "",
|
||||||
guarantor2CardName: order.guarantor2CardName ?? "",
|
guarantor2CardName: order.guarantor2CardName ?? "",
|
||||||
guarantor2CardExpMonth: order.guarantor2CardExpMonth ?? "",
|
guarantor2CardMonth: order.guarantor2CardMonth ?? "",
|
||||||
guarantor2CardExpYear: order.guarantor2CardExpYear ?? "",
|
guarantor2CardYear: order.guarantor2CardYear ?? "",
|
||||||
guarantor2Note: order.guarantor2Note ?? "",
|
guarantor2Note: order.guarantor2Note ?? "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -32,39 +32,55 @@ export interface LoanOrder {
|
|||||||
workProvinceId?: number | string;
|
workProvinceId?: number | string;
|
||||||
createdById?: number | string;
|
createdById?: number | string;
|
||||||
createdBy?: string | null;
|
createdBy?: string | null;
|
||||||
firstName: string;
|
customerName: string;
|
||||||
lastName: string;
|
customerSurname: string;
|
||||||
|
customerPatronicName?: string | null;
|
||||||
|
firstName?: string;
|
||||||
|
lastName?: string;
|
||||||
patronicName?: string | null;
|
patronicName?: string | null;
|
||||||
fullName?: string | null;
|
fullName?: string | null;
|
||||||
phone: string;
|
phone: string;
|
||||||
|
phoneHome?: string | null;
|
||||||
homePhone?: string | null;
|
homePhone?: string | null;
|
||||||
phoneAdditional?: string | null;
|
phoneAdditional?: string | null;
|
||||||
|
phoneAlt?: string | null;
|
||||||
status: LoanOrderStatus;
|
status: LoanOrderStatus;
|
||||||
note?: string | null;
|
note?: string | null;
|
||||||
notes?: string | null;
|
notes?: string | null;
|
||||||
|
|
||||||
loanAmount?: number | null;
|
loanAmount?: number | null;
|
||||||
|
amount?: number | null;
|
||||||
loanHistory?: string | null;
|
loanHistory?: string | null;
|
||||||
|
loanOrderRequiredDocId?: number | null;
|
||||||
loanOrderRequiredDoc?: { id: number; name: string } | null;
|
loanOrderRequiredDoc?: { id: number; name: string } | null;
|
||||||
satisfiable?: string | null;
|
satisfiable?: string | null;
|
||||||
|
|
||||||
education?: string | null;
|
education?: string | null;
|
||||||
marriageStatus?: string | null;
|
marriageStatus?: string | null;
|
||||||
maritalStatus?: string | null;
|
maritalStatus?: string | null;
|
||||||
|
bornAt?: string | null;
|
||||||
dateOfBirth?: string | null;
|
dateOfBirth?: string | null;
|
||||||
birthDate?: string | null;
|
birthDate?: string | null;
|
||||||
|
bornPlace?: string | null;
|
||||||
|
passportBirthPlace?: string | null;
|
||||||
|
passportAddress?: string | null;
|
||||||
residence?: string | null;
|
residence?: string | null;
|
||||||
registeredAddress?: string | null;
|
registeredAddress?: string | null;
|
||||||
|
realAddress?: string | null;
|
||||||
currentResidence?: string | null;
|
currentResidence?: string | null;
|
||||||
currentAddress?: string | null;
|
currentAddress?: string | null;
|
||||||
|
|
||||||
passportSerie?: string | null;
|
passportSerie?: string | null;
|
||||||
|
passportId?: string | null;
|
||||||
passportNumber?: string | null;
|
passportNumber?: string | null;
|
||||||
|
passportGivenAt?: string | null;
|
||||||
passportDateOfIssue?: string | null;
|
passportDateOfIssue?: string | null;
|
||||||
passportGivenBy?: string | null;
|
passportGivenBy?: string | null;
|
||||||
passportIssuedBy?: string | null;
|
passportIssuedBy?: string | null;
|
||||||
bornPlace?: string | null;
|
passportOne?: string | null;
|
||||||
passportBirthPlace?: string | null;
|
passportTwo?: string | null;
|
||||||
|
passportThree?: string | null;
|
||||||
|
passportFour?: string | null;
|
||||||
passportPage1Url?: string | null;
|
passportPage1Url?: string | null;
|
||||||
passportPage23Url?: string | null;
|
passportPage23Url?: string | null;
|
||||||
passportPage89Url?: string | null;
|
passportPage89Url?: string | null;
|
||||||
@@ -74,21 +90,42 @@ export interface LoanOrder {
|
|||||||
|
|
||||||
workCompany?: string | null;
|
workCompany?: string | null;
|
||||||
employer?: string | null;
|
employer?: string | null;
|
||||||
|
workCompanyAccountantNumber?: string | null;
|
||||||
workHrPhone?: string | null;
|
workHrPhone?: string | null;
|
||||||
deptPhone?: string | null;
|
deptPhone?: string | null;
|
||||||
workRegion?: string | null;
|
workRegion?: string | null;
|
||||||
workProvince?: string | null;
|
workProvince?: string | null;
|
||||||
workCity?: string | null;
|
workCity?: string | null;
|
||||||
|
workPosition?: string | null;
|
||||||
position?: string | null;
|
position?: string | null;
|
||||||
|
workSalary?: number | null;
|
||||||
salary?: number | null;
|
salary?: number | null;
|
||||||
workStartedAt?: string | null;
|
workStartedAt?: string | null;
|
||||||
employedSince?: string | null;
|
employedSince?: string | null;
|
||||||
|
|
||||||
cardNumber?: string | null;
|
cardNumber?: string | null;
|
||||||
cardName?: string | null;
|
cardName?: string | null;
|
||||||
|
cardMonth?: string | null;
|
||||||
|
cardYear?: string | null;
|
||||||
cardExpMonth?: string | null;
|
cardExpMonth?: string | null;
|
||||||
cardExpYear?: string | null;
|
cardExpYear?: string | null;
|
||||||
|
|
||||||
|
loanCardNumber?: string | null;
|
||||||
|
loanCardName?: string | null;
|
||||||
|
loanCardMonth?: string | null;
|
||||||
|
loanCardYear?: string | null;
|
||||||
|
|
||||||
|
guarantorName?: string | null;
|
||||||
|
guarantorSurname?: string | null;
|
||||||
|
guarantorPatronicName?: string | null;
|
||||||
|
guarantorPassportSerie?: string | null;
|
||||||
|
guarantorPassportId?: string | null;
|
||||||
|
guarantorCardNumber?: string | null;
|
||||||
|
guarantorCardName?: string | null;
|
||||||
|
guarantorCardMonth?: string | null;
|
||||||
|
guarantorCardYear?: string | null;
|
||||||
|
guarantorNote?: string | null;
|
||||||
|
|
||||||
guarantor1Name?: string | null;
|
guarantor1Name?: string | null;
|
||||||
guarantor1Surname?: string | null;
|
guarantor1Surname?: string | null;
|
||||||
guarantor1Patronic?: string | null;
|
guarantor1Patronic?: string | null;
|
||||||
@@ -103,22 +140,18 @@ export interface LoanOrder {
|
|||||||
|
|
||||||
guarantor2Name?: string | null;
|
guarantor2Name?: string | null;
|
||||||
guarantor2Surname?: string | null;
|
guarantor2Surname?: string | null;
|
||||||
|
guarantor2PatronicName?: string | null;
|
||||||
guarantor2Patronic?: string | null;
|
guarantor2Patronic?: string | null;
|
||||||
guarantor2PassportSerie?: string | null;
|
guarantor2PassportSerie?: string | null;
|
||||||
|
guarantor2PassportId?: string | null;
|
||||||
guarantor2PassportNumber?: string | null;
|
guarantor2PassportNumber?: string | null;
|
||||||
guarantor2CardNumber?: string | null;
|
guarantor2CardNumber?: string | null;
|
||||||
guarantor2CardName?: string | null;
|
guarantor2CardName?: string | null;
|
||||||
|
guarantor2CardMonth?: string | null;
|
||||||
|
guarantor2CardYear?: string | null;
|
||||||
guarantor2CardExpMonth?: string | null;
|
guarantor2CardExpMonth?: string | null;
|
||||||
guarantor2CardExpYear?: string | null;
|
guarantor2CardExpYear?: string | null;
|
||||||
guarantor2Note?: string | null;
|
guarantor2Note?: string | null;
|
||||||
|
|
||||||
loanCardNumber?: string | null;
|
|
||||||
loanCardName?: string | null;
|
|
||||||
loanCardMonth?: string | null;
|
|
||||||
loanCardYear?: string | null;
|
|
||||||
|
|
||||||
amount?: number | null;
|
|
||||||
phoneAlt?: string | null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LoanOrdersParams {
|
export interface LoanOrdersParams {
|
||||||
@@ -130,7 +163,6 @@ export interface LoanOrdersParams {
|
|||||||
createdById?: string | number;
|
createdById?: string | number;
|
||||||
userId?: string | number;
|
userId?: string | number;
|
||||||
user_id?: string | number;
|
user_id?: string | number;
|
||||||
archived?: string;
|
|
||||||
page?: number;
|
page?: number;
|
||||||
perPage?: number;
|
perPage?: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
@@ -144,45 +176,79 @@ export interface LoanOrdersResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface LoanOrderPayload {
|
export interface LoanOrderPayload {
|
||||||
status: string;
|
status?: string;
|
||||||
loanType: string;
|
loanType?: string | number;
|
||||||
region: string;
|
region?: string;
|
||||||
branch: string;
|
branchId?: string | number;
|
||||||
|
branch?: string | number;
|
||||||
userId?: string | number;
|
userId?: string | number;
|
||||||
firstName: string;
|
customerName?: string;
|
||||||
lastName: string;
|
customerSurname?: string;
|
||||||
|
customerPatronicName?: string;
|
||||||
|
firstName?: string;
|
||||||
|
lastName?: string;
|
||||||
patronicName?: string;
|
patronicName?: string;
|
||||||
education: string;
|
education?: string;
|
||||||
marriageStatus: string;
|
marriageStatus?: string;
|
||||||
dateOfBirth: string;
|
bornAt?: string;
|
||||||
residence: string;
|
dateOfBirth?: string;
|
||||||
|
passportAddress?: string;
|
||||||
|
residence?: string;
|
||||||
|
realAddress?: string;
|
||||||
currentResidence?: string;
|
currentResidence?: string;
|
||||||
passportSerie: string;
|
passportSerie?: string;
|
||||||
passportNumber: string;
|
passportId?: string;
|
||||||
passportDateOfIssue: string;
|
passportNumber?: string;
|
||||||
passportGivenBy: string;
|
passportGivenAt?: string;
|
||||||
|
passportDateOfIssue?: string;
|
||||||
|
passportGivenBy?: string;
|
||||||
bornPlace?: string;
|
bornPlace?: string;
|
||||||
email?: string;
|
email?: string;
|
||||||
phone: string;
|
phone?: string;
|
||||||
phoneAdditional?: string;
|
phoneAdditional?: string;
|
||||||
|
phoneHome?: string;
|
||||||
homePhone?: string;
|
homePhone?: string;
|
||||||
workCompany: string;
|
workCompany?: string;
|
||||||
|
workCompanyAccountantNumber?: string;
|
||||||
workHrPhone?: string;
|
workHrPhone?: string;
|
||||||
workRegion?: string;
|
workRegion?: string;
|
||||||
workProvince?: string;
|
workProvinceId?: string | number;
|
||||||
position: string;
|
workProvince?: string | number;
|
||||||
salary: number;
|
workPosition?: string;
|
||||||
workStartedAt: string;
|
position?: string;
|
||||||
|
workSalary?: string | number;
|
||||||
|
salary?: string | number;
|
||||||
|
workStartedAt?: string;
|
||||||
|
|
||||||
|
notes?: string;
|
||||||
note?: string;
|
note?: string;
|
||||||
loanAmount?: number;
|
loanAmount?: string | number;
|
||||||
|
loanOrderRequiredDocId?: string | number;
|
||||||
loanHistory?: string;
|
loanHistory?: string;
|
||||||
|
|
||||||
cardNumber?: string;
|
cardNumber?: string;
|
||||||
cardName?: string;
|
cardName?: string;
|
||||||
|
cardMonth?: string;
|
||||||
|
cardYear?: string;
|
||||||
cardExpMonth?: string;
|
cardExpMonth?: string;
|
||||||
cardExpYear?: string;
|
cardExpYear?: string;
|
||||||
|
|
||||||
|
loanCardNumber?: string;
|
||||||
|
loanCardName?: string;
|
||||||
|
loanCardMonth?: string;
|
||||||
|
loanCardYear?: string;
|
||||||
|
|
||||||
|
guarantorName?: string;
|
||||||
|
guarantorSurname?: string;
|
||||||
|
guarantorPatronicName?: string;
|
||||||
|
guarantorPassportSerie?: string;
|
||||||
|
guarantorPassportId?: string;
|
||||||
|
guarantorCardNumber?: string;
|
||||||
|
guarantorCardName?: string;
|
||||||
|
guarantorCardMonth?: string;
|
||||||
|
guarantorCardYear?: string;
|
||||||
|
guarantorNote?: string;
|
||||||
|
|
||||||
guarantor1Name?: string;
|
guarantor1Name?: string;
|
||||||
guarantor1Surname?: string;
|
guarantor1Surname?: string;
|
||||||
guarantor1Patronic?: string;
|
guarantor1Patronic?: string;
|
||||||
@@ -192,15 +258,19 @@ export interface LoanOrderPayload {
|
|||||||
guarantor1CardName?: string;
|
guarantor1CardName?: string;
|
||||||
guarantor1CardExpMonth?: string;
|
guarantor1CardExpMonth?: string;
|
||||||
guarantor1CardExpYear?: string;
|
guarantor1CardExpYear?: string;
|
||||||
guarantor1Salary?: number;
|
guarantor1Note?: string;
|
||||||
|
|
||||||
guarantor2Name?: string;
|
guarantor2Name?: string;
|
||||||
guarantor2Surname?: string;
|
guarantor2Surname?: string;
|
||||||
|
guarantor2PatronicName?: string;
|
||||||
guarantor2Patronic?: string;
|
guarantor2Patronic?: string;
|
||||||
guarantor2PassportSerie?: string;
|
guarantor2PassportSerie?: string;
|
||||||
|
guarantor2PassportId?: string;
|
||||||
guarantor2PassportNumber?: string;
|
guarantor2PassportNumber?: string;
|
||||||
guarantor2CardNumber?: string;
|
guarantor2CardNumber?: string;
|
||||||
guarantor2CardName?: string;
|
guarantor2CardName?: string;
|
||||||
|
guarantor2CardMonth?: string;
|
||||||
|
guarantor2CardYear?: string;
|
||||||
guarantor2CardExpMonth?: string;
|
guarantor2CardExpMonth?: string;
|
||||||
guarantor2CardExpYear?: string;
|
guarantor2CardExpYear?: string;
|
||||||
guarantor2Note?: string;
|
guarantor2Note?: string;
|
||||||
@@ -210,6 +280,8 @@ export interface LoanOrderPayload {
|
|||||||
passportThree?: string;
|
passportThree?: string;
|
||||||
passportFour?: string;
|
passportFour?: string;
|
||||||
source?: string;
|
source?: string;
|
||||||
|
satisfiable?: string;
|
||||||
|
uniqueId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Backend types ─────────────────────────────────────────────────────────────
|
// ─── Backend types ─────────────────────────────────────────────────────────────
|
||||||
@@ -342,6 +414,9 @@ export function toNum(value: string | number | null | undefined): number | null
|
|||||||
export function mapBackendToUI(order: BackendLoanOrder): LoanOrder {
|
export function mapBackendToUI(order: BackendLoanOrder): LoanOrder {
|
||||||
const rawStatus = order.status ?? "";
|
const rawStatus = order.status ?? "";
|
||||||
const status: LoanOrderStatus = isStatusValue(rawStatus) ? rawStatus : "pending";
|
const status: LoanOrderStatus = isStatusValue(rawStatus) ? rawStatus : "pending";
|
||||||
|
const custName = order.customerName ?? "";
|
||||||
|
const custSurname = order.customerSurname ?? "";
|
||||||
|
const custPatronic = order.customerPatronicName ?? "";
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: String(order.id ?? order.uniqueId ?? ""),
|
id: String(order.id ?? order.uniqueId ?? ""),
|
||||||
@@ -359,20 +434,28 @@ export function mapBackendToUI(order: BackendLoanOrder): LoanOrder {
|
|||||||
workProvinceId: resolveNestedId(order.workProvince) ?? order.workProvinceId ?? undefined,
|
workProvinceId: resolveNestedId(order.workProvince) ?? order.workProvinceId ?? undefined,
|
||||||
createdById: order.user?.id ?? order.userId ?? undefined,
|
createdById: order.user?.id ?? order.userId ?? undefined,
|
||||||
createdBy: order.user?.name ?? order.userName ?? "",
|
createdBy: order.user?.name ?? order.userName ?? "",
|
||||||
firstName: order.customerName ?? "",
|
customerName: custName,
|
||||||
lastName: order.customerSurname ?? "",
|
customerSurname: custSurname,
|
||||||
patronicName: order.customerPatronicName ?? "",
|
customerPatronicName: custPatronic,
|
||||||
fullName: [order.customerName, order.customerSurname].filter(Boolean).join(" "),
|
firstName: custName,
|
||||||
|
lastName: custSurname,
|
||||||
|
patronicName: custPatronic,
|
||||||
|
fullName: [custName, custSurname].filter(Boolean).join(" "),
|
||||||
phone: formatFromApiPhone(order.phone ?? order.phoneHome ?? ""),
|
phone: formatFromApiPhone(order.phone ?? order.phoneHome ?? ""),
|
||||||
|
phoneHome: formatFromApiPhone(order.phoneHome),
|
||||||
homePhone: formatFromApiPhone(order.phoneHome),
|
homePhone: formatFromApiPhone(order.phoneHome),
|
||||||
phoneAdditional: formatFromApiPhone(order.phoneAdditional),
|
phoneAdditional: formatFromApiPhone(order.phoneAdditional),
|
||||||
|
phoneAlt: formatFromApiPhone(order.phoneAdditional),
|
||||||
status,
|
status,
|
||||||
note: order.notes ?? "",
|
note: order.notes ?? "",
|
||||||
notes: order.notes ?? "",
|
notes: order.notes ?? "",
|
||||||
loanAmount: toNum(order.loanAmount),
|
loanAmount: toNum(order.loanAmount),
|
||||||
|
amount: toNum(order.loanAmount),
|
||||||
loanHistory: order.loanOrderRequiredDoc?.name || (order.loanOrderRequiredDocId ? String(order.loanOrderRequiredDocId) : ""),
|
loanHistory: order.loanOrderRequiredDoc?.name || (order.loanOrderRequiredDocId ? String(order.loanOrderRequiredDocId) : ""),
|
||||||
|
loanOrderRequiredDocId: order.loanOrderRequiredDocId ?? order.loanOrderRequiredDoc?.id ?? undefined,
|
||||||
loanOrderRequiredDoc: order.loanOrderRequiredDoc ?? undefined,
|
loanOrderRequiredDoc: order.loanOrderRequiredDoc ?? undefined,
|
||||||
satisfiable: order.satisfiable ?? "",
|
satisfiable: order.satisfiable ?? "",
|
||||||
|
bornAt: formatFromApiDate(order.bornAt),
|
||||||
dateOfBirth: formatFromApiDate(order.bornAt),
|
dateOfBirth: formatFromApiDate(order.bornAt),
|
||||||
birthDate: formatFromApiDate(order.bornAt),
|
birthDate: formatFromApiDate(order.bornAt),
|
||||||
bornPlace: order.bornPlace ?? "",
|
bornPlace: order.bornPlace ?? "",
|
||||||
@@ -380,35 +463,62 @@ export function mapBackendToUI(order: BackendLoanOrder): LoanOrder {
|
|||||||
education: order.education ?? "",
|
education: order.education ?? "",
|
||||||
marriageStatus: order.marriageStatus ?? "",
|
marriageStatus: order.marriageStatus ?? "",
|
||||||
maritalStatus: order.marriageStatus ?? "",
|
maritalStatus: order.marriageStatus ?? "",
|
||||||
|
passportAddress: order.passportAddress ?? "",
|
||||||
residence: order.passportAddress ?? "",
|
residence: order.passportAddress ?? "",
|
||||||
registeredAddress: order.passportAddress ?? "",
|
registeredAddress: order.passportAddress ?? "",
|
||||||
|
realAddress: order.realAddress ?? "",
|
||||||
currentResidence: order.realAddress ?? "",
|
currentResidence: order.realAddress ?? "",
|
||||||
currentAddress: order.realAddress ?? "",
|
currentAddress: order.realAddress ?? "",
|
||||||
email: order.email ?? "",
|
email: order.email ?? "",
|
||||||
passportSerie: order.passportSerie ?? "",
|
passportSerie: order.passportSerie ?? "",
|
||||||
|
passportId: order.passportId ?? "",
|
||||||
passportNumber: order.passportId ?? "",
|
passportNumber: order.passportId ?? "",
|
||||||
|
passportGivenAt: formatFromApiDate(order.passportGivenAt),
|
||||||
passportDateOfIssue: formatFromApiDate(order.passportGivenAt),
|
passportDateOfIssue: formatFromApiDate(order.passportGivenAt),
|
||||||
passportGivenBy: order.passportGivenBy ?? "",
|
passportGivenBy: order.passportGivenBy ?? "",
|
||||||
passportIssuedBy: order.passportGivenBy ?? "",
|
passportIssuedBy: order.passportGivenBy ?? "",
|
||||||
|
passportOne: order.passportOne ?? "",
|
||||||
|
passportTwo: order.passportTwo ?? "",
|
||||||
|
passportThree: order.passportThree ?? "",
|
||||||
|
passportFour: order.passportFour ?? "",
|
||||||
passportPage1Url: order.passportOne ?? "",
|
passportPage1Url: order.passportOne ?? "",
|
||||||
passportPage23Url: order.passportTwo ?? "",
|
passportPage23Url: order.passportTwo ?? "",
|
||||||
passportPage89Url: order.passportThree ?? "",
|
passportPage89Url: order.passportThree ?? "",
|
||||||
passportPage32Url: order.passportFour ?? "",
|
passportPage32Url: order.passportFour ?? "",
|
||||||
workCompany: order.workCompany ?? "",
|
workCompany: order.workCompany ?? "",
|
||||||
employer: order.workCompany ?? "",
|
employer: order.workCompany ?? "",
|
||||||
|
workCompanyAccountantNumber: formatFromApiPhone(order.workCompanyAccountantNumber),
|
||||||
workHrPhone: formatFromApiPhone(order.workCompanyAccountantNumber),
|
workHrPhone: formatFromApiPhone(order.workCompanyAccountantNumber),
|
||||||
deptPhone: formatFromApiPhone(order.workCompanyAccountantNumber),
|
deptPhone: formatFromApiPhone(order.workCompanyAccountantNumber),
|
||||||
workRegion: order.workRegion ?? "",
|
workRegion: order.workRegion ?? "",
|
||||||
workProvince: resolveNestedName(order.workProvince) || resolveLocalizedName(order.workProvinceName),
|
workProvince: resolveNestedName(order.workProvince) || resolveLocalizedName(order.workProvinceName),
|
||||||
workCity: resolveNestedName(order.workProvince) || resolveLocalizedName(order.workProvinceName),
|
workCity: resolveNestedName(order.workProvince) || resolveLocalizedName(order.workProvinceName),
|
||||||
|
workSalary: toNum(order.workSalary),
|
||||||
salary: toNum(order.workSalary),
|
salary: toNum(order.workSalary),
|
||||||
|
workPosition: order.workPosition ?? "",
|
||||||
position: order.workPosition ?? "",
|
position: order.workPosition ?? "",
|
||||||
workStartedAt: formatFromApiDate(order.workStartedAt),
|
workStartedAt: formatFromApiDate(order.workStartedAt),
|
||||||
employedSince: formatFromApiDate(order.workStartedAt),
|
employedSince: formatFromApiDate(order.workStartedAt),
|
||||||
cardNumber: order.cardNumber ?? order.loanCardNumber ?? "",
|
cardNumber: order.cardNumber ?? "",
|
||||||
cardName: order.cardName ?? order.loanCardName ?? "",
|
cardName: order.cardName ?? "",
|
||||||
cardExpMonth: order.cardMonth ?? order.loanCardMonth ?? "",
|
cardMonth: order.cardMonth ?? "",
|
||||||
cardExpYear: order.cardYear ?? order.loanCardYear ?? "",
|
cardYear: order.cardYear ?? "",
|
||||||
|
cardExpMonth: order.cardMonth ?? "",
|
||||||
|
cardExpYear: order.cardYear ?? "",
|
||||||
|
loanCardNumber: order.loanCardNumber ?? "",
|
||||||
|
loanCardName: order.loanCardName ?? "",
|
||||||
|
loanCardMonth: order.loanCardMonth ?? "",
|
||||||
|
loanCardYear: order.loanCardYear ?? "",
|
||||||
|
guarantorName: order.guarantorName ?? "",
|
||||||
|
guarantorSurname: order.guarantorSurname ?? "",
|
||||||
|
guarantorPatronicName: order.guarantorPatronicName ?? "",
|
||||||
|
guarantorPassportSerie: order.guarantorPassportSerie ?? "",
|
||||||
|
guarantorPassportId: order.guarantorPassportId ?? "",
|
||||||
|
guarantorCardNumber: order.guarantorCardNumber ?? "",
|
||||||
|
guarantorCardName: order.guarantorCardName ?? "",
|
||||||
|
guarantorCardMonth: order.guarantorCardMonth ?? "",
|
||||||
|
guarantorCardYear: order.guarantorCardYear ?? "",
|
||||||
|
guarantorNote: order.guarantorNote ?? "",
|
||||||
guarantor1Name: order.guarantorName ?? "",
|
guarantor1Name: order.guarantorName ?? "",
|
||||||
guarantor1Surname: order.guarantorSurname ?? "",
|
guarantor1Surname: order.guarantorSurname ?? "",
|
||||||
guarantor1Patronic: order.guarantorPatronicName ?? "",
|
guarantor1Patronic: order.guarantorPatronicName ?? "",
|
||||||
@@ -422,96 +532,106 @@ export function mapBackendToUI(order: BackendLoanOrder): LoanOrder {
|
|||||||
guarantor1Note: order.guarantorNote ?? "",
|
guarantor1Note: order.guarantorNote ?? "",
|
||||||
guarantor2Name: order.guarantor2Name ?? "",
|
guarantor2Name: order.guarantor2Name ?? "",
|
||||||
guarantor2Surname: order.guarantor2Surname ?? "",
|
guarantor2Surname: order.guarantor2Surname ?? "",
|
||||||
|
guarantor2PatronicName: order.guarantor2PatronicName ?? "",
|
||||||
guarantor2Patronic: order.guarantor2PatronicName ?? "",
|
guarantor2Patronic: order.guarantor2PatronicName ?? "",
|
||||||
guarantor2PassportSerie: order.guarantor2PassportSerie ?? "",
|
guarantor2PassportSerie: order.guarantor2PassportSerie ?? "",
|
||||||
|
guarantor2PassportId: order.guarantor2PassportId ?? "",
|
||||||
guarantor2PassportNumber: order.guarantor2PassportId ?? "",
|
guarantor2PassportNumber: order.guarantor2PassportId ?? "",
|
||||||
guarantor2CardNumber: order.guarantor2CardNumber ?? "",
|
guarantor2CardNumber: order.guarantor2CardNumber ?? "",
|
||||||
guarantor2CardName: order.guarantor2CardName ?? "",
|
guarantor2CardName: order.guarantor2CardName ?? "",
|
||||||
|
guarantor2CardMonth: order.guarantor2CardMonth ?? "",
|
||||||
|
guarantor2CardYear: order.guarantor2CardYear ?? "",
|
||||||
guarantor2CardExpMonth: order.guarantor2CardMonth ?? "",
|
guarantor2CardExpMonth: order.guarantor2CardMonth ?? "",
|
||||||
guarantor2CardExpYear: order.guarantor2CardYear ?? "",
|
guarantor2CardExpYear: order.guarantor2CardYear ?? "",
|
||||||
guarantor2Note: order.guarantor2Note ?? "",
|
guarantor2Note: order.guarantor2Note ?? "",
|
||||||
loanCardNumber: order.loanCardNumber ?? "",
|
|
||||||
loanCardName: order.loanCardName ?? "",
|
|
||||||
loanCardMonth: order.loanCardMonth ?? "",
|
|
||||||
loanCardYear: order.loanCardYear ?? "",
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mapPayloadToBackend(payload: LoanOrderPayload | Partial<LoanOrderPayload>): Record<string, unknown> {
|
export function mapPayloadToBackend(payload: LoanOrderPayload | Partial<LoanOrderPayload>): Record<string, unknown> {
|
||||||
|
const customerName = payload.customerName || payload.firstName || "";
|
||||||
|
const customerSurname = payload.customerSurname || payload.lastName || "";
|
||||||
|
const customerPatronicName = payload.customerPatronicName || payload.patronicName || "";
|
||||||
|
const branchId = toNum(payload.branchId ?? payload.branch);
|
||||||
|
const loanType = toNum(payload.loanType);
|
||||||
|
const userId = toNum(payload.userId) ?? 0;
|
||||||
|
const workProvinceId = toNum(payload.workProvinceId ?? payload.workProvince);
|
||||||
|
const loanOrderRequiredDocId = toNum(payload.loanOrderRequiredDocId ?? payload.loanHistory) ?? 0;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
customerName: payload.firstName ?? "",
|
bornAt: formatToApiDate(payload.bornAt || payload.dateOfBirth),
|
||||||
customerSurname: payload.lastName ?? "",
|
|
||||||
customerPatronicName: payload.patronicName || "",
|
|
||||||
branchId: toNum(payload.branch),
|
|
||||||
loanType: toNum(payload.loanType),
|
|
||||||
region: payload.region ?? "",
|
|
||||||
education: payload.education || "",
|
|
||||||
marriageStatus: payload.marriageStatus || "",
|
|
||||||
bornAt: formatToApiDate(payload.dateOfBirth),
|
|
||||||
bornPlace: payload.bornPlace || "",
|
bornPlace: payload.bornPlace || "",
|
||||||
passportAddress: payload.residence || "",
|
branchId,
|
||||||
realAddress: payload.currentResidence || "",
|
cardMonth: payload.cardMonth || payload.cardExpMonth || "",
|
||||||
passportSerie: payload.passportSerie || "",
|
cardName: payload.cardName || "",
|
||||||
passportId: payload.passportNumber || "",
|
cardNumber: payload.cardNumber || "",
|
||||||
passportGivenAt: formatToApiDate(payload.passportDateOfIssue),
|
cardYear: payload.cardYear || payload.cardExpYear || "",
|
||||||
passportGivenBy: payload.passportGivenBy || "",
|
customerName,
|
||||||
|
customerPatronicName,
|
||||||
|
customerSurname,
|
||||||
|
education: payload.education || "",
|
||||||
email: payload.email || "",
|
email: payload.email || "",
|
||||||
|
guarantor2CardMonth: payload.guarantor2CardMonth || payload.guarantor2CardExpMonth || "",
|
||||||
|
guarantor2CardName: payload.guarantor2CardName || "",
|
||||||
|
guarantor2CardNumber: payload.guarantor2CardNumber || "",
|
||||||
|
guarantor2CardYear: payload.guarantor2CardYear || payload.guarantor2CardExpYear || "",
|
||||||
|
guarantor2Name: payload.guarantor2Name || "",
|
||||||
|
guarantor2Note: payload.guarantor2Note || "",
|
||||||
|
guarantor2PassportId: payload.guarantor2PassportId || payload.guarantor2PassportNumber || "",
|
||||||
|
guarantor2PassportSerie: payload.guarantor2PassportSerie || "",
|
||||||
|
guarantor2PatronicName: payload.guarantor2PatronicName || payload.guarantor2Patronic || "",
|
||||||
|
guarantor2Surname: payload.guarantor2Surname || "",
|
||||||
|
guarantorCardMonth: payload.guarantorCardMonth || payload.guarantor1CardExpMonth || "",
|
||||||
|
guarantorCardName: payload.guarantorCardName || payload.guarantor1CardName || "",
|
||||||
|
guarantorCardNumber: payload.guarantorCardNumber || payload.guarantor1CardNumber || "",
|
||||||
|
guarantorCardYear: payload.guarantorCardYear || payload.guarantor1CardExpYear || "",
|
||||||
|
guarantorName: payload.guarantorName || payload.guarantor1Name || "",
|
||||||
|
guarantorNote: payload.guarantorNote || payload.guarantor1Note || "",
|
||||||
|
guarantorPassportId: payload.guarantorPassportId || payload.guarantor1PassportNumber || "",
|
||||||
|
guarantorPassportSerie: payload.guarantorPassportSerie || payload.guarantor1PassportSerie || "",
|
||||||
|
guarantorPatronicName: payload.guarantorPatronicName || payload.guarantor1Patronic || "",
|
||||||
|
guarantorSurname: payload.guarantorSurname || payload.guarantor1Surname || "",
|
||||||
|
loanAmount: payload.loanAmount != null ? String(payload.loanAmount) : "",
|
||||||
|
loanCardMonth: payload.loanCardMonth || "",
|
||||||
|
loanCardName: payload.loanCardName || "",
|
||||||
|
loanCardNumber: payload.loanCardNumber || "",
|
||||||
|
loanCardYear: payload.loanCardYear || "",
|
||||||
|
loanOrderRequiredDocId,
|
||||||
|
loanType,
|
||||||
|
marriageStatus: payload.marriageStatus || "",
|
||||||
|
notes: payload.notes || payload.note || "",
|
||||||
|
passportAddress: payload.passportAddress || payload.residence || "",
|
||||||
|
passportFour: payload.passportFour || "",
|
||||||
|
passportGivenAt: formatToApiDate(payload.passportGivenAt || payload.passportDateOfIssue),
|
||||||
|
passportGivenBy: payload.passportGivenBy || "",
|
||||||
|
passportId: payload.passportId || payload.passportNumber || "",
|
||||||
|
passportOne: payload.passportOne || "",
|
||||||
|
passportSerie: payload.passportSerie || "",
|
||||||
|
passportThree: payload.passportThree || "",
|
||||||
|
passportTwo: payload.passportTwo || "",
|
||||||
phone: formatToApiPhone(payload.phone),
|
phone: formatToApiPhone(payload.phone),
|
||||||
phoneAdditional: formatToApiPhone(payload.phoneAdditional),
|
phoneAdditional: formatToApiPhone(payload.phoneAdditional),
|
||||||
phoneHome: formatToApiPhone(payload.homePhone),
|
phoneHome: formatToApiPhone(payload.phoneHome || payload.homePhone),
|
||||||
workCompany: payload.workCompany || "",
|
realAddress: payload.realAddress || payload.currentResidence || "",
|
||||||
workCompanyAccountantNumber: formatToApiPhone(payload.workHrPhone),
|
region: payload.region ?? "",
|
||||||
workRegion: payload.workRegion || "",
|
satisfiable: payload.satisfiable || "yes",
|
||||||
workProvinceId: toNum(payload.workProvince),
|
|
||||||
workSalary: payload.salary != null ? String(payload.salary) : "",
|
|
||||||
workPosition: payload.position || "",
|
|
||||||
workStartedAt: formatToApiDate(payload.workStartedAt),
|
|
||||||
loanAmount: payload.loanAmount != null ? String(payload.loanAmount) : "",
|
|
||||||
cardNumber: payload.cardNumber || "",
|
|
||||||
cardName: payload.cardName || "",
|
|
||||||
cardMonth: payload.cardExpMonth || "",
|
|
||||||
cardYear: payload.cardExpYear || "",
|
|
||||||
loanCardNumber: payload.cardNumber || "",
|
|
||||||
loanCardName: payload.cardName || "",
|
|
||||||
loanCardMonth: payload.cardExpMonth || "",
|
|
||||||
loanCardYear: payload.cardExpYear || "",
|
|
||||||
guarantorName: payload.guarantor1Name || "",
|
|
||||||
guarantorSurname: payload.guarantor1Surname || "",
|
|
||||||
guarantorPatronicName: payload.guarantor1Patronic || "",
|
|
||||||
guarantorPassportSerie: payload.guarantor1PassportSerie || "",
|
|
||||||
guarantorPassportId: payload.guarantor1PassportNumber || "",
|
|
||||||
guarantorCardNumber: payload.guarantor1CardNumber || "",
|
|
||||||
guarantorCardName: payload.guarantor1CardName || "",
|
|
||||||
guarantorCardMonth: payload.guarantor1CardExpMonth || "",
|
|
||||||
guarantorCardYear: payload.guarantor1CardExpYear || "",
|
|
||||||
guarantorNote: "",
|
|
||||||
guarantor2Name: payload.guarantor2Name || "",
|
|
||||||
guarantor2Surname: payload.guarantor2Surname || "",
|
|
||||||
guarantor2PatronicName: payload.guarantor2Patronic || "",
|
|
||||||
guarantor2PassportSerie: payload.guarantor2PassportSerie || "",
|
|
||||||
guarantor2PassportId: payload.guarantor2PassportNumber || "",
|
|
||||||
guarantor2CardNumber: payload.guarantor2CardNumber || "",
|
|
||||||
guarantor2CardName: payload.guarantor2CardName || "",
|
|
||||||
guarantor2CardMonth: payload.guarantor2CardExpMonth || "",
|
|
||||||
guarantor2CardYear: payload.guarantor2CardExpYear || "",
|
|
||||||
guarantor2Note: payload.guarantor2Note || "",
|
|
||||||
notes: payload.note || "",
|
|
||||||
passportOne: payload.passportOne || "",
|
|
||||||
passportTwo: payload.passportTwo || "",
|
|
||||||
passportThree: payload.passportThree || "",
|
|
||||||
passportFour: payload.passportFour || "",
|
|
||||||
status: payload.status ?? "pending",
|
|
||||||
satisfiable: "yes",
|
|
||||||
source: payload.source ?? "web",
|
source: payload.source ?? "web",
|
||||||
loanOrderRequiredDocId: payload.loanHistory ? Number(payload.loanHistory) : 0,
|
status: payload.status ?? "pending",
|
||||||
userId: toNum(payload.userId) ?? 0,
|
uniqueId: payload.uniqueId || "",
|
||||||
|
userId,
|
||||||
|
workCompany: payload.workCompany || "",
|
||||||
|
workCompanyAccountantNumber: formatToApiPhone(payload.workCompanyAccountantNumber || payload.workHrPhone),
|
||||||
|
workPosition: payload.workPosition || payload.position || "",
|
||||||
|
workProvinceId,
|
||||||
|
workRegion: payload.workRegion || "",
|
||||||
|
workSalary: payload.workSalary != null ? String(payload.workSalary) : payload.salary != null ? String(payload.salary) : "",
|
||||||
|
workStartedAt: formatToApiDate(payload.workStartedAt),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── API Functions ─────────────────────────────────────────────────────────────
|
// ─── API Functions ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export async function fetchLoanOrders(params: LoanOrdersParams = {}, signal?: AbortSignal): Promise<LoanOrdersResponse> {
|
export async function fetchLoanOrders(params: LoanOrdersParams = {}, signal?: AbortSignal): Promise<LoanOrdersResponse> {
|
||||||
const { page, perPage, limit, search, region, status, branch, branch_id, createdById, userId, user_id, archived } = params;
|
const { page, perPage, limit, search, region, status, branch, branch_id, createdById, userId, user_id } = params;
|
||||||
const branchId = branch || branch_id;
|
const branchId = branch || branch_id;
|
||||||
const uid = createdById || userId || user_id;
|
const uid = createdById || userId || user_id;
|
||||||
|
|
||||||
@@ -524,7 +644,6 @@ export async function fetchLoanOrders(params: LoanOrdersParams = {}, signal?: Ab
|
|||||||
status: status || undefined,
|
status: status || undefined,
|
||||||
branch_id: branchId || undefined,
|
branch_id: branchId || undefined,
|
||||||
user_id: uid || undefined,
|
user_id: uid || undefined,
|
||||||
archived: archived || undefined,
|
|
||||||
},
|
},
|
||||||
signal,
|
signal,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,55 +22,26 @@ import { useInfiniteBranches } from "@/features/shared/hooks/useSharedBranchUser
|
|||||||
import { useInfiniteProvinces } from "@/features/branches/hooks/useBranches";
|
import { useInfiniteProvinces } from "@/features/branches/hooks/useBranches";
|
||||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||||
import { formatFromApiDate, formatFromApiPhone } from "@/lib/utils";
|
import { formatFromApiDate, formatFromApiPhone } from "@/lib/utils";
|
||||||
import { PASSPORT_SERIES_OPTIONS, getStatusOptions } from "@/constants";
|
import {
|
||||||
|
PASSPORT_SERIES_OPTIONS,
|
||||||
|
getStatusOptions,
|
||||||
|
getRegionOptions,
|
||||||
|
EDUCATION_OPTIONS,
|
||||||
|
MARRIAGE_OPTIONS,
|
||||||
|
MONTH_OPTIONS,
|
||||||
|
YEAR_OPTIONS,
|
||||||
|
} from "@/constants";
|
||||||
import { useGetRequiredDocuments } from "@/features/requiredDocuments/hooks/useRequiredDocuments";
|
import { useGetRequiredDocuments } from "@/features/requiredDocuments/hooks/useRequiredDocuments";
|
||||||
import { useInfiniteClients } from "@/features/clients/hooks/useClients";
|
import { useInfiniteClients } from "@/features/clients/hooks/useClients";
|
||||||
|
|
||||||
// ─── Static options ───────────────────────────────────────────────────────────
|
// ─── Static options ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const REGION_CODES = ["AG", "AH", "BN", "DZ", "LB", "MR"] as const;
|
|
||||||
|
|
||||||
function resolveLocalizedName(name: LocalizedText | string | null | undefined, 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 ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRegionOptions(t: TFunction): SelectOption[] {
|
|
||||||
return REGION_CODES.map((code) => ({
|
|
||||||
value: code,
|
|
||||||
label: t(`loanOrders.regions.${code}`, code),
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
const EDUCATION_OPTIONS = [
|
|
||||||
{ value: "high", label: "Ýokary bilim" },
|
|
||||||
{ value: "unfinished_high", label: "Gutarylmadyk ýokary bilim" },
|
|
||||||
{ value: "masters", label: "Magistr" },
|
|
||||||
{ value: "phd", label: "Ylymlaryň doktory" },
|
|
||||||
{ value: "middle", label: "Orta mekdep" },
|
|
||||||
{ value: "school", label: "Orta bilim" },
|
|
||||||
{ value: "school_dropout", label: "Gutarylmadyk orta bilim" },
|
|
||||||
];
|
|
||||||
|
|
||||||
const MARRIAGE_OPTIONS = [
|
|
||||||
{ value: "MARRIED", label: "Öýlenen / Durmuşa çykan" },
|
|
||||||
{ value: "SINGLE", label: "Öýlenmedik / Durmuşa çykmadyk" },
|
|
||||||
{ value: "DIVORCED", label: "Aýrylşan" },
|
|
||||||
{ value: "WIDOW", label: "Adamsy ýa-da aýaly aradan çykan" },
|
|
||||||
{ value: "LEGAL", label: "Raýat nika" },
|
|
||||||
];
|
|
||||||
|
|
||||||
const MONTH_OPTIONS = Array.from({ length: 12 }, (_, i) => ({
|
|
||||||
value: String(i + 1).padStart(2, "0"),
|
|
||||||
label: String(i + 1).padStart(2, "0"),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const YEAR_OPTIONS = Array.from({ length: 15 }, (_, i) => ({
|
|
||||||
value: String(new Date().getFullYear() + i),
|
|
||||||
label: String(new Date().getFullYear() + i),
|
|
||||||
}));
|
|
||||||
|
|
||||||
// ─── Form errors helper ──────────────────────────────────────────────────────
|
// ─── Form errors helper ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
type FlatErrors = Partial<Record<keyof LoanOrderFormData, string>>;
|
type FlatErrors = Partial<Record<keyof LoanOrderFormData, string>>;
|
||||||
@@ -222,8 +193,8 @@ function StepStatus({ form, errors, set, t }: StepContentProps) {
|
|||||||
<FormInput
|
<FormInput
|
||||||
type="textarea"
|
type="textarea"
|
||||||
label={t("Note") || "Bellik"}
|
label={t("Note") || "Bellik"}
|
||||||
value={form.note}
|
value={form.notes}
|
||||||
onChange={(v) => set("note", v)}
|
onChange={(v) => set("notes", v)}
|
||||||
placeholder={t("loanOrderForm.placeholders.note") || "Bellik..."}
|
placeholder={t("loanOrderForm.placeholders.note") || "Bellik..."}
|
||||||
rows={3}
|
rows={3}
|
||||||
/>
|
/>
|
||||||
@@ -234,6 +205,7 @@ function StepStatus({ form, errors, set, t }: StepContentProps) {
|
|||||||
|
|
||||||
function StepLoan({ form, errors, set, t, initialData }: StepContentProps & { initialData?: LoanOrder }) {
|
function StepLoan({ form, errors, set, t, initialData }: StepContentProps & { initialData?: LoanOrder }) {
|
||||||
const { i18n } = useTranslation();
|
const { i18n } = useTranslation();
|
||||||
|
const { data: requiredDocsData } = useGetRequiredDocuments({ page: 1, limit: 100 });
|
||||||
const [loanTypeSearch, setLoanTypeSearch] = useState("");
|
const [loanTypeSearch, setLoanTypeSearch] = useState("");
|
||||||
const loanTypesQuery = useInfiniteLoanTypes(loanTypeSearch);
|
const loanTypesQuery = useInfiniteLoanTypes(loanTypeSearch);
|
||||||
|
|
||||||
@@ -249,38 +221,98 @@ function StepLoan({ form, errors, set, t, initialData }: StepContentProps & { in
|
|||||||
return opts;
|
return opts;
|
||||||
}, [loanTypesQuery, i18n.language, initialData]);
|
}, [loanTypesQuery, i18n.language, initialData]);
|
||||||
|
|
||||||
return (
|
const docOptions = useMemo<SelectOption[]>(
|
||||||
<BentoGrid cols={2}>
|
() =>
|
||||||
<BentoCard>
|
(requiredDocsData?.loansDocuments ?? []).map((doc) => ({
|
||||||
<InfiniteSelect
|
value: String(doc.id),
|
||||||
label={t("Loan type") || "Karz görnüşi"}
|
label: doc.name,
|
||||||
required
|
})),
|
||||||
value={form.loanType}
|
[requiredDocsData],
|
||||||
onChange={(v) => set("loanType", v)}
|
);
|
||||||
options={loanTypeOptions}
|
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
|
||||||
error={errors.loanType}
|
|
||||||
loading={loanTypesQuery.isLoading}
|
|
||||||
isLoadingMore={loanTypesQuery.isFetchingNextPage}
|
|
||||||
hasNextPage={!!loanTypesQuery.hasNextPage}
|
|
||||||
onLoadMore={() => loanTypesQuery.fetchNextPage()}
|
|
||||||
searchValue={loanTypeSearch}
|
|
||||||
onSearchChange={setLoanTypeSearch}
|
|
||||||
/>
|
|
||||||
</BentoCard>
|
|
||||||
|
|
||||||
<BentoCard>
|
return (
|
||||||
<FormInput
|
<div className="space-y-4">
|
||||||
type="number"
|
<BentoGrid cols={3}>
|
||||||
label={t("loanOrderForm.labels.loanAmount") || "Karz möçberi"}
|
<BentoCard>
|
||||||
required
|
<InfiniteSelect
|
||||||
value={form.loanAmount}
|
label={t("Loan type") || "Karz görnüşi"}
|
||||||
onChange={(v) => set("loanAmount", v)}
|
required
|
||||||
placeholder={t("loanOrderForm.placeholders.amount") || "0.00"}
|
value={form.loanType}
|
||||||
error={errors.loanAmount}
|
onChange={(v) => set("loanType", v)}
|
||||||
/>
|
options={loanTypeOptions}
|
||||||
</BentoCard>
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
</BentoGrid>
|
error={errors.loanType}
|
||||||
|
loading={loanTypesQuery.isLoading}
|
||||||
|
isLoadingMore={loanTypesQuery.isFetchingNextPage}
|
||||||
|
hasNextPage={!!loanTypesQuery.hasNextPage}
|
||||||
|
onLoadMore={() => loanTypesQuery.fetchNextPage()}
|
||||||
|
searchValue={loanTypeSearch}
|
||||||
|
onSearchChange={setLoanTypeSearch}
|
||||||
|
/>
|
||||||
|
</BentoCard>
|
||||||
|
|
||||||
|
<BentoCard>
|
||||||
|
<FormInput
|
||||||
|
type="number"
|
||||||
|
label={t("loanOrderForm.labels.loanAmount") || "Karz möçberi"}
|
||||||
|
required
|
||||||
|
value={form.loanAmount}
|
||||||
|
onChange={(v) => set("loanAmount", v)}
|
||||||
|
placeholder={t("loanOrderForm.placeholders.amount") || "0.00"}
|
||||||
|
error={errors.loanAmount}
|
||||||
|
/>
|
||||||
|
</BentoCard>
|
||||||
|
|
||||||
|
<BentoCard>
|
||||||
|
<FormInput
|
||||||
|
type="select"
|
||||||
|
label={t("loanOrderForm.labels.requiredDoc") || "Gerekli resminat"}
|
||||||
|
value={form.loanOrderRequiredDocId}
|
||||||
|
onChange={(v) => set("loanOrderRequiredDocId", v)}
|
||||||
|
options={docOptions}
|
||||||
|
placeholder={t("loanOrderForm.placeholders.select") || "Saýlaň"}
|
||||||
|
/>
|
||||||
|
</BentoCard>
|
||||||
|
</BentoGrid>
|
||||||
|
|
||||||
|
<BentoGrid cols={2}>
|
||||||
|
<BentoCard title={t("loanOrderForm.titles.loanCardInfo") || "Karz karty maglumatlary"}>
|
||||||
|
<FormInput
|
||||||
|
type="text"
|
||||||
|
label={t("Loan card number") || "Karz kart belgisi"}
|
||||||
|
value={form.loanCardNumber}
|
||||||
|
onChange={(v) => set("loanCardNumber", v)}
|
||||||
|
placeholder={t("Loan card number") || "Karz kart belgisi"}
|
||||||
|
/>
|
||||||
|
<FormInput
|
||||||
|
type="text"
|
||||||
|
label={t("Loan card name") || "Karz kartdaky ady"}
|
||||||
|
value={form.loanCardName}
|
||||||
|
onChange={(v) => set("loanCardName", v)}
|
||||||
|
placeholder={t("Loan card name") || "Karz kartdaky ady"}
|
||||||
|
/>
|
||||||
|
</BentoCard>
|
||||||
|
|
||||||
|
<BentoCard title={t("loanOrderForm.titles.loanCardExpiry") || "Karz kart möhleti"}>
|
||||||
|
<FormInput
|
||||||
|
type="searchable-select"
|
||||||
|
label={t("loanOrderForm.labels.cardExpMonth") || "Aý"}
|
||||||
|
value={form.loanCardMonth}
|
||||||
|
onChange={(v) => set("loanCardMonth", v)}
|
||||||
|
options={MONTH_OPTIONS}
|
||||||
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
|
/>
|
||||||
|
<FormInput
|
||||||
|
type="searchable-select"
|
||||||
|
label={t("loanOrderForm.labels.cardExpYear") || "Ýyl"}
|
||||||
|
value={form.loanCardYear}
|
||||||
|
onChange={(v) => set("loanCardYear", v)}
|
||||||
|
options={YEAR_OPTIONS}
|
||||||
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
|
/>
|
||||||
|
</BentoCard>
|
||||||
|
</BentoGrid>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,7 +348,7 @@ function StepLocation({ form, errors, set, t, initialData }: StepContentProps &
|
|||||||
value={form.region}
|
value={form.region}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
set("region", v);
|
set("region", v);
|
||||||
set("branch", "");
|
set("branchId", "");
|
||||||
}}
|
}}
|
||||||
options={regionOptions}
|
options={regionOptions}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
@@ -328,12 +360,12 @@ function StepLocation({ form, errors, set, t, initialData }: StepContentProps &
|
|||||||
<InfiniteSelect
|
<InfiniteSelect
|
||||||
label={t("Branch") || "Şahamça"}
|
label={t("Branch") || "Şahamça"}
|
||||||
required
|
required
|
||||||
value={form.branch}
|
value={form.branchId}
|
||||||
onChange={(v) => set("branch", v)}
|
onChange={(v) => set("branchId", v)}
|
||||||
options={branchOptions}
|
options={branchOptions}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
disabled={!form.region}
|
disabled={!form.region}
|
||||||
error={errors.branch}
|
error={errors.branchId}
|
||||||
loading={branchQuery.isLoading}
|
loading={branchQuery.isLoading}
|
||||||
isLoadingMore={branchQuery.isFetchingNextPage}
|
isLoadingMore={branchQuery.isFetchingNextPage}
|
||||||
hasNextPage={!!branchQuery.hasNextPage}
|
hasNextPage={!!branchQuery.hasNextPage}
|
||||||
@@ -347,8 +379,6 @@ function StepLocation({ form, errors, set, t, initialData }: StepContentProps &
|
|||||||
}
|
}
|
||||||
|
|
||||||
function StepPersonal({ form, errors, set, t, initialData }: StepContentProps & { initialData?: LoanOrder }) {
|
function StepPersonal({ form, errors, set, t, initialData }: StepContentProps & { initialData?: LoanOrder }) {
|
||||||
const { data: requiredDocsData } = useGetRequiredDocuments({ page: 1, limit: 100 });
|
|
||||||
|
|
||||||
const [clientSearch, setClientSearch] = useState("");
|
const [clientSearch, setClientSearch] = useState("");
|
||||||
const clientsQuery = useInfiniteClients(clientSearch);
|
const clientsQuery = useInfiniteClients(clientSearch);
|
||||||
|
|
||||||
@@ -369,15 +399,6 @@ function StepPersonal({ form, errors, set, t, initialData }: StepContentProps &
|
|||||||
return opts;
|
return opts;
|
||||||
}, [clientsQuery.data, initialData]);
|
}, [clientsQuery.data, initialData]);
|
||||||
|
|
||||||
const loanHistoryOptions = useMemo<SelectOption[]>(
|
|
||||||
() =>
|
|
||||||
(requiredDocsData?.loansDocuments ?? []).map((doc) => ({
|
|
||||||
value: String(doc.id),
|
|
||||||
label: doc.name,
|
|
||||||
})),
|
|
||||||
[requiredDocsData],
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<BentoGrid cols={1}>
|
<BentoGrid cols={1}>
|
||||||
@@ -402,25 +423,25 @@ function StepPersonal({ form, errors, set, t, initialData }: StepContentProps &
|
|||||||
type="text"
|
type="text"
|
||||||
label={t("Name") || "Ady"}
|
label={t("Name") || "Ady"}
|
||||||
required
|
required
|
||||||
value={form.firstName}
|
value={form.customerName}
|
||||||
onChange={(v) => set("firstName", v)}
|
onChange={(v) => set("customerName", v)}
|
||||||
placeholder={t("Name") || "Ady"}
|
placeholder={t("Name") || "Ady"}
|
||||||
error={errors.firstName}
|
error={errors.customerName}
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t("Surname") || "Familiýasy"}
|
label={t("Surname") || "Familiýasy"}
|
||||||
required
|
required
|
||||||
value={form.lastName}
|
value={form.customerSurname}
|
||||||
onChange={(v) => set("lastName", v)}
|
onChange={(v) => set("customerSurname", v)}
|
||||||
placeholder={t("Surname") || "Familiýasy"}
|
placeholder={t("Surname") || "Familiýasy"}
|
||||||
error={errors.lastName}
|
error={errors.customerSurname}
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t("Patronic name") || "Atasynyň ady"}
|
label={t("Patronic name") || "Atasynyň ady"}
|
||||||
value={form.patronicName}
|
value={form.customerPatronicName}
|
||||||
onChange={(v) => set("patronicName", v)}
|
onChange={(v) => set("customerPatronicName", v)}
|
||||||
placeholder={t("Patronic name") || "Atasynyň ady"}
|
placeholder={t("Patronic name") || "Atasynyň ady"}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -454,9 +475,9 @@ function StepPersonal({ form, errors, set, t, initialData }: StepContentProps &
|
|||||||
type="date"
|
type="date"
|
||||||
label={t("Date of birth") || "Doglan güni"}
|
label={t("Date of birth") || "Doglan güni"}
|
||||||
required
|
required
|
||||||
value={form.dateOfBirth}
|
value={form.bornAt}
|
||||||
onChange={(v) => set("dateOfBirth", v)}
|
onChange={(v) => set("bornAt", v)}
|
||||||
error={errors.dateOfBirth}
|
error={errors.bornAt}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
@@ -468,28 +489,27 @@ function StepPersonal({ form, errors, set, t, initialData }: StepContentProps &
|
|||||||
type="text"
|
type="text"
|
||||||
label={t("Residence (passport)") || "Ýazgy edilen salgyňyz"}
|
label={t("Residence (passport)") || "Ýazgy edilen salgyňyz"}
|
||||||
required
|
required
|
||||||
value={form.residence}
|
value={form.passportAddress}
|
||||||
onChange={(v) => set("residence", v)}
|
onChange={(v) => set("passportAddress", v)}
|
||||||
placeholder={t("loanOrderForm.placeholders.residence") || "Ýazgy edilen salgy"}
|
placeholder={t("loanOrderForm.placeholders.residence") || "Ýazgy edilen salgy"}
|
||||||
error={errors.residence}
|
error={errors.passportAddress}
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t("Current Residence") || "Häzirki ýaşaýyş ýeri"}
|
label={t("Current Residence") || "Häzirki ýaşaýyş ýeri"}
|
||||||
value={form.currentResidence}
|
value={form.realAddress}
|
||||||
onChange={(v) => set("currentResidence", v)}
|
onChange={(v) => set("realAddress", v)}
|
||||||
placeholder={t("loanOrderForm.placeholders.currentResidence") || "Häzirki ýaşaýyş ýeri"}
|
placeholder={t("loanOrderForm.placeholders.currentResidence") || "Häzirki ýaşaýyş ýeri"}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t("loanOrderForm.titles.loanHistory") || "Karz taryhy"}>
|
<BentoCard title={t("loanOrderForm.titles.bornPlace") || "Doglan ýeri"}>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="select"
|
type="text"
|
||||||
label={t("Loan history") || "Karz taryhy"}
|
label={t("Born place (passport)") || "Doglan ýeri (pasport)"}
|
||||||
value={form.loanHistory}
|
value={form.bornPlace}
|
||||||
onChange={(v) => set("loanHistory", v)}
|
onChange={(v) => set("bornPlace", v)}
|
||||||
options={loanHistoryOptions}
|
placeholder={t("Born place (passport)") || "Doglan ýeri (pasport)"}
|
||||||
placeholder={t("loanOrderForm.placeholders.select") || "Saýlaň"}
|
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
@@ -526,21 +546,21 @@ function StepCard({ form, errors, set, t }: StepContentProps) {
|
|||||||
type="searchable-select"
|
type="searchable-select"
|
||||||
label={t("loanOrderForm.labels.cardExpMonth") || "Aý"}
|
label={t("loanOrderForm.labels.cardExpMonth") || "Aý"}
|
||||||
required
|
required
|
||||||
value={form.cardExpMonth}
|
value={form.cardMonth}
|
||||||
onChange={(v) => set("cardExpMonth", v)}
|
onChange={(v) => set("cardMonth", v)}
|
||||||
options={MONTH_OPTIONS}
|
options={MONTH_OPTIONS}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
error={errors.cardExpMonth}
|
error={errors.cardMonth}
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="searchable-select"
|
type="searchable-select"
|
||||||
label={t("loanOrderForm.labels.cardExpYear") || "Ýyl"}
|
label={t("loanOrderForm.labels.cardExpYear") || "Ýyl"}
|
||||||
required
|
required
|
||||||
value={form.cardExpYear}
|
value={form.cardYear}
|
||||||
onChange={(v) => set("cardExpYear", v)}
|
onChange={(v) => set("cardYear", v)}
|
||||||
options={YEAR_OPTIONS}
|
options={YEAR_OPTIONS}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
error={errors.cardExpYear}
|
error={errors.cardYear}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
@@ -568,10 +588,10 @@ function StepPassport({ form, errors, set, t, mode }: StepContentProps & { mode:
|
|||||||
type="text"
|
type="text"
|
||||||
label={t("Passport id") || "Pasport belgisi"}
|
label={t("Passport id") || "Pasport belgisi"}
|
||||||
required
|
required
|
||||||
value={form.passportNumber}
|
value={form.passportId}
|
||||||
onChange={(v) => set("passportNumber", v)}
|
onChange={(v) => set("passportId", v)}
|
||||||
placeholder={t("Passport id") || "Pasport belgisi"}
|
placeholder={t("Passport id") || "Pasport belgisi"}
|
||||||
error={errors.passportNumber}
|
error={errors.passportId}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
<BentoCard>
|
<BentoCard>
|
||||||
@@ -579,14 +599,14 @@ function StepPassport({ form, errors, set, t, mode }: StepContentProps & { mode:
|
|||||||
type="date"
|
type="date"
|
||||||
label={t("Passport date of issue") || "Pasport berlen senesi"}
|
label={t("Passport date of issue") || "Pasport berlen senesi"}
|
||||||
required
|
required
|
||||||
value={form.passportDateOfIssue}
|
value={form.passportGivenAt}
|
||||||
onChange={(v) => set("passportDateOfIssue", v)}
|
onChange={(v) => set("passportGivenAt", v)}
|
||||||
error={errors.passportDateOfIssue}
|
error={errors.passportGivenAt}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
|
|
||||||
<BentoGrid cols={2}>
|
<BentoGrid cols={1}>
|
||||||
<BentoCard>
|
<BentoCard>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
@@ -598,15 +618,6 @@ function StepPassport({ form, errors, set, t, mode }: StepContentProps & { mode:
|
|||||||
error={errors.passportGivenBy}
|
error={errors.passportGivenBy}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
<BentoCard>
|
|
||||||
<FormInput
|
|
||||||
type="text"
|
|
||||||
label={t("Born place (passport)") || "Doglan ýeri (pasport)"}
|
|
||||||
value={form.bornPlace}
|
|
||||||
onChange={(v) => set("bornPlace", v)}
|
|
||||||
placeholder={t("Born place (passport)") || "Doglan ýeri (pasport)"}
|
|
||||||
/>
|
|
||||||
</BentoCard>
|
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
|
|
||||||
<BentoGrid cols={2}>
|
<BentoGrid cols={2}>
|
||||||
@@ -696,10 +707,10 @@ function StepContact({ form, errors, set, t }: StepContentProps) {
|
|||||||
<FormInput
|
<FormInput
|
||||||
type="phone"
|
type="phone"
|
||||||
label={t("Home phone") || "Öý telefony"}
|
label={t("Home phone") || "Öý telefony"}
|
||||||
value={form.homePhone}
|
value={form.phoneHome}
|
||||||
onChange={(v) => set("homePhone", v)}
|
onChange={(v) => set("phoneHome", v)}
|
||||||
placeholder={t("loanOrderForm.placeholders.phone") || "61 097 651"}
|
placeholder={t("loanOrderForm.placeholders.phone") || "61 097 651"}
|
||||||
error={errors.homePhone}
|
error={errors.phoneHome}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
@@ -719,8 +730,8 @@ function StepJob({ form, errors, set, t, initialData }: StepContentProps & { ini
|
|||||||
.flatMap((p) => p?.provinces ?? [])
|
.flatMap((p) => p?.provinces ?? [])
|
||||||
.map((prov) => ({ value: String(prov.id), label: resolveLocalizedName(prov.name, lang) || String(prov.id) }));
|
.map((prov) => ({ value: String(prov.id), label: resolveLocalizedName(prov.name, lang) || String(prov.id) }));
|
||||||
|
|
||||||
if (initialData?.workCityId && !opts.some((o) => o.value === String(initialData.workCityId))) {
|
if (initialData?.workProvinceId && !opts.some((o) => o.value === String(initialData.workProvinceId))) {
|
||||||
opts.unshift({ value: String(initialData.workCityId), label: initialData.workCity || String(initialData.workCityId) });
|
opts.unshift({ value: String(initialData.workProvinceId), label: initialData.workProvince || String(initialData.workProvinceId) });
|
||||||
}
|
}
|
||||||
return opts;
|
return opts;
|
||||||
}, [provinceQuery, i18n.language, initialData]);
|
}, [provinceQuery, i18n.language, initialData]);
|
||||||
@@ -741,10 +752,10 @@ function StepJob({ form, errors, set, t, initialData }: StepContentProps & { ini
|
|||||||
<FormInput
|
<FormInput
|
||||||
type="phone"
|
type="phone"
|
||||||
label={t("HR department work number") || "Işgärler bölüminiň iş belgisi"}
|
label={t("HR department work number") || "Işgärler bölüminiň iş belgisi"}
|
||||||
value={form.workHrPhone}
|
value={form.workCompanyAccountantNumber}
|
||||||
onChange={(v) => set("workHrPhone", v)}
|
onChange={(v) => set("workCompanyAccountantNumber", v)}
|
||||||
placeholder={t("loanOrderForm.placeholders.phone") || "61 097 651"}
|
placeholder={t("loanOrderForm.placeholders.phone") || "61 097 651"}
|
||||||
error={errors.workHrPhone}
|
error={errors.workCompanyAccountantNumber}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
@@ -759,8 +770,8 @@ function StepJob({ form, errors, set, t, initialData }: StepContentProps & { ini
|
|||||||
/>
|
/>
|
||||||
<InfiniteSelect
|
<InfiniteSelect
|
||||||
label={t("Work province") || "Işleýän etrabyňyz"}
|
label={t("Work province") || "Işleýän etrabyňyz"}
|
||||||
value={form.workProvince}
|
value={form.workProvinceId}
|
||||||
onChange={(v) => set("workProvince", v)}
|
onChange={(v) => set("workProvinceId", v)}
|
||||||
options={provinceOptions}
|
options={provinceOptions}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
loading={provinceQuery.isLoading}
|
loading={provinceQuery.isLoading}
|
||||||
@@ -779,10 +790,10 @@ function StepJob({ form, errors, set, t, initialData }: StepContentProps & { ini
|
|||||||
type="text"
|
type="text"
|
||||||
label={t("Position") || "Wezipe"}
|
label={t("Position") || "Wezipe"}
|
||||||
required
|
required
|
||||||
value={form.position}
|
value={form.workPosition}
|
||||||
onChange={(v) => set("position", v)}
|
onChange={(v) => set("workPosition", v)}
|
||||||
placeholder={t("Position") || "Wezipe"}
|
placeholder={t("Position") || "Wezipe"}
|
||||||
error={errors.position}
|
error={errors.workPosition}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
<BentoCard>
|
<BentoCard>
|
||||||
@@ -790,10 +801,10 @@ function StepJob({ form, errors, set, t, initialData }: StepContentProps & { ini
|
|||||||
type="number"
|
type="number"
|
||||||
label={t("Salary") || "Zähmet haky"}
|
label={t("Salary") || "Zähmet haky"}
|
||||||
required
|
required
|
||||||
value={form.salary}
|
value={form.workSalary}
|
||||||
onChange={(v) => set("salary", v)}
|
onChange={(v) => set("workSalary", v)}
|
||||||
placeholder={t("Salary") || "Zähmet haky"}
|
placeholder={t("Salary") || "Zähmet haky"}
|
||||||
error={errors.salary}
|
error={errors.workSalary}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
<BentoCard>
|
<BentoCard>
|
||||||
@@ -820,10 +831,10 @@ function StepGuarantor({ form, errors, set, t }: StepContentProps) {
|
|||||||
type="text"
|
type="text"
|
||||||
label={t("Guarantor name") || "Zamunyň ady"}
|
label={t("Guarantor name") || "Zamunyň ady"}
|
||||||
required
|
required
|
||||||
value={form.guarantor1Name}
|
value={form.guarantorName}
|
||||||
onChange={(v) => set("guarantor1Name", v)}
|
onChange={(v) => set("guarantorName", v)}
|
||||||
placeholder={t("Guarantor name") || "Zamunyň ady"}
|
placeholder={t("Guarantor name") || "Zamunyň ady"}
|
||||||
error={errors.guarantor1Name}
|
error={errors.guarantorName}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
<BentoCard>
|
<BentoCard>
|
||||||
@@ -831,18 +842,18 @@ function StepGuarantor({ form, errors, set, t }: StepContentProps) {
|
|||||||
type="text"
|
type="text"
|
||||||
label={t("Guarantor Surname") || "Zamunyň familiýasy"}
|
label={t("Guarantor Surname") || "Zamunyň familiýasy"}
|
||||||
required
|
required
|
||||||
value={form.guarantor1Surname}
|
value={form.guarantorSurname}
|
||||||
onChange={(v) => set("guarantor1Surname", v)}
|
onChange={(v) => set("guarantorSurname", v)}
|
||||||
placeholder={t("Guarantor Surname") || "Zamunyň familiýasy"}
|
placeholder={t("Guarantor Surname") || "Zamunyň familiýasy"}
|
||||||
error={errors.guarantor1Surname}
|
error={errors.guarantorSurname}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
<BentoCard>
|
<BentoCard>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t("Guarantor Patronic name") || "Zamunyň atasynyň ady"}
|
label={t("Guarantor Patronic name") || "Zamunyň atasynyň ady"}
|
||||||
value={form.guarantor1Patronic}
|
value={form.guarantorPatronicName}
|
||||||
onChange={(v) => set("guarantor1Patronic", v)}
|
onChange={(v) => set("guarantorPatronicName", v)}
|
||||||
placeholder={t("Guarantor Patronic name") || "Zamunyň atasynyň ady"}
|
placeholder={t("Guarantor Patronic name") || "Zamunyň atasynyň ady"}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
@@ -854,11 +865,11 @@ function StepGuarantor({ form, errors, set, t }: StepContentProps) {
|
|||||||
type="searchable-select"
|
type="searchable-select"
|
||||||
label={t("Passport serie") || "Pasport seriýasy"}
|
label={t("Passport serie") || "Pasport seriýasy"}
|
||||||
required
|
required
|
||||||
value={form.guarantor1PassportSerie}
|
value={form.guarantorPassportSerie}
|
||||||
onChange={(v) => set("guarantor1PassportSerie", v)}
|
onChange={(v) => set("guarantorPassportSerie", v)}
|
||||||
options={PASSPORT_SERIES_OPTIONS}
|
options={PASSPORT_SERIES_OPTIONS}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
error={errors.guarantor1PassportSerie}
|
error={errors.guarantorPassportSerie}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
<BentoCard>
|
<BentoCard>
|
||||||
@@ -866,65 +877,66 @@ function StepGuarantor({ form, errors, set, t }: StepContentProps) {
|
|||||||
type="text"
|
type="text"
|
||||||
label={t("Passport id") || "Pasport belgisi"}
|
label={t("Passport id") || "Pasport belgisi"}
|
||||||
required
|
required
|
||||||
value={form.guarantor1PassportNumber}
|
value={form.guarantorPassportId}
|
||||||
onChange={(v) => set("guarantor1PassportNumber", v)}
|
onChange={(v) => set("guarantorPassportId", v)}
|
||||||
placeholder={t("Passport id") || "Pasport belgisi"}
|
placeholder={t("Passport id") || "Pasport belgisi"}
|
||||||
error={errors.guarantor1PassportNumber}
|
error={errors.guarantorPassportId}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
|
|
||||||
<BentoGrid cols={2}>
|
<BentoGrid cols={2}>
|
||||||
<BentoCard>
|
<BentoCard title={t("loanOrderForm.titles.cardInfo") || "Kart maglumatlary"}>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t("Card number") || "Kart belgisi"}
|
label={t("Card number") || "Kart belgisi"}
|
||||||
required
|
required
|
||||||
value={form.guarantor1CardNumber}
|
value={form.guarantorCardNumber}
|
||||||
onChange={(v) => set("guarantor1CardNumber", v)}
|
onChange={(v) => set("guarantorCardNumber", v)}
|
||||||
placeholder={t("Card number") || "Kart belgisi"}
|
placeholder={t("Card number") || "Kart belgisi"}
|
||||||
error={errors.guarantor1CardNumber}
|
error={errors.guarantorCardNumber}
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t("Name on card") || "Kartdaky ady"}
|
label={t("Name on card") || "Kartdaky ady"}
|
||||||
required
|
required
|
||||||
value={form.guarantor1CardName}
|
value={form.guarantorCardName}
|
||||||
onChange={(v) => set("guarantor1CardName", v)}
|
onChange={(v) => set("guarantorCardName", v)}
|
||||||
placeholder={t("Name on card") || "Kartdaky ady"}
|
placeholder={t("Name on card") || "Kartdaky ady"}
|
||||||
error={errors.guarantor1CardName}
|
error={errors.guarantorCardName}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard>
|
<BentoCard title={t("loanOrderForm.titles.cardExpiry") || "Kart möhleti we bellik"}>
|
||||||
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
|
<FormInput
|
||||||
|
type="searchable-select"
|
||||||
|
label={t("Expiration month") || "Möhleti (aý)"}
|
||||||
|
required
|
||||||
|
value={form.guarantorCardMonth}
|
||||||
|
onChange={(v) => set("guarantorCardMonth", v)}
|
||||||
|
options={MONTH_OPTIONS}
|
||||||
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
|
error={errors.guarantorCardMonth}
|
||||||
|
/>
|
||||||
|
<FormInput
|
||||||
|
type="searchable-select"
|
||||||
|
label={t("Expiration year") || "Möhleti (ýyl)"}
|
||||||
|
required
|
||||||
|
value={form.guarantorCardYear}
|
||||||
|
onChange={(v) => set("guarantorCardYear", v)}
|
||||||
|
options={YEAR_OPTIONS}
|
||||||
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
|
error={errors.guarantorCardYear}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="searchable-select"
|
type="textarea"
|
||||||
label={t("Expiration month") || "Möhleti (aý)"}
|
label={t("Guarantor Note") || "Zamun belligi"}
|
||||||
required
|
value={form.guarantorNote}
|
||||||
value={form.guarantor1CardExpMonth}
|
onChange={(v) => set("guarantorNote", v)}
|
||||||
onChange={(v) => set("guarantor1CardExpMonth", v)}
|
placeholder={t("loanOrderForm.placeholders.note") || "Bellik..."}
|
||||||
options={MONTH_OPTIONS}
|
rows={2}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
|
||||||
error={errors.guarantor1CardExpMonth}
|
|
||||||
/>
|
|
||||||
<FormInput
|
|
||||||
type="searchable-select"
|
|
||||||
label={t("Expiration year") || "Möhleti (ýyl)"}
|
|
||||||
required
|
|
||||||
value={form.guarantor1CardExpYear}
|
|
||||||
onChange={(v) => set("guarantor1CardExpYear", v)}
|
|
||||||
options={YEAR_OPTIONS}
|
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
|
||||||
error={errors.guarantor1CardExpYear}
|
|
||||||
/>
|
|
||||||
<FormInput
|
|
||||||
type="number"
|
|
||||||
label={t("loanOrderForm.labels.guarantor1Salary") || "Ortaca zähmet haky"}
|
|
||||||
required
|
|
||||||
value={form.guarantor1Salary}
|
|
||||||
onChange={(v) => set("guarantor1Salary", v)}
|
|
||||||
placeholder={t("loanOrderForm.labels.guarantor1Salary") || "Ortaca zähmet haky"}
|
|
||||||
error={errors.guarantor1Salary}
|
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
@@ -960,8 +972,8 @@ function StepGuarantor2({ form, errors, set, t }: StepContentProps) {
|
|||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t("Guarantor 2 Patronic name") || "2. Zamunyň atasynyň ady"}
|
label={t("Guarantor 2 Patronic name") || "2. Zamunyň atasynyň ady"}
|
||||||
value={form.guarantor2Patronic}
|
value={form.guarantor2PatronicName}
|
||||||
onChange={(v) => set("guarantor2Patronic", v)}
|
onChange={(v) => set("guarantor2PatronicName", v)}
|
||||||
placeholder={t("Guarantor 2 Patronic name") || "2. Zamunyň atasynyň ady"}
|
placeholder={t("Guarantor 2 Patronic name") || "2. Zamunyň atasynyň ady"}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
@@ -983,16 +995,16 @@ function StepGuarantor2({ form, errors, set, t }: StepContentProps) {
|
|||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t("Passport id") || "Pasport belgisi"}
|
label={t("Passport id") || "Pasport belgisi"}
|
||||||
value={form.guarantor2PassportNumber}
|
value={form.guarantor2PassportId}
|
||||||
onChange={(v) => set("guarantor2PassportNumber", v)}
|
onChange={(v) => set("guarantor2PassportId", v)}
|
||||||
placeholder={t("Passport id") || "Pasport belgisi"}
|
placeholder={t("Passport id") || "Pasport belgisi"}
|
||||||
error={errors.guarantor2PassportNumber}
|
error={errors.guarantor2PassportId}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
|
|
||||||
<BentoGrid cols={2}>
|
<BentoGrid cols={2}>
|
||||||
<BentoCard>
|
<BentoCard title={t("loanOrderForm.titles.cardInfo") || "Kart maglumatlary"}>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t("Card number") || "Kart belgisi"}
|
label={t("Card number") || "Kart belgisi"}
|
||||||
@@ -1011,25 +1023,27 @@ function StepGuarantor2({ form, errors, set, t }: StepContentProps) {
|
|||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard>
|
<BentoCard title={t("loanOrderForm.titles.cardExpiry") || "Kart möhleti we bellik"}>
|
||||||
<FormInput
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
type="searchable-select"
|
<FormInput
|
||||||
label={t("Expiration month") || "Möhleti (aý)"}
|
type="searchable-select"
|
||||||
value={form.guarantor2CardExpMonth}
|
label={t("Expiration month") || "Möhleti (aý)"}
|
||||||
onChange={(v) => set("guarantor2CardExpMonth", v)}
|
value={form.guarantor2CardMonth}
|
||||||
options={MONTH_OPTIONS}
|
onChange={(v) => set("guarantor2CardMonth", v)}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
options={MONTH_OPTIONS}
|
||||||
error={errors.guarantor2CardExpMonth}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
/>
|
error={errors.guarantor2CardMonth}
|
||||||
<FormInput
|
/>
|
||||||
type="searchable-select"
|
<FormInput
|
||||||
label={t("Expiration year") || "Möhleti (ýyl)"}
|
type="searchable-select"
|
||||||
value={form.guarantor2CardExpYear}
|
label={t("Expiration year") || "Möhleti (ýyl)"}
|
||||||
onChange={(v) => set("guarantor2CardExpYear", v)}
|
value={form.guarantor2CardYear}
|
||||||
options={YEAR_OPTIONS}
|
onChange={(v) => set("guarantor2CardYear", v)}
|
||||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
options={YEAR_OPTIONS}
|
||||||
error={errors.guarantor2CardExpYear}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
/>
|
error={errors.guarantor2CardYear}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="textarea"
|
type="textarea"
|
||||||
label={t("Guarantor Note") || "Zamun belligi"}
|
label={t("Guarantor Note") || "Zamun belligi"}
|
||||||
@@ -1100,6 +1114,7 @@ export function LoanOrderForm({ mode, initialData }: LoanOrderFormProps) {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}, [form, mode, submittedSteps, i18n.language]);
|
}, [form, mode, submittedSteps, i18n.language]);
|
||||||
|
|
||||||
const errors = useMemo(() => {
|
const errors = useMemo(() => {
|
||||||
const fromRHF = flattenErrors(rhfErrors as Record<string, { message?: string } | undefined>);
|
const fromRHF = flattenErrors(rhfErrors as Record<string, { message?: string } | undefined>);
|
||||||
return { ...fromRHF, ...allSubmittedErrors };
|
return { ...fromRHF, ...allSubmittedErrors };
|
||||||
@@ -1247,64 +1262,75 @@ export function LoanOrderForm({ mode, initialData }: LoanOrderFormProps) {
|
|||||||
function mapInitial(order: LoanOrder): Partial<LoanOrderFormData> {
|
function mapInitial(order: LoanOrder): Partial<LoanOrderFormData> {
|
||||||
return {
|
return {
|
||||||
status: order.status ?? "pending",
|
status: order.status ?? "pending",
|
||||||
|
notes: order.notes ?? order.note ?? "",
|
||||||
|
source: order.source ?? "web",
|
||||||
|
satisfiable: order.satisfiable ?? "yes",
|
||||||
loanType: order.loanTypeId != null ? String(order.loanTypeId) : "",
|
loanType: order.loanTypeId != null ? String(order.loanTypeId) : "",
|
||||||
|
loanAmount: order.loanAmount != null ? String(order.loanAmount) : "",
|
||||||
|
loanOrderRequiredDocId:
|
||||||
|
order.loanOrderRequiredDocId != null
|
||||||
|
? String(order.loanOrderRequiredDocId)
|
||||||
|
: order.loanOrderRequiredDoc?.id != null
|
||||||
|
? String(order.loanOrderRequiredDoc.id)
|
||||||
|
: (order.loanHistory ?? ""),
|
||||||
|
loanCardNumber: order.loanCardNumber ?? "",
|
||||||
|
loanCardName: order.loanCardName ?? "",
|
||||||
|
loanCardMonth: order.loanCardMonth ?? "",
|
||||||
|
loanCardYear: order.loanCardYear ?? "",
|
||||||
region: order.region ?? "AG",
|
region: order.region ?? "AG",
|
||||||
branch: order.branchId != null ? String(order.branchId) : "",
|
branchId: order.branchId != null ? String(order.branchId) : "",
|
||||||
userId: order.createdById != null ? String(order.createdById) : "",
|
userId: order.createdById != null ? String(order.createdById) : order.user?.id != null ? String(order.user.id) : "",
|
||||||
firstName: order.firstName ?? "",
|
customerName: order.customerName ?? order.firstName ?? "",
|
||||||
lastName: order.lastName ?? "",
|
customerSurname: order.customerSurname ?? order.lastName ?? "",
|
||||||
patronicName: order.patronicName ?? "",
|
customerPatronicName: order.customerPatronicName ?? order.patronicName ?? "",
|
||||||
education: order.education ?? "",
|
education: order.education ?? "",
|
||||||
marriageStatus: order.marriageStatus ?? "",
|
marriageStatus: order.marriageStatus ?? "",
|
||||||
dateOfBirth: formatFromApiDate(order.dateOfBirth),
|
bornAt: formatFromApiDate(order.bornAt ?? order.dateOfBirth),
|
||||||
residence: order.residence ?? "",
|
|
||||||
currentResidence: order.currentResidence ?? "",
|
|
||||||
passportSerie: order.passportSerie ?? "",
|
|
||||||
passportNumber: order.passportNumber ?? "",
|
|
||||||
passportDateOfIssue: formatFromApiDate(order.passportDateOfIssue),
|
|
||||||
passportGivenBy: order.passportGivenBy ?? "",
|
|
||||||
passportOne: order.passportPage1Url ?? "",
|
|
||||||
passportTwo: order.passportPage23Url ?? "",
|
|
||||||
passportThree: order.passportPage89Url ?? "",
|
|
||||||
passportFour: order.passportPage32Url ?? "",
|
|
||||||
bornPlace: order.bornPlace ?? "",
|
bornPlace: order.bornPlace ?? "",
|
||||||
email: order.email ?? "",
|
passportAddress: order.passportAddress ?? order.residence ?? "",
|
||||||
phone: formatFromApiPhone(order.phone),
|
realAddress: order.realAddress ?? order.currentResidence ?? "",
|
||||||
phoneAdditional: formatFromApiPhone(order.phoneAdditional),
|
|
||||||
homePhone: formatFromApiPhone(order.homePhone),
|
|
||||||
workCompany: order.workCompany ?? "",
|
|
||||||
workHrPhone: formatFromApiPhone(order.workHrPhone),
|
|
||||||
workRegion: order.workRegion ?? "AG",
|
|
||||||
workProvince: order.workCityId != null ? String(order.workCityId) : "",
|
|
||||||
position: order.position ?? "",
|
|
||||||
salary: order.salary != null ? String(order.salary) : "",
|
|
||||||
workStartedAt: formatFromApiDate(order.workStartedAt),
|
|
||||||
note: order.note ?? "",
|
|
||||||
loanAmount: order.loanAmount != null ? String(order.loanAmount) : "",
|
|
||||||
loanHistory: order.loanHistory ?? "",
|
|
||||||
cardNumber: order.cardNumber ?? "",
|
cardNumber: order.cardNumber ?? "",
|
||||||
cardName: order.cardName ?? "",
|
cardName: order.cardName ?? "",
|
||||||
cardExpMonth: order.cardExpMonth ?? "",
|
cardMonth: order.cardMonth ?? order.cardExpMonth ?? "",
|
||||||
cardExpYear: order.cardExpYear ?? "",
|
cardYear: order.cardYear ?? order.cardExpYear ?? "",
|
||||||
guarantor1Name: order.guarantor1Name ?? "",
|
passportSerie: order.passportSerie ?? "",
|
||||||
guarantor1Surname: order.guarantor1Surname ?? "",
|
passportId: order.passportId ?? order.passportNumber ?? "",
|
||||||
guarantor1Patronic: order.guarantor1Patronic ?? "",
|
passportGivenAt: formatFromApiDate(order.passportGivenAt ?? order.passportDateOfIssue),
|
||||||
guarantor1PassportSerie: order.guarantor1PassportSerie ?? "",
|
passportGivenBy: order.passportGivenBy ?? "",
|
||||||
guarantor1PassportNumber: order.guarantor1PassportNumber ?? "",
|
passportOne: order.passportOne ?? order.passportPage1Url ?? "",
|
||||||
guarantor1CardNumber: order.guarantor1CardNumber ?? "",
|
passportTwo: order.passportTwo ?? order.passportPage23Url ?? "",
|
||||||
guarantor1CardName: order.guarantor1CardName ?? "",
|
passportThree: order.passportThree ?? order.passportPage89Url ?? "",
|
||||||
guarantor1CardExpMonth: order.guarantor1CardExpMonth ?? "",
|
passportFour: order.passportFour ?? order.passportPage32Url ?? "",
|
||||||
guarantor1CardExpYear: order.guarantor1CardExpYear ?? "",
|
phone: formatFromApiPhone(order.phone),
|
||||||
guarantor1Salary: order.guarantor1Salary != null ? String(order.guarantor1Salary) : "",
|
phoneAdditional: formatFromApiPhone(order.phoneAdditional),
|
||||||
|
phoneHome: formatFromApiPhone(order.phoneHome ?? order.homePhone),
|
||||||
|
email: order.email ?? "",
|
||||||
|
workCompany: order.workCompany ?? "",
|
||||||
|
workCompanyAccountantNumber: formatFromApiPhone(order.workCompanyAccountantNumber ?? order.workHrPhone),
|
||||||
|
workRegion: order.workRegion ?? "AG",
|
||||||
|
workProvinceId: order.workProvinceId != null ? String(order.workProvinceId) : order.workCityId != null ? String(order.workCityId) : "",
|
||||||
|
workPosition: order.workPosition ?? order.position ?? "",
|
||||||
|
workSalary: order.workSalary != null ? String(order.workSalary) : order.salary != null ? String(order.salary) : "",
|
||||||
|
workStartedAt: formatFromApiDate(order.workStartedAt),
|
||||||
|
guarantorName: order.guarantorName ?? order.guarantor1Name ?? "",
|
||||||
|
guarantorSurname: order.guarantorSurname ?? order.guarantor1Surname ?? "",
|
||||||
|
guarantorPatronicName: order.guarantorPatronicName ?? order.guarantor1Patronic ?? "",
|
||||||
|
guarantorPassportSerie: order.guarantorPassportSerie ?? order.guarantor1PassportSerie ?? "",
|
||||||
|
guarantorPassportId: order.guarantorPassportId ?? order.guarantor1PassportNumber ?? "",
|
||||||
|
guarantorCardNumber: order.guarantorCardNumber ?? order.guarantor1CardNumber ?? "",
|
||||||
|
guarantorCardName: order.guarantorCardName ?? order.guarantor1CardName ?? "",
|
||||||
|
guarantorCardMonth: order.guarantorCardMonth ?? order.guarantor1CardExpMonth ?? "",
|
||||||
|
guarantorCardYear: order.guarantorCardYear ?? order.guarantor1CardExpYear ?? "",
|
||||||
|
guarantorNote: order.guarantorNote ?? order.guarantor1Note ?? "",
|
||||||
guarantor2Name: order.guarantor2Name ?? "",
|
guarantor2Name: order.guarantor2Name ?? "",
|
||||||
guarantor2Surname: order.guarantor2Surname ?? "",
|
guarantor2Surname: order.guarantor2Surname ?? "",
|
||||||
guarantor2Patronic: order.guarantor2Patronic ?? "",
|
guarantor2PatronicName: order.guarantor2PatronicName ?? order.guarantor2Patronic ?? "",
|
||||||
guarantor2PassportSerie: order.guarantor2PassportSerie ?? "",
|
guarantor2PassportSerie: order.guarantor2PassportSerie ?? "",
|
||||||
guarantor2PassportNumber: order.guarantor2PassportNumber ?? "",
|
guarantor2PassportId: order.guarantor2PassportId ?? order.guarantor2PassportNumber ?? "",
|
||||||
guarantor2CardNumber: order.guarantor2CardNumber ?? "",
|
guarantor2CardNumber: order.guarantor2CardNumber ?? "",
|
||||||
guarantor2CardName: order.guarantor2CardName ?? "",
|
guarantor2CardName: order.guarantor2CardName ?? "",
|
||||||
guarantor2CardExpMonth: order.guarantor2CardExpMonth ?? "",
|
guarantor2CardMonth: order.guarantor2CardMonth ?? order.guarantor2CardExpMonth ?? "",
|
||||||
guarantor2CardExpYear: order.guarantor2CardExpYear ?? "",
|
guarantor2CardYear: order.guarantor2CardYear ?? order.guarantor2CardExpYear ?? "",
|
||||||
guarantor2Note: order.guarantor2Note ?? "",
|
guarantor2Note: order.guarantor2Note ?? "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -2,134 +2,120 @@ import { z } from "zod";
|
|||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
|
|
||||||
const VALID_PHONE_PREFIXES = ["61", "62", "63", "64", "65", "71"];
|
const VALID_PHONE_PREFIXES = ["61", "62", "63", "64", "65", "71"];
|
||||||
|
|
||||||
export const loanOrderFormSchema = z.object({
|
export const loanOrderFormSchema = z.object({
|
||||||
|
// ── Step 0: Status & Notes ────────────────────────
|
||||||
status: z.string().min(1, "validation.required"),
|
status: z.string().min(1, "validation.required"),
|
||||||
|
notes: z.string().optional(),
|
||||||
|
source: z.string().optional(),
|
||||||
|
satisfiable: z.string().optional(),
|
||||||
|
|
||||||
|
// ── Step 1: Loan & Loan Card ──────────────────────
|
||||||
loanType: z.string().min(1, "validation.required"),
|
loanType: z.string().min(1, "validation.required"),
|
||||||
|
loanAmount: z.string().min(1, "validation.required"),
|
||||||
|
loanOrderRequiredDocId: z.string().optional(),
|
||||||
|
loanCardNumber: z.string().optional(),
|
||||||
|
loanCardName: z.string().optional(),
|
||||||
|
loanCardMonth: z.string().optional(),
|
||||||
|
loanCardYear: z.string().optional(),
|
||||||
|
|
||||||
|
// ── Step 2: Location ──────────────────────────────
|
||||||
region: z.string().min(1, "validation.required"),
|
region: z.string().min(1, "validation.required"),
|
||||||
branch: z.string().min(1, "validation.required"),
|
branchId: z.string().min(1, "validation.required"),
|
||||||
|
|
||||||
|
// ── Step 3: Personal ──────────────────────────────
|
||||||
userId: z.string().min(1, "validation.required"),
|
userId: z.string().min(1, "validation.required"),
|
||||||
firstName: z.string().min(1, "validation.required"),
|
customerName: z.string().min(1, "validation.required"),
|
||||||
lastName: z.string().min(1, "validation.required"),
|
customerSurname: z.string().min(1, "validation.required"),
|
||||||
patronicName: z.string().optional(),
|
customerPatronicName: z.string().optional(),
|
||||||
education: z.string().min(1, "validation.required"),
|
education: z.string().min(1, "validation.required"),
|
||||||
marriageStatus: z.string().min(1, "validation.required"),
|
marriageStatus: z.string().min(1, "validation.required"),
|
||||||
dateOfBirth: z.string().min(1, "validation.required"),
|
bornAt: z.string().min(1, "validation.required"),
|
||||||
residence: z.string().min(1, "validation.required"),
|
|
||||||
currentResidence: z.string().optional(),
|
|
||||||
passportSerie: z.string().min(1, "validation.required"),
|
|
||||||
passportNumber: z.string().min(1, "validation.required"),
|
|
||||||
passportDateOfIssue: z.string().min(1, "validation.required"),
|
|
||||||
passportGivenBy: z.string().min(1, "validation.required"),
|
|
||||||
bornPlace: z.string().optional(),
|
bornPlace: z.string().optional(),
|
||||||
email: z.string().optional(),
|
passportAddress: z.string().min(1, "validation.required"),
|
||||||
phone: z
|
realAddress: z.string().optional(),
|
||||||
.string()
|
|
||||||
.min(1, "validation.required")
|
|
||||||
.refine(
|
|
||||||
(val) => {
|
|
||||||
const digits = val.replace(/\D/g, "");
|
|
||||||
return digits.length === 8;
|
|
||||||
},
|
|
||||||
{ message: "validation.invalidPhone" },
|
|
||||||
)
|
|
||||||
.refine(
|
|
||||||
(val) => {
|
|
||||||
const digits = val.replace(/\D/g, "");
|
|
||||||
const prefix = digits.slice(0, 2);
|
|
||||||
return VALID_PHONE_PREFIXES.includes(prefix);
|
|
||||||
},
|
|
||||||
{ message: "validation.invalidPhonePrefix" },
|
|
||||||
),
|
|
||||||
phoneAdditional: z
|
|
||||||
.string()
|
|
||||||
.refine(
|
|
||||||
(val) => {
|
|
||||||
if (!val || val.replace(/\D/g, "").length === 0) return true;
|
|
||||||
const digits = val.replace(/\D/g, "");
|
|
||||||
return digits.length === 8;
|
|
||||||
},
|
|
||||||
{ message: "validation.invalidPhone" },
|
|
||||||
)
|
|
||||||
.refine(
|
|
||||||
(val) => {
|
|
||||||
if (!val || val.replace(/\D/g, "").length === 0) return true;
|
|
||||||
const digits = val.replace(/\D/g, "");
|
|
||||||
return VALID_PHONE_PREFIXES.includes(digits.slice(0, 2));
|
|
||||||
},
|
|
||||||
{ message: "validation.invalidPhonePrefix" },
|
|
||||||
)
|
|
||||||
.optional(),
|
|
||||||
|
|
||||||
homePhone: z
|
// ── Step 4: Salary Card ───────────────────────────
|
||||||
.string()
|
cardNumber: z.string().min(1, "validation.required"),
|
||||||
.refine(
|
cardName: z.string().min(1, "validation.required"),
|
||||||
(val) => {
|
cardMonth: z.string().min(1, "validation.required"),
|
||||||
if (!val || val.replace(/\D/g, "").length === 0) return true;
|
cardYear: z.string().min(1, "validation.required"),
|
||||||
return val.replace(/\D/g, "").length === 8;
|
|
||||||
},
|
// ── Step 5: Passport ──────────────────────────────
|
||||||
{ message: "validation.invalidPhone" },
|
passportSerie: z.string().min(1, "validation.required"),
|
||||||
)
|
passportId: z.string().min(1, "validation.required"),
|
||||||
.refine(
|
passportGivenAt: z.string().min(1, "validation.required"),
|
||||||
(val) => {
|
passportGivenBy: z.string().min(1, "validation.required"),
|
||||||
if (!val || val.replace(/\D/g, "").length === 0) return true;
|
|
||||||
return VALID_PHONE_PREFIXES.includes(val.replace(/\D/g, "").slice(0, 2));
|
|
||||||
},
|
|
||||||
{ message: "validation.invalidPhonePrefix" },
|
|
||||||
)
|
|
||||||
.optional(),
|
|
||||||
workCompany: z.string().min(1, "validation.required"),
|
|
||||||
workHrPhone: z
|
|
||||||
.string()
|
|
||||||
.refine(
|
|
||||||
(val) => {
|
|
||||||
if (!val || val.replace(/\D/g, "").length === 0) return true;
|
|
||||||
return val.replace(/\D/g, "").length === 8;
|
|
||||||
},
|
|
||||||
{ message: "validation.invalidPhone" },
|
|
||||||
)
|
|
||||||
.refine(
|
|
||||||
(val) => {
|
|
||||||
if (!val || val.replace(/\D/g, "").length === 0) return true;
|
|
||||||
return VALID_PHONE_PREFIXES.includes(val.replace(/\D/g, "").slice(0, 2));
|
|
||||||
},
|
|
||||||
{ message: "validation.invalidPhonePrefix" },
|
|
||||||
)
|
|
||||||
.optional(),
|
|
||||||
workRegion: z.string().optional(),
|
|
||||||
workProvince: z.string().optional(),
|
|
||||||
position: z.string().min(1, "validation.required"),
|
|
||||||
salary: z.string().min(1, "validation.required"),
|
|
||||||
workStartedAt: z.string().min(1, "validation.required"),
|
|
||||||
passportOne: z.string().optional(),
|
passportOne: z.string().optional(),
|
||||||
passportTwo: z.string().optional(),
|
passportTwo: z.string().optional(),
|
||||||
passportThree: z.string().optional(),
|
passportThree: z.string().optional(),
|
||||||
passportFour: z.string().optional(),
|
passportFour: z.string().optional(),
|
||||||
note: z.string().optional(),
|
|
||||||
loanAmount: z.string().min(1, "validation.required"),
|
// ── Step 6: Contacts ──────────────────────────────
|
||||||
loanHistory: z.string().optional(),
|
phone: z
|
||||||
cardNumber: z.string().min(1, "validation.required"),
|
.string()
|
||||||
cardName: z.string().min(1, "validation.required"),
|
.min(1, "validation.required")
|
||||||
cardExpMonth: z.string().min(1, "validation.required"),
|
.refine((val) => val.replace(/\D/g, "").length === 8, { message: "validation.invalidPhone" })
|
||||||
cardExpYear: z.string().min(1, "validation.required"),
|
.refine((val) => VALID_PHONE_PREFIXES.includes(val.replace(/\D/g, "").slice(0, 2)), { message: "validation.invalidPhonePrefix" }),
|
||||||
guarantor1Name: z.string().min(1, "validation.required"),
|
phoneAdditional: z
|
||||||
guarantor1Surname: z.string().min(1, "validation.required"),
|
.string()
|
||||||
guarantor1Patronic: z.string().optional(),
|
.refine((val) => !val || val.replace(/\D/g, "").length === 0 || val.replace(/\D/g, "").length === 8, {
|
||||||
guarantor1PassportSerie: z.string().min(1, "validation.required"),
|
message: "validation.invalidPhone",
|
||||||
guarantor1PassportNumber: z.string().min(1, "validation.required"),
|
})
|
||||||
guarantor1CardNumber: z.string().min(1, "validation.required"),
|
.refine((val) => !val || val.replace(/\D/g, "").length === 0 || VALID_PHONE_PREFIXES.includes(val.replace(/\D/g, "").slice(0, 2)), {
|
||||||
guarantor1CardName: z.string().min(1, "validation.required"),
|
message: "validation.invalidPhonePrefix",
|
||||||
guarantor1CardExpMonth: z.string().min(1, "validation.required"),
|
})
|
||||||
guarantor1CardExpYear: z.string().min(1, "validation.required"),
|
.optional(),
|
||||||
guarantor1Salary: z.string().min(1, "validation.required"),
|
phoneHome: z
|
||||||
|
.string()
|
||||||
|
.refine((val) => !val || val.replace(/\D/g, "").length === 0 || val.replace(/\D/g, "").length === 8, {
|
||||||
|
message: "validation.invalidPhone",
|
||||||
|
})
|
||||||
|
.refine((val) => !val || val.replace(/\D/g, "").length === 0 || VALID_PHONE_PREFIXES.includes(val.replace(/\D/g, "").slice(0, 2)), {
|
||||||
|
message: "validation.invalidPhonePrefix",
|
||||||
|
})
|
||||||
|
.optional(),
|
||||||
|
email: z.string().optional(),
|
||||||
|
|
||||||
|
// ── Step 7: Employment ────────────────────────────
|
||||||
|
workCompany: z.string().min(1, "validation.required"),
|
||||||
|
workCompanyAccountantNumber: z
|
||||||
|
.string()
|
||||||
|
.refine((val) => !val || val.replace(/\D/g, "").length === 0 || val.replace(/\D/g, "").length === 8, {
|
||||||
|
message: "validation.invalidPhone",
|
||||||
|
})
|
||||||
|
.refine((val) => !val || val.replace(/\D/g, "").length === 0 || VALID_PHONE_PREFIXES.includes(val.replace(/\D/g, "").slice(0, 2)), {
|
||||||
|
message: "validation.invalidPhonePrefix",
|
||||||
|
})
|
||||||
|
.optional(),
|
||||||
|
workRegion: z.string().optional(),
|
||||||
|
workProvinceId: z.string().optional(),
|
||||||
|
workPosition: z.string().min(1, "validation.required"),
|
||||||
|
workSalary: z.string().min(1, "validation.required"),
|
||||||
|
workStartedAt: z.string().min(1, "validation.required"),
|
||||||
|
|
||||||
|
// ── Step 8: Guarantor 1 ───────────────────────────
|
||||||
|
guarantorName: z.string().min(1, "validation.required"),
|
||||||
|
guarantorSurname: z.string().min(1, "validation.required"),
|
||||||
|
guarantorPatronicName: z.string().optional(),
|
||||||
|
guarantorPassportSerie: z.string().min(1, "validation.required"),
|
||||||
|
guarantorPassportId: z.string().min(1, "validation.required"),
|
||||||
|
guarantorCardNumber: z.string().min(1, "validation.required"),
|
||||||
|
guarantorCardName: z.string().min(1, "validation.required"),
|
||||||
|
guarantorCardMonth: z.string().min(1, "validation.required"),
|
||||||
|
guarantorCardYear: z.string().min(1, "validation.required"),
|
||||||
|
guarantorNote: z.string().optional(),
|
||||||
|
|
||||||
|
// ── Step 9: Guarantor 2 ───────────────────────────
|
||||||
guarantor2Name: z.string().optional(),
|
guarantor2Name: z.string().optional(),
|
||||||
guarantor2Surname: z.string().optional(),
|
guarantor2Surname: z.string().optional(),
|
||||||
guarantor2Patronic: z.string().optional(),
|
guarantor2PatronicName: z.string().optional(),
|
||||||
guarantor2PassportSerie: z.string().optional(),
|
guarantor2PassportSerie: z.string().optional(),
|
||||||
guarantor2PassportNumber: z.string().optional(),
|
guarantor2PassportId: z.string().optional(),
|
||||||
guarantor2CardNumber: z.string().optional(),
|
guarantor2CardNumber: z.string().optional(),
|
||||||
guarantor2CardName: z.string().optional(),
|
guarantor2CardName: z.string().optional(),
|
||||||
guarantor2CardExpMonth: z.string().optional(),
|
guarantor2CardMonth: z.string().optional(),
|
||||||
guarantor2CardExpYear: z.string().optional(),
|
guarantor2CardYear: z.string().optional(),
|
||||||
guarantor2Note: z.string().optional(),
|
guarantor2Note: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -138,59 +124,58 @@ export type LoanOrderFormData = z.infer<typeof loanOrderFormSchema>;
|
|||||||
export const stepSchemas: Record<number, z.ZodType<Partial<LoanOrderFormData>>> = {
|
export const stepSchemas: Record<number, z.ZodType<Partial<LoanOrderFormData>>> = {
|
||||||
0: loanOrderFormSchema.pick({ status: true }),
|
0: loanOrderFormSchema.pick({ status: true }),
|
||||||
1: loanOrderFormSchema.pick({ loanType: true, loanAmount: true }),
|
1: loanOrderFormSchema.pick({ loanType: true, loanAmount: true }),
|
||||||
2: loanOrderFormSchema.pick({ region: true, branch: true }),
|
2: loanOrderFormSchema.pick({ region: true, branchId: true }),
|
||||||
3: loanOrderFormSchema.pick({
|
3: loanOrderFormSchema.pick({
|
||||||
userId: true,
|
userId: true,
|
||||||
firstName: true,
|
customerName: true,
|
||||||
lastName: true,
|
customerSurname: true,
|
||||||
education: true,
|
education: true,
|
||||||
marriageStatus: true,
|
marriageStatus: true,
|
||||||
dateOfBirth: true,
|
bornAt: true,
|
||||||
residence: true,
|
passportAddress: true,
|
||||||
}),
|
}),
|
||||||
4: loanOrderFormSchema.pick({
|
4: loanOrderFormSchema.pick({
|
||||||
cardNumber: true,
|
cardNumber: true,
|
||||||
cardName: true,
|
cardName: true,
|
||||||
cardExpMonth: true,
|
cardMonth: true,
|
||||||
cardExpYear: true,
|
cardYear: true,
|
||||||
}),
|
}),
|
||||||
5: loanOrderFormSchema.pick({
|
5: loanOrderFormSchema.pick({
|
||||||
passportSerie: true,
|
passportSerie: true,
|
||||||
passportNumber: true,
|
passportId: true,
|
||||||
passportDateOfIssue: true,
|
passportGivenAt: true,
|
||||||
passportGivenBy: true,
|
passportGivenBy: true,
|
||||||
passportOne: true,
|
passportOne: true,
|
||||||
passportTwo: true,
|
passportTwo: true,
|
||||||
}),
|
}),
|
||||||
6: loanOrderFormSchema.pick({ phone: true, phoneAdditional: true, homePhone: true }),
|
6: loanOrderFormSchema.pick({ phone: true, phoneAdditional: true, phoneHome: true }),
|
||||||
7: loanOrderFormSchema.pick({
|
7: loanOrderFormSchema.pick({
|
||||||
workCompany: true,
|
workCompany: true,
|
||||||
position: true,
|
workPosition: true,
|
||||||
salary: true,
|
workSalary: true,
|
||||||
workStartedAt: true,
|
workStartedAt: true,
|
||||||
workHrPhone: true,
|
workCompanyAccountantNumber: true,
|
||||||
}),
|
}),
|
||||||
8: loanOrderFormSchema.pick({
|
8: loanOrderFormSchema.pick({
|
||||||
guarantor1Name: true,
|
guarantorName: true,
|
||||||
guarantor1Surname: true,
|
guarantorSurname: true,
|
||||||
guarantor1PassportSerie: true,
|
guarantorPassportSerie: true,
|
||||||
guarantor1PassportNumber: true,
|
guarantorPassportId: true,
|
||||||
guarantor1CardNumber: true,
|
guarantorCardNumber: true,
|
||||||
guarantor1CardName: true,
|
guarantorCardName: true,
|
||||||
guarantor1CardExpMonth: true,
|
guarantorCardMonth: true,
|
||||||
guarantor1CardExpYear: true,
|
guarantorCardYear: true,
|
||||||
guarantor1Salary: true,
|
|
||||||
}),
|
}),
|
||||||
9: loanOrderFormSchema.pick({
|
9: loanOrderFormSchema.pick({
|
||||||
guarantor2Name: true,
|
guarantor2Name: true,
|
||||||
guarantor2Surname: true,
|
guarantor2Surname: true,
|
||||||
guarantor2Patronic: true,
|
guarantor2PatronicName: true,
|
||||||
guarantor2PassportSerie: true,
|
guarantor2PassportSerie: true,
|
||||||
guarantor2PassportNumber: true,
|
guarantor2PassportId: true,
|
||||||
guarantor2CardNumber: true,
|
guarantor2CardNumber: true,
|
||||||
guarantor2CardName: true,
|
guarantor2CardName: true,
|
||||||
guarantor2CardExpMonth: true,
|
guarantor2CardMonth: true,
|
||||||
guarantor2CardExpYear: true,
|
guarantor2CardYear: true,
|
||||||
guarantor2Note: true,
|
guarantor2Note: true,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
@@ -206,8 +191,8 @@ export function validateStep(
|
|||||||
stepIndex === 5 && mode === "edit"
|
stepIndex === 5 && mode === "edit"
|
||||||
? loanOrderFormSchema.pick({
|
? loanOrderFormSchema.pick({
|
||||||
passportSerie: true,
|
passportSerie: true,
|
||||||
passportNumber: true,
|
passportId: true,
|
||||||
passportDateOfIssue: true,
|
passportGivenAt: true,
|
||||||
passportGivenBy: true,
|
passportGivenBy: true,
|
||||||
})
|
})
|
||||||
: stepSchemas[stepIndex];
|
: stepSchemas[stepIndex];
|
||||||
@@ -227,128 +212,140 @@ export function validateStep(
|
|||||||
|
|
||||||
export const DEFAULT_FORM_VALUES: LoanOrderFormData = {
|
export const DEFAULT_FORM_VALUES: LoanOrderFormData = {
|
||||||
status: "pending",
|
status: "pending",
|
||||||
|
notes: "",
|
||||||
|
source: "web",
|
||||||
|
satisfiable: "yes",
|
||||||
loanType: "",
|
loanType: "",
|
||||||
|
loanAmount: "",
|
||||||
|
loanOrderRequiredDocId: "",
|
||||||
|
loanCardNumber: "",
|
||||||
|
loanCardName: "",
|
||||||
|
loanCardMonth: "",
|
||||||
|
loanCardYear: "",
|
||||||
region: "AG",
|
region: "AG",
|
||||||
branch: "",
|
branchId: "",
|
||||||
userId: "",
|
userId: "",
|
||||||
firstName: "",
|
customerName: "",
|
||||||
lastName: "",
|
customerSurname: "",
|
||||||
patronicName: "",
|
customerPatronicName: "",
|
||||||
education: "",
|
education: "",
|
||||||
marriageStatus: "",
|
marriageStatus: "",
|
||||||
dateOfBirth: "",
|
bornAt: "",
|
||||||
residence: "",
|
|
||||||
currentResidence: "",
|
|
||||||
passportSerie: "",
|
|
||||||
passportNumber: "",
|
|
||||||
passportDateOfIssue: "",
|
|
||||||
passportGivenBy: "",
|
|
||||||
bornPlace: "",
|
bornPlace: "",
|
||||||
email: "",
|
passportAddress: "",
|
||||||
phone: "",
|
realAddress: "",
|
||||||
phoneAdditional: "",
|
cardNumber: "",
|
||||||
homePhone: "",
|
cardName: "",
|
||||||
workCompany: "",
|
cardMonth: "",
|
||||||
workHrPhone: "",
|
cardYear: "",
|
||||||
workRegion: "AG",
|
passportSerie: "",
|
||||||
workProvince: "",
|
passportId: "",
|
||||||
position: "",
|
passportGivenAt: "",
|
||||||
salary: "",
|
passportGivenBy: "",
|
||||||
workStartedAt: "",
|
|
||||||
passportOne: "",
|
passportOne: "",
|
||||||
passportTwo: "",
|
passportTwo: "",
|
||||||
passportThree: "",
|
passportThree: "",
|
||||||
passportFour: "",
|
passportFour: "",
|
||||||
note: "",
|
phone: "",
|
||||||
loanAmount: "",
|
phoneAdditional: "",
|
||||||
loanHistory: "",
|
phoneHome: "",
|
||||||
cardNumber: "",
|
email: "",
|
||||||
cardName: "",
|
workCompany: "",
|
||||||
cardExpMonth: "",
|
workCompanyAccountantNumber: "",
|
||||||
cardExpYear: "",
|
workRegion: "AG",
|
||||||
guarantor1Name: "",
|
workProvinceId: "",
|
||||||
guarantor1Surname: "",
|
workPosition: "",
|
||||||
guarantor1Patronic: "",
|
workSalary: "",
|
||||||
guarantor1PassportSerie: "",
|
workStartedAt: "",
|
||||||
guarantor1PassportNumber: "",
|
guarantorName: "",
|
||||||
guarantor1CardNumber: "",
|
guarantorSurname: "",
|
||||||
guarantor1CardName: "",
|
guarantorPatronicName: "",
|
||||||
guarantor1CardExpMonth: "",
|
guarantorPassportSerie: "",
|
||||||
guarantor1CardExpYear: "",
|
guarantorPassportId: "",
|
||||||
guarantor1Salary: "",
|
guarantorCardNumber: "",
|
||||||
|
guarantorCardName: "",
|
||||||
|
guarantorCardMonth: "",
|
||||||
|
guarantorCardYear: "",
|
||||||
|
guarantorNote: "",
|
||||||
guarantor2Name: "",
|
guarantor2Name: "",
|
||||||
guarantor2Surname: "",
|
guarantor2Surname: "",
|
||||||
guarantor2Patronic: "",
|
guarantor2PatronicName: "",
|
||||||
guarantor2PassportSerie: "",
|
guarantor2PassportSerie: "",
|
||||||
guarantor2PassportNumber: "",
|
guarantor2PassportId: "",
|
||||||
guarantor2CardNumber: "",
|
guarantor2CardNumber: "",
|
||||||
guarantor2CardName: "",
|
guarantor2CardName: "",
|
||||||
guarantor2CardExpMonth: "",
|
guarantor2CardMonth: "",
|
||||||
guarantor2CardExpYear: "",
|
guarantor2CardYear: "",
|
||||||
guarantor2Note: "",
|
guarantor2Note: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
export function buildPayload(data: LoanOrderFormData) {
|
export function buildPayload(data: LoanOrderFormData) {
|
||||||
return {
|
return {
|
||||||
status: data.status,
|
status: data.status,
|
||||||
|
notes: data.notes || undefined,
|
||||||
|
source: data.source || "web",
|
||||||
|
satisfiable: data.satisfiable || "yes",
|
||||||
loanType: data.loanType,
|
loanType: data.loanType,
|
||||||
|
loanAmount: data.loanAmount,
|
||||||
|
loanOrderRequiredDocId: data.loanOrderRequiredDocId || undefined,
|
||||||
|
loanCardNumber: data.loanCardNumber || undefined,
|
||||||
|
loanCardName: data.loanCardName || undefined,
|
||||||
|
loanCardMonth: data.loanCardMonth || undefined,
|
||||||
|
loanCardYear: data.loanCardYear || undefined,
|
||||||
region: data.region,
|
region: data.region,
|
||||||
branch: data.branch,
|
branchId: data.branchId,
|
||||||
userId: data.userId,
|
userId: data.userId,
|
||||||
firstName: data.firstName,
|
customerName: data.customerName,
|
||||||
lastName: data.lastName,
|
customerSurname: data.customerSurname,
|
||||||
patronicName: data.patronicName || undefined,
|
customerPatronicName: data.customerPatronicName || undefined,
|
||||||
education: data.education,
|
education: data.education,
|
||||||
marriageStatus: data.marriageStatus,
|
marriageStatus: data.marriageStatus,
|
||||||
dateOfBirth: data.dateOfBirth,
|
bornAt: data.bornAt,
|
||||||
residence: data.residence,
|
|
||||||
currentResidence: data.currentResidence || undefined,
|
|
||||||
passportSerie: data.passportSerie,
|
|
||||||
passportNumber: data.passportNumber,
|
|
||||||
passportDateOfIssue: data.passportDateOfIssue,
|
|
||||||
passportGivenBy: data.passportGivenBy,
|
|
||||||
bornPlace: data.bornPlace || undefined,
|
bornPlace: data.bornPlace || undefined,
|
||||||
email: data.email || undefined,
|
passportAddress: data.passportAddress,
|
||||||
phone: data.phone,
|
realAddress: data.realAddress || undefined,
|
||||||
phoneAdditional: data.phoneAdditional || undefined,
|
cardNumber: data.cardNumber,
|
||||||
homePhone: data.homePhone || undefined,
|
cardName: data.cardName,
|
||||||
workCompany: data.workCompany,
|
cardMonth: data.cardMonth,
|
||||||
workHrPhone: data.workHrPhone || undefined,
|
cardYear: data.cardYear,
|
||||||
workRegion: data.workRegion || undefined,
|
passportSerie: data.passportSerie,
|
||||||
workProvince: data.workProvince || undefined,
|
passportId: data.passportId,
|
||||||
position: data.position,
|
passportGivenAt: data.passportGivenAt,
|
||||||
salary: Number(data.salary),
|
passportGivenBy: data.passportGivenBy,
|
||||||
workStartedAt: data.workStartedAt,
|
|
||||||
note: data.note || undefined,
|
|
||||||
loanAmount: Number(data.loanAmount) || undefined,
|
|
||||||
loanHistory: data.loanHistory || undefined,
|
|
||||||
cardNumber: data.cardNumber || undefined,
|
|
||||||
cardName: data.cardName || undefined,
|
|
||||||
cardExpMonth: data.cardExpMonth || undefined,
|
|
||||||
cardExpYear: data.cardExpYear || undefined,
|
|
||||||
guarantor1Name: data.guarantor1Name || undefined,
|
|
||||||
guarantor1Surname: data.guarantor1Surname || undefined,
|
|
||||||
guarantor1Patronic: data.guarantor1Patronic || undefined,
|
|
||||||
guarantor1PassportSerie: data.guarantor1PassportSerie || undefined,
|
|
||||||
guarantor1PassportNumber: data.guarantor1PassportNumber || undefined,
|
|
||||||
guarantor1CardNumber: data.guarantor1CardNumber || undefined,
|
|
||||||
guarantor1CardName: data.guarantor1CardName || undefined,
|
|
||||||
guarantor1CardExpMonth: data.guarantor1CardExpMonth || undefined,
|
|
||||||
guarantor1CardExpYear: data.guarantor1CardExpYear || undefined,
|
|
||||||
guarantor1Salary: Number(data.guarantor1Salary) || undefined,
|
|
||||||
guarantor2Name: data.guarantor2Name || undefined,
|
|
||||||
guarantor2Surname: data.guarantor2Surname || undefined,
|
|
||||||
guarantor2Patronic: data.guarantor2Patronic || undefined,
|
|
||||||
guarantor2PassportSerie: data.guarantor2PassportSerie || undefined,
|
|
||||||
guarantor2PassportNumber: data.guarantor2PassportNumber || undefined,
|
|
||||||
guarantor2CardNumber: data.guarantor2CardNumber || undefined,
|
|
||||||
guarantor2CardName: data.guarantor2CardName || undefined,
|
|
||||||
guarantor2CardExpMonth: data.guarantor2CardExpMonth || undefined,
|
|
||||||
guarantor2CardExpYear: data.guarantor2CardExpYear || undefined,
|
|
||||||
guarantor2Note: data.guarantor2Note || undefined,
|
|
||||||
passportOne: data.passportOne || undefined,
|
passportOne: data.passportOne || undefined,
|
||||||
passportTwo: data.passportTwo || undefined,
|
passportTwo: data.passportTwo || undefined,
|
||||||
passportThree: data.passportThree || undefined,
|
passportThree: data.passportThree || undefined,
|
||||||
passportFour: data.passportFour || undefined,
|
passportFour: data.passportFour || undefined,
|
||||||
|
phone: data.phone,
|
||||||
|
phoneAdditional: data.phoneAdditional || undefined,
|
||||||
|
phoneHome: data.phoneHome || undefined,
|
||||||
|
email: data.email || undefined,
|
||||||
|
workCompany: data.workCompany,
|
||||||
|
workCompanyAccountantNumber: data.workCompanyAccountantNumber || undefined,
|
||||||
|
workRegion: data.workRegion || undefined,
|
||||||
|
workProvinceId: data.workProvinceId || undefined,
|
||||||
|
workPosition: data.workPosition,
|
||||||
|
workSalary: data.workSalary,
|
||||||
|
workStartedAt: data.workStartedAt,
|
||||||
|
guarantorName: data.guarantorName,
|
||||||
|
guarantorSurname: data.guarantorSurname,
|
||||||
|
guarantorPatronicName: data.guarantorPatronicName || undefined,
|
||||||
|
guarantorPassportSerie: data.guarantorPassportSerie,
|
||||||
|
guarantorPassportId: data.guarantorPassportId,
|
||||||
|
guarantorCardNumber: data.guarantorCardNumber,
|
||||||
|
guarantorCardName: data.guarantorCardName,
|
||||||
|
guarantorCardMonth: data.guarantorCardMonth,
|
||||||
|
guarantorCardYear: data.guarantorCardYear,
|
||||||
|
guarantorNote: data.guarantorNote || undefined,
|
||||||
|
guarantor2Name: data.guarantor2Name || undefined,
|
||||||
|
guarantor2Surname: data.guarantor2Surname || undefined,
|
||||||
|
guarantor2PatronicName: data.guarantor2PatronicName || undefined,
|
||||||
|
guarantor2PassportSerie: data.guarantor2PassportSerie || undefined,
|
||||||
|
guarantor2PassportId: data.guarantor2PassportId || undefined,
|
||||||
|
guarantor2CardNumber: data.guarantor2CardNumber || undefined,
|
||||||
|
guarantor2CardName: data.guarantor2CardName || undefined,
|
||||||
|
guarantor2CardMonth: data.guarantor2CardMonth || undefined,
|
||||||
|
guarantor2CardYear: data.guarantor2CardYear || undefined,
|
||||||
|
guarantor2Note: data.guarantor2Note || undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ import { InfiniteSelect, type InfiniteSelectOption, type InfiniteSelectProps } f
|
|||||||
import { DocumentUpload } from "@/components/documentUpload";
|
import { DocumentUpload } from "@/components/documentUpload";
|
||||||
import { StepBarCards, type StepCardItem } from "@/components/stepBarV2";
|
import { StepBarCards, type StepCardItem } from "@/components/stepBarV2";
|
||||||
import { BentoGrid, BentoCard } from "@/components/bento";
|
import { BentoGrid, BentoCard } from "@/components/bento";
|
||||||
import { PASSPORT_SERIES_OPTIONS, getStatusOptions } from "@/constants";
|
import { PASSPORT_SERIES_OPTIONS, getStatusOptions, getRegionOptions, LOAN_PAID_OFF_REGION_CODES } from "@/constants";
|
||||||
import { useInfiniteBranches } from "@/features/shared/hooks/useSharedBranchUsers";
|
import { useInfiniteBranches } from "@/features/shared/hooks/useSharedBranchUsers";
|
||||||
import { useInfiniteUsers } from "@/features/allUsers/hooks/useAllUsers";
|
import { useInfiniteUsers } from "@/features/allUsers/hooks/useAllUsers";
|
||||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||||
@@ -56,8 +56,6 @@ function resolveLocalizedName(name: LocalizedText | string | undefined | null, l
|
|||||||
|
|
||||||
// ─── Static options ───────────────────────────────────────────────────────────
|
// ─── Static options ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const REGION_CODES = ["AG", "AH", "BA", "DA", "LE", "MA"] as const;
|
|
||||||
|
|
||||||
// ─── Step definitions ─────────────────────────────────────────────────────────
|
// ─── Step definitions ─────────────────────────────────────────────────────────
|
||||||
|
|
||||||
interface StepDef {
|
interface StepDef {
|
||||||
@@ -429,14 +427,7 @@ export function LoanPaidOffLetterForm({ mode, initialData }: LoanPaidOffLetterFo
|
|||||||
|
|
||||||
const statusOptions = useMemo<SelectOption[]>(() => getStatusOptions(t, "loanPaidOffLetters.status"), [t]);
|
const statusOptions = useMemo<SelectOption[]>(() => getStatusOptions(t, "loanPaidOffLetters.status"), [t]);
|
||||||
|
|
||||||
const regionOptions = useMemo<SelectOption[]>(
|
const regionOptions = useMemo<SelectOption[]>(() => getRegionOptions(t, "loanPaidOffLetters", LOAN_PAID_OFF_REGION_CODES), [t]);
|
||||||
() =>
|
|
||||||
REGION_CODES.map((code) => ({
|
|
||||||
value: code,
|
|
||||||
label: t(`loanPaidOffLetters.regions.${code}`, code),
|
|
||||||
})),
|
|
||||||
[t],
|
|
||||||
);
|
|
||||||
|
|
||||||
// ── Step validation state ───────────────────────────────────────────────────
|
// ── Step validation state ───────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,19 @@ import apiClient from "@/lib/api/client";
|
|||||||
|
|
||||||
// ─── Types ─────────────────────────────────────────────────────────────────────
|
// ─── Types ─────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export interface LoanRemainingUser {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
username?: string;
|
||||||
|
phone?: string;
|
||||||
|
email?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface LoanRemaining {
|
export interface LoanRemaining {
|
||||||
id: number;
|
id: number;
|
||||||
userId: number;
|
user?: LoanRemainingUser | null;
|
||||||
userName: string;
|
userId?: number;
|
||||||
|
userName?: string;
|
||||||
passportSerie: string;
|
passportSerie: string;
|
||||||
passportId: string;
|
passportId: string;
|
||||||
accountNumber: string;
|
accountNumber: string;
|
||||||
|
|||||||
@@ -45,12 +45,13 @@ export function LoanRemainingForm({ mode, initialData }: LoanRemainingFormProps)
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
if (initialData?.userId) {
|
const effectiveUserId = initialData?.user?.id ?? initialData?.userId;
|
||||||
const currentVal = String(initialData.userId);
|
if (effectiveUserId) {
|
||||||
|
const currentVal = String(effectiveUserId);
|
||||||
if (!opts.some((o) => o.value === currentVal)) {
|
if (!opts.some((o) => o.value === currentVal)) {
|
||||||
opts.unshift({
|
opts.unshift({
|
||||||
value: currentVal,
|
value: currentVal,
|
||||||
label: initialData.userName || currentVal,
|
label: initialData?.user?.name || initialData?.user?.username || initialData?.userName || currentVal,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,11 +81,12 @@ export function LoanRemainingForm({ mode, initialData }: LoanRemainingFormProps)
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (mode === "edit" && initialData) {
|
if (mode === "edit" && initialData) {
|
||||||
|
const uId = initialData.user?.id ?? initialData.userId;
|
||||||
reset({
|
reset({
|
||||||
passportSerie: initialData.passportSerie,
|
passportSerie: initialData.passportSerie,
|
||||||
passportId: initialData.passportId,
|
passportId: initialData.passportId,
|
||||||
accountNumber: initialData.accountNumber,
|
accountNumber: initialData.accountNumber,
|
||||||
userId: String(initialData.userId),
|
userId: uId != null ? String(uId) : "",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [mode, initialData, reset]);
|
}, [mode, initialData, reset]);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import type { IntlPaymentFormData } from "../schemas/visaMasterPayment.schema";
|
|||||||
import { useInfiniteBranches } from "@/features/shared/hooks/useSharedBranchUsers";
|
import { useInfiniteBranches } from "@/features/shared/hooks/useSharedBranchUsers";
|
||||||
import { useInfiniteClients } from "@/features/clients/hooks/useClients";
|
import { useInfiniteClients } from "@/features/clients/hooks/useClients";
|
||||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||||
import { PASSPORT_SERIES_OPTIONS, getStatusOptions } from "@/constants";
|
import { PASSPORT_SERIES_OPTIONS, getStatusOptions, getRegionOptions, REGION_CODES, REGION_LABELS } from "@/constants";
|
||||||
|
|
||||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -38,17 +38,6 @@ const CURRENCY_OPTIONS = [
|
|||||||
{ value: "mastercard", label: "MasterCard" },
|
{ value: "mastercard", label: "MasterCard" },
|
||||||
];
|
];
|
||||||
|
|
||||||
const REGION_CODES = ["AG", "AH", "BN", "DZ", "LB", "MR"] as const;
|
|
||||||
|
|
||||||
const REGION_LABELS: Record<string, string> = {
|
|
||||||
AG: "Aşgabat",
|
|
||||||
AH: "Ahal",
|
|
||||||
BN: "Balkan",
|
|
||||||
DZ: "Daşoguz",
|
|
||||||
LB: "Lebap",
|
|
||||||
MR: "Mary",
|
|
||||||
};
|
|
||||||
|
|
||||||
function resolveLocalizedName(name: LocalizedText | string | null | undefined, 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;
|
||||||
@@ -56,13 +45,6 @@ function resolveLocalizedName(name: LocalizedText | string | null | undefined, l
|
|||||||
return name[key as keyof LocalizedText] ?? name.tm ?? name.en ?? name.ru ?? "";
|
return name[key as keyof LocalizedText] ?? name.tm ?? name.en ?? name.ru ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRegionOptions(t: TFunction): { value: string; label: string }[] {
|
|
||||||
return REGION_CODES.map((code) => ({
|
|
||||||
value: code,
|
|
||||||
label: t(`intlPayment.regions.${code}`, REGION_LABELS[code] ?? code),
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
const KABUL_DOCS: { key: keyof IntlPaymentFormData; label: string }[] = [
|
const KABUL_DOCS: { key: keyof IntlPaymentFormData; label: string }[] = [
|
||||||
{ key: "doc_sberbank_account", label: "Talypyň SBERBANK kartynyň rekwizitleri" },
|
{ key: "doc_sberbank_account", label: "Talypyň SBERBANK kartynyň rekwizitleri" },
|
||||||
{ key: "doc_school_enrollment", label: "Daşary ýurt ÝOM-da okaýandygy barada güwänamasy" },
|
{ key: "doc_school_enrollment", label: "Daşary ýurt ÝOM-da okaýandygy barada güwänamasy" },
|
||||||
@@ -251,7 +233,7 @@ function StepLocation({ form, errors, set, t, initialData }: StepContentProps) {
|
|||||||
const [branchSearch, setBranchSearch] = useState("");
|
const [branchSearch, setBranchSearch] = useState("");
|
||||||
const branchQuery = useInfiniteBranches(branchSearch);
|
const branchQuery = useInfiniteBranches(branchSearch);
|
||||||
|
|
||||||
const regionOptions = useMemo(() => getRegionOptions(t), [t]);
|
const regionOptions = useMemo(() => getRegionOptions(t, "intlPayment", REGION_CODES, REGION_LABELS), [t]);
|
||||||
|
|
||||||
const branchOptions: InfiniteSelectOption[] = useMemo(() => {
|
const branchOptions: InfiniteSelectOption[] = useMemo(() => {
|
||||||
const opts: InfiniteSelectOption[] = (branchQuery.data?.pages ?? [])
|
const opts: InfiniteSelectOption[] = (branchQuery.data?.pages ?? [])
|
||||||
|
|||||||
@@ -423,6 +423,12 @@ function AppSidebar() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const isAdmin = user?.role?.code === "admin";
|
||||||
|
|
||||||
|
const filteredNavGroups = isAdmin
|
||||||
|
? navGroups
|
||||||
|
: (navGroups.filter((_, i) => i === 1).map((group) => ({ ...group, items: [group.items[0]] })) as NavGroup[]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Sidebar collapsible="icon">
|
<Sidebar collapsible="icon">
|
||||||
{/* Logo */}
|
{/* Logo */}
|
||||||
@@ -438,7 +444,7 @@ function AppSidebar() {
|
|||||||
|
|
||||||
{/* Nav */}
|
{/* Nav */}
|
||||||
<SidebarContent className="px-2 py-2">
|
<SidebarContent className="px-2 py-2">
|
||||||
{navGroups.map((group, gi) => (
|
{filteredNavGroups.map((group, gi) => (
|
||||||
<div key={gi}>
|
<div key={gi}>
|
||||||
{group.label && <NavGroupLabel label={group.label} />}
|
{group.label && <NavGroupLabel label={group.label} />}
|
||||||
<SidebarMenu className="gap-0.5">
|
<SidebarMenu className="gap-0.5">
|
||||||
|
|||||||
@@ -377,6 +377,7 @@
|
|||||||
"common.backToHome": "Go to home",
|
"common.backToHome": "Go to home",
|
||||||
"errors.pageNotFoundTitle": "Page not found",
|
"errors.pageNotFoundTitle": "Page not found",
|
||||||
"errors.pageNotFoundDescription": "The page you are looking for does not exist or has been moved.",
|
"errors.pageNotFoundDescription": "The page you are looking for does not exist or has been moved.",
|
||||||
|
"errors.forbidden": "You do not have permission to perform this action.",
|
||||||
"Phone or username": "Phone or username",
|
"Phone or username": "Phone or username",
|
||||||
"featureNotImplemented": "Not implemented",
|
"featureNotImplemented": "Not implemented",
|
||||||
"common.search": "Search",
|
"common.search": "Search",
|
||||||
|
|||||||
@@ -377,6 +377,7 @@
|
|||||||
"common.backToHome": "На главную",
|
"common.backToHome": "На главную",
|
||||||
"errors.pageNotFoundTitle": "Страница не найдена",
|
"errors.pageNotFoundTitle": "Страница не найдена",
|
||||||
"errors.pageNotFoundDescription": "Страница, которую вы ищете, не существует или была перемещена.",
|
"errors.pageNotFoundDescription": "Страница, которую вы ищете, не существует или была перемещена.",
|
||||||
|
"errors.forbidden": "У вас нет разрешения на выполнение этого действия.",
|
||||||
"Phone or username": "Телефон или имя пользователя",
|
"Phone or username": "Телефон или имя пользователя",
|
||||||
"featureNotImplemented": "Эта функция еще не реализована",
|
"featureNotImplemented": "Эта функция еще не реализована",
|
||||||
"common.search": "Поиск",
|
"common.search": "Поиск",
|
||||||
|
|||||||
@@ -377,6 +377,7 @@
|
|||||||
"common.backToHome": "Baş sahypa",
|
"common.backToHome": "Baş sahypa",
|
||||||
"errors.pageNotFoundTitle": "Sahypa tapylmady",
|
"errors.pageNotFoundTitle": "Sahypa tapylmady",
|
||||||
"errors.pageNotFoundDescription": "Gözleýän sahypaňyz ýok ýa-da başga ýere geçirilen bolup biler.",
|
"errors.pageNotFoundDescription": "Gözleýän sahypaňyz ýok ýa-da başga ýere geçirilen bolup biler.",
|
||||||
|
"errors.forbidden": "Bu amaly ýerine ýetirmäge rugsadyňyz ýok.",
|
||||||
"Phone or username": "Telefon ýada ulanyjy ady",
|
"Phone or username": "Telefon ýada ulanyjy ady",
|
||||||
"featureNotImplemented": "Bu funksiýa entek durmuşa geçirilmedi",
|
"featureNotImplemented": "Bu funksiýa entek durmuşa geçirilmedi",
|
||||||
"common.search": "Gözlemek",
|
"common.search": "Gözlemek",
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import { resolveLocalizedName } from "@/features/cardRequisites/api/cardRequisit
|
|||||||
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
|
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
|
||||||
import { useInfiniteCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
|
import { useInfiniteCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
|
||||||
import { useInfiniteClients } from "@/features/clients/hooks/useClients";
|
import { useInfiniteClients } from "@/features/clients/hooks/useClients";
|
||||||
|
import { getRegionOptions } from "@/constants";
|
||||||
|
|
||||||
// ─── Status Badge ─────────────────────────────────────────────────────────────
|
// ─── Status Badge ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -42,8 +43,6 @@ const COLUMN_IDS = ["id", "uniqueId", "cardType", "customer", "user", "region",
|
|||||||
|
|
||||||
// ─── Filter constants ─────────────────────────────────────────────────────────
|
// ─── Filter constants ─────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const REGION_CODES = ["AG", "AH", "BN", "DZ", "LB", "MR"] as const;
|
|
||||||
|
|
||||||
export default function CardRequisitesPage() {
|
export default function CardRequisitesPage() {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
const lang = (i18n.language === "ru" ? "ru" : i18n.language === "en" ? "en" : "tm") as "tm" | "ru" | "en";
|
const lang = (i18n.language === "ru" ? "ru" : i18n.language === "en" ? "en" : "tm") as "tm" | "ru" | "en";
|
||||||
@@ -147,7 +146,7 @@ export default function CardRequisitesPage() {
|
|||||||
const total = data?.count ?? 0;
|
const total = data?.count ?? 0;
|
||||||
const totalPages = Math.max(1, Math.ceil(total / perPage));
|
const totalPages = Math.max(1, Math.ceil(total / perPage));
|
||||||
|
|
||||||
const regionOptions = useMemo(() => REGION_CODES.map((code) => ({ value: code, label: t(`loanOrders.regions.${code}`, code) })), [t]);
|
const regionOptions = useMemo(() => getRegionOptions(t), [t]);
|
||||||
|
|
||||||
const statusOptions = useMemo(
|
const statusOptions = useMemo(
|
||||||
() => [
|
() => [
|
||||||
|
|||||||
@@ -17,20 +17,10 @@ import type { IntlPaymentStatus, IntlPaymentItem } from "@/features/visaMasterPa
|
|||||||
import { useInfiniteBranches } from "@/features/shared/hooks/useSharedBranchUsers";
|
import { useInfiniteBranches } from "@/features/shared/hooks/useSharedBranchUsers";
|
||||||
import { useInfiniteUsers } from "@/features/allUsers/hooks/useAllUsers";
|
import { useInfiniteUsers } from "@/features/allUsers/hooks/useAllUsers";
|
||||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||||
|
import { REGION_CODES, REGION_LABELS } from "@/constants";
|
||||||
|
|
||||||
// ─── Constants ────────────────────────────────────────────────────────────────
|
// ─── Constants ────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const REGION_CODES = ["AG", "AH", "BN", "DZ", "LB", "MR"] as const;
|
|
||||||
|
|
||||||
const REGION_LABELS: Record<string, string> = {
|
|
||||||
AG: "Aşgabat",
|
|
||||||
AH: "Ahal",
|
|
||||||
BN: "Balkan",
|
|
||||||
DZ: "Daşoguz",
|
|
||||||
LB: "Lebap",
|
|
||||||
MR: "Mary",
|
|
||||||
};
|
|
||||||
|
|
||||||
function resolveLocalizedName(name: LocalizedText | string | null | undefined, lang: string): string {
|
function resolveLocalizedName(name: LocalizedText | string | null | undefined, lang: string): string {
|
||||||
if (!name) return "";
|
if (!name) return "";
|
||||||
if (typeof name === "string") return name;
|
if (typeof name === "string") return name;
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import { useLoanOrderMobiles, useDeleteLoanOrderMobile } from "@/features/loanOr
|
|||||||
import type { LoanOrderMobile, LoanOrderMobileStatus } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi";
|
import type { LoanOrderMobile, LoanOrderMobileStatus } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi";
|
||||||
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
|
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
import { getStatusLabel, getStatusOptions, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
import { getStatusLabel, getStatusOptions, getRegionOptions, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||||
|
import { formatFromApiDate } from "@/lib/utils";
|
||||||
// ─── Status Badge (inline) ────────────────────────────────────────────────────
|
// ─── Status Badge (inline) ────────────────────────────────────────────────────
|
||||||
|
|
||||||
const STATUS_ICONS: Record<StatusValue, React.ElementType> = {
|
const STATUS_ICONS: Record<StatusValue, React.ElementType> = {
|
||||||
@@ -38,8 +38,6 @@ const COLUMN_IDS = ["id", "loanType", "createdAt", "region", "branch", "firstNam
|
|||||||
|
|
||||||
// ─── Filter fields ────────────────────────────────────────────────────────────
|
// ─── Filter fields ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const REGION_CODES = ["AG", "AH", "BN", "DZ", "LB", "MR"] as const;
|
|
||||||
|
|
||||||
// ─── Page Component ───────────────────────────────────────────────────────────
|
// ─── Page Component ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export default function LoanOrderMobilesPage() {
|
export default function LoanOrderMobilesPage() {
|
||||||
@@ -97,7 +95,7 @@ export default function LoanOrderMobilesPage() {
|
|||||||
const { data, isLoading } = useLoanOrderMobiles(queryParams);
|
const { data, isLoading } = useLoanOrderMobiles(queryParams);
|
||||||
const totalPages = data ? Math.ceil(data.total / perPage) : 1;
|
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 regionOptions = useMemo(() => getRegionOptions(t), [t]);
|
||||||
|
|
||||||
const handleFilterChange = useCallback((fieldId: string, value: string) => {
|
const handleFilterChange = useCallback((fieldId: string, value: string) => {
|
||||||
setActiveFilters((prev) => prev.map((f) => (f.fieldId === fieldId ? { ...f, value } : f)));
|
setActiveFilters((prev) => prev.map((f) => (f.fieldId === fieldId ? { ...f, value } : f)));
|
||||||
@@ -138,7 +136,7 @@ export default function LoanOrderMobilesPage() {
|
|||||||
id: "createdAt",
|
id: "createdAt",
|
||||||
accessorKey: "createdAt",
|
accessorKey: "createdAt",
|
||||||
header: t("Created at", "DÖREDILEN WAGTY"),
|
header: t("Created at", "DÖREDILEN WAGTY"),
|
||||||
cell: ({ row }) => <span className="text-sm text-foreground whitespace-nowrap">{row.original.createdAt}</span>,
|
cell: ({ row }) => <span className="text-sm text-foreground whitespace-nowrap">{formatFromApiDate(row.original.createdAt)}</span>,
|
||||||
size: 160,
|
size: 160,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
|||||||
import { BentoGrid, BentoCard, InfoRow, PassportImage, AuditLog, type AuditRowProps } from "@/components/viewPageComponents";
|
import { BentoGrid, BentoCard, InfoRow, PassportImage, AuditLog, type AuditRowProps } from "@/components/viewPageComponents";
|
||||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||||
import { getStatusLabel, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
import { getStatusLabel, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||||
|
import { formatFromApiDate } from "@/lib/utils";
|
||||||
|
|
||||||
// ─── Status config ────────────────────────────────────────────────────────────
|
// ─── Status config ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -87,7 +88,9 @@ export default function LoanOrderMobilesViewPage() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const hasCard = !!(order.cardNumber || order.cardName);
|
const hasCard = !!(order.cardNumber || order.cardName);
|
||||||
|
const hasLoanCard = !!(order.loanCardNumber || order.loanCardName);
|
||||||
const hasGuarantor = !!(order.guarantor1Name || order.guarantor1CardNumber);
|
const hasGuarantor = !!(order.guarantor1Name || order.guarantor1CardNumber);
|
||||||
|
const hasGuarantor2 = !!(order.guarantor2Name || order.guarantor2Surname || order.guarantor2CardNumber);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-6">
|
<div className="flex flex-col gap-6">
|
||||||
@@ -119,11 +122,17 @@ export default function LoanOrderMobilesViewPage() {
|
|||||||
<BentoGrid cols={3}>
|
<BentoGrid cols={3}>
|
||||||
<BentoCard title={t("loanOrders.sections.meta", "Esasy maglumatlar")}>
|
<BentoCard title={t("loanOrders.sections.meta", "Esasy maglumatlar")}>
|
||||||
<InfoRow label={t("common.id", "ID")} value={order.id} />
|
<InfoRow label={t("common.id", "ID")} value={order.id} />
|
||||||
|
<InfoRow label={t("loanOrders.fields.uniqueId", "Ýeke-täk ID")} value={order.uniqueId || undefined} />
|
||||||
<InfoRow label={t("loanOrders.columns.status", "Status")}>
|
<InfoRow label={t("loanOrders.columns.status", "Status")}>
|
||||||
<LoanOrderMobileStatusBadge status={order.status} />
|
<LoanOrderMobileStatusBadge status={order.status} />
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow label={t("loanOrders.columns.createdAt", "Döredilen wagty")} value={order.createdAt} />
|
<InfoRow label={t("loanOrders.columns.createdAt", "Döredilen wagty")} value={formatFromApiDate(order.createdAt)} />
|
||||||
|
<InfoRow label={t("loanOrders.fields.updatedAt", "Üýtgedilen wagty")} value={formatFromApiDate(order.updatedAt) || undefined} />
|
||||||
|
<InfoRow label={t("loanOrders.fields.source", "Çeşme")} value={order.source ?? undefined} />
|
||||||
|
<InfoRow
|
||||||
|
label={t("loanOrders.fields.satisfiable", "Kanagatlandyrylan")}
|
||||||
|
value={order.satisfiable ? t(`loanOrders.satisfiable.${order.satisfiable}`, order.satisfiable) : undefined}
|
||||||
|
/>
|
||||||
<InfoRow label={t("loanOrders.fields.note", "Bellik")} value={order.note || undefined} />
|
<InfoRow label={t("loanOrders.fields.note", "Bellik")} value={order.note || undefined} />
|
||||||
<InfoRow label={t("loanOrders.columns.createdBy", "Döreden")} value={order.createdBy} />
|
<InfoRow label={t("loanOrders.columns.createdBy", "Döreden")} value={order.createdBy} />
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
@@ -169,37 +178,44 @@ export default function LoanOrderMobilesViewPage() {
|
|||||||
<InfoRow label={t("loanOrders.fields.cardName", "Kartdaky ady")} value={order.cardName} />
|
<InfoRow label={t("loanOrders.fields.cardName", "Kartdaky ady")} value={order.cardName} />
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
{/* Guarantor card — shown side-by-side with main card when both exist */}
|
{/* Loan disbursement card — shown side-by-side with personal card */}
|
||||||
{hasGuarantor && (
|
{hasLoanCard && (
|
||||||
<BentoCard title={t("loanOrders.sections.guarantor", "1. Zamun")} noPadding>
|
<BentoCard title={t("loanOrders.sections.loanCard", "Karz geçiriljek kartoçka")} noPadding>
|
||||||
<InfoRow
|
<div className="p-6 bg-slate-50 dark:bg-slate-900/50 border-b border-border flex items-center justify-center">
|
||||||
label={t("loanOrders.fields.guarantorName", "Zamunyň doly ady")}
|
<CreditCardVisual
|
||||||
value={`${order.guarantor1Name || ""} ${order.guarantor1Surname || ""} ${order.guarantor1Patronic || ""}`.trim()}
|
cardNumber={order.loanCardNumber}
|
||||||
/>
|
cardName={order.loanCardName}
|
||||||
<InfoRow
|
expMonth={order.loanCardMonth}
|
||||||
label={t("loanOrders.fields.guarantorPassport", "Pasport")}
|
expYear={order.loanCardYear}
|
||||||
value={`${order.guarantor1PassportSerie || ""} ${order.guarantor1PassportNumber || ""}`.trim()}
|
variant="primary"
|
||||||
/>
|
/>
|
||||||
<InfoRow
|
</div>
|
||||||
label={t("loanOrders.fields.guarantorSalary", "Ortaca zähmet haky")}
|
<InfoRow label={t("loanOrders.fields.loanCardNumber", "Kart belgisi")} value={order.loanCardNumber ?? undefined} />
|
||||||
value={order.guarantor1Salary ? String(order.guarantor1Salary) : undefined}
|
<InfoRow label={t("loanOrders.fields.loanCardName", "Kartdaky ady")} value={order.loanCardName ?? undefined} />
|
||||||
/>
|
|
||||||
{order.guarantor1CardNumber && (
|
|
||||||
<div className="p-6 bg-slate-50 dark:bg-slate-900/50 border-t border-border flex items-center justify-center">
|
|
||||||
<CreditCardVisual
|
|
||||||
cardNumber={order.guarantor1CardNumber}
|
|
||||||
cardName={order.guarantor1CardName}
|
|
||||||
expMonth={order.guarantor1CardExpMonth}
|
|
||||||
expYear={order.guarantor1CardExpYear}
|
|
||||||
variant="secondary"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
)}
|
)}
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* If there's no personal card but a loan card exists, still show it on its own row */}
|
||||||
|
{!hasCard && hasLoanCard && (
|
||||||
|
<BentoGrid cols={2}>
|
||||||
|
<BentoCard title={t("loanOrders.sections.loanCard", "Karz geçiriljek kartoçka")} noPadding>
|
||||||
|
<div className="p-6 bg-slate-50 dark:bg-slate-900/50 border-b border-border flex items-center justify-center">
|
||||||
|
<CreditCardVisual
|
||||||
|
cardNumber={order.loanCardNumber}
|
||||||
|
cardName={order.loanCardName}
|
||||||
|
expMonth={order.loanCardMonth}
|
||||||
|
expYear={order.loanCardYear}
|
||||||
|
variant="primary"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<InfoRow label={t("loanOrders.fields.loanCardNumber", "Kart belgisi")} value={order.loanCardNumber ?? undefined} />
|
||||||
|
<InfoRow label={t("loanOrders.fields.loanCardName", "Kartdaky ady")} value={order.loanCardName ?? undefined} />
|
||||||
|
</BentoCard>
|
||||||
|
</BentoGrid>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* ── Row 3: Personal + Contacts ──────────────────────────────────── */}
|
{/* ── Row 3: Personal + Contacts ──────────────────────────────────── */}
|
||||||
<BentoGrid cols={2}>
|
<BentoGrid cols={2}>
|
||||||
<BentoCard title={t("loanOrders.sections.personal", "Şahsy maglumatlar")}>
|
<BentoCard title={t("loanOrders.sections.personal", "Şahsy maglumatlar")}>
|
||||||
@@ -241,7 +257,9 @@ export default function LoanOrderMobilesViewPage() {
|
|||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t("loanOrders.sections.passport", "Pasport")}>
|
<BentoCard title={t("loanOrders.sections.passport", "Pasport")}>
|
||||||
|
<InfoRow label={t("loanOrders.fields.passportSerie", "Pasport seriýasy")} value={order.passportSerie ?? undefined} />
|
||||||
<InfoRow label={t("loanOrders.fields.passportNumber", "Pasport")} value={order.passportNumber ?? undefined} />
|
<InfoRow label={t("loanOrders.fields.passportNumber", "Pasport")} value={order.passportNumber ?? undefined} />
|
||||||
|
<InfoRow label={t("loanOrders.fields.passportGivenAt", "Berlen senesi")} value={order.passportDateOfIssue ?? undefined} />
|
||||||
<InfoRow label={t("loanOrders.fields.passportIssuedBy", "Kim tarapyndan berildi")} value={order.passportGivenBy ?? undefined} />
|
<InfoRow label={t("loanOrders.fields.passportIssuedBy", "Kim tarapyndan berildi")} value={order.passportGivenBy ?? undefined} />
|
||||||
<InfoRow label={t("loanOrders.fields.passportBirthPlace", "Doglan ýeri (pasport)")} value={order.bornPlace ?? undefined} />
|
<InfoRow label={t("loanOrders.fields.passportBirthPlace", "Doglan ýeri (pasport)")} value={order.bornPlace ?? undefined} />
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
@@ -269,9 +287,9 @@ export default function LoanOrderMobilesViewPage() {
|
|||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
|
|
||||||
{/* ── Guarantor (standalone — only when no card to pair with) ─────── */}
|
{/* ── Guarantor 1 (standalone — only when no personal card to pair with) ── */}
|
||||||
{hasGuarantor && !hasCard && (
|
{hasGuarantor && !hasCard && (
|
||||||
<BentoGrid cols={2}>
|
<BentoGrid cols={hasGuarantor2 ? 2 : 1}>
|
||||||
<BentoCard title={t("loanOrders.sections.guarantor", "1. Zamun")}>
|
<BentoCard title={t("loanOrders.sections.guarantor", "1. Zamun")}>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t("loanOrders.fields.guarantorName", "Zamunyň doly ady")}
|
label={t("loanOrders.fields.guarantorName", "Zamunyň doly ady")}
|
||||||
@@ -285,6 +303,7 @@ export default function LoanOrderMobilesViewPage() {
|
|||||||
label={t("loanOrders.fields.guarantorSalary", "Ortaca zähmet haky")}
|
label={t("loanOrders.fields.guarantorSalary", "Ortaca zähmet haky")}
|
||||||
value={order.guarantor1Salary ? String(order.guarantor1Salary) : undefined}
|
value={order.guarantor1Salary ? String(order.guarantor1Salary) : undefined}
|
||||||
/>
|
/>
|
||||||
|
<InfoRow label={t("loanOrders.fields.guarantorNote", "Bellik")} value={order.guarantor1Note ?? undefined} />
|
||||||
{order.guarantor1CardNumber && (
|
{order.guarantor1CardNumber && (
|
||||||
<div className="p-6 bg-slate-50 dark:bg-slate-900/50 border-t border-border flex items-center justify-center">
|
<div className="p-6 bg-slate-50 dark:bg-slate-900/50 border-t border-border flex items-center justify-center">
|
||||||
<CreditCardVisual
|
<CreditCardVisual
|
||||||
@@ -297,6 +316,69 @@ export default function LoanOrderMobilesViewPage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
|
{/* Guarantor 2 — paired with guarantor 1 here since no personal card row is shown */}
|
||||||
|
{hasGuarantor2 && (
|
||||||
|
<BentoCard title={t("loanOrders.sections.guarantor2", "2. Zamun")}>
|
||||||
|
<InfoRow
|
||||||
|
label={t("loanOrders.fields.guarantorName", "Zamunyň doly ady")}
|
||||||
|
value={`${order.guarantor2Name || ""} ${order.guarantor2Surname || ""} ${order.guarantor2Patronic || ""}`.trim()}
|
||||||
|
/>
|
||||||
|
<InfoRow
|
||||||
|
label={t("loanOrders.fields.guarantorPassport", "Pasport")}
|
||||||
|
value={`${order.guarantor2PassportSerie || ""} ${order.guarantor2PassportNumber || ""}`.trim()}
|
||||||
|
/>
|
||||||
|
<InfoRow label={t("loanOrders.fields.guarantorNote", "Bellik")} value={order.guarantor2Note ?? undefined} />
|
||||||
|
{order.guarantor2CardNumber && (
|
||||||
|
<div className="p-6 bg-slate-50 dark:bg-slate-900/50 border-t border-border flex items-center justify-center">
|
||||||
|
<CreditCardVisual
|
||||||
|
cardNumber={order.guarantor2CardNumber}
|
||||||
|
cardName={order.guarantor2CardName}
|
||||||
|
expMonth={order.guarantor2CardExpMonth}
|
||||||
|
expYear={order.guarantor2CardExpYear}
|
||||||
|
variant="secondary"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</BentoCard>
|
||||||
|
)}
|
||||||
|
</BentoGrid>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* ── Guarantor 1 + 2 (standalone — when a personal card already paired guarantor1 above) ── */}
|
||||||
|
{hasGuarantor && hasCard && hasGuarantor2 && (
|
||||||
|
<BentoGrid cols={1}>
|
||||||
|
<BentoCard title={t("loanOrders.sections.guarantor2", "2. Zamun")}>
|
||||||
|
<InfoRow
|
||||||
|
label={t("loanOrders.fields.guarantorName", "Zamunyň doly ady")}
|
||||||
|
value={`${order.guarantor2Name || ""} ${order.guarantor2Surname || ""} ${order.guarantor2Patronic || ""}`.trim()}
|
||||||
|
/>
|
||||||
|
<InfoRow
|
||||||
|
label={t("loanOrders.fields.guarantorPassport", "Pasport")}
|
||||||
|
value={`${order.guarantor2PassportSerie || ""} ${order.guarantor2PassportNumber || ""}`.trim()}
|
||||||
|
/>
|
||||||
|
<InfoRow label={t("loanOrders.fields.guarantorNote", "Bellik")} value={order.guarantor2Note ?? undefined} />
|
||||||
|
{order.guarantor2CardNumber && (
|
||||||
|
<div className="p-6 bg-slate-50 dark:bg-slate-900/50 border-t border-border flex items-center justify-center">
|
||||||
|
<CreditCardVisual
|
||||||
|
cardNumber={order.guarantor2CardNumber}
|
||||||
|
cardName={order.guarantor2CardName}
|
||||||
|
expMonth={order.guarantor2CardExpMonth}
|
||||||
|
expYear={order.guarantor2CardExpYear}
|
||||||
|
variant="secondary"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</BentoCard>
|
||||||
|
</BentoGrid>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* ── Guarantor 1 note when it was paired with the personal card above (Row 2) ── */}
|
||||||
|
{hasGuarantor && hasCard && order.guarantor1Note && (
|
||||||
|
<BentoGrid cols={1}>
|
||||||
|
<BentoCard title={t("loanOrders.fields.guarantorNote", "1. Zamunyň bellik")}>
|
||||||
|
<InfoRow label={t("loanOrders.fields.guarantorNote", "Bellik")} value={order.guarantor1Note ?? undefined} />
|
||||||
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import type { LoanOrderStatus } from "@/features/loanOrders/api/loanOrdersApi";
|
|||||||
import { BentoGrid, BentoCard, InfoRow, PassportImage, AuditLog, type AuditRowProps } from "@/components/viewPageComponents";
|
import { BentoGrid, BentoCard, InfoRow, PassportImage, AuditLog, type AuditRowProps } from "@/components/viewPageComponents";
|
||||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||||
import { getStatusLabel, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
import { getStatusLabel, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||||
|
import { formatFromApiDate } from "@/lib/utils";
|
||||||
|
|
||||||
// ─── Status config ────────────────────────────────────────────────────────────
|
// ─── Status config ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -27,6 +28,14 @@ function LoanOrderMobileStatusBadge({ status }: { status: LoanOrderStatus }) {
|
|||||||
return <StatusBadge label={getStatusLabel(status, t, "loanOrderStatus")} variant={variant} icon={Icon} />;
|
return <StatusBadge label={getStatusLabel(status, t, "loanOrderStatus")} variant={variant} icon={Icon} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/** Combine expiry month/year into a single "MM/YYYY" string, or undefined if both are empty. */
|
||||||
|
function formatCardExpiry(month?: string | null, year?: string | null): string | undefined {
|
||||||
|
if (!month && !year) return undefined;
|
||||||
|
return [month, year].filter(Boolean).join("/");
|
||||||
|
}
|
||||||
|
|
||||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
function LoanOrderViewSkeleton() {
|
function LoanOrderViewSkeleton() {
|
||||||
@@ -81,10 +90,15 @@ export default function LoanOrderViewPage() {
|
|||||||
by: order.createdBy ?? "",
|
by: order.createdBy ?? "",
|
||||||
target: `${t("loanOrders.title", "Karz sargyt")}: ${order.id}`,
|
target: `${t("loanOrders.title", "Karz sargyt")}: ${order.id}`,
|
||||||
status: "FINISHED",
|
status: "FINISHED",
|
||||||
date: order.createdAt ?? "",
|
date: formatFromApiDate(order.createdAt),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const guarantor1Name = [order.guarantorName, order.guarantorSurname, order.guarantorPatronicName].filter(Boolean).join(" ");
|
||||||
|
const guarantor2Name = [order.guarantor2Name, order.guarantor2Surname, order.guarantor2PatronicName].filter(Boolean).join(" ");
|
||||||
|
|
||||||
|
const hasGuarantor2 = order.guarantor2Name || order.guarantor2Surname || order.guarantor2PassportId || order.guarantor2CardNumber;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-6">
|
<div className="flex flex-col gap-6">
|
||||||
{/* ── Page header ──────────────────────────────────────────────────── */}
|
{/* ── Page header ──────────────────────────────────────────────────── */}
|
||||||
@@ -116,10 +130,17 @@ export default function LoanOrderViewPage() {
|
|||||||
{/* Meta */}
|
{/* Meta */}
|
||||||
<BentoCard title={t("loanOrders.sections.meta", "Esasy maglumatlar")}>
|
<BentoCard title={t("loanOrders.sections.meta", "Esasy maglumatlar")}>
|
||||||
<InfoRow label={t("common.id", "ID")} value={order.id} />
|
<InfoRow label={t("common.id", "ID")} value={order.id} />
|
||||||
<InfoRow label={t("loanOrders.columns.createdAt", "Döredilen wagty")} value={order.createdAt} />
|
<InfoRow label={t("loanOrders.fields.uniqueId", "Ýeke-täk ID")} value={order.uniqueId || undefined} />
|
||||||
|
<InfoRow label={t("loanOrders.columns.createdAt", "Döredilen wagty")} value={formatFromApiDate(order.createdAt) || undefined} />
|
||||||
|
<InfoRow label={t("loanOrders.fields.updatedAt", "Üýtgedilen wagty")} value={formatFromApiDate(order.updatedAt) || undefined} />
|
||||||
<InfoRow label={t("loanOrders.columns.status", "Status")}>
|
<InfoRow label={t("loanOrders.columns.status", "Status")}>
|
||||||
<LoanOrderMobileStatusBadge status={order.status} />
|
<LoanOrderMobileStatusBadge status={order.status} />
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
|
<InfoRow label={t("loanOrders.fields.source", "Çeşme")} value={order.source ?? undefined} />
|
||||||
|
<InfoRow
|
||||||
|
label={t("loanOrders.fields.satisfiable", "Kanagatlandyrylan")}
|
||||||
|
value={order.satisfiable ? t(`loanOrders.satisfiable.${order.satisfiable}`, order.satisfiable) : undefined}
|
||||||
|
/>
|
||||||
<InfoRow label={t("loanOrders.fields.amount", "Berlik")} value={order.amount ? String(order.amount) : undefined} />
|
<InfoRow label={t("loanOrders.fields.amount", "Berlik")} value={order.amount ? String(order.amount) : undefined} />
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t("loanOrders.fields.createdBy", "Sargyt eden")}
|
label={t("loanOrders.fields.createdBy", "Sargyt eden")}
|
||||||
@@ -127,6 +148,7 @@ export default function LoanOrderViewPage() {
|
|||||||
isLink
|
isLink
|
||||||
href={order.createdById ? `/all-users/${order.createdById}` : "/all-users"}
|
href={order.createdById ? `/all-users/${order.createdById}` : "/all-users"}
|
||||||
/>
|
/>
|
||||||
|
<InfoRow label={t("loanOrders.fields.notes", "Bellik")} value={order.notes ?? undefined} />
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
{/* Loan */}
|
{/* Loan */}
|
||||||
@@ -141,6 +163,7 @@ export default function LoanOrderViewPage() {
|
|||||||
label={t("loanOrders.fields.loanAmount", "Karz mukdary")}
|
label={t("loanOrders.fields.loanAmount", "Karz mukdary")}
|
||||||
value={order.loanAmount ? String(order.loanAmount) : undefined}
|
value={order.loanAmount ? String(order.loanAmount) : undefined}
|
||||||
/>
|
/>
|
||||||
|
<InfoRow label={t("loanOrders.fields.loanHistory", "Talap edilýän resminama")} value={order.loanHistory || undefined} />
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
{/* Location */}
|
{/* Location */}
|
||||||
@@ -160,9 +183,10 @@ export default function LoanOrderViewPage() {
|
|||||||
{/* Personal */}
|
{/* Personal */}
|
||||||
<BentoCard title={t("loanOrders.sections.personal", "Şahsy maglumatlar")}>
|
<BentoCard title={t("loanOrders.sections.personal", "Şahsy maglumatlar")}>
|
||||||
<InfoRow label={t("loanOrders.fields.fullName", "Doly ady")} value={order.fullName ?? `${order.firstName} ${order.lastName}`} />
|
<InfoRow label={t("loanOrders.fields.fullName", "Doly ady")} value={order.fullName ?? `${order.firstName} ${order.lastName}`} />
|
||||||
|
<InfoRow label={t("loanOrders.fields.patronicName", "Atasynyň ady")} value={order.patronicName ?? undefined} />
|
||||||
<InfoRow label={t("loanOrders.fields.education", "Bilimi")} value={order.education ?? undefined} />
|
<InfoRow label={t("loanOrders.fields.education", "Bilimi")} value={order.education ?? undefined} />
|
||||||
<InfoRow label={t("loanOrders.fields.maritalStatus", "Maşgala ýagdaýy")} value={order.maritalStatus ?? undefined} />
|
<InfoRow label={t("loanOrders.fields.maritalStatus", "Maşgala ýagdaýy")} value={order.maritalStatus ?? undefined} />
|
||||||
<InfoRow label={t("loanOrders.fields.birthDate", "Doglan güni")} value={order.birthDate ?? undefined} />
|
<InfoRow label={t("loanOrders.fields.birthDate", "Doglan güni")} value={formatFromApiDate(order.birthDate) || undefined} />
|
||||||
<InfoRow label={t("loanOrders.fields.registeredAddress", "Ýazgy edilen salgy")} value={order.registeredAddress ?? undefined} />
|
<InfoRow label={t("loanOrders.fields.registeredAddress", "Ýazgy edilen salgy")} value={order.registeredAddress ?? undefined} />
|
||||||
<InfoRow label={t("loanOrders.fields.currentAddress", "Häzirki ýaşaýyş ýeri")} value={order.currentAddress ?? undefined} />
|
<InfoRow label={t("loanOrders.fields.currentAddress", "Häzirki ýaşaýyş ýeri")} value={order.currentAddress ?? undefined} />
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
@@ -191,12 +215,20 @@ export default function LoanOrderViewPage() {
|
|||||||
/>
|
/>
|
||||||
<InfoRow label={t("loanOrders.fields.position", "Wezipe")} value={order.position ?? undefined} />
|
<InfoRow label={t("loanOrders.fields.position", "Wezipe")} value={order.position ?? undefined} />
|
||||||
<InfoRow label={t("loanOrders.fields.salary", "Zähmet haky")} value={order.salary ? String(order.salary) : undefined} />
|
<InfoRow label={t("loanOrders.fields.salary", "Zähmet haky")} value={order.salary ? String(order.salary) : undefined} />
|
||||||
<InfoRow label={t("loanOrders.fields.employedSince", "Işe başlan wagty")} value={order.employedSince ?? undefined} />
|
<InfoRow
|
||||||
|
label={t("loanOrders.fields.employedSince", "Işe başlan wagty")}
|
||||||
|
value={formatFromApiDate(order.employedSince) || undefined}
|
||||||
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
{/* Passport info */}
|
{/* Passport info */}
|
||||||
<BentoCard title={t("loanOrders.sections.passport", "Pasport")}>
|
<BentoCard title={t("loanOrders.sections.passport", "Pasport")}>
|
||||||
<InfoRow label={t("loanOrders.fields.passportNumber", "Pasport")} value={order.passportNumber ?? undefined} />
|
<InfoRow label={t("loanOrders.fields.passportSerie", "Pasport seriýasy")} value={order.passportSerie ?? undefined} />
|
||||||
|
<InfoRow label={t("loanOrders.fields.passportNumber", "Pasport belgisi")} value={order.passportNumber ?? undefined} />
|
||||||
|
<InfoRow
|
||||||
|
label={t("loanOrders.fields.passportGivenAt", "Berlen senesi")}
|
||||||
|
value={formatFromApiDate(order.passportDateOfIssue) || undefined}
|
||||||
|
/>
|
||||||
<InfoRow label={t("loanOrders.fields.passportIssuedBy", "Kim tarapyndan berildi")} value={order.passportIssuedBy ?? undefined} />
|
<InfoRow label={t("loanOrders.fields.passportIssuedBy", "Kim tarapyndan berildi")} value={order.passportIssuedBy ?? undefined} />
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t("loanOrders.fields.passportBirthPlace", "Doglan ýeri (pasport)")}
|
label={t("loanOrders.fields.passportBirthPlace", "Doglan ýeri (pasport)")}
|
||||||
@@ -227,6 +259,71 @@ export default function LoanOrderViewPage() {
|
|||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
|
|
||||||
|
{/* ── Row 5: Salary Card + Loan Card ──────────────────────────────── */}
|
||||||
|
<BentoGrid cols={2}>
|
||||||
|
{/* Salary / personal card */}
|
||||||
|
<BentoCard title={t("loanOrders.sections.salaryCard", "Zähmet haky kartoçkasy")}>
|
||||||
|
<InfoRow label={t("loanOrders.fields.cardNumber", "Karta belgisi")} value={order.cardNumber ?? undefined} />
|
||||||
|
<InfoRow label={t("loanOrders.fields.cardName", "Kartdaky ady")} value={order.cardName ?? undefined} />
|
||||||
|
<InfoRow
|
||||||
|
label={t("loanOrders.fields.cardExpiry", "Möhleti")}
|
||||||
|
value={formatCardExpiry(order.cardExpMonth ?? order.cardMonth, order.cardExpYear ?? order.cardYear)}
|
||||||
|
/>
|
||||||
|
</BentoCard>
|
||||||
|
|
||||||
|
{/* Loan card (disbursement card) */}
|
||||||
|
<BentoCard title={t("loanOrders.sections.loanCard", "Karz geçiriljek kartoçka")}>
|
||||||
|
<InfoRow label={t("loanOrders.fields.loanCardNumber", "Karta belgisi")} value={order.loanCardNumber ?? undefined} />
|
||||||
|
<InfoRow label={t("loanOrders.fields.loanCardName", "Kartdaky ady")} value={order.loanCardName ?? undefined} />
|
||||||
|
<InfoRow label={t("loanOrders.fields.cardExpiry", "Möhleti")} value={formatCardExpiry(order.loanCardMonth, order.loanCardYear)} />
|
||||||
|
</BentoCard>
|
||||||
|
</BentoGrid>
|
||||||
|
|
||||||
|
{/* ── Row 6: Guarantors ───────────────────────────────────────────── */}
|
||||||
|
<BentoGrid cols={hasGuarantor2 ? 2 : 1}>
|
||||||
|
{/* Guarantor 1 */}
|
||||||
|
<BentoCard title={t("loanOrders.sections.guarantor1", "1-nji zamun")}>
|
||||||
|
<InfoRow label={t("loanOrders.fields.guarantorFullName", "Doly ady")} value={guarantor1Name || undefined} />
|
||||||
|
<InfoRow
|
||||||
|
label={t("loanOrders.fields.guarantorPassportSerie", "Pasport seriýasy")}
|
||||||
|
value={order.guarantor1PassportSerie ?? undefined}
|
||||||
|
/>
|
||||||
|
<InfoRow
|
||||||
|
label={t("loanOrders.fields.guarantorPassportNumber", "Pasport belgisi")}
|
||||||
|
value={order.guarantor1PassportNumber ?? undefined}
|
||||||
|
/>
|
||||||
|
<InfoRow label={t("loanOrders.fields.guarantorCardNumber", "Karta belgisi")} value={order.guarantor1CardNumber ?? undefined} />
|
||||||
|
<InfoRow label={t("loanOrders.fields.guarantorCardName", "Kartdaky ady")} value={order.guarantor1CardName ?? undefined} />
|
||||||
|
<InfoRow
|
||||||
|
label={t("loanOrders.fields.cardExpiry", "Möhleti")}
|
||||||
|
value={formatCardExpiry(order.guarantor1CardExpMonth, order.guarantor1CardExpYear)}
|
||||||
|
/>
|
||||||
|
<InfoRow label={t("loanOrders.fields.guarantorNote", "Bellik")} value={order.guarantor1Note ?? undefined} />
|
||||||
|
</BentoCard>
|
||||||
|
|
||||||
|
{/* Guarantor 2 (optional) */}
|
||||||
|
{hasGuarantor2 && (
|
||||||
|
<BentoCard title={t("loanOrders.sections.guarantor2", "2-nji zamun")}>
|
||||||
|
<InfoRow label={t("loanOrders.fields.guarantorFullName", "Doly ady")} value={guarantor2Name || undefined} />
|
||||||
|
<InfoRow
|
||||||
|
label={t("loanOrders.fields.guarantorPassportSerie", "Pasport seriýasy")}
|
||||||
|
value={order.guarantor2PassportSerie ?? undefined}
|
||||||
|
/>
|
||||||
|
<InfoRow
|
||||||
|
label={t("loanOrders.fields.guarantorPassportNumber", "Pasport belgisi")}
|
||||||
|
value={order.guarantor2PassportNumber ?? undefined}
|
||||||
|
/>
|
||||||
|
<InfoRow label={t("loanOrders.fields.guarantorCardNumber", "Karta belgisi")} value={order.guarantor2CardNumber ?? undefined} />
|
||||||
|
<InfoRow label={t("loanOrders.fields.guarantorCardName", "Kartdaky ady")} value={order.guarantor2CardName ?? undefined} />
|
||||||
|
<InfoRow
|
||||||
|
label={t("loanOrders.fields.cardExpiry", "Möhleti")}
|
||||||
|
value={formatCardExpiry(order.guarantor2CardExpMonth, order.guarantor2CardExpYear)}
|
||||||
|
/>
|
||||||
|
<InfoRow label={t("loanOrders.fields.guarantorNote", "Bellik")} value={order.guarantor2Note ?? undefined} />
|
||||||
|
</BentoCard>
|
||||||
|
)}
|
||||||
|
</BentoGrid>
|
||||||
|
|
||||||
{/* ── Audit log ────────────────────────────────────────────────────── */}
|
{/* ── Audit log ────────────────────────────────────────────────────── */}
|
||||||
<AuditLog logs={auditLogs} />
|
<AuditLog logs={auditLogs} />
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import { useLoanOrders, useDeleteLoanOrder } from "@/features/loanOrders/hooks/u
|
|||||||
import type { LoanOrder, LoanOrderStatus } from "@/features/loanOrders/api/loanOrdersApi";
|
import type { LoanOrder, LoanOrderStatus } from "@/features/loanOrders/api/loanOrdersApi";
|
||||||
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
|
import { useInfiniteBranches } from "@/features/branches/hooks/useBranches";
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
import { getStatusLabel, getStatusOptions, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
import { getStatusLabel, getStatusOptions, getRegionOptions, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||||
|
import { formatFromApiDate } from "@/lib/utils";
|
||||||
// ─── Status Badge (inline) ────────────────────────────────────────────────────
|
// ─── Status Badge (inline) ────────────────────────────────────────────────────
|
||||||
|
|
||||||
const STATUS_ICONS: Record<StatusValue, React.ElementType> = {
|
const STATUS_ICONS: Record<StatusValue, React.ElementType> = {
|
||||||
@@ -38,8 +38,6 @@ const COLUMN_IDS = ["id", "loanType", "createdAt", "region", "branch", "firstNam
|
|||||||
|
|
||||||
// ─── Filter fields ────────────────────────────────────────────────────────────
|
// ─── Filter fields ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const REGION_CODES = ["AG", "AH", "BN", "DZ", "LB", "MR"] as const;
|
|
||||||
|
|
||||||
// ─── Page Component ───────────────────────────────────────────────────────────
|
// ─── Page Component ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export default function LoanOrdersPage() {
|
export default function LoanOrdersPage() {
|
||||||
@@ -78,7 +76,6 @@ export default function LoanOrdersPage() {
|
|||||||
{ fieldId: "region", value: "" },
|
{ fieldId: "region", value: "" },
|
||||||
{ fieldId: "status", value: "" },
|
{ fieldId: "status", value: "" },
|
||||||
{ fieldId: "branch", value: "" },
|
{ fieldId: "branch", value: "" },
|
||||||
{ fieldId: "archived", value: "" },
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const queryParams = useMemo(() => {
|
const queryParams = useMemo(() => {
|
||||||
@@ -88,7 +85,6 @@ export default function LoanOrdersPage() {
|
|||||||
region: filterMap.region || undefined,
|
region: filterMap.region || undefined,
|
||||||
status: (filterMap.status as LoanOrderStatus) || undefined,
|
status: (filterMap.status as LoanOrderStatus) || undefined,
|
||||||
branch: filterMap.branch || undefined,
|
branch: filterMap.branch || undefined,
|
||||||
archived: filterMap.archived || undefined,
|
|
||||||
page,
|
page,
|
||||||
perPage,
|
perPage,
|
||||||
};
|
};
|
||||||
@@ -97,7 +93,7 @@ export default function LoanOrdersPage() {
|
|||||||
const { data, isLoading } = useLoanOrders(queryParams);
|
const { data, isLoading } = useLoanOrders(queryParams);
|
||||||
const totalPages = data ? Math.ceil(data.total / perPage) : 1;
|
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 regionOptions = useMemo(() => getRegionOptions(t), [t]);
|
||||||
|
|
||||||
const handleFilterChange = useCallback((fieldId: string, value: string) => {
|
const handleFilterChange = useCallback((fieldId: string, value: string) => {
|
||||||
setActiveFilters((prev) => prev.map((f) => (f.fieldId === fieldId ? { ...f, value } : f)));
|
setActiveFilters((prev) => prev.map((f) => (f.fieldId === fieldId ? { ...f, value } : f)));
|
||||||
@@ -138,7 +134,7 @@ export default function LoanOrdersPage() {
|
|||||||
id: "createdAt",
|
id: "createdAt",
|
||||||
accessorKey: "createdAt",
|
accessorKey: "createdAt",
|
||||||
header: t("Created at", "DÖREDILEN WAGTY"),
|
header: t("Created at", "DÖREDILEN WAGTY"),
|
||||||
cell: ({ row }) => <span className="text-sm text-foreground whitespace-nowrap">{row.original.createdAt}</span>,
|
cell: ({ row }) => <span className="text-sm text-foreground whitespace-nowrap">{formatFromApiDate(row.original.createdAt)}</span>,
|
||||||
size: 160,
|
size: 160,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -229,14 +225,6 @@ export default function LoanOrdersPage() {
|
|||||||
searchValue: branchSearch,
|
searchValue: branchSearch,
|
||||||
onSearchChange: setBranchSearch,
|
onSearchChange: setBranchSearch,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: "archived",
|
|
||||||
label: t("loanOrders.filters.archived", "ARHIWLENEN"),
|
|
||||||
options: [
|
|
||||||
{ value: "true", label: t("common.yes", "Hawa") },
|
|
||||||
{ value: "false", label: t("common.no", "Ýok") },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
[t, regionOptions, branchOptions, isBranchesLoading, isFetchingNextBranches, hasNextBranches, branchSearch],
|
[t, regionOptions, branchOptions, isBranchesLoading, isFetchingNextBranches, hasNextBranches, branchSearch],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export default function LoanRemainingPage() {
|
|||||||
id: "userId",
|
id: "userId",
|
||||||
accessorKey: "userId",
|
accessorKey: "userId",
|
||||||
header: t("loanRemaining.columns.userId", "ULANYJY ID"),
|
header: t("loanRemaining.columns.userId", "ULANYJY ID"),
|
||||||
cell: ({ row }) => <span className="text-sm text-foreground">{row.original.userId}</span>,
|
cell: ({ row }) => <span className="text-sm text-foreground">{row.original.user?.id ?? row.original.userId ?? "—"}</span>,
|
||||||
size: 120,
|
size: 120,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import { Skeleton } from "@/components/ui/skeleton";
|
|||||||
import { InfoRow, Section } from "@/components/viewPageComponents";
|
import { InfoRow, Section } from "@/components/viewPageComponents";
|
||||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||||
|
|
||||||
|
import { formatFromApiDate } from "@/lib/utils";
|
||||||
|
|
||||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
function LoanRemainingViewSkeleton() {
|
function LoanRemainingViewSkeleton() {
|
||||||
@@ -78,16 +80,22 @@ export default function LoanRemainingViewPage() {
|
|||||||
{/* ── Basic Info ─────────────────────────────────────────────────────── */}
|
{/* ── Basic Info ─────────────────────────────────────────────────────── */}
|
||||||
<Section title={t("loanRemaining.sections.info", "Esasy maglumatlar")}>
|
<Section title={t("loanRemaining.sections.info", "Esasy maglumatlar")}>
|
||||||
<InfoRow label={t("common.id", "ID")} value={String(record.id)} />
|
<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.userId", "Ulanyjy ID")}
|
||||||
|
value={record.user?.id != null ? String(record.user.id) : record.userId != null ? String(record.userId) : "—"}
|
||||||
|
/>
|
||||||
<InfoRow
|
<InfoRow
|
||||||
label={t("loanRemaining.columns.userName", "Ulanyjy ady")}
|
label={t("loanRemaining.columns.userName", "Ulanyjy ady")}
|
||||||
isLink
|
isLink={Boolean(record.user?.id || record.userId)}
|
||||||
href={`/all-users/${record.userId}`}
|
href={`/all-users/${record.user?.id ?? record.userId}`}
|
||||||
value={String(record.userName)}
|
value={record.user?.name || record.user?.username || record.userName || "—"}
|
||||||
/>
|
/>
|
||||||
<InfoRow label={t("loanRemaining.columns.passportSerie", "Pasport seriýasy")} value={record.passportSerie} />
|
<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.passportId", "Pasport belgisi")} value={record.passportId} />
|
||||||
<InfoRow label={t("loanRemaining.columns.accountNumber", "Karz hasaby")} value={record.accountNumber} />
|
<InfoRow label={t("loanRemaining.columns.accountNumber", "Karz hasaby")} value={record.accountNumber} />
|
||||||
|
{record.createdAt && (
|
||||||
|
<InfoRow label={t("loanRemaining.columns.createdAt", "Döredilen wagty")} value={formatFromApiDate(record.createdAt)} />
|
||||||
|
)}
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
|
|||||||
+21
-21
@@ -26,7 +26,7 @@ import { useInfiniteBranches } from "@/features/shared/hooks/useSharedBranchUser
|
|||||||
import { useInfiniteStaff } from "@/features/operators/hooks/useOperators";
|
import { useInfiniteStaff } from "@/features/operators/hooks/useOperators";
|
||||||
import { useAssignRoleToUser, useAssignPermissionToRole, useAssignBranchToUser } from "@/features/shared/hooks/useSharedUserAssignments";
|
import { useAssignRoleToUser, useAssignPermissionToRole, useAssignBranchToUser } from "@/features/shared/hooks/useSharedUserAssignments";
|
||||||
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
import type { LocalizedText } from "@/features/branches/api/branchesApi";
|
||||||
|
import { formatFromApiDate } from "@/lib/utils/dateUtils";
|
||||||
type AssignDialogKind = "role" | "permission" | "branch";
|
type AssignDialogKind = "role" | "permission" | "branch";
|
||||||
|
|
||||||
export default function ProfilePage() {
|
export default function ProfilePage() {
|
||||||
@@ -44,6 +44,7 @@ export default function ProfilePage() {
|
|||||||
|
|
||||||
const branches = user?.branches ?? [];
|
const branches = user?.branches ?? [];
|
||||||
const permissions = user?.permissions ?? [];
|
const permissions = user?.permissions ?? [];
|
||||||
|
const isAdmin = authUser?.role?.code === "admin";
|
||||||
|
|
||||||
// ── Form State for Editing ──
|
// ── Form State for Editing ──
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
@@ -182,10 +183,7 @@ export default function ProfilePage() {
|
|||||||
<BentoCard title={t("profile.sections.account", "Hasap maglumatlary")}>
|
<BentoCard title={t("profile.sections.account", "Hasap maglumatlary")}>
|
||||||
<InfoRow label={t("common.id", "ID")} value={user.id} />
|
<InfoRow label={t("common.id", "ID")} value={user.id} />
|
||||||
<InfoRow label={t("users.fields.username", "Ulanyjy ady")} value={user.name} />
|
<InfoRow label={t("users.fields.username", "Ulanyjy ady")} value={user.name} />
|
||||||
<InfoRow
|
<InfoRow label={t("users.fields.createdAt", "Döredilen wagty")} value={formatFromApiDate(user.createdAt) || "—"} />
|
||||||
label={t("users.fields.createdAt", "Döredilen wagty")}
|
|
||||||
value={user.createdAt ? new Date(user.createdAt).toLocaleString() : "—"}
|
|
||||||
/>
|
|
||||||
{user.email && <InfoRow label={t("users.fields.email", "E-poçta")} value={user.email} />}
|
{user.email && <InfoRow label={t("users.fields.email", "E-poçta")} value={user.email} />}
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
@@ -253,22 +251,24 @@ export default function ProfilePage() {
|
|||||||
</InfoRow>
|
</InfoRow>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t("profile.sections.actions", "Amallar")}>
|
{isAdmin && (
|
||||||
<div className="flex flex-wrap gap-2 px-4 py-3">
|
<BentoCard title={t("profile.sections.actions", "Amallar")}>
|
||||||
<Button variant="outline" size="sm" className="gap-1.5" onClick={() => setAssignDialog("role")}>
|
<div className="flex flex-wrap gap-2 px-4 py-3">
|
||||||
<Shield size={14} />
|
<Button variant="outline" size="sm" className="gap-1.5" onClick={() => setAssignDialog("role")}>
|
||||||
{t("profile.actions.assignRole", "Rol birikdiriň")}
|
<Shield size={14} />
|
||||||
</Button>
|
{t("profile.actions.assignRole", "Rol birikdiriň")}
|
||||||
<Button variant="outline" size="sm" className="gap-1.5" onClick={() => setAssignDialog("permission")}>
|
</Button>
|
||||||
<KeyRound size={14} />
|
<Button variant="outline" size="sm" className="gap-1.5" onClick={() => setAssignDialog("permission")}>
|
||||||
{t("profile.actions.assignPermission", "Rugsat birikdiriň")}
|
<KeyRound size={14} />
|
||||||
</Button>
|
{t("profile.actions.assignPermission", "Rugsat birikdiriň")}
|
||||||
<Button variant="outline" size="sm" className="gap-1.5" onClick={() => setAssignDialog("branch")}>
|
</Button>
|
||||||
<Building2 size={14} />
|
<Button variant="outline" size="sm" className="gap-1.5" onClick={() => setAssignDialog("branch")}>
|
||||||
{t("profile.actions.assignBranch", "Şahamça birikdiriň")}
|
<Building2 size={14} />
|
||||||
</Button>
|
{t("profile.actions.assignBranch", "Şahamça birikdiriň")}
|
||||||
</div>
|
</Button>
|
||||||
</BentoCard>
|
</div>
|
||||||
|
</BentoCard>
|
||||||
|
)}
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
Reference in new issue
Block a user