Merge branch 'release/v1.7.4'
This commit is contained in:
@@ -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"
|
||||
@@ -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"];
|
||||
}
|
||||
|
||||
@@ -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 (
|
||||
<>
|
||||
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||
<Controller
|
||||
name="driver_rate"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<TextField
|
||||
value={field.value}
|
||||
variant="outlined"
|
||||
name="driver_rate"
|
||||
type={"tel"}
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
max: 100,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
onChange={(event) => {
|
||||
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 }}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<RadioGroup
|
||||
aria-label="file-options"
|
||||
name="file-options"
|
||||
@@ -45,7 +76,7 @@ const DamageReport = ({ control }) => {
|
||||
</Stack>
|
||||
</RadioGroup>
|
||||
{selectedOption === "police_file_checkbox" && <PoliceFileReport control={control} />}
|
||||
</>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default DamageReport;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"} ریال
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={12} sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Chip
|
||||
icon={<Person />}
|
||||
label={
|
||||
<Typography variant="body2" sx={{ fontWeight: 600, color: "grey.700" }}>
|
||||
سهم راننده از خسارت
|
||||
</Typography>
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
<Divider sx={{ flex: 1, mx: 2 }} />
|
||||
<Typography variant="body2" sx={{ fontWeight: 600, color: "grey.800" }}>
|
||||
{(row.original?.driver_share_amount / 1).toLocaleString() || "0"} ریال
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={12} sx={{ display: "flex" }}>
|
||||
<Divider sx={{ flex: 1 }} />
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={12} sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Chip
|
||||
@@ -142,7 +162,7 @@ const CreateFactorContent = ({ row, mutate, rowId, setOpenCreateFactorDialog })
|
||||
<Divider sx={{ flex: 1, mx: 2 }} />
|
||||
<Typography variant="h5" sx={{ fontWeight: 600, color: "primary.main" }}>
|
||||
{(
|
||||
row.original?.sum -
|
||||
row.original?.driver_share_amount -
|
||||
(row.original?.deposit_insurance_amount + row.original?.deposit_daghi_amount)
|
||||
).toLocaleString() || "0"}{" "}
|
||||
ریال
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -421,6 +421,30 @@ const OperatorList = () => {
|
||||
</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
header: "سهم راننده (درصد)",
|
||||
id: "driver_rate",
|
||||
enableColumnFilter: false,
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => (
|
||||
<Typography variant={"body2"} sx={{ margin: 1 }} component="span">
|
||||
{(row.original.driver_rate / 1).toLocaleString()}
|
||||
</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
header: "سهم راننده (ریال)",
|
||||
id: "driver_share_amount",
|
||||
enableColumnFilter: false,
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => (
|
||||
<Typography variant={"body2"} sx={{ margin: 1 }} component="span">
|
||||
{(row.original.driver_share_amount / 1).toLocaleString()}
|
||||
</Typography>
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user