started connect with api
This commit is contained in:
1 parent
0ca218505d
commit
6da59f42d9
112 files changed
+7091
-6989
No files matched your search
@@ -1,143 +1,503 @@
|
||||
import { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useState, useCallback, useMemo } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { TFunction } from "i18next";
|
||||
import { useForm, type PathValue } from "react-hook-form";
|
||||
import { toast } from "sonner";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { User, FileText, Wallet, MapPin } from "lucide-react";
|
||||
import type { LucideIcon } from "lucide-react";
|
||||
|
||||
import { FormInput } from "@/components/formInput";
|
||||
import { FormInput, type SelectOption } from "@/components/formInput";
|
||||
import { FormActions } from "@/components/formActions";
|
||||
import { StepBarCards, type StepCardItem } from "@/components/stepBarV2";
|
||||
import { BentoGrid, BentoCard } from "@/components/bento";
|
||||
|
||||
import { useCreateLoanPaidOffLetter, useUpdateLoanPaidOffLetter } from "../hooks/useLoanPaidOffLetters";
|
||||
import type { LoanPaidOffLetter } from "../api/loanPaidOffLettersApi";
|
||||
import {
|
||||
loanPaidOffLetterFormSchema,
|
||||
validateStep,
|
||||
type LoanPaidOffLetterFormData,
|
||||
DEFAULT_FORM_VALUES,
|
||||
buildPayload,
|
||||
mapInitial,
|
||||
} from "../schemas/loanPaidOffLetter.schema";
|
||||
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
|
||||
type FormMode = "create" | "edit";
|
||||
|
||||
interface LoanPaidOffLetterFormProps {
|
||||
mode: "create" | "edit";
|
||||
mode: FormMode;
|
||||
initialData?: LoanPaidOffLetter;
|
||||
}
|
||||
|
||||
type FlatErrors = Partial<Record<keyof LoanPaidOffLetterFormData, string>>;
|
||||
|
||||
function flattenErrors(errors: Record<string, { message?: string } | undefined>): FlatErrors {
|
||||
const result: FlatErrors = {};
|
||||
for (const key of Object.keys(errors)) {
|
||||
const msg = errors[key]?.message;
|
||||
if (msg) result[key as keyof LoanPaidOffLetterFormData] = msg;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// ─── Static options ───────────────────────────────────────────────────────────
|
||||
|
||||
const REGION_CODES = ["AG", "AH", "BA", "DA", "LE", "MA"] as const;
|
||||
|
||||
// ─── Step definitions ─────────────────────────────────────────────────────────
|
||||
|
||||
interface StepDef {
|
||||
id: string;
|
||||
titleKey: string;
|
||||
titleFallback: string;
|
||||
subtitleKey: string;
|
||||
subtitleFallback: string;
|
||||
icon: LucideIcon;
|
||||
validate: (form: LoanPaidOffLetterFormData) => FlatErrors;
|
||||
}
|
||||
|
||||
const STEPS: StepDef[] = [
|
||||
{
|
||||
id: "customer",
|
||||
titleKey: "loanPaidOffLetters.sections.customer",
|
||||
titleFallback: "Müşderi maglumatlary",
|
||||
subtitleKey: "loanPaidOffLetters.steps.customer.subtitle",
|
||||
subtitleFallback: "At, familiýa, senesi, telefon",
|
||||
icon: User,
|
||||
validate: (form) => validateStep(0, form),
|
||||
},
|
||||
{
|
||||
id: "passport",
|
||||
titleKey: "loanPaidOffLetters.sections.passport",
|
||||
titleFallback: "Pasport",
|
||||
subtitleKey: "loanPaidOffLetters.steps.passport.subtitle",
|
||||
subtitleFallback: "Seriýa we belgisi",
|
||||
icon: FileText,
|
||||
validate: (form) => validateStep(1, form),
|
||||
},
|
||||
{
|
||||
id: "loan",
|
||||
titleKey: "loanPaidOffLetters.sections.loan",
|
||||
titleFallback: "Karz maglumatlary",
|
||||
subtitleKey: "loanPaidOffLetters.steps.loan.subtitle",
|
||||
subtitleFallback: "Şertnama, senesi, möçberi",
|
||||
icon: Wallet,
|
||||
validate: (form) => validateStep(2, form),
|
||||
},
|
||||
{
|
||||
id: "location",
|
||||
titleKey: "loanPaidOffLetters.sections.additional",
|
||||
titleFallback: "Lokasiýa we Status",
|
||||
subtitleKey: "loanPaidOffLetters.steps.additional.subtitle",
|
||||
subtitleFallback: "Sebit, şahamça, status",
|
||||
icon: MapPin,
|
||||
validate: (form) => validateStep(3, form),
|
||||
},
|
||||
];
|
||||
|
||||
// ─── Step components ──────────────────────────────────────────────────────────
|
||||
|
||||
interface StepContentProps {
|
||||
form: LoanPaidOffLetterFormData;
|
||||
errors: FlatErrors;
|
||||
set: <K extends keyof LoanPaidOffLetterFormData>(k: K) => (v: string) => void;
|
||||
t: TFunction;
|
||||
}
|
||||
|
||||
function StepCustomer({ form, errors, set, t }: StepContentProps) {
|
||||
return (
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard span="full">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<FormInput
|
||||
type="text"
|
||||
label={t("loanPaidOffLetters.fields.customerName", "Ady")}
|
||||
value={form.customerName}
|
||||
onChange={set("customerName")}
|
||||
error={errors.customerName}
|
||||
required
|
||||
/>
|
||||
<FormInput
|
||||
type="text"
|
||||
label={t("loanPaidOffLetters.fields.customerSurname", "Familiýasy")}
|
||||
value={form.customerSurname}
|
||||
onChange={set("customerSurname")}
|
||||
error={errors.customerSurname}
|
||||
required
|
||||
/>
|
||||
<FormInput
|
||||
type="text"
|
||||
label={t("loanPaidOffLetters.fields.customerPatronicName", "Atasynyň ady")}
|
||||
value={form.customerPatronicName ?? ""}
|
||||
onChange={set("customerPatronicName")}
|
||||
/>
|
||||
<FormInput
|
||||
type="date"
|
||||
label={t("loanPaidOffLetters.fields.bornAt", "Doglan senesi")}
|
||||
value={form.bornAt}
|
||||
onChange={set("bornAt")}
|
||||
error={errors.bornAt}
|
||||
required
|
||||
/>
|
||||
<FormInput
|
||||
type="phone"
|
||||
label={t("loanPaidOffLetters.fields.phone", "Telefon")}
|
||||
value={form.phone}
|
||||
onChange={set("phone")}
|
||||
error={errors.phone}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
);
|
||||
}
|
||||
|
||||
function StepPassport({ form, errors, set, t }: StepContentProps) {
|
||||
return (
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard span="full">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<FormInput
|
||||
type="text"
|
||||
label={t("loanPaidOffLetters.fields.passportSerie", "Pasport seriýasy")}
|
||||
value={form.passportSerie}
|
||||
onChange={set("passportSerie")}
|
||||
placeholder="I-AG"
|
||||
error={errors.passportSerie}
|
||||
required
|
||||
/>
|
||||
<FormInput
|
||||
type="text"
|
||||
label={t("loanPaidOffLetters.fields.passportId", "Pasport belgisi")}
|
||||
value={form.passportId}
|
||||
onChange={set("passportId")}
|
||||
placeholder="101010"
|
||||
error={errors.passportId}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
);
|
||||
}
|
||||
|
||||
function StepLoan({ form, errors, set, t }: StepContentProps) {
|
||||
return (
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard span="full">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<FormInput
|
||||
type="text"
|
||||
label={t("loanPaidOffLetters.fields.loanContractNumber", "Karz şertnamasy belgisi")}
|
||||
value={form.loanContractNumber}
|
||||
onChange={set("loanContractNumber")}
|
||||
error={errors.loanContractNumber}
|
||||
required
|
||||
/>
|
||||
<FormInput
|
||||
type="date"
|
||||
label={t("loanPaidOffLetters.fields.loanContractDate", "Karz şertnamasy senesi")}
|
||||
value={form.loanContractDate}
|
||||
onChange={set("loanContractDate")}
|
||||
error={errors.loanContractDate}
|
||||
required
|
||||
/>
|
||||
<FormInput
|
||||
type="number"
|
||||
label={t("loanPaidOffLetters.fields.loanAmount", "Karz möçberi")}
|
||||
value={form.loanAmount}
|
||||
onChange={set("loanAmount")}
|
||||
error={errors.loanAmount}
|
||||
required
|
||||
/>
|
||||
<FormInput
|
||||
type="text"
|
||||
label={t("loanPaidOffLetters.fields.loanReason", "Karz sebäbi")}
|
||||
value={form.loanReason ?? ""}
|
||||
onChange={set("loanReason")}
|
||||
/>
|
||||
</div>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
);
|
||||
}
|
||||
|
||||
function StepLocation({
|
||||
form,
|
||||
errors,
|
||||
set,
|
||||
t,
|
||||
regionOptions,
|
||||
statusOptions,
|
||||
}: StepContentProps & { regionOptions: SelectOption[]; statusOptions: SelectOption[] }) {
|
||||
return (
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard>
|
||||
<div className="flex flex-col gap-4">
|
||||
<FormInput
|
||||
type="select"
|
||||
label={t("loanPaidOffLetters.fields.region", "Sebit")}
|
||||
value={form.region}
|
||||
onChange={set("region")}
|
||||
options={regionOptions}
|
||||
error={errors.region}
|
||||
required
|
||||
/>
|
||||
<FormInput
|
||||
type="number"
|
||||
label={t("loanPaidOffLetters.fields.branchId", "Şahamça ID")}
|
||||
value={form.branchId}
|
||||
onChange={set("branchId")}
|
||||
error={errors.branchId}
|
||||
required
|
||||
/>
|
||||
<FormInput
|
||||
type="number"
|
||||
label={t("loanPaidOffLetters.fields.userId", "Ulanyjy ID")}
|
||||
value={form.userId ?? ""}
|
||||
onChange={set("userId")}
|
||||
/>
|
||||
<FormInput
|
||||
type="select"
|
||||
label={t("loanPaidOffLetters.fields.status", "Status")}
|
||||
value={form.status}
|
||||
onChange={set("status")}
|
||||
options={statusOptions}
|
||||
error={errors.status}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard>
|
||||
<div className="flex flex-col gap-4">
|
||||
<FormInput
|
||||
type="text"
|
||||
label={t("loanPaidOffLetters.fields.uniqueId", "Unikal ID")}
|
||||
value={form.uniqueId ?? ""}
|
||||
onChange={set("uniqueId")}
|
||||
placeholder="LPL-2026-0001"
|
||||
/>
|
||||
<FormInput
|
||||
type="text"
|
||||
label={t("loanPaidOffLetters.fields.loanFile", "Faýl")}
|
||||
value={form.loanFile ?? ""}
|
||||
onChange={set("loanFile")}
|
||||
placeholder="letter1.pdf"
|
||||
/>
|
||||
<FormInput
|
||||
type="textarea"
|
||||
label={t("loanPaidOffLetters.fields.notes", "Bellikler")}
|
||||
value={form.notes ?? ""}
|
||||
onChange={set("notes")}
|
||||
rows={3}
|
||||
/>
|
||||
</div>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
);
|
||||
}
|
||||
|
||||
// ─── LoanPaidOffLetterForm ────────────────────────────────────────────────────
|
||||
|
||||
export function LoanPaidOffLetterForm({ mode, initialData }: LoanPaidOffLetterFormProps) {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const createMutation = useCreateLoanPaidOffLetter();
|
||||
const updateMutation = useUpdateLoanPaidOffLetter(initialData?.id ?? 0);
|
||||
|
||||
const isPending = createMutation.isPending || updateMutation.isPending;
|
||||
|
||||
const [currentStep, setCurrentStep] = useState(0);
|
||||
const [visited, setVisited] = useState<Set<number>>(() => (mode === "edit" ? new Set(STEPS.map((_, i) => i)) : new Set<number>([0])));
|
||||
const [submittedSteps, setSubmittedSteps] = useState<Set<number>>(() => new Set());
|
||||
|
||||
const {
|
||||
handleSubmit,
|
||||
watch,
|
||||
setValue,
|
||||
reset,
|
||||
formState: { errors },
|
||||
formState: { errors: rhfErrors },
|
||||
clearErrors,
|
||||
setError,
|
||||
getValues,
|
||||
} = useForm<LoanPaidOffLetterFormData>({
|
||||
resolver: zodResolver(loanPaidOffLetterFormSchema),
|
||||
defaultValues: DEFAULT_FORM_VALUES,
|
||||
mode: "onSubmit",
|
||||
defaultValues: initialData ? { ...DEFAULT_FORM_VALUES, ...mapInitial(initialData) } : DEFAULT_FORM_VALUES,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (mode === "edit" && initialData) {
|
||||
reset({
|
||||
passportSeries: initialData.passportSeries,
|
||||
passportNumber: initialData.passportNumber,
|
||||
loanAccount: initialData.loanAccount,
|
||||
issuedAt: initialData.issuedAt,
|
||||
});
|
||||
}
|
||||
}, [mode, initialData, reset]);
|
||||
const form = watch();
|
||||
const errors = useMemo(() => flattenErrors(rhfErrors as Record<string, { message?: string } | undefined>), [rhfErrors]);
|
||||
|
||||
const onSubmit = (data: LoanPaidOffLetterFormData) => {
|
||||
const payload = buildPayload(data);
|
||||
const set = useCallback(
|
||||
<K extends keyof LoanPaidOffLetterFormData>(key: K) =>
|
||||
(value: string) => {
|
||||
setValue(key, value as PathValue<LoanPaidOffLetterFormData, K>);
|
||||
clearErrors(key);
|
||||
},
|
||||
[setValue, clearErrors],
|
||||
);
|
||||
|
||||
const statusOptions = useMemo<SelectOption[]>(
|
||||
() => [
|
||||
{ value: "pending", label: t("loanPaidOffLetters.status.pending", "Pending") },
|
||||
{ value: "approved", label: t("loanPaidOffLetters.status.approved", "Approved") },
|
||||
{ value: "rejected", label: t("loanPaidOffLetters.status.rejected", "Rejected") },
|
||||
],
|
||||
[t],
|
||||
);
|
||||
|
||||
const regionOptions = useMemo<SelectOption[]>(
|
||||
() =>
|
||||
REGION_CODES.map((code) => ({
|
||||
value: code,
|
||||
label: t(`loanPaidOffLetters.regions.${code}`, code),
|
||||
})),
|
||||
[t],
|
||||
);
|
||||
|
||||
// ── Step validation state ───────────────────────────────────────────────────
|
||||
|
||||
const stepsWithErrors = useMemo(() => {
|
||||
const set = new Set<number>();
|
||||
STEPS.forEach((step, i) => {
|
||||
if (visited.has(i) || submittedSteps.has(i)) {
|
||||
const stepErrs = step.validate(form);
|
||||
if (Object.keys(stepErrs).length > 0) set.add(i);
|
||||
}
|
||||
});
|
||||
return set;
|
||||
}, [form, visited, submittedSteps]);
|
||||
|
||||
const markVisited = (idx: number) => setVisited((prev) => new Set([...prev, idx]));
|
||||
|
||||
// ── Step Navigation ─────────────────────────────────────────────────────────
|
||||
|
||||
const handleNext = () => {
|
||||
markVisited(currentStep);
|
||||
setSubmittedSteps((prev) => new Set([...prev, currentStep]));
|
||||
|
||||
const stepErrs = STEPS[currentStep].validate(form);
|
||||
if (Object.keys(stepErrs).length > 0) {
|
||||
Object.entries(stepErrs).forEach(([key, msg]) => {
|
||||
setError(key as keyof LoanPaidOffLetterFormData, { type: "manual", message: msg });
|
||||
});
|
||||
toast.error(t("common.errors.fillRequired", "Hökman doldurylmaly öýjükleri dolduryň"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentStep < STEPS.length - 1) {
|
||||
setCurrentStep(currentStep + 1);
|
||||
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||
}
|
||||
};
|
||||
|
||||
const handleBack = () => {
|
||||
if (currentStep > 0) {
|
||||
markVisited(currentStep);
|
||||
setCurrentStep(currentStep - 1);
|
||||
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||
}
|
||||
};
|
||||
|
||||
const handleGoTo = (i: number) => {
|
||||
markVisited(currentStep);
|
||||
setCurrentStep(i);
|
||||
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||
};
|
||||
|
||||
// ── Submit ──────────────────────────────────────────────────────────────────
|
||||
|
||||
const doSubmit = async () => {
|
||||
setVisited(new Set(STEPS.map((_, i) => i)));
|
||||
setSubmittedSteps(new Set(STEPS.map((_, i) => i)));
|
||||
|
||||
const allErrors: FlatErrors = {};
|
||||
for (const step of STEPS) Object.assign(allErrors, step.validate(form));
|
||||
|
||||
if (Object.keys(allErrors).length > 0) {
|
||||
Object.entries(allErrors).forEach(([key, msg]) => {
|
||||
setError(key as keyof LoanPaidOffLetterFormData, { type: "manual", message: msg });
|
||||
});
|
||||
toast.error(t("common.errors.fillRequired", "Hökman doldurylmaly öýjükleri dolduryň"));
|
||||
for (let i = 0; i < STEPS.length; i++) {
|
||||
if (Object.keys(STEPS[i].validate(form)).length > 0) {
|
||||
setCurrentStep(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const payload = buildPayload(getValues());
|
||||
|
||||
if (mode === "create") {
|
||||
createMutation.mutate(payload, {
|
||||
onSuccess: () => {
|
||||
toast.success(t("common.success.create", "Üstünlikli döredildi"));
|
||||
navigate("/loan-paid-off-letters");
|
||||
},
|
||||
});
|
||||
const result = await createMutation.mutateAsync(payload);
|
||||
navigate(`/loan-paid-off-letters/${result.id}`);
|
||||
} else {
|
||||
updateMutation.mutate(payload, {
|
||||
onSuccess: () => {
|
||||
toast.success(t("common.success.save", "Üstünlikli ýatda saklandy"));
|
||||
navigate("/loan-paid-off-letters");
|
||||
},
|
||||
});
|
||||
await updateMutation.mutateAsync(payload);
|
||||
navigate(`/loan-paid-off-letters/${initialData!.id}`);
|
||||
}
|
||||
};
|
||||
|
||||
const errMsg = (msg: string | undefined) => (msg?.startsWith("validation.") ? t(msg, msg) : msg);
|
||||
// ── StepBar items ───────────────────────────────────────────────────────────
|
||||
|
||||
const onError = () => {
|
||||
toast.error(t("common.errors.fillRequired", "Hökman doldurylmaly öýjükleri dolduryň"));
|
||||
};
|
||||
const stepBarItems: StepCardItem[] = STEPS.map((s, i) => {
|
||||
const isActive = i === currentStep;
|
||||
const hasErrors = stepsWithErrors.has(i);
|
||||
const isDone = visited.has(i) && !hasErrors;
|
||||
return {
|
||||
id: s.id,
|
||||
title: t(s.titleKey, s.titleFallback),
|
||||
subtitle: t(s.subtitleKey, s.subtitleFallback),
|
||||
icon: s.icon,
|
||||
status: isActive ? "active" : hasErrors ? "error" : isDone ? "done" : "idle",
|
||||
};
|
||||
});
|
||||
|
||||
const isLastStep = currentStep === STEPS.length - 1;
|
||||
|
||||
const stepProps = { form, errors, set, t };
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-5">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{mode === "create"
|
||||
? t("loanPaidOffLetters.createTitle", "Karzyň ýapylandygy barada güwanama almak dörediň")
|
||||
: t("loanPaidOffLetters.editTitle", "Karzyň ýapylandygy barada güwanama almak üýtgetmek")}
|
||||
</h1>
|
||||
<form onSubmit={handleSubmit(onSubmit, onError)} className="space-y-6">
|
||||
<BentoGrid cols={1}>
|
||||
<BentoCard>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<FormInput
|
||||
label={t("loanPaidOffLetters.columns.passportSeries", "Pasport seriýasy")}
|
||||
required
|
||||
value={watch("passportSeries")}
|
||||
onChange={(v) => setValue("passportSeries", v)}
|
||||
placeholder={t("loanPaidOffLetters.placeholders.passportSeries", "TM")}
|
||||
error={errMsg(errors.passportSeries?.message)}
|
||||
/>
|
||||
{/* Page Header */}
|
||||
<div>
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{mode === "create"
|
||||
? t("loanPaidOffLetters.createTitle", "Karzyň ýapylandygy barada güwanama almak dörediň")
|
||||
: t("loanPaidOffLetters.editTitle", "Karzyň ýapylandygy barada güwanama almak üýtgetmek")}
|
||||
</h1>
|
||||
<p className="text-sm text-muted-foreground mt-1">
|
||||
{t("loanPaidOffLetters.stepDescription", "Ähli meýdanlary dolduryp, ädim-ädim öň geçiň.")}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<FormInput
|
||||
label={t("loanPaidOffLetters.columns.passportNumber", "Pasport belgisi")}
|
||||
required
|
||||
value={watch("passportNumber")}
|
||||
onChange={(v) => setValue("passportNumber", v)}
|
||||
placeholder="A123456"
|
||||
error={errMsg(errors.passportNumber?.message)}
|
||||
/>
|
||||
{/* Step Bar */}
|
||||
<div className="bg-card border border-border rounded-xl p-3 overflow-x-auto">
|
||||
<StepBarCards steps={stepBarItems} onGoTo={handleGoTo} />
|
||||
</div>
|
||||
|
||||
<FormInput
|
||||
label={t("loanPaidOffLetters.columns.loanAccount", "Karz hasaby")}
|
||||
required
|
||||
value={watch("loanAccount")}
|
||||
onChange={(v) => setValue("loanAccount", v)}
|
||||
placeholder="LOAN-..."
|
||||
error={errMsg(errors.loanAccount?.message)}
|
||||
/>
|
||||
{/* Step Panels */}
|
||||
{currentStep === 0 && <StepCustomer {...stepProps} />}
|
||||
{currentStep === 1 && <StepPassport {...stepProps} />}
|
||||
{currentStep === 2 && <StepLoan {...stepProps} />}
|
||||
{currentStep === 3 && <StepLocation {...stepProps} regionOptions={regionOptions} statusOptions={statusOptions} />}
|
||||
|
||||
<FormInput
|
||||
label={t("loanPaidOffLetters.columns.issuedAt", "Berlen wagty")}
|
||||
required
|
||||
type="date"
|
||||
value={watch("issuedAt")}
|
||||
onChange={(v) => setValue("issuedAt", v)}
|
||||
error={errMsg(errors.issuedAt?.message)}
|
||||
/>
|
||||
</div>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
<FormActions
|
||||
isPending={isPending}
|
||||
onSubmit={handleSubmit(onSubmit, onError)}
|
||||
onCancel={() => navigate("/loan-paid-off-letters")}
|
||||
submitLabel={mode === "create" ? t("common.create", "Döret") : t("common.save", "Ýatda sakla")}
|
||||
/>
|
||||
</form>
|
||||
{/* Form Actions */}
|
||||
<FormActions
|
||||
isPending={isPending}
|
||||
onCancel={currentStep === 0 ? () => navigate("/loan-paid-off-letters") : undefined}
|
||||
onPrev={currentStep > 0 ? handleBack : undefined}
|
||||
onNext={!isLastStep ? handleNext : undefined}
|
||||
showSubmit={isLastStep}
|
||||
onSubmit={isLastStep ? doSubmit : undefined}
|
||||
submitLabel={mode === "create" ? t("common.create", "Döret") : t("common.save", "Ýatda sakla")}
|
||||
loadingLabel={t("common.loading", "Ýüklenilýär...")}
|
||||
cancelLabel={t("common.cancel", "Ýatyr")}
|
||||
prevLabel={t("common.back", "Yza")}
|
||||
nextLabel={t("common.next", "Indiki")}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user