diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx
index f47a3b8..00d8c2f 100644
--- a/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx
+++ b/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx
@@ -8,6 +8,7 @@ import {CONFIRM_MACHINARY_OFFICE} from "@/core/data/apiRoutes";
import UploadFileNotification from "@/core/components/notifications/UploadFileNotification";
import { useState } from "react";
import PriceField from "@/core/components/PriceField";
+import * as Yup from "yup";
const ConfirmContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => {
const t = useTranslations();
@@ -18,12 +19,21 @@ const ConfirmContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => {
const requestServer = useRequest({auth: true})
const {update_notification} = useNotification()
+ const validationSchema = Yup.object().shape({
+ proposed_amount: Yup.mixed().test(
+ "is-number",
+ `${t("ConfirmDialog.proposed_amount_number")}`,
+ (value) => !isNaN(value)
+ ).test("positive", `${t("ConfirmDialog.proposed_amount_positive")}`, (value) => value >= 0)
+ .required(t("ConfirmDialog.proposed_amount_error"))
+ });
+
const formik = useFormik({
initialValues: {
description: "",
proposed_amount: "",
confirm_img: null
- },
+ },validationSchema,
onSubmit: (values, {setSubmitting}) => {
const formData = new FormData();
formData.append("proposed_amount", values.proposed_amount);
@@ -141,7 +151,7 @@ const ConfirmContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => {
{t("ConfirmDialog.button-cancel")}
diff --git a/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx b/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx
similarity index 53%
rename from src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx
rename to src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx
index 0654985..6c229e0 100644
--- a/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx
+++ b/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx
@@ -1,37 +1,21 @@
-import {useTranslations} from "next-intl";
-import {useState} from "react";
-import {
- Button,
- Dialog,
- DialogActions,
- DialogContent,
- DialogTitle,
- IconButton,
- Stack,
- TextField,
- Tooltip,
- Typography
-} from "@mui/material";
-import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt";
import UploadSystem from "@/core/components/UploadSystem";
-import useDirection from "@/lib/app/hooks/useDirection";
-import {useFormik} from "formik";
-import UploadFileNotification from "@/core/components/notifications/UploadFileNotification";
-import * as Yup from "yup";
-import useRequest from "@/lib/app/hooks/useRequest";
-import {CONFIRM_PASSENGER_BOSS} from "@/core/data/apiRoutes";
import useNotification from "@/lib/app/hooks/useNotification";
+import useRequest from "@/lib/app/hooks/useRequest";
+import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material"
+import { useFormik } from "formik";
+import { useTranslations } from "next-intl";
+import {CONFIRM_PASSENGER_BOSS} from "@/core/data/apiRoutes";
+import UploadFileNotification from "@/core/components/notifications/UploadFileNotification";
+import { useState } from "react";
import PriceField from "@/core/components/PriceField";
+import * as Yup from "yup";
-
-const Confirm = ({rowId, fetchUrl, mutate}) => {
+const ConfirmContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => {
const t = useTranslations();
- const {directionApp} = useDirection();
const [selectedImage, setSelectedImage] = useState("");
const [fileType, setfileType] = useState(null);
const [fileName, setfileName] = useState(null);
const [showAddIcon, setShowAddIcon] = useState(true);
- const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
const requestServer = useRequest({auth: true})
const {update_notification} = useNotification()
@@ -43,17 +27,17 @@ const Confirm = ({rowId, fetchUrl, mutate}) => {
).test("positive", `${t("ConfirmDialog.approved_amount_positive")}`, (value) => value >= 0)
.required(t("ConfirmDialog.approved_amount_error"))
});
+
const formik = useFormik({
initialValues: {
description: "",
approved_amount: "",
confirm_img: null
- },
- validationSchema,
+ },validationSchema,
onSubmit: (values, {setSubmitting}) => {
const formData = new FormData();
formData.append("approved_amount", values.approved_amount);
- if (values.description != "") formData.append("expert_description", values.description);
+ if (values.description != "") formData.append("description", values.description);
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
requestServer(`${CONFIRM_PASSENGER_BOSS}/${rowId}`, 'post', {
@@ -71,13 +55,7 @@ const Confirm = ({rowId, fetchUrl, mutate}) => {
const handleDescriptionChange = (event) => {
formik.setFieldValue("description", event.target.value)
};
- const handleAmountChange = (event) => {
- if (!isNaN(event.target.value)) {
- formik.setFieldValue("approved_amount", event.target.value)
- } else {
- formik.setFieldValue("approved_amount", formik.values.approved_amount)
- }
- };
+
const handleUploadChange = (event) => {
const uploadedFile = event.target?.files?.[0];
if (uploadedFile) {
@@ -97,38 +75,33 @@ const Confirm = ({rowId, fetchUrl, mutate}) => {
setShowAddIcon(false);
}
};
- return (
+ const handleAmountChange = (event) => {
+ if (!isNaN(event.target.value)) {
+ formik.setFieldValue("approved_amount", event.target.value)
+ } else {
+ formik.setFieldValue("approved_amount", formik.values.approved_amount)
+ }
+ };
+
+ return(
<>
-
- {
- setOpenConfirmDialog(true)
- }}
- >
-
-
-
-
+
+
+
+
+
+
>
- );
-};
-export default Confirm;
\ No newline at end of file
+ )
+
+}
+export default ConfirmContent
\ No newline at end of file
diff --git a/src/components/dashboard/passenger-boss/Form/ConfirmForm/index.jsx b/src/components/dashboard/passenger-boss/Form/ConfirmForm/index.jsx
new file mode 100644
index 0000000..3683d82
--- /dev/null
+++ b/src/components/dashboard/passenger-boss/Form/ConfirmForm/index.jsx
@@ -0,0 +1,31 @@
+import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
+import { useTranslations } from "next-intl";
+import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt";
+import { useState } from "react";
+import ConfirmContent from "./ConfirmContent";
+
+const Confirm = ({rowId, fetchUrl, mutate}) => {
+ const t = useTranslations();
+ const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
+ return(
+ <>
+
+ {
+ setOpenConfirmDialog(true)
+ }}
+ >
+
+
+
+
+ >
+ )
+
+}
+export default Confirm;
\ No newline at end of file
diff --git a/src/components/dashboard/passenger-boss/Form/RejectForm.jsx b/src/components/dashboard/passenger-boss/Form/RejectForm.jsx
deleted file mode 100644
index 01dcfc8..0000000
--- a/src/components/dashboard/passenger-boss/Form/RejectForm.jsx
+++ /dev/null
@@ -1,148 +0,0 @@
-import {REJECT_PASSENGER_BOSS} from "@/core/data/apiRoutes";
-import {
- Button,
- Dialog,
- DialogActions,
- DialogContent,
- DialogTitle,
- IconButton,
- Stack,
- TextField,
- Tooltip,
- Typography,
-} from "@mui/material";
-import {useTranslations} from "next-intl";
-import {useFormik} from "formik";
-import * as Yup from "yup";
-import {useState} from "react";
-import UploadSystem from "@/core/components/UploadSystem";
-import UploadFileNotification from "@/core/components/notifications/UploadFileNotification";
-import useDirection from "@/lib/app/hooks/useDirection";
-import ThumbDownIcon from "@mui/icons-material/ThumbDown";
-import useRequest from "@/lib/app/hooks/useRequest";
-import useNotification from "@/lib/app/hooks/useNotification";
-
-
-const Reject = ({rowId, fetchUrl, mutate}) => {
- const [selectedImage, setSelectedImage] = useState("");
- const [fileType, setfileType] = useState(null);
- const [fileName, setfileName] = useState(null);
- const [showAddIcon, setShowAddIcon] = useState(true);
- const t = useTranslations();
- const {directionApp} = useDirection();
- const [openRejectDialog, setOpenRejectDialog] = useState(false);
- const requestServer = useRequest({auth: true})
- const {update_notification} = useNotification()
-
- const validationSchema = Yup.object().shape({
- description: Yup.string().required(t("RejectDialog.description_error")),
- });
-
- const formik = useFormik({
- initialValues: {
- description: "",
- reject_img: null
- },
- validationSchema,
- onSubmit: (values, {setSubmitting}) => {
- const formData = new FormData();
- formData.append("expert_description", values.description);
- if (values.reject_img != null) formData.append("attachment", values.reject_img);
-
- requestServer(`${REJECT_PASSENGER_BOSS}/${rowId}`, 'post', {
- data: formData,
- }).then((response) => {
- mutate(fetchUrl)
- update_notification()
- }).catch(() => {
- }).finally(() => {
- setSubmitting(false);
- });
- },
- });
-
- const handleDescriptionChange = (event) => {
- formik.setFieldValue("description", event.target.value);
- formik.handleChange(event);
- };
- const handleUploadChange = (event) => {
- const uploadedFile = event.target?.files?.[0];
- if (uploadedFile) {
- const maxFileSize = 2 * 1024 * 1024;
- if (uploadedFile.size > maxFileSize) {
- UploadFileNotification(t);
- event.target.value = "";
- return;
- }
- const fileType = event.target?.files?.[0].type;
- const fileName = event.target?.files?.[0].name;
- setSelectedImage(URL.createObjectURL(uploadedFile));
- setfileType(fileType);
- setfileName(fileName);
- formik.setFieldValue("reject_img", uploadedFile);
- setShowAddIcon(false);
- }
- };
- return (
- <>
-
- setOpenRejectDialog(true)}>
-
-
-
-
- >
- );
-};
-export default Reject;
\ No newline at end of file
diff --git a/src/components/dashboard/passenger-boss/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/passenger-boss/Form/RejectForm/RejectContent.jsx
new file mode 100644
index 0000000..3583903
--- /dev/null
+++ b/src/components/dashboard/passenger-boss/Form/RejectForm/RejectContent.jsx
@@ -0,0 +1,122 @@
+import UploadSystem from "@/core/components/UploadSystem"
+import useNotification from "@/lib/app/hooks/useNotification";
+import useRequest from "@/lib/app/hooks/useRequest";
+import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material"
+import { useFormik } from "formik";
+import { useTranslations } from "next-intl";
+import { useState } from "react";
+import * as Yup from "yup";
+import {REJECT_PASSENGER_BOSS} from "@/core/data/apiRoutes";
+
+const RejectContent = ({rowId, fetchUrl, mutate, setOpenRejectDialog}) => {
+ const [selectedImage, setSelectedImage] = useState("");
+ const [fileType, setfileType] = useState(null);
+ const [fileName, setfileName] = useState(null);
+ const [showAddIcon, setShowAddIcon] = useState(true);
+ const t = useTranslations();
+ const requestServer = useRequest({auth: true})
+ const {update_notification} = useNotification()
+
+ const validationSchema = Yup.object().shape({
+ description: Yup.string().required(t("RejectDialog.description_error")),
+ });
+
+ const formik = useFormik({
+ initialValues: {
+ description: "",
+ reject_img: null
+ },
+ validationSchema,
+ onSubmit: (values, {setSubmitting}) => {
+ const formData = new FormData();
+ formData.append("description", values.description);
+ if (values.reject_img != null) formData.append("attachment", values.reject_img);
+
+ requestServer(`${REJECT_PASSENGER_BOSS}/${rowId}`, 'post', {
+ data: formData,
+ }).then((response) => {
+ mutate(fetchUrl)
+ update_notification()
+ }).catch(() => {
+ }).finally(() => {
+ setSubmitting(false);
+ });
+ },
+ });
+
+ const handleDescriptionChange = (event) => {
+ formik.setFieldValue("description", event.target.value);
+ formik.handleChange(event);
+ };
+ const handleUploadChange = (event) => {
+ const uploadedFile = event.target?.files?.[0];
+ if (uploadedFile) {
+ const maxFileSize = 2 * 1024 * 1024;
+ if (uploadedFile.size > maxFileSize) {
+ UploadFileNotification(t);
+ event.target.value = "";
+ return;
+ }
+ const fileType = event.target?.files?.[0].type;
+ const fileName = event.target?.files?.[0].name;
+ setSelectedImage(URL.createObjectURL(uploadedFile));
+ setfileType(fileType);
+ setfileName(fileName);
+ formik.setFieldValue("reject_img", uploadedFile);
+ setShowAddIcon(false);
+ }
+ };
+ return(
+ <>
+
+
+
+
+
+
+ {t("UploadSystem.upload_file")}{t("UploadSystem.optional")}
+
+
+
+
+
+
+
+
+ >
+ )
+}
+export default RejectContent
\ No newline at end of file
diff --git a/src/components/dashboard/passenger-boss/Form/RejectForm/index.jsx b/src/components/dashboard/passenger-boss/Form/RejectForm/index.jsx
new file mode 100644
index 0000000..678a842
--- /dev/null
+++ b/src/components/dashboard/passenger-boss/Form/RejectForm/index.jsx
@@ -0,0 +1,25 @@
+import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"
+import { useTranslations } from "next-intl";
+import { useState } from "react";
+import RejectContent from "./RejectContent";
+import ThumbDownIcon from "@mui/icons-material/ThumbDown";
+
+const Reject = ({rowId, fetchUrl, mutate}) => {
+ const t = useTranslations();
+ const [openRejectDialog, setOpenRejectDialog] = useState(false);
+ return (
+ <>
+
+ setOpenRejectDialog(true)}>
+
+
+
+
+ >
+ )
+}
+export default Reject
\ No newline at end of file
diff --git a/src/components/dashboard/passenger-boss/TableRowActions.jsx b/src/components/dashboard/passenger-boss/TableRowActions.jsx
index 601240f..c22cf80 100644
--- a/src/components/dashboard/passenger-boss/TableRowActions.jsx
+++ b/src/components/dashboard/passenger-boss/TableRowActions.jsx
@@ -1,17 +1,18 @@
import {Box} from "@mui/material";
-import ConfirmForm from "./Form/ConfirmForm"
import RejectForm from "./Form/RejectForm"
+import Confirm from "./Form/ConfirmForm";
+import Reject from "./Form/RejectForm";
const TableRow = ({row, mutate, fetchUrl}) => {
return (
-
-