This commit is contained in:
2026-05-31 18:00:43 +03:30
parent 98af7d639b
commit b241d12ff5
20 changed files with 939 additions and 797 deletions

View File

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

53
core/constant/index.ts Normal file
View File

@@ -0,0 +1,53 @@
import { QueryClientConfig } from "@tanstack/react-query";
export const queryClientOptionsData: QueryClientConfig = {
defaultOptions: {
queries: {
// مدت زمانی که داده fresh حساب می‌شود
staleTime: 1000 * 60 * 5, // 5 دقیقه
// مدت نگهداری کش در حافظه بعد از unmount
gcTime: 1000 * 60 * 30, // 30 دقیقه
// چند بار در صورت خطا retry کند
retry: (failureCount: any, error: any) => {
// برای خطاهای 4xx معمولاً retry منطقی نیست
const status = error?.response?.status;
if (status >= 400 && status < 500) return false;
return failureCount < 2;
},
// تاخیر بین retryها
retryDelay: (attemptIndex: any) =>
Math.min(1000 * 2 ** attemptIndex, 10000),
// جلوگیری از رفرش‌های اضافه
refetchOnWindowFocus: false,
refetchOnReconnect: true,
refetchOnMount: false,
},
mutations: {
retry: 0,
},
},
};
export const genderOptions = [
{
id: 1,
label: "مرد",
value: "male",
},
{
id: 2,
label: "زن",
value: "female",
},
{
id: 3,
label: "ساير",
value: "other",
},
];
export const religionOptions = ["اسلام", "مسیحیت", "یهودیت", "زرتشتی", "سایر"];

45
core/types/index.ts Normal file
View File

@@ -0,0 +1,45 @@
export type genderType = "male" | "female" | "other";
export interface IdentityFormValues {
firstName: string;
lastName: string;
fatherName: string;
nationalCode: string;
birthDate: string;
birthPlace: string;
gender: string;
religion: string;
nationality: string;
profilePhotoId: string;
}
export type CenterItem = {
id: string;
name: string;
address: string;
isUrgent: boolean;
};
export interface WizardFormData {
registrationCenter: {
selectedCenter: CenterItem | null;
};
identity: IdentityFormValues; // برای مرحله ۲
}
// مقدار اولیه برای همه مراحل
export const INITIAL_WIZARD_DATA: WizardFormData = {
registrationCenter: {
selectedCenter:null
},
identity: {
firstName: "",
lastName: "",
birthDate: "",
birthPlace: "",
fatherName: "",
gender: "",
nationalCode: "",
nationality: "",
profilePhotoId: "",
religion: "",
},
};

10
core/utils/index.ts Normal file
View File

@@ -0,0 +1,10 @@
import axios from "axios";
export function handleAxiosError(error: unknown) {
if (axios.isAxiosError(error)) {
// اینجا می‌دونیم که خطا از axios است
return error.response?.data?.error?.message;
} else {
return "Unexpected error";
}
}