From 19dd89839b4f07af0e19c4d428489e8aa2f470cc Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Sun, 7 Sep 2025 11:15:26 +0330 Subject: [PATCH 1/3] add driver rate --- .../create/Forms/CreateFormContent.jsx | 8 +++- .../Actions/create/Forms/DamageReport.jsx | 39 +++++++++++++++++-- .../operator/Actions/create/Forms/index.jsx | 4 +- .../Form/CreateFactor/CreateFactorContent.jsx | 20 +++++++++- .../operator/Form/EditForm/EditController.jsx | 4 +- .../RegisterInsuranceContent.jsx | 16 ++++---- .../damages/operator/OperatorList.jsx | 28 ++++++++++++- 7 files changed, 101 insertions(+), 18 deletions(-) diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx index b41c6ab..e8991f4 100644 --- a/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx @@ -32,6 +32,11 @@ const validationSchema = object({ province_id: number().required("لطفا استان را وارد کنید!!!"), city_id: number().required("لطفا شهرستان را وارد کنید!!!"), axis_name: string().required("لطفا نام محور را وارد کنید!!!"), + driver_rate: number() + .typeError("سهم راننده باید یک عدد باشد") + .required("لطفا سهم راننده را وارد کنید!!!") + .min(0, "سهم راننده نمی‌تواند کمتر از ۰ باشد") + .max(100, "سهم راننده نمی‌تواند بیشتر از ۱۰۰ باشد"), driver_name: string().when("isForeign", { is: "0", then: (schema) => schema.required("لطفا نام و نام خانوادگی را وارد کنید!!!"), @@ -111,6 +116,7 @@ const CreateFormContent = ({ setOpen, SubmitDamage, defaultData }) => { plate_part2: defaultData.plate_part2, plate_part3: defaultData.plate_part3, plate_part4: defaultData.plate_part4, + driver_rate: defaultData.driver_rate, radio_button: defaultData.radio_button, damage_picture1: defaultData.damage_picture1, damage_picture2: defaultData.damage_picture2, @@ -169,7 +175,7 @@ const CreateFormContent = ({ setOpen, SubmitDamage, defaultData }) => { "damage_picture2", ]; } else if (tabState === 1) { - fieldsToValidate = ["report_base", "police_file", "police_file_date", "police_serial"]; + fieldsToValidate = ["report_base", "police_file", "police_file_date", "police_serial", 'driver_rate']; } else if (tabState === 2) { fieldsToValidate = ["items_damage"]; } diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/DamageReport.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/DamageReport.jsx index 857a6f6..b952add 100644 --- a/src/components/dashboard/damages/operator/Actions/create/Forms/DamageReport.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/DamageReport.jsx @@ -1,4 +1,4 @@ -import { FormControlLabel, RadioGroup, Stack } from "@mui/material"; +import { FormControlLabel, RadioGroup, Stack, TextField } from "@mui/material"; import { Controller, useWatch } from "react-hook-form"; import { useState } from "react"; import PoliceFileReport from "./PoliceFileReport"; @@ -7,14 +7,45 @@ import Radio from "@mui/material/Radio"; const DamageReport = ({ control }) => { const watchedStatus = useWatch({ control, name: "radio_button" }); const [selectedOption, setSelectedOption] = useState(watchedStatus || null); - // const [selectedOption, setSelectedOption] = useState("report_base"); const handleOptionChange = (e) => { setSelectedOption(e.target.value); }; return ( - <> + + ( + { + const inputValue = event.target.value; + if (isNaN(Number(inputValue))) { + return; + } + field.onChange(inputValue); + }} + label="سهم راننده از خسارت (درصد)" + placeholder={"سهم راننده از خسارت را وارد کنید"} + sx={{ width: 300, my: 2 }} + size="small" + error={error} + helperText={error?.message} + InputLabelProps={{ shrink: true }} + /> + )} + /> { {selectedOption === "police_file_checkbox" && } - + ); }; export default DamageReport; diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx index eea9507..bd5ceb3 100644 --- a/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx @@ -29,6 +29,7 @@ const OperatorCreateForm = ({ open, setOpen, mutate }) => { formData.append("driver_national_code", result.national_code); formData.append("plaque", PlateNumber); } + formData.append("driver_rate", result.driver_rate); formData.append("damage_picture1", result.damage_picture1); formData.append("damage_picture2", result.damage_picture2); formData.append("lat", result.start_point.lat); @@ -54,7 +55,7 @@ const OperatorCreateForm = ({ open, setOpen, mutate }) => { mutate(); setOpen(false); }) - .catch(() => {}); + .catch(() => { }); }; const defaultData = { isForeign: "0", @@ -72,6 +73,7 @@ const OperatorCreateForm = ({ open, setOpen, mutate }) => { plate_part2: "الف", plate_part3: "", plate_part4: "", + driver_rate: "", radio_button: "report_base", damage_picture1: null, damage_picture2: null, diff --git a/src/components/dashboard/damages/operator/Form/CreateFactor/CreateFactorContent.jsx b/src/components/dashboard/damages/operator/Form/CreateFactor/CreateFactorContent.jsx index fe8380b..88ec990 100644 --- a/src/components/dashboard/damages/operator/Form/CreateFactor/CreateFactorContent.jsx +++ b/src/components/dashboard/damages/operator/Form/CreateFactor/CreateFactorContent.jsx @@ -1,5 +1,6 @@ import { CHECK_PAYMENT_STATUS, CREATE_FACTOR_DAMAGE, SEND_SMS_AGAIN } from "@/core/utils/routes"; import useRequest from "@/lib/hooks/useRequest"; +import { Person } from "@mui/icons-material"; import PaymentIcon from "@mui/icons-material/Payment"; import ReceiptLongIcon from "@mui/icons-material/ReceiptLong"; import RequestQuoteIcon from "@mui/icons-material/RequestQuote"; @@ -96,6 +97,23 @@ const CreateFactorContent = ({ row, mutate, rowId, setOpenCreateFactorDialog }) {(row.original?.sum / 1).toLocaleString() || "0"} ریال + + + } + label={ + + سهم راننده از خسارت + + } + /> + + + + {(row.original?.driver_share_amount / 1).toLocaleString() || "0"} ریال + + + {( - row.original?.sum - + row.original?.driver_share_amount - (row.original?.deposit_insurance_amount + row.original?.deposit_daghi_amount) ).toLocaleString() || "0"}{" "} ریال diff --git a/src/components/dashboard/damages/operator/Form/EditForm/EditController.jsx b/src/components/dashboard/damages/operator/Form/EditForm/EditController.jsx index 1bbfb03..8d94853 100644 --- a/src/components/dashboard/damages/operator/Form/EditForm/EditController.jsx +++ b/src/components/dashboard/damages/operator/Form/EditForm/EditController.jsx @@ -49,6 +49,7 @@ const EditController = ({ rowId, mutate, setOpenEditDialog }) => { plate_part2: plaqueNumber[1] || "", plate_part3: plaqueNumber[2] || "", plate_part4: plaqueNumber[3] || "", + driver_rate: damageItemDetails?.driver_rate, radio_button: damageItemDetails?.report_base === 1 ? "report_base" : "police_file_checkbox", report_base: damageItemDetails?.report_base, province_id: damageItemDetails?.province_id || null, @@ -70,6 +71,7 @@ const EditController = ({ rowId, mutate, setOpenEditDialog }) => { formData.append("city_id", result.city_id); formData.append("axis_name", result.axis_name); formData.append("is_foreign", result.isForeign); + formData.append("driver_rate", result.driver_rate); if (result.isForeign == "0") { formData.append("driver_name", result.driver_name); formData.append("driver_phone_number", result.phone_number); @@ -103,7 +105,7 @@ const EditController = ({ rowId, mutate, setOpenEditDialog }) => { mutate(); setOpenEditDialog(false); }) - .catch(() => {}); + .catch(() => { }); }; return ( <> diff --git a/src/components/dashboard/damages/operator/Form/RegisterInsurance/RegisterInsuranceContent.jsx b/src/components/dashboard/damages/operator/Form/RegisterInsurance/RegisterInsuranceContent.jsx index 9470c5e..d51f095 100644 --- a/src/components/dashboard/damages/operator/Form/RegisterInsurance/RegisterInsuranceContent.jsx +++ b/src/components/dashboard/damages/operator/Form/RegisterInsurance/RegisterInsuranceContent.jsx @@ -41,10 +41,10 @@ const validationSchema = object({ then: (schema) => schema.required("مبلغ داغی الزامی است."), otherwise: (schema) => schema.notRequired(), }) - .test("max-percentage", "مبلغ داغی نباید بیشتر از ۳۰ درصد مبلغ کل خسارت باشد.", function (value) { - const sum = this.options.context.sum || 0; - if (!value || isNaN(value) || !sum) return true; - return parseFloat(value) <= sum * 0.3; + .test("max-percentage", "مبلغ داغی نباید بیشتر از ۳۰ درصد مبلغ کل سهم راننده از خسارت باشد.", function (value) { + const driver_share_amount = this.options.context.driver_share_amount || 0; + if (!value || isNaN(value) || !driver_share_amount) return true; + return parseFloat(value) <= driver_share_amount * 0.3; }), deposit_daghi_image: mixed().when("deposit_daghi_status", { is: "has_daghi", @@ -52,10 +52,10 @@ const validationSchema = object({ otherwise: (schema) => schema.notRequired(), }), }).test("total-amount-limit", "مجموع مبلغ بیمه و داغی نباید از کل مبلغ خسارت بیشتر باشد.", function (values) { - const sum = this.options.context.sum || 0; + const driver_share_amount = this.options.context.driver_share_amount || 0; const depositInsuranceAmount = parseFloat(values.deposit_insurance_amount) || 0; const depositDaghiAmount = parseFloat(values.deposit_daghi_amount) || 0; - return depositInsuranceAmount + depositDaghiAmount <= sum; + return depositInsuranceAmount + depositDaghiAmount <= driver_share_amount; }); const RegisterInsuranceContent = ({ setOpenRegisterInsuranceDialog, row, mutate, rowId }) => { @@ -103,7 +103,7 @@ const RegisterInsuranceContent = ({ setOpenRegisterInsuranceDialog, row, mutate, defaultValues, resolver: yupResolver(validationSchema), mode: "all", - context: { sum: row?.original?.sum }, + context: { driver_share_amount: row?.original?.driver_share_amount }, }); const onSubmitBase = async (data) => { @@ -127,7 +127,7 @@ const RegisterInsuranceContent = ({ setOpenRegisterInsuranceDialog, row, mutate, }); mutate(); setOpenRegisterInsuranceDialog(false); - } catch (error) {} + } catch (error) { } }; return ( diff --git a/src/components/dashboard/damages/operator/OperatorList.jsx b/src/components/dashboard/damages/operator/OperatorList.jsx index 308ac7c..6985b90 100644 --- a/src/components/dashboard/damages/operator/OperatorList.jsx +++ b/src/components/dashboard/damages/operator/OperatorList.jsx @@ -162,8 +162,8 @@ const OperatorList = () => { props.dependencyFieldValue?.value === "" ? "empty" : loadingCityList - ? "loading" - : props.filterParameters.value + ? "loading" + : props.filterParameters.value } columnSelectOption={getColumnSelectOptions} /> @@ -421,6 +421,30 @@ const OperatorList = () => { ), }, + { + header: "سهم راننده (درصد)", + id: "driver_rate", + enableColumnFilter: false, + grow: false, + size: 100, + Cell: ({ row }) => ( + + {(row.original.driver_rate / 1).toLocaleString()} + + ), + }, + { + header: "سهم راننده (ریال)", + id: "driver_share_amount", + enableColumnFilter: false, + grow: false, + size: 100, + Cell: ({ row }) => ( + + {(row.original.driver_share_amount / 1).toLocaleString()} + + ), + }, ], }, { From b07fa07f19e30011281e16eba9c6b8f22437a7bb Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Sun, 7 Sep 2025 11:16:04 +0330 Subject: [PATCH 2/3] formatting --- .../operator/Actions/create/Forms/CreateFormContent.jsx | 2 +- .../dashboard/damages/operator/Actions/create/Forms/index.jsx | 2 +- .../operator/Form/CreateFactor/CreateFactorContent.jsx | 4 +++- .../damages/operator/Form/EditForm/EditController.jsx | 2 +- .../Form/RegisterInsurance/RegisterInsuranceContent.jsx | 2 +- src/components/dashboard/damages/operator/OperatorList.jsx | 4 ++-- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx index e8991f4..a67cac4 100644 --- a/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx @@ -175,7 +175,7 @@ const CreateFormContent = ({ setOpen, SubmitDamage, defaultData }) => { "damage_picture2", ]; } else if (tabState === 1) { - fieldsToValidate = ["report_base", "police_file", "police_file_date", "police_serial", 'driver_rate']; + fieldsToValidate = ["report_base", "police_file", "police_file_date", "police_serial", "driver_rate"]; } else if (tabState === 2) { fieldsToValidate = ["items_damage"]; } diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx index bd5ceb3..6537566 100644 --- a/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx @@ -55,7 +55,7 @@ const OperatorCreateForm = ({ open, setOpen, mutate }) => { mutate(); setOpen(false); }) - .catch(() => { }); + .catch(() => {}); }; const defaultData = { isForeign: "0", diff --git a/src/components/dashboard/damages/operator/Form/CreateFactor/CreateFactorContent.jsx b/src/components/dashboard/damages/operator/Form/CreateFactor/CreateFactorContent.jsx index 88ec990..629eaf5 100644 --- a/src/components/dashboard/damages/operator/Form/CreateFactor/CreateFactorContent.jsx +++ b/src/components/dashboard/damages/operator/Form/CreateFactor/CreateFactorContent.jsx @@ -113,7 +113,9 @@ const CreateFactorContent = ({ row, mutate, rowId, setOpenCreateFactorDialog }) {(row.original?.driver_share_amount / 1).toLocaleString() || "0"} ریال - + + + { mutate(); setOpenEditDialog(false); }) - .catch(() => { }); + .catch(() => {}); }; return ( <> diff --git a/src/components/dashboard/damages/operator/Form/RegisterInsurance/RegisterInsuranceContent.jsx b/src/components/dashboard/damages/operator/Form/RegisterInsurance/RegisterInsuranceContent.jsx index d51f095..cefad80 100644 --- a/src/components/dashboard/damages/operator/Form/RegisterInsurance/RegisterInsuranceContent.jsx +++ b/src/components/dashboard/damages/operator/Form/RegisterInsurance/RegisterInsuranceContent.jsx @@ -127,7 +127,7 @@ const RegisterInsuranceContent = ({ setOpenRegisterInsuranceDialog, row, mutate, }); mutate(); setOpenRegisterInsuranceDialog(false); - } catch (error) { } + } catch (error) {} }; return ( diff --git a/src/components/dashboard/damages/operator/OperatorList.jsx b/src/components/dashboard/damages/operator/OperatorList.jsx index 6985b90..50dd984 100644 --- a/src/components/dashboard/damages/operator/OperatorList.jsx +++ b/src/components/dashboard/damages/operator/OperatorList.jsx @@ -162,8 +162,8 @@ const OperatorList = () => { props.dependencyFieldValue?.value === "" ? "empty" : loadingCityList - ? "loading" - : props.filterParameters.value + ? "loading" + : props.filterParameters.value } columnSelectOption={getColumnSelectOptions} /> From d8c8e2b71a018a060d58c92463ffb57848eb0a60 Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Sun, 7 Sep 2025 11:16:59 +0330 Subject: [PATCH 3/3] change version to 1.7.4 --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 1328a44..7c7adbf 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ HOST="rms.witel.ir" -NEXT_PUBLIC_VERSION="1.7.3" +NEXT_PUBLIC_VERSION="1.7.4" NEXT_PUBLIC_API_URL="https://rms.witel.ir" NEXT_PUBLIC_MAPTILE_ENDPOINT="https://rmsmap.rmto.ir/141map" \ No newline at end of file