LFFE-12 debugs and testing manually
This commit is contained in:
@@ -37,7 +37,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => {
|
||||
onSubmit: (values, {setSubmitting}) => {
|
||||
const formData = new FormData();
|
||||
formData.append("proposed_amount", values.proposed_amount);
|
||||
if (values.description != "") formData.append("description", values.description);
|
||||
if (values.description != "") formData.append("expert_description", values.description);
|
||||
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
|
||||
|
||||
requestServer(`${CONFIRM_MACHINARY_OFFICE}/${rowId}`, 'post', {
|
||||
|
||||
@@ -6,7 +6,7 @@ import {useFormik} from "formik";
|
||||
import {useTranslations} from "next-intl";
|
||||
import {useState} from "react";
|
||||
import * as Yup from "yup";
|
||||
import {REJECT_INSPECTOR_EXPERT} from "@/core/data/apiRoutes";
|
||||
import {REJECT_MACHINARY_OFFICE} from "@/core/data/apiRoutes";
|
||||
|
||||
const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
||||
const [selectedImage, setSelectedImage] = useState("");
|
||||
@@ -29,10 +29,10 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
||||
validationSchema,
|
||||
onSubmit: (values, {setSubmitting}) => {
|
||||
const formData = new FormData();
|
||||
formData.append("description", values.description);
|
||||
formData.append("expert_description", values.description);
|
||||
if (values.reject_img != null) formData.append("attachment", values.reject_img);
|
||||
|
||||
requestServer(`${REJECT_INSPECTOR_EXPERT}/${rowId}`, 'post', {
|
||||
requestServer(`${REJECT_MACHINARY_OFFICE}/${rowId}`, 'post', {
|
||||
data: formData,
|
||||
}).then((response) => {
|
||||
setOpenRejectDialog(false)
|
||||
|
||||
@@ -24,7 +24,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => {
|
||||
},
|
||||
onSubmit: (values, {setSubmitting}) => {
|
||||
const formData = new FormData();
|
||||
if (values.description != "") formData.append("description", values.description);
|
||||
if (values.description != "") formData.append("expert_description", values.description);
|
||||
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
|
||||
|
||||
requestServer(`${CONFIRM_NAVGAN_PROVINCE_MANAGER}/${rowId}`, 'post', {
|
||||
|
||||
@@ -29,7 +29,7 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
||||
validationSchema,
|
||||
onSubmit: (values, {setSubmitting}) => {
|
||||
const formData = new FormData();
|
||||
formData.append("description", values.description);
|
||||
formData.append("expert_description", values.description);
|
||||
if (values.reject_img != null) formData.append("attachment", values.reject_img);
|
||||
|
||||
requestServer(`${REJECT_NAVGAN_PROVINCE_MANAGER}/${rowId}`, 'post', {
|
||||
|
||||
@@ -37,7 +37,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => {
|
||||
onSubmit: (values, {setSubmitting}) => {
|
||||
const formData = new FormData();
|
||||
formData.append("approved_amount", values.approved_amount);
|
||||
if (values.description != "") formData.append("description", values.description);
|
||||
if (values.description != "") formData.append("expert_description", values.description);
|
||||
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
|
||||
|
||||
requestServer(`${CONFIRM_PASSENGER_BOSS}/${rowId}`, 'post', {
|
||||
|
||||
@@ -29,7 +29,7 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
||||
validationSchema,
|
||||
onSubmit: (values, {setSubmitting}) => {
|
||||
const formData = new FormData();
|
||||
formData.append("description", values.description);
|
||||
formData.append("expert_description", values.description);
|
||||
if (values.reject_img != null) formData.append("attachment", values.reject_img);
|
||||
|
||||
requestServer(`${REJECT_PASSENGER_BOSS}/${rowId}`, 'post', {
|
||||
|
||||
@@ -29,7 +29,7 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
||||
validationSchema,
|
||||
onSubmit: (values, {setSubmitting}) => {
|
||||
const formData = new FormData();
|
||||
formData.append("description", values.description);
|
||||
formData.append("expert_description", values.description);
|
||||
if (values.reject_img != null) formData.append("attachment", values.reject_img);
|
||||
|
||||
requestServer(`${REJECT_PASSENGER_OFFICE}/${rowId}`, 'post', {
|
||||
|
||||
@@ -24,7 +24,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => {
|
||||
},
|
||||
onSubmit: (values, {setSubmitting}) => {
|
||||
const formData = new FormData();
|
||||
if (values.description != "") formData.append("description", values.description);
|
||||
if (values.description != "") formData.append("expert_description", values.description);
|
||||
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
|
||||
|
||||
requestServer(`${CONFIRM_TRANSPORTATION_ASSISTANCE}/${rowId}`, 'post', {
|
||||
@@ -106,7 +106,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => {
|
||||
{t("ConfirmDialog.button-cancel")}
|
||||
</Button>
|
||||
<Button onClick={formik.handleSubmit} variant="contained" color="primary"
|
||||
disabled={formik.isSubmitting || !formik.dirty || !formik.isValid}>
|
||||
disabled={formik.isSubmitting}>
|
||||
{t("ConfirmDialog.button-confirm")}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
|
||||
@@ -29,7 +29,7 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
|
||||
validationSchema,
|
||||
onSubmit: (values, {setSubmitting}) => {
|
||||
const formData = new FormData();
|
||||
formData.append("description", values.description);
|
||||
formData.append("expert_description", values.description);
|
||||
if (values.reject_img != null) formData.append("attachment", values.reject_img);
|
||||
|
||||
requestServer(`${REJECT_TRANSPORTATION_ASSISTANCE}/${rowId}`, 'post', {
|
||||
|
||||
@@ -2,8 +2,8 @@ import DangerousIcon from "@mui/icons-material/Dangerous";
|
||||
import {Box, Typography} from "@mui/material";
|
||||
import {toast} from "react-toastify";
|
||||
|
||||
const ErrorNotification = (t, status, message) => {
|
||||
toast(
|
||||
const ErrorNotification = (pushToastList, notificationType, t, status, message) => {
|
||||
const toastId = toast(
|
||||
() => (
|
||||
<>
|
||||
<Box
|
||||
@@ -29,11 +29,13 @@ const ErrorNotification = (t, status, message) => {
|
||||
</>
|
||||
),
|
||||
{
|
||||
containerId: 'validation',
|
||||
autoClose: false,
|
||||
closeOnClick: false,
|
||||
draggable: false,
|
||||
}
|
||||
);
|
||||
pushToastList(notificationType, toastId);
|
||||
};
|
||||
|
||||
export default ErrorNotification;
|
||||
export default ErrorNotification;
|
||||
@@ -1,12 +1,14 @@
|
||||
import {toast} from "react-toastify";
|
||||
|
||||
const PendingNotification = (t) => {
|
||||
toast(t("notifications.pending"), {
|
||||
const PendingNotification = (pushToastList, notificationType, t) => {
|
||||
const toastId = toast(t("notifications.pending"), {
|
||||
containerId: 'validation',
|
||||
autoClose: false,
|
||||
closeButton: false,
|
||||
closeOnClick: false,
|
||||
draggable: false,
|
||||
});
|
||||
pushToastList(notificationType, toastId);
|
||||
};
|
||||
|
||||
export default PendingNotification;
|
||||
export default PendingNotification;
|
||||
@@ -2,8 +2,8 @@ import BeenhereIcon from "@mui/icons-material/Beenhere";
|
||||
import {Box, Typography} from "@mui/material";
|
||||
import {toast} from "react-toastify";
|
||||
|
||||
const SuccessNotification = (t, status) => {
|
||||
toast(
|
||||
const SuccessNotification = (pushToastList, notificationType, t, status) => {
|
||||
const toastId = toast(
|
||||
() => (
|
||||
<>
|
||||
<Box
|
||||
@@ -30,6 +30,7 @@ const SuccessNotification = (t, status) => {
|
||||
</>
|
||||
),
|
||||
{
|
||||
containerId: 'validation',
|
||||
autoClose: 3000,
|
||||
hideProgressBar: true,
|
||||
pauseOnHover: true,
|
||||
@@ -37,6 +38,7 @@ const SuccessNotification = (t, status) => {
|
||||
draggable: true,
|
||||
}
|
||||
);
|
||||
pushToastList(notificationType, toastId);
|
||||
};
|
||||
|
||||
export default SuccessNotification;
|
||||
export default SuccessNotification;
|
||||
@@ -26,6 +26,8 @@ const UploadFileNotification = (t) => {
|
||||
</>
|
||||
),
|
||||
{
|
||||
containerId: 'validation',
|
||||
toastId: 'upload',
|
||||
autoClose: 3000,
|
||||
hideProgressBar: true,
|
||||
pauseOnHover: true,
|
||||
@@ -35,4 +37,4 @@ const UploadFileNotification = (t) => {
|
||||
);
|
||||
};
|
||||
|
||||
export default UploadFileNotification;
|
||||
export default UploadFileNotification;
|
||||
@@ -2,8 +2,8 @@ import ReportIcon from "@mui/icons-material/Report";
|
||||
import {Box, Typography} from "@mui/material";
|
||||
import {toast} from "react-toastify";
|
||||
|
||||
const WarningNotification = (t, status) => {
|
||||
toast(
|
||||
const WarningNotification = (pushToastList, notificationType, t, status) => {
|
||||
const toastId = toast(
|
||||
() => (
|
||||
<>
|
||||
<Box
|
||||
@@ -30,11 +30,13 @@ const WarningNotification = (t, status) => {
|
||||
</>
|
||||
),
|
||||
{
|
||||
containerId: 'validation',
|
||||
autoClose: false,
|
||||
closeOnClick: false,
|
||||
draggable: false,
|
||||
}
|
||||
);
|
||||
pushToastList(notificationType, toastId);
|
||||
};
|
||||
|
||||
export default WarningNotification;
|
||||
export default WarningNotification;
|
||||
@@ -1,54 +1,27 @@
|
||||
import {toast} from "react-toastify";
|
||||
import ErrorNotification from "./ErrorNotification";
|
||||
import WarningNotification from "./WarningNotification";
|
||||
import SuccessNotification from "./SuccessNotification";
|
||||
import pendingNotification from "@/core/components/notifications/PendingNotification";
|
||||
import WarningNotification from "@/core/components/notifications/WarningNotification";
|
||||
import ErrorNotification from "@/core/components/notifications/ErrorNotification";
|
||||
import SuccessNotification from "@/core/components/notifications/SuccessNotification";
|
||||
|
||||
const Notifications = async (t, response) => {
|
||||
const {status, data} = response != undefined ? response : ""
|
||||
toast.dismiss();
|
||||
switch (status) {
|
||||
case 200:
|
||||
SuccessNotification(t, status);
|
||||
const Notifications = (pushToastList, notificationType, t, status, message) => {
|
||||
switch (notificationType) {
|
||||
case "pending":
|
||||
pendingNotification(pushToastList, notificationType, t);
|
||||
break;
|
||||
case 400:
|
||||
ErrorNotification(t, status);
|
||||
case "warning":
|
||||
WarningNotification(pushToastList, notificationType, t, status);
|
||||
break;
|
||||
case 401:
|
||||
ErrorNotification(t, status);
|
||||
case "error":
|
||||
if (message) {
|
||||
ErrorNotification(pushToastList, notificationType, t, status, message)
|
||||
} else {
|
||||
ErrorNotification(pushToastList, notificationType, t, status)
|
||||
}
|
||||
break;
|
||||
case 403:
|
||||
ErrorNotification(t, status);
|
||||
break;
|
||||
case 422:
|
||||
ErrorNotification(t, status, data.message);
|
||||
break;
|
||||
case 500:
|
||||
WarningNotification(t, status);
|
||||
break;
|
||||
case 503:
|
||||
WarningNotification(t, status);
|
||||
break;
|
||||
case 504:
|
||||
WarningNotification(t, status);
|
||||
break;
|
||||
default:
|
||||
toast(t("notifications.pending"), {
|
||||
autoClose: false,
|
||||
closeOnClick: false,
|
||||
draggable: false,
|
||||
});
|
||||
case "success":
|
||||
SuccessNotification(pushToastList, notificationType, t, status);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
export default Notifications;
|
||||
|
||||
/*
|
||||
usage document
|
||||
|
||||
** for pending use ( Notifications( t, undefined) ) this before your request.
|
||||
** for success use ( Notifications( t, response) ) this inside .then() of your request.
|
||||
** for Error and Warning use ( Notifications( t, error.response) ) this inside .catche() of your request.
|
||||
|
||||
end usage document
|
||||
*/
|
||||
|
||||
@@ -15,7 +15,7 @@ export async function getServerSideProps({req, locale}) {
|
||||
title: "Dashboard.expert_management",
|
||||
isBot,
|
||||
locale,
|
||||
layout: {name: 'DashboardLayout', props: {permissions: ["manage_transportation_navgan"]}}
|
||||
layout: {name: 'DashboardLayout', props: {permissions: ["manage_experts"]}}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user