update food

This commit is contained in:
hamid zarghami
2025-11-15 14:45:04 +03:30
parent 0fd87e99f2
commit eaa9ef2a9a
18 changed files with 609 additions and 61 deletions
+20
View File
@@ -52,3 +52,23 @@ export const timeAgo = (date: string | Date): string => {
return "همین الان";
};
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;
}
};