This commit is contained in:
hamid zarghami
2026-01-27 12:23:27 +03:30
parent 1f33fa7a7f
commit 9785078c8f
19 changed files with 832 additions and 7 deletions
+1
View File
@@ -1,5 +1,6 @@
export const Paths = {
home: '/home',
profile: '/profile',
myOrders: '/my-orders',
proformaInvoice: '/proforma-invoice',
newOrder: '/new-order',
+1 -1
View File
@@ -9,7 +9,7 @@ const instance = axios.create({
instance.interceptors.request.use(
(config) => {
const token =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIwMUtGWjREWDhTNVJNOFMzMDc1NVZTWUNQUSIsImlhdCI6MTc2OTQ5NzYyMSwiZXhwIjoxNzY5NDk4ODIxfQ.YK6hQh3y-msWITy2sdLMsmwBvwXC5iHa3OxtWphyWQI" ||
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIwMUtGWjREWDhTNVJNOFMzMDc1NVZTWUNQUSIsImlhdCI6MTc2OTUwMTE0OCwiZXhwIjoxNzY5NTAyMzQ4fQ.IOYPKCBPCUS9BtWdIDJWG1uG3nnVmLoInDirEZfsl6k" ||
getToken();
if (token) {
config.headers.Authorization = `Bearer ${token}`;
+20
View File
@@ -45,3 +45,23 @@ export const NumberFormat = (num?: number): string => {
if (!num) return "0";
return num.toLocaleString("fa-IR");
};
export interface IGeneralError {
status: number;
success: boolean;
error: {
message: string[];
};
}
export const extractErrorMessage = (
error: Error | unknown,
fallbackMessage: string = "خطایی رخ داده است",
): string => {
try {
const axiosError = error as { response?: { data: IGeneralError } };
return axiosError?.response?.data?.error?.message?.[0] || fallbackMessage;
} catch {
return fallbackMessage;
}
};