diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json
index 99ce155..6d4bba5 100644
--- a/public/locales/fa/app.json
+++ b/public/locales/fa/app.json
@@ -264,13 +264,10 @@
"vehicle_type": "نوع ماشین",
"state_name": "وضعیت درخواست",
"confirm": "ارجاع به معاون حمل و نقل",
- "upload_file": "صورت جلسه کارگروه را بارگذاری کنید",
- "upload_file_first_required": "وارد کردن فرم الف الزامیست",
- "upload_file_second_required": "وارد کردن فرم ب الزامیست",
+ "upload_file": "فایل خود را بارگذاری کنید(اختیاری)",
+ "upload_file_required": "وارد کردن گزارش کارشناسی الزامیست",
"upload_file_unit": "فایل بارگذاری شده باید حداکثر 5Mb باشد",
"upload_file_format": "فرمت قابل قبول : png,jpg,pdf",
- "print_form_a": "چاپ فرم الف",
- "print_form_b": "چاپ فرم ب",
"max_amount": "حداکثر مبلغ تصویب شده {value} میلیون ریال می باشد",
"excel_report": "گزارش اکسل",
"first_form": "فرم الف را بارگذاری کنید",
diff --git a/src/components/dashboard/passenger-boss/Buttons/printFormA.jsx b/src/components/dashboard/passenger-boss/Buttons/printFormA.jsx
deleted file mode 100644
index 6e0405e..0000000
--- a/src/components/dashboard/passenger-boss/Buttons/printFormA.jsx
+++ /dev/null
@@ -1,89 +0,0 @@
-import {useTranslations} from "next-intl";
-import {useRouter} from "next/router";
-import {useState} from "react";
-import useRequest from "@/lib/app/hooks/useRequest";
-import usePrint from "@/lib/app/hooks/usePrint";
-import {Button, CircularProgress} from "@mui/material";
-import PrintIcon from "@mui/icons-material/Print";
-import {GET_PASSENGER_BOSS} from "@/core/data/apiRoutes";
-
-const PrintFormA = () => {
- const t = useTranslations();
- const router = useRouter()
- const [loading, setLoading] = useState(false)
- const requestServer = useRequest({auth: true, pending: false, success: {notification: {show: false}}})
- const {setPrintPage, setPrintTitle} = usePrint()
-
- const filterRequest = async (filterArr) => {
- setLoading(true);
-
- const requests = filterArr.map(async (item) => {
- try {
- const params = new URLSearchParams();
- params.set("start", '0');
- params.set("filters", JSON.stringify([item]));
- params.set("sorting", '[]');
-
- const response = await requestServer(`${GET_PASSENGER_BOSS}?${params}`, 'get');
- const _chunkSize = 6;
- const _data = response.data.data;
- const chunk = Array.from({length: Math.ceil(_data.length / _chunkSize)}, (v, i) =>
- _data.slice(i * _chunkSize, i * _chunkSize + _chunkSize)
- );
- return chunk;
- } catch (error) {
- setLoading(false);
- throw error; // Propagate the error
- }
- });
-
- try {
- const chunks = await Promise.all(requests);
- setLoading(false);
- return chunks.flat(); // Flatten the chunks into a single array
- } catch (error) {
- console.error("Error processing requests:", error);
- throw error;
- }
- };
-
- const clickHandler = async () => {
- try {
- const chunks = await filterRequest([
- {
- id: "vehicle_type",
- value: "اتوبوس",
- fn: "contains",
- datatype: "text",
- },
- {
- id: "vehicle_type",
- value: "مینی بوس",
- fn: "contains",
- datatype: "text",
- },
- ]);
- setPrintPage(chunks.length);
- setPrintTitle(t('PassengerBoss.print_form_a'));
- sessionStorage.setItem('form-a-print', JSON.stringify(chunks));
- router.push('/dashboard/passenger-boss/prints/form-a');
- } catch (error) {
- console.error("Error in clickHandler:", error);
- }
- };
- return (
- : }
- onClick={clickHandler}
- >
- {t("PassengerBoss.print_form_a")}
-
- )
-}
-
-export default PrintFormA
\ No newline at end of file
diff --git a/src/components/dashboard/passenger-boss/Buttons/printFormB.jsx b/src/components/dashboard/passenger-boss/Buttons/printFormB.jsx
deleted file mode 100644
index 8380b07..0000000
--- a/src/components/dashboard/passenger-boss/Buttons/printFormB.jsx
+++ /dev/null
@@ -1,47 +0,0 @@
-import {useTranslations} from "next-intl";
-import {useRouter} from "next/router";
-import {useState} from "react";
-import useRequest from "@/lib/app/hooks/useRequest";
-import usePrint from "@/lib/app/hooks/usePrint";
-import {GET_PASSENGER_BOSS} from "@/core/data/apiRoutes";
-import {Button, CircularProgress} from "@mui/material";
-import PrintIcon from "@mui/icons-material/Print";
-
-const PrintFormB = () => {
- const t = useTranslations();
- const router = useRouter()
- const [loading, setLoading] = useState(false)
- const requestServer = useRequest({auth: true, pending: false, success: {notification: {show: false}}})
- const {setPrintPage, setPrintTitle} = usePrint()
- const clickHandler = () => {
- setLoading(true)
- const params = new URLSearchParams();
- params.set("start", '0');
- params.set("filters", '[]');
- params.set("sorting", '[]');
- requestServer(`${GET_PASSENGER_BOSS}?${params}`, 'get').then((response) => {
- const _data = response.data.data
- setPrintPage(_data.length)
- setPrintTitle(t('PassengerBoss.print_form_b'))
- sessionStorage.setItem('form-b-print', JSON.stringify(_data))
- router.push('/dashboard/passenger-boss/prints/form-b')
- }).catch(() => {
- setLoading(false)
- })
- }
- return (
- : }
- onClick={clickHandler}
- >
- {t("PassengerBoss.print_form_b")}
-
- )
-}
-
-export default PrintFormB
\ No newline at end of file
diff --git a/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx
index ff140ba..b4cddd6 100644
--- a/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx
+++ b/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx
@@ -28,14 +28,10 @@ const vehicle_amount = {
}
const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, handleSizeChangeClick}) => {
const t = useTranslations();
- const [selectedImageAForm, setSelectedImageAForm] = useState("");
- const [selectedImageBForm, setSelectedImageBForm] = useState("");
- const [fileTypesA, setFileTypesA] = useState(null);
- const [fileNamesA, setFileNamesA] = useState(null);
- const [fileTypesB, setFileTypesB] = useState(null);
- const [fileNamesB, setFileNamesB] = useState(null);
- const [showAddIconA, setShowAddIconA] = useState(true);
- const [showAddIconB, setShowAddIconB] = useState(true);
+ const [selectedImage, setSelectedImage] = useState("");
+ const [fileType, setFileType] = useState(null);
+ const [fileName, setFileName] = useState(null);
+ const [showAddIcon, setShowAddIcon] = useState(true);
const requestServer = useRequest({auth: true, notification: false})
const {update_notification} = useNotification();
const [attachmentsData, setAttachmentsData] = useState([]);
@@ -98,22 +94,14 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, hand
(value) => value <= vehicle_amount[vehicle_type])
.test("positive", `${t("ConfirmDialog.approved_amount_positive")}`, (value) => value >= 0)
.required(t("ConfirmDialog.approved_amount_error")),
- first_img: Yup.mixed()
- .required(t("PassengerBoss.upload_file_first_required"))
+ confirm_img: Yup.mixed().notRequired(t("ConfirmDialog.approved_amount_error"))
.test('fileSize', `${t("PassengerBoss.upload_file_unit")}`, (value) => {
+ if (!value) return true
return value.size <= 5 * 1024 * 1024;
})
.test('fileType', `${t("PassengerBoss.upload_file_format")}`, (value) => {
- const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types
- return allowedTypes.includes(value.type);
- }),
- second_img: Yup.mixed()
- .required(t("PassengerBoss.upload_file_second_required"))
- .test('fileSize', `${t("PassengerBoss.upload_file_unit")}`, (value) => {
- return value.size <= 5 * 1024 * 1024;
- })
- .test('fileType', `${t("PassengerBoss.upload_file_format")}`, (value) => {
- const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types
+ if (!value) return true
+ const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf'];
return allowedTypes.includes(value.type);
})
});
@@ -122,25 +110,25 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, hand
initialValues: {
description: "",
approved_amount: "",
- first_img: null,
- second_img: null
+ confirm_img: null,
}, validationSchema,
onSubmit: (values, {setSubmitting}) => {
const formData = new FormData();
formData.append("approved_amount", values.approved_amount);
-
if (values.description != "") formData.append("expert_description", values.description);
-
- const attachments = [
- {title: 'فرم الف', file: values.first_img},
- {title: 'فرم ب', file: values.second_img}
- ];
-
- attachments.forEach((attachment, index) => {
- formData.append(`attachment[${index}][title]`, attachment.title);
- formData.append(`attachment[${index}][file]`, attachment.file);
- });
+ if (values.confirm_img != null) {
+ const attachments = [
+ {
+ title: "فایل ضمیمه کارتابل کارگروه",
+ file: values.confirm_img
+ }
+ ];
+ attachments.forEach((attachment, index) => {
+ formData.append(`attachment[${index}][title]`, attachment.title);
+ formData.append(`attachment[${index}][file]`, attachment.file);
+ });
+ }
requestServer(`${CONFIRM_PASSENGER_BOSS}/${rowId}`, 'post', {
notification: true,
@@ -160,32 +148,18 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, hand
formik.setFieldValue("description", event.target.value)
};
- const handleUploadChangeAForm = (event) => {
+ const handleUploadChange = (event) => {
const uploadedFile = event.target?.files?.[0];
if (uploadedFile) {
const fileType = event.target?.files?.[0].type;
const fileName = event.target?.files?.[0].name;
- setSelectedImageAForm(URL.createObjectURL(uploadedFile));
- setFileTypesA(fileType);
- setFileNamesA(fileName);
- formik.setFieldValue("first_img", uploadedFile).then(() => {
- formik.setFieldTouched("first_img", true);
+ setSelectedImage(URL.createObjectURL(uploadedFile));
+ setFileType(fileType);
+ setFileName(fileName);
+ formik.setFieldValue("confirm_img", uploadedFile).then(() => {
+ formik.setFieldTouched("confirm_img", true);
})
- setShowAddIconA(false);
- }
- };
- const handleUploadChangeBForm = (event) => {
- const uploadedFile = event.target?.files?.[0];
- if (uploadedFile) {
- const fileType = event.target?.files?.[0].type;
- const fileName = event.target?.files?.[0].name;
- setSelectedImageBForm(URL.createObjectURL(uploadedFile));
- setFileTypesB(fileType);
- setFileNamesB(fileName);
- formik.setFieldValue("second_img", uploadedFile).then(() => {
- formik.setFieldTouched("second_img", true);
- })
- setShowAddIconB(false);
+ setShowAddIcon(false);
}
};
const handleAmountChange = (event) => {
@@ -279,60 +253,30 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type, hand
/>
-
-
- {t("PassengerBoss.first_form")}
- formik.handleBlur("first_img")}
- error={
- formik.touched.first_img &&
- Boolean(formik.errors.first_img)
- }
- />
-
- {formik.touched.first_img && formik.errors.first_img}
-
-
-
- {t("PassengerBoss.second_form")}
- formik.handleBlur("second_img")}
- error={
- formik.touched.second_img &&
- Boolean(formik.errors.second_img)
- }
- />
-
- {formik.touched.second_img && formik.errors.second_img}
-
-
-
+ {t("PassengerBoss.upload_file")}
+
+
+ {formik.touched.confirm_img && formik.errors.confirm_img}
+
diff --git a/src/components/dashboard/passenger-boss/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/passenger-boss/Form/RejectForm/RejectContent.jsx
index 3431cde..6851197 100644
--- a/src/components/dashboard/passenger-boss/Form/RejectForm/RejectContent.jsx
+++ b/src/components/dashboard/passenger-boss/Form/RejectForm/RejectContent.jsx
@@ -9,38 +9,24 @@ import * as Yup from "yup";
import {REJECT_PASSENGER_BOSS} from "@/core/data/apiRoutes";
const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
- const [selectedImageAForm, setSelectedImageAForm] = useState("");
- const [selectedImageBForm, setSelectedImageBForm] = useState("");
- const [fileTypesA, setFileTypesA] = useState(null);
- const [fileNamesA, setFileNamesA] = useState(null);
- const [fileTypesB, setFileTypesB] = useState(null);
- const [fileNamesB, setFileNamesB] = useState(null);
- const [showAddIconA, setShowAddIconA] = useState(true);
- const [showAddIconB, setShowAddIconB] = useState(true);
+ 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")),
-
- first_reject_img: Yup.mixed()
- .required(t("PassengerBoss.upload_file_first_required"))
+ confirm_img: Yup.mixed().notRequired(t("ConfirmDialog.approved_amount_error"))
.test('fileSize', `${t("PassengerBoss.upload_file_unit")}`, (value) => {
+ if (!value) return true
return value.size <= 5 * 1024 * 1024;
})
.test('fileType', `${t("PassengerBoss.upload_file_format")}`, (value) => {
- const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types
- return allowedTypes.includes(value.type);
- }),
-
- second_reject_img: Yup.mixed()
- .required(t("PassengerBoss.upload_file_second_required"))
- .test('fileSize', `${t("PassengerBoss.upload_file_unit")}`, (value) => {
- return value.size <= 5 * 1024 * 1024;
- })
- .test('fileType', `${t("PassengerBoss.upload_file_format")}`, (value) => {
- const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types
+ if (!value) return true
+ const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf'];
return allowedTypes.includes(value.type);
})
});
@@ -48,23 +34,24 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
const formik = useFormik({
initialValues: {
description: "",
- first_reject_img: null,
- second_reject_img:null
+ confirm_img: null,
},
validationSchema,
onSubmit: (values, {setSubmitting}) => {
const formData = new FormData();
formData.append("expert_description", values.description);
-
- const attachments = [
- { title: 'فرم الف', file: values.first_reject_img },
- { title: 'فرم ب', file: values.second_reject_img }
- ];
-
- attachments.forEach((attachment, index) => {
- formData.append(`attachment[${index}][title]`, attachment.title);
- formData.append(`attachment[${index}][file]`, attachment.file);
- });
+ if (values.confirm_img != null) {
+ const attachments = [
+ {
+ title: "فایل ضمیمه کارتابل کارگروه",
+ file: values.confirm_img
+ }
+ ];
+ attachments.forEach((attachment, index) => {
+ formData.append(`attachment[${index}][title]`, attachment.title);
+ formData.append(`attachment[${index}][file]`, attachment.file);
+ });
+ }
requestServer(`${REJECT_PASSENGER_BOSS}/${rowId}`, 'post', {
data: formData,
@@ -83,32 +70,18 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
formik.setFieldValue("description", event.target.value);
formik.handleChange(event);
};
- const handleUploadChangeAForm = (event) => {
+ const handleUploadChange = (event) => {
const uploadedFile = event.target?.files?.[0];
if (uploadedFile) {
const fileType = event.target?.files?.[0].type;
const fileName = event.target?.files?.[0].name;
- setSelectedImageAForm(URL.createObjectURL(uploadedFile));
- setFileTypesA(fileType);
- setFileNamesA(fileName);
- formik.setFieldValue("first_reject_img", uploadedFile).then(() => {
- formik.setFieldTouched("first_reject_img", true);
+ setSelectedImage(URL.createObjectURL(uploadedFile));
+ setFileType(fileType);
+ setFileName(fileName);
+ formik.setFieldValue("confirm_img", uploadedFile).then(() => {
+ formik.setFieldTouched("confirm_img", true);
})
- setShowAddIconA(false);
- }
- };
- const handleUploadChangeBForm = (event) => {
- const uploadedFile = event.target?.files?.[0];
- if (uploadedFile) {
- const fileType = event.target?.files?.[0].type;
- const fileName = event.target?.files?.[0].name;
- setSelectedImageBForm(URL.createObjectURL(uploadedFile));
- setFileTypesB(fileType);
- setFileNamesB(fileName);
- formik.setFieldValue("second_reject_img", uploadedFile).then(() => {
- formik.setFieldTouched("second_reject_img", true);
- })
- setShowAddIconB(false);
+ setShowAddIcon(false);
}
};
return (
@@ -134,60 +107,30 @@ const RejectContent = ({rowId, mutate, setOpenRejectDialog}) => {
/>
-
-
- {t("PassengerBoss.first_form")}
- formik.handleBlur("first_reject_img")}
- error={
- formik.touched.first_reject_img &&
- Boolean(formik.errors.first_reject_img)
- }
- />
-
- {formik.touched.first_reject_img && formik.errors.first_reject_img}
-
-
-
- {t("PassengerBoss.second_form")}
- formik.handleBlur("second_reject_img")}
- error={
- formik.touched.second_reject_img &&
- Boolean(formik.errors.second_reject_img)
- }
- />
-
- {formik.touched.second_reject_img && formik.errors.second_reject_img}
-
-
-
+ {t("PassengerBoss.upload_file")}
+
+
+ {formik.touched.confirm_img && formik.errors.confirm_img}
+
diff --git a/src/components/dashboard/passenger-boss/TableToolbar.jsx b/src/components/dashboard/passenger-boss/TableToolbar.jsx
index b59a19f..d050624 100644
--- a/src/components/dashboard/passenger-boss/TableToolbar.jsx
+++ b/src/components/dashboard/passenger-boss/TableToolbar.jsx
@@ -1,13 +1,9 @@
import {Stack} from "@mui/material";
import PrintExcel from "@/components/dashboard/passenger-boss/Buttons/printExcel";
-import PrintFormB from "@/components/dashboard/passenger-boss/Buttons/printFormB";
-import PrintFormA from "@/components/dashboard/passenger-boss/Buttons/printFormA";
const TableToolbar = ({table}) => {
return (
-
-
)