change some files

This commit is contained in:
2026-06-02 17:08:52 +03:30
parent b8dc1d0e1b
commit cfb48c5bb0
76 changed files with 5204 additions and 2555 deletions

View File

@@ -1,7 +1,7 @@
import axios from "axios";
const callAPISetting = axios.create({
baseURL: "http://localhost:4000/api/v1",
baseURL: "http://localhost:5000/api/v1",
withCredentials: true,
});

View File

@@ -1,3 +1,5 @@
import { EducationFormValues } from "@/ui/forms/education/EducationForm";
export type genderType = "male" | "female" | "other";
export interface IdentityFormValues {
firstName: string;
@@ -23,12 +25,13 @@ export interface WizardFormData {
selectedCenter: CenterItem | null;
};
identity: IdentityFormValues; // برای مرحله ۲
education: EducationFormValues[]; // به جای education
}
// مقدار اولیه برای همه مراحل
export const INITIAL_WIZARD_DATA: WizardFormData = {
registrationCenter: {
selectedCenter:null
selectedCenter: null,
},
identity: {
firstName: "",
@@ -42,4 +45,5 @@ export const INITIAL_WIZARD_DATA: WizardFormData = {
profilePhotoId: "",
religion: "",
},
education: [],
};

View File

@@ -1,4 +1,5 @@
import axios from "axios";
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
export function handleAxiosError(error: unknown) {
if (axios.isAxiosError(error)) {
@@ -7,4 +8,54 @@ export function handleAxiosError(error: unknown) {
} else {
return "Unexpected error";
}
}
}
export const handleBack = (props: any, key: string) => {
// قبل از رفتن به عقب، مقادیر فعلی فرم را در استیت والد ذخیره کن
props?.update({ [key]: props?.values });
props.setStep(props?.step - 1);
};
type LoginData = {
token?: string;
applicant?: {
id?: string;
fullname?: string;
formStep?: number;
centerId?: string;
} | null;
};
export const handleLoginRedirect = (
router: AppRouterInstance,
data: {data:LoginData},
) => {
const applicant = data?.data?.applicant;
console.log(applicant)
// اگر کاربر قبلاً applicant داشته باشد
if (applicant?.id) {
const targetStep = applicant.formStep || 1;
localStorage.setItem(
"applicationDraft",
JSON.stringify({
applicantId: applicant.id,
centerId: applicant.centerId,
formStep: targetStep,
}),
);
if (targetStep === 1) {
router.push("/form");
} else {
router.push(`/form?step=${targetStep}`);
}
return;
}
// اگر کاربر جدید باشد و هنوز applicant نداشته باشد
localStorage.removeItem("applicationDraft");
router.push("/form");
};