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
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..a67cac4 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..6537566 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);
@@ -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..629eaf5 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,25 @@ 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..2d34b82 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);
diff --git a/src/components/dashboard/damages/operator/Form/RegisterInsurance/RegisterInsuranceContent.jsx b/src/components/dashboard/damages/operator/Form/RegisterInsurance/RegisterInsuranceContent.jsx
index 9470c5e..cefad80 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) => {
diff --git a/src/components/dashboard/damages/operator/OperatorList.jsx b/src/components/dashboard/damages/operator/OperatorList.jsx
index 308ac7c..50dd984 100644
--- a/src/components/dashboard/damages/operator/OperatorList.jsx
+++ b/src/components/dashboard/damages/operator/OperatorList.jsx
@@ -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()}
+
+ ),
+ },
],
},
{