diff --git a/src/components/auth/change-password-from.tsx b/src/components/auth/change-password-from.tsx index f2ff64f..121d2f7 100644 --- a/src/components/auth/change-password-from.tsx +++ b/src/components/auth/change-password-from.tsx @@ -46,12 +46,17 @@ const ChangePasswordForm = () => { }, { onError: (error: any) => { - Object.keys(error?.response?.data).forEach((field: any) => { - setError(field, { - type: 'manual', - message: error?.response?.data[field][0], + if (error.response?.data?.errors?.length) { + error.response?.data?.errors?.map((err) => { + if (err.field) { + toast.error(`${err.field} : ${err.message}`); + } else { + toast.error(err.message); + } }); - }); + } else { + toast.error(error.message || t("errorOccurred")); + } }, onSuccess: (data) => { if (!data?.success) { diff --git a/src/components/auth/login-form.tsx b/src/components/auth/login-form.tsx index edb708d..6a2d5c7 100644 --- a/src/components/auth/login-form.tsx +++ b/src/components/auth/login-form.tsx @@ -16,6 +16,7 @@ import { hasAccess, setAuthCredentials, } from '@/utils/auth-utils'; +import { toast } from 'react-toastify'; const loginFormSchema = yup.object().shape({ phone_number: yup.string().required('Phone number is required'), @@ -53,20 +54,19 @@ const LoginForm = () => { } */ }, - onError: (err: any) => { + onError: (error: any) => { // Extract the error message from the server response - let message = 'form:error-credential-wrong'; // Default error message - - if (err.response && err.response.data && err.response.data.message) { - message = err.response.data.message; - } else if (err.message) { - message = err.message; + if (error.response?.data?.errors?.length) { + error.response?.data?.errors?.map((err) => { + if (err.field) { + toast.error(`${err.field} : ${err.message}`); + } else { + toast.error(err.message); + } + }); + } else { + toast.error(error.message || t("errorOccurred")); } - - // Set the error message state - setErrorMessage(message); - - console.error('Login error:', err); }, }, ); diff --git a/src/components/chat/file-message.tsx b/src/components/chat/file-message.tsx index 7500e5c..1f4df09 100644 --- a/src/components/chat/file-message.tsx +++ b/src/components/chat/file-message.tsx @@ -168,7 +168,7 @@ const FileMessage = ({ file }) => {
{fileName}
-{formatBytes(file?.size)}
+{file?.content_size}
); diff --git a/src/components/dashboard/admin.tsx b/src/components/dashboard/admin.tsx index add300e..159536b 100644 --- a/src/components/dashboard/admin.tsx +++ b/src/components/dashboard/admin.tsx @@ -150,21 +150,22 @@ export default function Dashboard() { { name: t('text-monthly'), day: 30 }, { name: t('text-yearly'), day: 365 }, ]; +console.log(data); useEffect(() => { switch (activeTimeFrame) { case 1: - setOrderDataRange(data?.todayTotalOrderByStatus); + setOrderDataRange(data?.merchant_info?.order_status?.today); break; case 7: - setOrderDataRange(data?.weeklyTotalOrderByStatus); + setOrderDataRange(data?.merchant_info?.order_status?.weekly); break; case 30: - setOrderDataRange(data?.monthlyTotalOrderByStatus); - break; - case 365: - setOrderDataRange(data?.yearlyTotalOrderByStatus); + setOrderDataRange(data?.merchant_info?.order_status?.monthly); break; + // case 365: + // setOrderDataRange(data?.order_status?.yearly); + // break; default: setOrderDataRange(orderDataRange); diff --git a/src/components/dashboard/widgets/box/widget-order-by-status.tsx b/src/components/dashboard/widgets/box/widget-order-by-status.tsx index 45665dd..d711cec 100644 --- a/src/components/dashboard/widgets/box/widget-order-by-status.tsx +++ b/src/components/dashboard/widgets/box/widget-order-by-status.tsx @@ -93,28 +93,31 @@ const WidgetOrderByStatus: React.FC