From 72afdef3dd4f769e19270fa6d1c864f13416383b Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Tue, 7 Nov 2023 15:21:23 +0330 Subject: [PATCH 1/6] LFFE-19 add maximum amount in validation of machinary and passenger boss --- public/locales/fa/app.json | 6 ++++-- .../machinary-office/Form/ConfirmForm/ConfirmContent.jsx | 3 ++- .../passenger-boss/Form/ConfirmForm/ConfirmContent.jsx | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 87ae5d6..0f56b9a 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -205,7 +205,8 @@ "upload_file": "صورت جلسه کارگروه استانی را بارگذاری کنید", "upload_file_required": "وارد کردن صورت جلسه کارگروه استانی الزامیست", "upload_file_unit": "فایل بارگذاری شده باید حداکثر 2Mb باشد", - "upload_file_format": "فرمت قابل قبول : png,jpg,pdf" + "upload_file_format": "فرمت قابل قبول : png,jpg,pdf", + "max_amount": "حداکثر مبلغ پیشنهادی {value} هزار تومان می باشد" }, "RefahiProvinceManager": { "name": "نام", @@ -303,7 +304,8 @@ "upload_file": "گزارش کارشناسی را بارگذاری کنید", "upload_file_required": "وارد کردن گزارش کارشناسی الزامیست", "upload_file_unit": "فایل بارگذاری شده باید حداکثر 2Mb باشد", - "upload_file_format": "فرمت قابل قبول : png,jpg,pdf" + "upload_file_format": "فرمت قابل قبول : png,jpg,pdf", + "max_amount": "حداکثر مبلغ پیشنهادی {value} هزار تومان می باشد" }, "UserManagement": { "name": "نام", diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx index ea8687d..86e8a5e 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx @@ -23,7 +23,8 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => { "is-number", `${t("ConfirmDialog.proposed_amount_number")}`, (value) => !isNaN(value) - ).test("positive", `${t("ConfirmDialog.proposed_amount_positive")}`, (value) => value >= 0) + ).test("max-amount", `${t("MachinaryOffice.max_amount", {value: 7000})}`, (value) => value <= 7000) + .test("positive", `${t("ConfirmDialog.proposed_amount_positive")}`, (value) => value >= 0) .required(t("ConfirmDialog.proposed_amount_error")), confirm_img: Yup.mixed() .required(t("MachinaryOffice.upload_file_required")) diff --git a/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx index d86a0e6..4e7332b 100644 --- a/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx @@ -23,7 +23,8 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => { "is-number", `${t("ConfirmDialog.approved_amount_number")}`, (value) => !isNaN(value) - ).test("positive", `${t("ConfirmDialog.approved_amount_positive")}`, (value) => value >= 0) + ).test("max-amount", `${t("PassengerBoss.max_amount", {value: 7000})}`, (value) => value <= 7000) + .test("positive", `${t("ConfirmDialog.approved_amount_positive")}`, (value) => value >= 0) .required(t("ConfirmDialog.approved_amount_error")), confirm_img: Yup.mixed() .required(t("PassengerBoss.upload_file_required")) From ff5e0430da27103cf342b9682638d2deb0511ddd Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Tue, 7 Nov 2023 15:50:02 +0330 Subject: [PATCH 2/6] LFFE-19 set maximum limit for max number --- public/locales/fa/app.json | 2 +- .../machinary-office/Form/ConfirmForm/ConfirmContent.jsx | 3 ++- .../passenger-boss/Form/ConfirmForm/ConfirmContent.jsx | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 0f56b9a..2e60776 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -206,7 +206,7 @@ "upload_file_required": "وارد کردن صورت جلسه کارگروه استانی الزامیست", "upload_file_unit": "فایل بارگذاری شده باید حداکثر 2Mb باشد", "upload_file_format": "فرمت قابل قبول : png,jpg,pdf", - "max_amount": "حداکثر مبلغ پیشنهادی {value} هزار تومان می باشد" + "max_amount": "حداکثر مبلغ پیشنهادی {value} تومان می باشد" }, "RefahiProvinceManager": { "name": "نام", diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx index 86e8a5e..62b704c 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx @@ -10,6 +10,7 @@ import PriceField from "@/core/components/PriceField"; import * as Yup from "yup"; const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => { + const max_amount_number = 70000000000 const t = useTranslations(); const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); @@ -23,7 +24,7 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => { "is-number", `${t("ConfirmDialog.proposed_amount_number")}`, (value) => !isNaN(value) - ).test("max-amount", `${t("MachinaryOffice.max_amount", {value: 7000})}`, (value) => value <= 7000) + ).test("max-amount", `${t("MachinaryOffice.max_amount", {value: parseInt(max_amount_number).toLocaleString('en')})}`, (value) => value <= max_amount_number) .test("positive", `${t("ConfirmDialog.proposed_amount_positive")}`, (value) => value >= 0) .required(t("ConfirmDialog.proposed_amount_error")), confirm_img: Yup.mixed() diff --git a/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx index 4e7332b..9269ebc 100644 --- a/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx @@ -10,6 +10,7 @@ import PriceField from "@/core/components/PriceField"; import * as Yup from "yup"; const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => { + const max_amount_number = 70000000000 const t = useTranslations(); const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); @@ -18,12 +19,13 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => { const requestServer = useRequest({auth: true}) const {update_notification} = useNotification() + const validationSchema = Yup.object().shape({ approved_amount: Yup.mixed().test( "is-number", `${t("ConfirmDialog.approved_amount_number")}`, (value) => !isNaN(value) - ).test("max-amount", `${t("PassengerBoss.max_amount", {value: 7000})}`, (value) => value <= 7000) + ).test("max-amount", `${t("PassengerBoss.max_amount", {value: parseInt(max_amount_number).toLocaleString('en')})}`, (value) => value <= max_amount_number) .test("positive", `${t("ConfirmDialog.approved_amount_positive")}`, (value) => value >= 0) .required(t("ConfirmDialog.approved_amount_error")), confirm_img: Yup.mixed() From 87dd2844cc0517f30c732130e84825cd58c2ea2c Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Mon, 13 Nov 2023 14:15:00 +0330 Subject: [PATCH 3/6] LFFE-24 Change unit price from (Toman, Rial) to (Milion Toman, Milion Rial) --- public/locales/fa/app.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 87ae5d6..0ec9394 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -331,14 +331,14 @@ "button-confirm": "ارجاع", "description_error": "وارد کردن توضیحات الزامی است!", "optional": " (اختیاری)", - "unit": " (ریال)", + "unit": " (میلیون ریال)", "description": "توضیحات خود را وارد نمائید", "choose_file": "انتخاب فایل", "approved_amount": "مبلغ تصویب شده", "approved_amount_error": "وارد کردن مبلغ تصویب شده الزامیست", "approved_amount_positive": "مبلغ تصویب شده باید مثبت باشد", "approved_amount_number": "مبلغ تصویب شده باید عدد باشد", - "toman": "تومان", + "toman": "میلیون تومان", "proposed_amount_error": "وارد کردن مقدار پیشنهادی الزامیست", "proposed_amount": "مقدار پیشنهادی", "proposed_amount_positive": "مقدار پیشنهادی باید مثبت باشد", From ff6a9607596114461a86e14804e4f98954f94f8b Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Mon, 13 Nov 2023 15:55:17 +0330 Subject: [PATCH 4/6] change style list sidebar --- src/components/layouts/Dashboard/Sidebar/SidebarList.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/layouts/Dashboard/Sidebar/SidebarList.jsx b/src/components/layouts/Dashboard/Sidebar/SidebarList.jsx index 3a2eb44..1c76f07 100644 --- a/src/components/layouts/Dashboard/Sidebar/SidebarList.jsx +++ b/src/components/layouts/Dashboard/Sidebar/SidebarList.jsx @@ -87,7 +87,7 @@ export default function SidebarList({handleDrawerToggle}) { }, [selectedKey]); return ( - + {itemMenu.map((itemArr, index) => ( {itemArr.map((item) => From fb7bb856b5f7d59ea10e5800e0b6b25f3278b0d2 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Tue, 14 Nov 2023 11:10:27 +0330 Subject: [PATCH 5/6] LFFE-19 get vehicle type and set maximum number base on it --- public/locales/fa/app.json | 4 ++-- .../Form/ConfirmForm/ConfirmContent.jsx | 22 +++++++++++-------- .../Form/ConfirmForm/index.jsx | 6 +++-- .../machinary-office/TableRowActions.jsx | 2 +- .../Form/ConfirmForm/ConfirmContent.jsx | 15 +++++++++---- .../passenger-boss/Form/ConfirmForm/index.jsx | 6 +++-- .../passenger-boss/TableRowActions.jsx | 1 + 7 files changed, 36 insertions(+), 20 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 27d4b0e..0481f1a 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -206,7 +206,7 @@ "upload_file_required": "وارد کردن صورت جلسه کارگروه استانی الزامیست", "upload_file_unit": "فایل بارگذاری شده باید حداکثر 2Mb باشد", "upload_file_format": "فرمت قابل قبول : png,jpg,pdf", - "max_amount": "حداکثر مبلغ پیشنهادی {value} تومان می باشد" + "max_amount": "حداکثر مبلغ تصویب شده {value} میلیون تومان می باشد" }, "RefahiProvinceManager": { "name": "نام", @@ -305,7 +305,7 @@ "upload_file_required": "وارد کردن گزارش کارشناسی الزامیست", "upload_file_unit": "فایل بارگذاری شده باید حداکثر 2Mb باشد", "upload_file_format": "فرمت قابل قبول : png,jpg,pdf", - "max_amount": "حداکثر مبلغ پیشنهادی {value} هزار تومان می باشد" + "max_amount": "حداکثر مبلغ پیشنهادی {value} میلیون تومان می باشد" }, "UserManagement": { "name": "نام", diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx index 62b704c..93ee5a2 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx @@ -9,8 +9,7 @@ import {useState} from "react"; import PriceField from "@/core/components/PriceField"; import * as Yup from "yup"; -const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => { - const max_amount_number = 70000000000 +const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type}) => { const t = useTranslations(); const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); @@ -18,24 +17,30 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => { const [showAddIcon, setShowAddIcon] = useState(true); const requestServer = useRequest({auth: true}) const {update_notification} = useNotification() - + let max_amount_number + if (vehicle_type === "اتوبوس") { + max_amount_number = 7000 + } else if (vehicle_type === "مینی بوس") { + max_amount_number = 2000 + } else { + max_amount_number = 5000 + } const validationSchema = Yup.object().shape({ proposed_amount: Yup.mixed().test( "is-number", `${t("ConfirmDialog.proposed_amount_number")}`, (value) => !isNaN(value) - ).test("max-amount", `${t("MachinaryOffice.max_amount", {value: parseInt(max_amount_number).toLocaleString('en')})}`, (value) => value <= max_amount_number) + ).test("max-amount", `${t("MachinaryOffice.max_amount", {value: parseInt(max_amount_number / 10).toLocaleString('en')})}`, + (value) => value <= max_amount_number) .test("positive", `${t("ConfirmDialog.proposed_amount_positive")}`, (value) => value >= 0) .required(t("ConfirmDialog.proposed_amount_error")), confirm_img: Yup.mixed() .required(t("MachinaryOffice.upload_file_required")) .test('fileSize', `${t("MachinaryOffice.upload_file_unit")}`, (value) => { - // if (!value) return true; // Skip if no file is provided - return value.size <= 2 * 1024 * 1024; // 100KB limit (adjust as needed) + return value.size <= 2 * 1024 * 1024; }) .test('fileType', `${t("MachinaryOffice.upload_file_format")}`, (value) => { - // if (!value) return true; // Skip if no file is provided - const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; // Define your allowed file types + const allowedTypes = ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']; return allowedTypes.includes(value.type); }) }); @@ -51,7 +56,6 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => { formData.append("proposed_amount", values.proposed_amount); 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', { data: formData, }).then((response) => { diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm/index.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm/index.jsx index 5ed809f..3affc7b 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm/index.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm/index.jsx @@ -3,7 +3,8 @@ import {useTranslations} from "next-intl"; import {useState} from "react"; import ConfirmContent from "./ConfirmContent"; import CallMadeIcon from '@mui/icons-material/CallMade'; -const Confirm = ({rowId, mutate}) => { + +const Confirm = ({rowId, mutate, vehicle_type}) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); return ( @@ -21,7 +22,8 @@ const Confirm = ({rowId, mutate}) => { {t("MachinaryOffice.confirm")} - + ) diff --git a/src/components/dashboard/machinary-office/TableRowActions.jsx b/src/components/dashboard/machinary-office/TableRowActions.jsx index 69f9d6f..f50938e 100644 --- a/src/components/dashboard/machinary-office/TableRowActions.jsx +++ b/src/components/dashboard/machinary-office/TableRowActions.jsx @@ -3,11 +3,11 @@ import Confirm from "./Form/ConfirmForm"; import Reject from "./Form/RejectForm"; const TableRow = ({row, mutate}) => { - return ( { - const max_amount_number = 70000000000 +const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type}) => { const t = useTranslations(); const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); @@ -18,14 +17,22 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog}) => { const [showAddIcon, setShowAddIcon] = useState(true); const requestServer = useRequest({auth: true}) const {update_notification} = useNotification() - + let max_amount_number + if (vehicle_type === "اتوبوس") { + max_amount_number = 7000 + } else if (vehicle_type === "مینی بوس") { + max_amount_number = 2000 + } else { + max_amount_number = 5000 + } const validationSchema = Yup.object().shape({ approved_amount: Yup.mixed().test( "is-number", `${t("ConfirmDialog.approved_amount_number")}`, (value) => !isNaN(value) - ).test("max-amount", `${t("PassengerBoss.max_amount", {value: parseInt(max_amount_number).toLocaleString('en')})}`, (value) => value <= max_amount_number) + ).test("max-amount", `${t("PassengerBoss.max_amount", {value: parseInt(max_amount_number / 10).toLocaleString('en')})}`, + (value) => value <= max_amount_number) .test("positive", `${t("ConfirmDialog.approved_amount_positive")}`, (value) => value >= 0) .required(t("ConfirmDialog.approved_amount_error")), confirm_img: Yup.mixed() diff --git a/src/components/dashboard/passenger-boss/Form/ConfirmForm/index.jsx b/src/components/dashboard/passenger-boss/Form/ConfirmForm/index.jsx index 30f15dd..004d119 100644 --- a/src/components/dashboard/passenger-boss/Form/ConfirmForm/index.jsx +++ b/src/components/dashboard/passenger-boss/Form/ConfirmForm/index.jsx @@ -3,7 +3,8 @@ import {useTranslations} from "next-intl"; import {useState} from "react"; import ConfirmContent from "./ConfirmContent"; import CallMadeIcon from '@mui/icons-material/CallMade'; -const Confirm = ({rowId, mutate}) => { + +const Confirm = ({rowId, mutate, vehicle_type}) => { const t = useTranslations(); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); return ( @@ -21,7 +22,8 @@ const Confirm = ({rowId, mutate}) => { {t("PassengerBoss.confirm")} - + ) diff --git a/src/components/dashboard/passenger-boss/TableRowActions.jsx b/src/components/dashboard/passenger-boss/TableRowActions.jsx index d10e248..cef474d 100644 --- a/src/components/dashboard/passenger-boss/TableRowActions.jsx +++ b/src/components/dashboard/passenger-boss/TableRowActions.jsx @@ -8,6 +8,7 @@ const TableRow = ({row, mutate}) => { Date: Tue, 14 Nov 2023 11:29:59 +0330 Subject: [PATCH 6/6] LFFE-19 maximum Rials --- public/locales/fa/app.json | 4 ++-- .../Form/ConfirmForm/ConfirmContent.jsx | 16 ++++++---------- .../Form/ConfirmForm/ConfirmContent.jsx | 16 ++++++---------- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 0481f1a..c905835 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -206,7 +206,7 @@ "upload_file_required": "وارد کردن صورت جلسه کارگروه استانی الزامیست", "upload_file_unit": "فایل بارگذاری شده باید حداکثر 2Mb باشد", "upload_file_format": "فرمت قابل قبول : png,jpg,pdf", - "max_amount": "حداکثر مبلغ تصویب شده {value} میلیون تومان می باشد" + "max_amount": "حداکثر مبلغ تصویب شده {value} میلیون ریال می باشد" }, "RefahiProvinceManager": { "name": "نام", @@ -305,7 +305,7 @@ "upload_file_required": "وارد کردن گزارش کارشناسی الزامیست", "upload_file_unit": "فایل بارگذاری شده باید حداکثر 2Mb باشد", "upload_file_format": "فرمت قابل قبول : png,jpg,pdf", - "max_amount": "حداکثر مبلغ پیشنهادی {value} میلیون تومان می باشد" + "max_amount": "حداکثر مبلغ پیشنهادی {value} میلیون ریال می باشد" }, "UserManagement": { "name": "نام", diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx index 93ee5a2..16b7ca3 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx @@ -9,6 +9,10 @@ import {useState} from "react"; import PriceField from "@/core/components/PriceField"; import * as Yup from "yup"; +const vehicle_amount = { + "اتوبوس": 7000, + "مینی بوس": 2000, +} const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type}) => { const t = useTranslations(); const [selectedImage, setSelectedImage] = useState(""); @@ -17,21 +21,13 @@ const ConfirmContent = ({mutate, setOpenConfirmDialog, rowId, vehicle_type}) => const [showAddIcon, setShowAddIcon] = useState(true); const requestServer = useRequest({auth: true}) const {update_notification} = useNotification() - let max_amount_number - if (vehicle_type === "اتوبوس") { - max_amount_number = 7000 - } else if (vehicle_type === "مینی بوس") { - max_amount_number = 2000 - } else { - max_amount_number = 5000 - } const validationSchema = Yup.object().shape({ proposed_amount: Yup.mixed().test( "is-number", `${t("ConfirmDialog.proposed_amount_number")}`, (value) => !isNaN(value) - ).test("max-amount", `${t("MachinaryOffice.max_amount", {value: parseInt(max_amount_number / 10).toLocaleString('en')})}`, - (value) => value <= max_amount_number) + ).test("max-amount", `${t("MachinaryOffice.max_amount", {value: parseInt(vehicle_amount[vehicle_type]).toLocaleString('en')})}`, + (value) => value <= vehicle_amount[vehicle_type]) .test("positive", `${t("ConfirmDialog.proposed_amount_positive")}`, (value) => value >= 0) .required(t("ConfirmDialog.proposed_amount_error")), confirm_img: Yup.mixed() diff --git a/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx index ade15d7..f0a8c12 100644 --- a/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx @@ -9,6 +9,10 @@ import {useState} from "react"; import PriceField from "@/core/components/PriceField"; import * as Yup from "yup"; +const vehicle_amount = { + "اتوبوس": 7000, + "مینی بوس": 2000, +} const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type}) => { const t = useTranslations(); const [selectedImage, setSelectedImage] = useState(""); @@ -17,22 +21,14 @@ const ConfirmContent = ({rowId, mutate, setOpenConfirmDialog, vehicle_type}) => const [showAddIcon, setShowAddIcon] = useState(true); const requestServer = useRequest({auth: true}) const {update_notification} = useNotification() - let max_amount_number - if (vehicle_type === "اتوبوس") { - max_amount_number = 7000 - } else if (vehicle_type === "مینی بوس") { - max_amount_number = 2000 - } else { - max_amount_number = 5000 - } const validationSchema = Yup.object().shape({ approved_amount: Yup.mixed().test( "is-number", `${t("ConfirmDialog.approved_amount_number")}`, (value) => !isNaN(value) - ).test("max-amount", `${t("PassengerBoss.max_amount", {value: parseInt(max_amount_number / 10).toLocaleString('en')})}`, - (value) => value <= max_amount_number) + ).test("max-amount", `${t("PassengerBoss.max_amount", {value: parseInt(vehicle_amount[vehicle_type]).toLocaleString('en')})}`, + (value) => value <= vehicle_amount[vehicle_type]) .test("positive", `${t("ConfirmDialog.approved_amount_positive")}`, (value) => value >= 0) .required(t("ConfirmDialog.approved_amount_error")), confirm_img: Yup.mixed()