Merge branch 'feature/insurance_registration' into 'develop'
Feature/insurance registration See merge request witel-front-end/rms!71
This commit is contained in:
@@ -3,9 +3,7 @@ import WithPermission from "@/core/middlewares/withPermission";
|
||||
|
||||
const Page = () => {
|
||||
return (
|
||||
<WithPermission
|
||||
permission_name={["manage-damage"]}
|
||||
>
|
||||
<WithPermission permission_name={["manage-damage"]}>
|
||||
<DamagesPage />
|
||||
</WithPermission>
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
import ActivityCodeLog from "@/core/components/ActivityCodeLog";
|
||||
import OperatorPage from "@/components/dashboard/technicalBuildingDamage/operator";
|
||||
import OperatorPage from "@/components/dashboard/damages/operator";
|
||||
const Page = () => {
|
||||
return (
|
||||
<WithPermission permission_name={["all"]}>
|
||||
@@ -4,14 +4,14 @@ import { Switch } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
|
||||
const Activity = ({ rowId, mutate, status }) => {
|
||||
const [disabled, setDisabled] = useState(false)
|
||||
const [disabled, setDisabled] = useState(false);
|
||||
const [checked, setChecked] = useState(status == 1);
|
||||
const requestServer = useRequest();
|
||||
|
||||
const handleSwitch = (event) => {
|
||||
const newChecked = event.target.checked;
|
||||
setChecked(newChecked);
|
||||
setDisabled(true)
|
||||
setDisabled(true);
|
||||
|
||||
requestServer(`${ATIVITY_RECEIPT_DAMAGE_ITEMS}/${rowId}`, "post")
|
||||
.then(() => {
|
||||
@@ -21,8 +21,8 @@ const Activity = ({ rowId, mutate, status }) => {
|
||||
setChecked(!newChecked);
|
||||
})
|
||||
.finally(() => {
|
||||
setDisabled(false)
|
||||
})
|
||||
setDisabled(false);
|
||||
});
|
||||
};
|
||||
|
||||
return <Switch size="small" disabled={disabled} checked={checked} onChange={handleSwitch} />;
|
||||
|
||||
@@ -4,7 +4,7 @@ import Edit from "./Edit";
|
||||
|
||||
const RowActions = ({ row, mutate }) => {
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1, alignItems: 'center' }}>
|
||||
<Box sx={{ display: "flex", gap: 1, alignItems: "center" }}>
|
||||
<Edit row={row} mutate={mutate} rowId={row.getValue("id")} />
|
||||
<Activity mutate={mutate} rowId={row.getValue("id")} status={row.original.status} />
|
||||
</Box>
|
||||
|
||||
@@ -2,8 +2,7 @@ import React, { useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { array, mixed, number, object, string } from "yup";
|
||||
import { useTheme } from "@emotion/react";
|
||||
import { Box, Button, DialogActions, DialogContent, Tab, Tabs, useMediaQuery } from "@mui/material";
|
||||
import { Box, Button, DialogActions, DialogContent, Tab, Tabs } from "@mui/material";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import FileCopyIcon from "@mui/icons-material/FileCopy";
|
||||
import InfoIcon from "@mui/icons-material/Info";
|
||||
@@ -44,7 +43,7 @@ const validationSchema = object({
|
||||
.required("لطفا کد ملی را وارد کنید!!!"),
|
||||
start_point: mixed()
|
||||
.test("start-point-required", "لطفاً نقطه تصادف را مشخص کنید!", function (value) {
|
||||
return !!value; // چک میکند که مقدار موجود است
|
||||
return !!value;
|
||||
})
|
||||
.required("لطفاً نقطه تصادف را مشخص کنید!"),
|
||||
plate_part1: mixed()
|
||||
@@ -59,50 +58,50 @@ const validationSchema = object({
|
||||
.required("plate_part4الزامیست"),
|
||||
damage_picture1: mixed().nullable().required("لطفا عکس تصادف را بارگذاری کنید!"),
|
||||
damage_picture2: mixed().nullable().required("لطفا عکس تصادف را بارگذاری کنید!"),
|
||||
police_serial: string().when("police_file_checkbox", {
|
||||
police_serial: string().when("radio_button", {
|
||||
is: "police_file_checkbox", // زمانی که گزینه "police_file_checkbox" انتخاب شده باشد
|
||||
then: (schema) => schema.required("شماره کروکی یا نامه پلیس راه الزامی است"),
|
||||
}),
|
||||
police_file_date: string().when("police_file_checkbox", {
|
||||
police_file_date: string().when("radio_button", {
|
||||
is: "police_file_checkbox", // زمانی که گزینه "police_file_checkbox" انتخاب شده باشد
|
||||
then: (schema) => schema.required("تاریخ کروکی یا نامه پلیس راه الزامی است"),
|
||||
}),
|
||||
police_file: string().when("police_file_checkbox", {
|
||||
police_file: mixed().when("radio_button", {
|
||||
is: "police_file_checkbox", // زمانی که گزینه "police_file_checkbox" انتخاب شده باشد
|
||||
then: (schema) => schema.required("تصویر کروکی یا نامه پلیس راه الزامی است"),
|
||||
then: (schema) => schema.nullable().required("تصویر کروکی یا نامه پلیس راه الزامی است"),
|
||||
otherwise: (schema) => schema.notRequired(),
|
||||
}),
|
||||
items_damage: array().min(1, "حداقل یک ایتم خسارت ضروریست!!!"),
|
||||
items_damage: array().min(1, "حداقل یک آیتم خسارت ضروریست!!!"),
|
||||
});
|
||||
|
||||
const CreateFormContent = ({ setOpen, mutate }) => {
|
||||
const CreateFormContent = ({ setOpen, SubmitDamage, defaultData }) => {
|
||||
const defaultValues = {
|
||||
accident_date: "",
|
||||
accident_time: "",
|
||||
accident_type: "",
|
||||
province_id: null,
|
||||
city_id: null,
|
||||
axis_name: "",
|
||||
driver_name: "",
|
||||
phone_number: "",
|
||||
national_code: "",
|
||||
plate_part1: "",
|
||||
plate_part2: "الف",
|
||||
plate_part3: "",
|
||||
plate_part4: "",
|
||||
damage_picture1: null,
|
||||
damage_picture2: null,
|
||||
report_base: "",
|
||||
police_file_checkbox: "",
|
||||
police_file: "",
|
||||
police_file_date: "",
|
||||
police_serial: "",
|
||||
start_point: "",
|
||||
items_damage: [],
|
||||
accident_date: defaultData.accident_date,
|
||||
accident_time: defaultData.accident_time,
|
||||
accident_type: defaultData.accident_type,
|
||||
province_id: defaultData.province_id,
|
||||
city_id: defaultData.city_id,
|
||||
axis_name: defaultData.axis_name,
|
||||
driver_name: defaultData.driver_name,
|
||||
phone_number: defaultData.phone_number,
|
||||
national_code: defaultData.national_code,
|
||||
plate_part1: defaultData.plate_part1,
|
||||
plate_part2: defaultData.plate_part2,
|
||||
plate_part3: defaultData.plate_part3,
|
||||
plate_part4: defaultData.plate_part4,
|
||||
radio_button: defaultData.radio_button,
|
||||
damage_picture1: defaultData.damage_picture1,
|
||||
damage_picture2: defaultData.damage_picture2,
|
||||
report_base: defaultData.report_base,
|
||||
police_file_checkbox: defaultData.police_file_checkbox,
|
||||
police_file: defaultData.police_file,
|
||||
police_file_date: defaultData.police_file_date,
|
||||
police_serial: defaultData.police_serial,
|
||||
start_point: defaultData.start_point,
|
||||
items_damage: defaultData.items_damage,
|
||||
};
|
||||
|
||||
const [tabState, setTabState] = useState(1);
|
||||
const theme = useTheme();
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
|
||||
const [tabState, setTabState] = useState(0);
|
||||
const handleClose = () => setOpen(false);
|
||||
const handleChangeTab = (event, newValue) => setTabState(newValue);
|
||||
const handlePrev = () => {
|
||||
@@ -124,7 +123,7 @@ const CreateFormContent = ({ setOpen, mutate }) => {
|
||||
mode: "all",
|
||||
});
|
||||
const onSubmitBase = async (data) => {
|
||||
console.log(data);
|
||||
await SubmitDamage(data);
|
||||
};
|
||||
const handleNext = async () => {
|
||||
let fieldsToValidate = [];
|
||||
@@ -163,7 +162,7 @@ const CreateFormContent = ({ setOpen, mutate }) => {
|
||||
allowScrollButtonsMobile
|
||||
value={tabState}
|
||||
onChange={handleChangeTab}
|
||||
variant={`${isMobile ? "scrollable" : "fullWidth"}`}
|
||||
variant="fullWidth"
|
||||
sx={{
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
@@ -174,7 +173,7 @@ const CreateFormContent = ({ setOpen, mutate }) => {
|
||||
>
|
||||
<Tab icon={<InfoIcon />} label="اطلاعات تصادف" />
|
||||
<Tab disabled={tabState === 0} icon={<FileCopyIcon />} label="گزارش میزان خسارت" />
|
||||
<Tab disabled={tabState === 0 || tabState === 1} icon={<MinorCrashIcon />} label="ایتم خسارت" />
|
||||
<Tab disabled={tabState === 0 || tabState === 1} icon={<MinorCrashIcon />} label="آیتم خسارت" />
|
||||
</Tabs>
|
||||
<DialogContent dividers sx={{ overflowY: "auto", maxHeight: "70vh" }}>
|
||||
<Box sx={{ flex: 1 }}>
|
||||
@@ -189,7 +188,13 @@ const CreateFormContent = ({ setOpen, mutate }) => {
|
||||
name={"items_damage"}
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return <DamageItem baseOnChange={field.onChange} />;
|
||||
return (
|
||||
<DamageItem
|
||||
baseDamageItems={defaultData.items_damage}
|
||||
baseControl={control}
|
||||
baseOnChange={field.onChange}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</TabPanel>
|
||||
@@ -198,6 +203,7 @@ const CreateFormContent = ({ setOpen, mutate }) => {
|
||||
<DialogActions sx={{ alignItems: "center", justifyContent: "center" }}>
|
||||
<Button
|
||||
onClick={handlePrev}
|
||||
key={"handlePrev"}
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
size="large"
|
||||
@@ -208,6 +214,7 @@ const CreateFormContent = ({ setOpen, mutate }) => {
|
||||
{tabState !== 2 ? (
|
||||
<Button
|
||||
onClick={handleNext}
|
||||
key={"handleNext"}
|
||||
variant="contained"
|
||||
size="large"
|
||||
endIcon={<KeyboardDoubleArrowLeftIcon />}
|
||||
@@ -218,11 +225,12 @@ const CreateFormContent = ({ setOpen, mutate }) => {
|
||||
<Button
|
||||
variant="contained"
|
||||
size="large"
|
||||
key={"Submit"}
|
||||
disabled={!isValid || isSubmitting}
|
||||
type={"submit"}
|
||||
endIcon={!isValid ? null : <BeenhereIcon />}
|
||||
>
|
||||
{!isValid ? "حداقل یک ایتم خسارت ضروریست" : isSubmitting ? "در حال ثبت خسارت" : "ثبت خسارت"}
|
||||
{!isValid ? "حداقل یک آیتم خسارت ضروریست" : isSubmitting ? "در حال ثبت خسارت" : "ثبت خسارت"}
|
||||
</Button>
|
||||
)}
|
||||
</DialogActions>
|
||||
@@ -4,27 +4,27 @@ import NumberField from "@/core/components/NumberField";
|
||||
import { useEffect } from "react";
|
||||
|
||||
const DamageAmount = ({ control, damageItemList, setValue }) => {
|
||||
const itemDamage = useWatch({ control, name: "items_damge_id" });
|
||||
const itemValue = useWatch({ control, name: "items_damge_value" });
|
||||
const itemDamage = useWatch({ control, name: "id" });
|
||||
const itemValue = useWatch({ control, name: "value" });
|
||||
const itemDamageId = damageItemList.find((damageItem) => damageItem.id === itemDamage);
|
||||
const isDisabled = itemDamageId?.base_price ? itemDamageId?.base_price !== 0 : false;
|
||||
const calculatedValue = itemValue * (itemDamageId?.base_price ? itemDamageId?.base_price : 0);
|
||||
useEffect(() => {
|
||||
if (isDisabled) {
|
||||
setValue("items_damge_amount", calculatedValue);
|
||||
setValue("amount", calculatedValue);
|
||||
}
|
||||
}, [itemValue, itemDamageId, isDisabled, setValue]);
|
||||
return (
|
||||
<Grid item xs={12} sm={6}>
|
||||
<Controller
|
||||
name="items_damge_amount"
|
||||
name="amount"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<NumberField
|
||||
value={isDisabled ? calculatedValue : field.value || ""}
|
||||
variant="outlined"
|
||||
name="items_damge_amount"
|
||||
name="amount"
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Controller } from "react-hook-form";
|
||||
import { Controller, useWatch } from "react-hook-form";
|
||||
import { Grid, Stack, TextField } from "@mui/material";
|
||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||
import MuiTimePicker from "@/core/components/MuiTimePicker";
|
||||
@@ -7,9 +7,10 @@ import useProvinces from "@/lib/hooks/useProvince";
|
||||
import PlateNumber from "@/core/components/PlateNumber";
|
||||
import ImageUpload from "./ImageUpload";
|
||||
import MapInfoOneMarker from "@/core/components/MapInfoOneMarker";
|
||||
import CityController from "@/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/CityController";
|
||||
import CityController from "@/components/dashboard/damages/operator/Actions/create/Forms/CityController";
|
||||
|
||||
const DamageInfo = ({ control, setValue, errors }) => {
|
||||
const StartPoint = useWatch({ control, name: "start_point" });
|
||||
const { provinces, errorProvinces, loadingProvinces } = useProvinces();
|
||||
|
||||
return (
|
||||
@@ -263,6 +264,7 @@ const DamageInfo = ({ control, setValue, errors }) => {
|
||||
<Stack sx={{ mt: 2 }}>
|
||||
<MapInfoOneMarker
|
||||
setValue={setValue}
|
||||
StartPoint={StartPoint}
|
||||
errors={errors}
|
||||
title={"برای ثبت محل تصادف، لطفاً نقشه را بیشتر زوم کنید."}
|
||||
/>
|
||||
@@ -1,5 +1,17 @@
|
||||
import { Autocomplete, Box, Button, Chip, Divider, Fade, Grid, Stack, TextField, Typography } from "@mui/material";
|
||||
import { Controller, useController, useForm } from "react-hook-form";
|
||||
import {
|
||||
Autocomplete,
|
||||
Box,
|
||||
Button,
|
||||
Chip,
|
||||
Divider,
|
||||
Fade,
|
||||
Grid,
|
||||
Skeleton,
|
||||
Stack,
|
||||
TextField,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { Controller, useForm, useWatch } from "react-hook-form";
|
||||
import LinearProgress from "@mui/material/LinearProgress";
|
||||
import { useEffect, useState } from "react";
|
||||
import DamageItemInfo from "./DamageItemInfo";
|
||||
@@ -9,17 +21,30 @@ import DamagePrice from "./DamagePrice";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
|
||||
const schema = object({
|
||||
items_damge_id: number().required("لطفا نوع خسارت را وارد کنید!!!"),
|
||||
items_damge_value: number().required("لطفا میزان خسارت را وارد کنید!!!"),
|
||||
items_damge_amount: number().required("لطفا هزینه خسارت را وارد کنید!!!"),
|
||||
id: number().required("لطفا نوع خسارت را وارد کنید!!!"),
|
||||
value: number().required("لطفا میزان خسارت را وارد کنید!!!"),
|
||||
amount: number().required("لطفا هزینه خسارت را وارد کنید!!!"),
|
||||
});
|
||||
const defaultValues = {
|
||||
items_damge_id: null,
|
||||
items_damge_value: null,
|
||||
items_damge_amount: null,
|
||||
id: null,
|
||||
value: null,
|
||||
amount: null,
|
||||
};
|
||||
const DamageItem = ({ baseOnChange, getValues }) => {
|
||||
const [selectedDamageItemList, setSelectedDamageItemList] = useState([]);
|
||||
const DamageItem = ({ baseOnChange, baseDamageItems }) => {
|
||||
const flattenBaseDamageItems = (items) => {
|
||||
return items.map((item) => ({
|
||||
id: item.id,
|
||||
title: item.title,
|
||||
unit: item.unit,
|
||||
base_price: item.base_price,
|
||||
status: item.status,
|
||||
until_27_shahrivar: item.until_27_shahrivar,
|
||||
...item.pivot, // اضافه کردن مقادیر موجود در pivot به سطح بالا
|
||||
}));
|
||||
};
|
||||
const [selectedDamageItemList, setSelectedDamageItemList] = useState(
|
||||
baseDamageItems.length !== 0 ? flattenBaseDamageItems(baseDamageItems) : []
|
||||
);
|
||||
const { damageItemList, loadingDamageItemList, errorDamageItemList } = useDamageItemList();
|
||||
const { control, handleSubmit, reset, setValue } = useForm({
|
||||
defaultValues,
|
||||
@@ -27,14 +52,14 @@ const DamageItem = ({ baseOnChange, getValues }) => {
|
||||
mode: "onBlur",
|
||||
});
|
||||
const deleteDamageItem = (id) => {
|
||||
setSelectedDamageItemList((prev) => prev.filter((DamageItem) => DamageItem.items_damge_id !== id));
|
||||
setSelectedDamageItemList((prev) => prev.filter((DamageItem) => DamageItem.id !== id));
|
||||
};
|
||||
useEffect(() => {
|
||||
baseOnChange(selectedDamageItemList);
|
||||
}, [selectedDamageItemList]);
|
||||
const handleCreateDamage = (data) => {
|
||||
setSelectedDamageItemList((prev) => {
|
||||
const isDuplicate = prev.some((item) => item.items_damge_id === data.items_damge_id);
|
||||
const isDuplicate = prev.some((item) => item.id === data.id);
|
||||
if (!isDuplicate) {
|
||||
return [...prev, data];
|
||||
} else {
|
||||
@@ -55,7 +80,7 @@ const DamageItem = ({ baseOnChange, getValues }) => {
|
||||
<>
|
||||
<Stack sx={{ minWidth: "200px" }}>
|
||||
<Controller
|
||||
name="items_damge_id"
|
||||
name="id"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<Autocomplete
|
||||
@@ -97,7 +122,7 @@ const DamageItem = ({ baseOnChange, getValues }) => {
|
||||
)}
|
||||
</Stack>
|
||||
<Divider sx={{ my: 2, width: "100%" }}>
|
||||
<Chip variant="outlined" label="لیست ایتم های خسارت" />
|
||||
<Chip variant="outlined" label="لیست آیتم های خسارت" />
|
||||
</Divider>
|
||||
{selectedDamageItemList.length === 0 && (
|
||||
<Box sx={{ my: 4, width: "100%", textAlign: "center" }}>
|
||||
@@ -118,7 +143,12 @@ const DamageItem = ({ baseOnChange, getValues }) => {
|
||||
overflowY: "auto",
|
||||
}}
|
||||
>
|
||||
{selectedDamageItemList.length !== 0 &&
|
||||
{loadingDamageItemList ? (
|
||||
<Stack sx={{ width: "100%", pl: 2, pt: 2 }}>
|
||||
<Skeleton animation="wave" variant="rounded" height={100} />
|
||||
</Stack>
|
||||
) : (
|
||||
selectedDamageItemList.length !== 0 &&
|
||||
selectedDamageItemList.map((selectedDamageItem, index) => (
|
||||
<Grid key={index} item xs={12}>
|
||||
<DamageItemInfo
|
||||
@@ -127,7 +157,8 @@ const DamageItem = ({ baseOnChange, getValues }) => {
|
||||
deleteDamageItem={deleteDamageItem}
|
||||
/>
|
||||
</Grid>
|
||||
))}
|
||||
))
|
||||
)}
|
||||
</Grid>
|
||||
</Fade>
|
||||
</>
|
||||
@@ -0,0 +1,60 @@
|
||||
import { Box, Card, IconButton, Stack, Typography } from "@mui/material";
|
||||
import DeleteIcon from "@mui/icons-material/Delete";
|
||||
import React from "react";
|
||||
import MinorCrashIcon from "@mui/icons-material/MinorCrash";
|
||||
|
||||
const DamageItemInfo = ({ deleteDamageItem, selectedDamageItem, damageItemList }) => {
|
||||
const itemDamageId = damageItemList.find((item) => item.id == selectedDamageItem.id);
|
||||
return (
|
||||
<Card
|
||||
elevation={0}
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
border: 1,
|
||||
borderColor: "divider",
|
||||
px: 1,
|
||||
py: 1,
|
||||
}}
|
||||
>
|
||||
<Box sx={{ display: "flex" }}>
|
||||
<MinorCrashIcon color="primary" sx={{ width: "50px", height: "50px" }} />
|
||||
<Stack sx={{ ml: 1, justifyContent: "center" }} spacing={0.5}>
|
||||
<Typography variant="body1" sx={{ letterSpacing: "1px", fontWeight: 500 }}>
|
||||
{itemDamageId.title}
|
||||
</Typography>
|
||||
<Stack>
|
||||
<Typography variant="caption">
|
||||
میزان خسارت ({itemDamageId.unit}) :{" "}
|
||||
<Typography
|
||||
component="span"
|
||||
variant="body1"
|
||||
sx={{ fontWeight: "bold", fontSize: "0.9rem" }}
|
||||
>
|
||||
{(selectedDamageItem.value / 1).toLocaleString()}
|
||||
</Typography>
|
||||
</Typography>
|
||||
|
||||
<Typography variant="caption">
|
||||
هزینه خسارت (ریال) :{" "}
|
||||
<Typography
|
||||
component="span"
|
||||
variant="body1"
|
||||
sx={{ fontWeight: "bold", fontSize: "0.9rem" }}
|
||||
>
|
||||
{(selectedDamageItem.amount / 1).toLocaleString()}
|
||||
</Typography>
|
||||
</Typography>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Box>
|
||||
<Box>
|
||||
<IconButton color="error" onClick={() => deleteDamageItem(selectedDamageItem.id)}>
|
||||
<DeleteIcon />
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
export default DamageItemInfo;
|
||||
@@ -3,14 +3,14 @@ import { Grid, TextField } from "@mui/material";
|
||||
import DamageAmount from "./DamageAmount";
|
||||
|
||||
const DamagePrice = ({ damageItemList, control, setValue }) => {
|
||||
const itemDamage = useWatch({ control, name: "items_damge_id" });
|
||||
const itemDamage = useWatch({ control, name: "id" });
|
||||
const itemDamageId = damageItemList.find((damageItem) => damageItem.id === itemDamage);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<Controller
|
||||
name="items_damge_value"
|
||||
name="value"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
@@ -23,7 +23,7 @@ const DamagePrice = ({ damageItemList, control, setValue }) => {
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
name="items_damge_value"
|
||||
name="value"
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
@@ -1,18 +1,16 @@
|
||||
import { FormControlLabel, RadioGroup, Stack } from "@mui/material";
|
||||
import { Controller } from "react-hook-form";
|
||||
import { Controller, useWatch } from "react-hook-form";
|
||||
import { useState } from "react";
|
||||
import PoliceFileReport from "./PoliceFileReport";
|
||||
import Radio from "@mui/material/Radio";
|
||||
|
||||
const DamageReport = ({ control, setValue }) => {
|
||||
const [selectedOption, setSelectedOption] = useState("report_base");
|
||||
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);
|
||||
if (e.target.value === "report_base") {
|
||||
setValue("police_file_checkbox", "");
|
||||
setValue("report_base", "1");
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -27,23 +25,23 @@ const DamageReport = ({ control, setValue }) => {
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Controller
|
||||
name="police_file_checkbox"
|
||||
control={control}
|
||||
render={({ field }) => <Radio {...field} value="police_file_checkbox" />}
|
||||
/>
|
||||
}
|
||||
label="کروکی یا نامه پلیس راه (معرفی فرد به اداره)"
|
||||
/>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Controller
|
||||
name="report_base"
|
||||
name="radio_button"
|
||||
control={control}
|
||||
render={({ field }) => <Radio {...field} value="report_base" />}
|
||||
/>
|
||||
}
|
||||
label="بازدید عوامل و کارشناسان راهداری"
|
||||
/>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Controller
|
||||
name="radio_button"
|
||||
control={control}
|
||||
render={({ field }) => <Radio {...field} value="police_file_checkbox" />}
|
||||
/>
|
||||
}
|
||||
label="کروکی یا نامه پلیس راه (معرفی فرد به اداره)"
|
||||
/>
|
||||
</Stack>
|
||||
</RadioGroup>
|
||||
{selectedOption === "police_file_checkbox" && <PoliceFileReport control={control} />}
|
||||
@@ -0,0 +1,77 @@
|
||||
import { FormControl, FormHelperText } from "@mui/material";
|
||||
import UploadSystem from "@/core/components/UploadSystem";
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
const ImageUpload = ({ name, value, onChange, error, title }) => {
|
||||
const [beforeImg, setBeforeImg] = useState(value ? value : null);
|
||||
const [beforeFileType, setBeforeFileType] = useState(value ? "image/" : null);
|
||||
const [beforeFileName, setBeforeFileName] = useState(null);
|
||||
const [showBeforeImage, setShowBeforeImage] = useState(!value);
|
||||
|
||||
useEffect(() => {
|
||||
if (value) {
|
||||
setShowBeforeImage(false);
|
||||
if (typeof value === "string") {
|
||||
setBeforeImg(value);
|
||||
setBeforeFileType("image/");
|
||||
} else if (value instanceof File) {
|
||||
setBeforeImg(URL.createObjectURL(value));
|
||||
setBeforeFileType(value.type);
|
||||
}
|
||||
}
|
||||
}, [value]);
|
||||
|
||||
const handleFileChange = (event) => {
|
||||
const uploadedFile = event.target?.files?.[0];
|
||||
if (uploadedFile) {
|
||||
const fileType = event.target?.files?.[0].type;
|
||||
const fileName = event.target?.files?.[0].name;
|
||||
setBeforeImg(URL.createObjectURL(uploadedFile));
|
||||
setBeforeFileType(fileType);
|
||||
setBeforeFileName(fileName);
|
||||
onChange(uploadedFile);
|
||||
setShowBeforeImage(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<FormControl
|
||||
error={error}
|
||||
sx={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
<FormHelperText
|
||||
sx={{
|
||||
fontSize: 14,
|
||||
border: 1,
|
||||
borderBottom: 0,
|
||||
borderColor: "divider",
|
||||
px: 2,
|
||||
py: 1,
|
||||
borderRadius: 2,
|
||||
borderBottomRightRadius: 0,
|
||||
borderBottomLeftRadius: 0,
|
||||
}}
|
||||
id={name}
|
||||
>
|
||||
{title}
|
||||
</FormHelperText>
|
||||
<UploadSystem
|
||||
selectedImage={beforeImg}
|
||||
handleUploadChange={handleFileChange}
|
||||
fileType={beforeFileType}
|
||||
fileName={beforeFileName}
|
||||
setSelectedImage={setBeforeImg}
|
||||
imageSize={[250, 150]}
|
||||
setShowAddIcon={setShowBeforeImage}
|
||||
showAddIcon={showBeforeImage}
|
||||
/>
|
||||
<FormHelperText id={name}>{error ? error.message : null}</FormHelperText>
|
||||
</FormControl>
|
||||
);
|
||||
};
|
||||
export default ImageUpload;
|
||||
@@ -49,15 +49,17 @@ const PoliceFileReport = ({ control }) => {
|
||||
<Controller
|
||||
name="police_file"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<ImageUpload
|
||||
name={field.name}
|
||||
value={field.value}
|
||||
error={error}
|
||||
title={"تصویر کروکی یا نامه پلیس راه"}
|
||||
onChange={field.onChange}
|
||||
/>
|
||||
)}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<ImageUpload
|
||||
name={field.name}
|
||||
value={field.value}
|
||||
error={error}
|
||||
title={"تصویر کروکی یا نامه پلیس راه"}
|
||||
onChange={field.onChange}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
);
|
||||
@@ -0,0 +1,86 @@
|
||||
"use client";
|
||||
import { Dialog } from "@mui/material";
|
||||
import CreateFormContent from "./CreateFormContent";
|
||||
import { format } from "date-fns";
|
||||
import { CREATE_DAMAGE } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
|
||||
const OperatorCreateForm = ({ open, setOpen, mutate }) => {
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const SubmitCreateDamage = async (result) => {
|
||||
const PlateNumber = `${result.plate_part1}-${result.plate_part2}-${result.plate_part3}-${result.plate_part4}`;
|
||||
const formData = new FormData();
|
||||
formData.append("accident_date", result.accident_date);
|
||||
formData.append("accident_time", format(new Date(result.accident_time), "HH:mm"));
|
||||
formData.append("accident_type", result.accident_type);
|
||||
formData.append("province_id", result.province_id);
|
||||
formData.append("city_id", result.city_id);
|
||||
formData.append("axis_name", result.axis_name);
|
||||
formData.append("driver_name", result.driver_name);
|
||||
formData.append("driver_phone_number", result.phone_number);
|
||||
formData.append("driver_national_code", result.national_code);
|
||||
formData.append("plaque", PlateNumber);
|
||||
formData.append("damage_picture1", result.damage_picture1);
|
||||
formData.append("damage_picture2", result.damage_picture2);
|
||||
formData.append("lat", result.start_point.lat);
|
||||
formData.append("lng", result.start_point.lng);
|
||||
result.items_damage.map((item, index) => {
|
||||
formData.append(`damage_items[${index}][id]`, item.id);
|
||||
formData.append(`damage_items[${index}][value]`, item.value);
|
||||
formData.append(`damage_items[${index}][amount]`, item.amount);
|
||||
});
|
||||
if (result.radio_button === "report_base") {
|
||||
formData.append("report_base", 1);
|
||||
}
|
||||
if (result.radio_button === "police_file_checkbox") {
|
||||
formData.append("report_base", 0);
|
||||
formData.append("police_file", result.police_file);
|
||||
formData.append("police_file_date", result.police_file_date);
|
||||
formData.append("police_serial", result.police_serial);
|
||||
}
|
||||
await requestServer(`${CREATE_DAMAGE}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then(() => {
|
||||
mutate();
|
||||
setOpen(false);
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
const defaultData = {
|
||||
accident_date: "",
|
||||
accident_time: "",
|
||||
accident_type: "",
|
||||
province_id: null,
|
||||
city_id: null,
|
||||
axis_name: "",
|
||||
driver_name: "",
|
||||
phone_number: "",
|
||||
national_code: "",
|
||||
plate_part1: "",
|
||||
plate_part2: "الف",
|
||||
plate_part3: "",
|
||||
plate_part4: "",
|
||||
radio_button: "report_base",
|
||||
damage_picture1: null,
|
||||
damage_picture2: null,
|
||||
report_base: "",
|
||||
police_file_checkbox: "",
|
||||
police_file: null,
|
||||
police_file_date: "",
|
||||
police_serial: "",
|
||||
start_point: "",
|
||||
items_damage: [],
|
||||
};
|
||||
return (
|
||||
<Dialog open={open} fullWidth maxWidth="md">
|
||||
<CreateFormContent
|
||||
defaultData={defaultData}
|
||||
SubmitDamage={SubmitCreateDamage}
|
||||
setOpen={setOpen}
|
||||
mutate={mutate}
|
||||
/>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
export default OperatorCreateForm;
|
||||
@@ -0,0 +1,75 @@
|
||||
"use client";
|
||||
import { Button, CircularProgress, IconButton, useMediaQuery } from "@mui/material";
|
||||
import { useMemo, useState } from "react";
|
||||
import moment from "jalali-moment";
|
||||
import FileSaver from "file-saver";
|
||||
import DescriptionIcon from "@mui/icons-material/Description";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { useTheme } from "@emotion/react";
|
||||
import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure";
|
||||
import isArrayEmpty from "@/core/utils/isArrayEmpty";
|
||||
import { EXPORT_DAMAGES_OPERATOR_LIST } from "@/core/utils/routes";
|
||||
|
||||
const PrintExcel = ({ table, filterData }) => {
|
||||
const theme = useTheme();
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
|
||||
const [loading, setLoading] = useState(false);
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const activeFilters = Object.entries(filterData).reduce((acc, [key, filter]) => {
|
||||
if (filter.value && (!Array.isArray(filter.value) || filter.value.some((item) => item.trim() !== ""))) {
|
||||
acc.push({ id: key, value: filter.value });
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
const filterParams = useMemo(() => {
|
||||
const params = new URLSearchParams();
|
||||
if (activeFilters.length > 0) {
|
||||
activeFilters.map((filter, index) => {
|
||||
const filteredFilterData = DataTableFilterDataStructure(filterData, isArrayEmpty);
|
||||
params.set("filters", JSON.stringify(filteredFilterData.length === 0 ? [] : filteredFilterData));
|
||||
});
|
||||
} else {
|
||||
params.set("filters", JSON.stringify([]));
|
||||
}
|
||||
return params;
|
||||
}, [activeFilters]);
|
||||
|
||||
const clickHandler = () => {
|
||||
setLoading(true);
|
||||
requestServer(`${EXPORT_DAMAGES_OPERATOR_LIST}?${filterParams}`, "get", {
|
||||
requestOptions: { responseType: "blob" },
|
||||
})
|
||||
.then((response) => {
|
||||
const filename = `خروجی کارتابل عملیات فعالیت روزانه تاریخ_${moment().format("jYYYY_jMM_jDD")}.xlsx`;
|
||||
FileSaver.saveAs(response.data, filename);
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{isMobile ? (
|
||||
<IconButton aria-label="خروجی اکسل" color="primary" onClick={clickHandler}>
|
||||
<DescriptionIcon sx={{ fontSize: "25px" }} />
|
||||
</IconButton>
|
||||
) : (
|
||||
<Button
|
||||
color="primary"
|
||||
variant="contained"
|
||||
size="small"
|
||||
disabled={loading}
|
||||
sx={{ textTransform: "unset", alignSelf: "center" }}
|
||||
startIcon={loading ? <CircularProgress size={18} color="inherit" /> : <DescriptionIcon />}
|
||||
onClick={clickHandler}
|
||||
>
|
||||
خروجی اکسل
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default PrintExcel;
|
||||
@@ -0,0 +1,208 @@
|
||||
import { Box, Button, Chip, DialogActions, DialogContent, Divider, Grid, Typography } from "@mui/material";
|
||||
import PaymentIcon from "@mui/icons-material/Payment";
|
||||
import WebAssetIcon from "@mui/icons-material/WebAsset";
|
||||
import RequestQuoteIcon from "@mui/icons-material/RequestQuote";
|
||||
import ReceiptLongIcon from "@mui/icons-material/ReceiptLong";
|
||||
import { useReducer, useState } from "react";
|
||||
import { CHECK_PAYMENT_STATUS, CREATE_FACTOR_DAMAGE, SEND_SMS_AGAIN } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
|
||||
const initialState = {
|
||||
submittingCreateFactor: false,
|
||||
submittingCheckFactor: false,
|
||||
submittingSms: false,
|
||||
};
|
||||
|
||||
const reducer = (state, action) => {
|
||||
switch (action.type) {
|
||||
case "SET_SUBMITTING_CREATE_FACTOR":
|
||||
return { ...state, submittingCreateFactor: action.payload };
|
||||
case "SET_SUBMITTING_CHECK_FACTOR":
|
||||
return { ...state, submittingCheckFactor: action.payload };
|
||||
case "SET_SUBMITTING_SMS":
|
||||
return { ...state, submittingSms: action.payload };
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
const CreateFactorContent = ({ row, mutate, rowId, setOpenCreateFactorDialog }) => {
|
||||
const [state, dispatch] = useReducer(reducer, initialState);
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const [factorCreated, setFactorCreated] = useState(row.original?.status === 3);
|
||||
const handleCreateFactor = () => {
|
||||
dispatch({ type: "SET_SUBMITTING_CREATE_FACTOR", payload: true });
|
||||
requestServer(`${CREATE_FACTOR_DAMAGE}/${rowId}`, "get")
|
||||
.then(() => {
|
||||
mutate();
|
||||
dispatch({ type: "SET_SUBMITTING_CREATE_FACTOR", payload: false });
|
||||
setFactorCreated(true);
|
||||
})
|
||||
.catch(() => {
|
||||
dispatch({ type: "SET_SUBMITTING_CREATE_FACTOR", payload: false });
|
||||
});
|
||||
};
|
||||
const handleCheckPaymentStatus = () => {
|
||||
dispatch({ type: "SET_SUBMITTING_CHECK_FACTOR", payload: true });
|
||||
requestServer(`${CHECK_PAYMENT_STATUS}/${rowId}`, "get")
|
||||
.then(() => {
|
||||
setOpenCreateFactorDialog(false);
|
||||
mutate();
|
||||
dispatch({ type: "SET_SUBMITTING_CHECK_FACTOR", payload: false });
|
||||
})
|
||||
.catch(() => {
|
||||
dispatch({ type: "SET_SUBMITTING_CHECK_FACTOR", payload: false });
|
||||
});
|
||||
};
|
||||
const handleSendSMS = () => {
|
||||
dispatch({ type: "SET_SUBMITTING_SMS", payload: true });
|
||||
requestServer(`${SEND_SMS_AGAIN}/${rowId}`, "get")
|
||||
.then(() => {
|
||||
dispatch({ type: "SET_SUBMITTING_SMS", payload: false });
|
||||
})
|
||||
.catch(() => {
|
||||
dispatch({ type: "SET_SUBMITTING_SMS", payload: false });
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Grid container spacing={3} sx={{ alignItems: "center", justifyContent: "space-around" }}>
|
||||
<Grid item xs={12} sm={12} sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Chip
|
||||
icon={<PaymentIcon />}
|
||||
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?.deposit_insurance_amount / 1).toLocaleString() || "0"} ریال
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={12} sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Chip
|
||||
icon={<WebAssetIcon />}
|
||||
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?.deposit_daghi_amount / 1).toLocaleString() || "0"} ریال
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={12} sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Chip
|
||||
icon={<RequestQuoteIcon />}
|
||||
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?.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={<ReceiptLongIcon />}
|
||||
label={
|
||||
<Typography variant="h6" sx={{ fontWeight: 600, color: "primary.main" }}>
|
||||
مبلغ قابل پرداخت
|
||||
</Typography>
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
<Divider sx={{ flex: 1, mx: 2 }} />
|
||||
<Typography variant="h5" sx={{ fontWeight: 600, color: "primary.main" }}>
|
||||
{(row.original?.sum / 1).toLocaleString() || "0"} ریال
|
||||
</Typography>
|
||||
</Grid>
|
||||
{!factorCreated && (
|
||||
<Grid item xs={12}>
|
||||
<Box sx={{ display: "flex", alignItems: "center", mt: 2 }}>
|
||||
<Typography sx={{ color: "red", mr: 1 }}>*</Typography>
|
||||
<Typography variant="body2" sx={{ color: "grey.700" }}>
|
||||
پس از ایجاد فاکتور امکان تغییر در اطلاعات کاربر و مبالغ وجود نخواهد داشت.
|
||||
</Typography>
|
||||
</Box>
|
||||
<Box sx={{ display: "flex", alignItems: "center", mt: 1 }}>
|
||||
<Typography sx={{ color: "red", mr: 1 }}>*</Typography>
|
||||
<Typography variant="body2" sx={{ color: "grey.700" }}>
|
||||
لینک پرداخت فاکتور به شماره {row.original?.driver_phone_number} ارسال خواهد شد.
|
||||
</Typography>
|
||||
</Box>
|
||||
</Grid>
|
||||
)}
|
||||
</Grid>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
{factorCreated ? (
|
||||
<>
|
||||
<Button
|
||||
key={"close"}
|
||||
onClick={() => setOpenCreateFactorDialog(false)}
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
>
|
||||
بستن
|
||||
</Button>
|
||||
<Button
|
||||
key={"submittingSms"}
|
||||
onClick={handleSendSMS}
|
||||
variant="outlined"
|
||||
color="warning"
|
||||
disabled={state.submittingSms}
|
||||
>
|
||||
{state.submittingSms ? "درحال ارسال مجدد پیام پرداخت..." : "ارسال مجدد پیام پرداخت"}
|
||||
</Button>
|
||||
<Button
|
||||
key={"submittingCheckFactor"}
|
||||
onClick={handleCheckPaymentStatus}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
disabled={state.submittingCheckFactor}
|
||||
>
|
||||
{state.submittingCheckFactor ? "درحال دریافت اطلاعات..." : "استعلام پرداخت"}
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Button
|
||||
key={"close"}
|
||||
onClick={() => setOpenCreateFactorDialog(false)}
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
>
|
||||
بستن
|
||||
</Button>
|
||||
<Button
|
||||
key={"submittingCreateFactor"}
|
||||
onClick={handleCreateFactor}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
disabled={state.submittingCreateFactor}
|
||||
>
|
||||
{state.submittingCreateFactor ? "درحال ایجاد فاکتور..." : "ایجاد فاکتور"}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</DialogActions>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default CreateFactorContent;
|
||||
@@ -0,0 +1,39 @@
|
||||
import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import ReceiptLongIcon from "@mui/icons-material/ReceiptLong";
|
||||
import CreateFactorContent from "./CreateFactorContent";
|
||||
|
||||
const CreateFactor = ({ row, rowId, mutate }) => {
|
||||
const [openCreateFactorDialog, setOpenCreateFactorDialog] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="ایجاد فاکتور">
|
||||
<IconButton color="primary" onClick={() => setOpenCreateFactorDialog(true)}>
|
||||
<ReceiptLongIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
fullWidth
|
||||
open={openCreateFactorDialog}
|
||||
onClose={() => setOpenCreateFactorDialog(false)}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
maxWidth={"sm"}
|
||||
scroll="paper"
|
||||
>
|
||||
<DialogTitle sx={{ fontSize: "large" }}>مدیریت پرداخت</DialogTitle>
|
||||
<CreateFactorContent
|
||||
setOpenCreateFactorDialog={setOpenCreateFactorDialog}
|
||||
rowId={rowId}
|
||||
mutate={mutate}
|
||||
row={row}
|
||||
/>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default CreateFactor;
|
||||
@@ -0,0 +1,113 @@
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import CreateFormContent from "@/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent";
|
||||
import { useEffect, useState } from "react";
|
||||
import { GET_DAMAGE_ITEM_DETAILS, UPDATE_DAMAGE_ITEM } from "@/core/utils/routes";
|
||||
import DialogLoading from "@/core/components/DialogLoading";
|
||||
import { format } from "date-fns";
|
||||
import moment from "jalali-moment";
|
||||
|
||||
const EditController = ({ rowId, mutate, setOpenEditDialog }) => {
|
||||
const requestServer = useRequest();
|
||||
const [damageItemDetails, setDamageItemDetails] = useState(null);
|
||||
const [damageItemDetailsLoading, setDamageItemDetailsLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setDamageItemDetailsLoading(true);
|
||||
requestServer(`${GET_DAMAGE_ITEM_DETAILS}/${rowId}`, "get")
|
||||
.then((response) => {
|
||||
setDamageItemDetails(response.data.data);
|
||||
setDamageItemDetailsLoading(false);
|
||||
})
|
||||
.catch((e) => {
|
||||
setDamageItemDetailsLoading(false);
|
||||
});
|
||||
}, [rowId]);
|
||||
|
||||
const today = new Date().toISOString().split("T")[0];
|
||||
const plaqueNumber = damageItemDetails?.plaque.split("-") || [];
|
||||
const defaultData = {
|
||||
damage_picture1: damageItemDetails?.damage_picture1 || null,
|
||||
damage_picture2: damageItemDetails?.damage_picture2 || null,
|
||||
accident_date: new Date(damageItemDetails?.accident_date) || "",
|
||||
accident_time: new Date(`${today} ${damageItemDetails?.accident_time || ""}`),
|
||||
accident_type: damageItemDetails?.accident_type || "",
|
||||
axis_name: damageItemDetails?.axis_name || "",
|
||||
driver_name: damageItemDetails?.driver_name || "",
|
||||
police_file: damageItemDetails?.police_file || null,
|
||||
police_file_date: damageItemDetails?.police_file_date || "",
|
||||
police_serial: damageItemDetails?.police_serial || "",
|
||||
items_damage: damageItemDetails?.damages || [],
|
||||
phone_number: damageItemDetails?.driver_phone_number || "",
|
||||
national_code: damageItemDetails?.driver_national_code || "",
|
||||
plate_part1: plaqueNumber[0] || "",
|
||||
plate_part2: plaqueNumber[1] || "",
|
||||
plate_part3: plaqueNumber[2] || "",
|
||||
plate_part4: plaqueNumber[3] || "",
|
||||
radio_button: damageItemDetails?.report_base === 1 ? "report_base" : "police_file_checkbox",
|
||||
report_base: damageItemDetails?.report_base,
|
||||
province_id: damageItemDetails?.province_id || null,
|
||||
city_id: damageItemDetails?.city_id || null,
|
||||
start_point: { lat: damageItemDetails?.lat || "", lng: damageItemDetails?.lng || "" },
|
||||
};
|
||||
const HandleSubmit = async (result) => {
|
||||
const PlateNumber = `${result.plate_part1}-${result.plate_part2}-${result.plate_part3}-${result.plate_part4}`;
|
||||
const formData = new FormData();
|
||||
const accidentDate =
|
||||
result.accident_date == defaultData.accident_date
|
||||
? moment(result.accident_date).locale("en").format("YYYY-MM-DD")
|
||||
: result.accident_date;
|
||||
formData.append("accident_date", accidentDate);
|
||||
formData.append("accident_time", format(new Date(result.accident_time), "HH:mm"));
|
||||
formData.append("accident_type", result.accident_type);
|
||||
formData.append("province_id", result.province_id);
|
||||
formData.append("city_id", result.city_id);
|
||||
formData.append("axis_name", result.axis_name);
|
||||
formData.append("driver_name", result.driver_name);
|
||||
formData.append("driver_phone_number", result.phone_number);
|
||||
formData.append("driver_national_code", result.national_code);
|
||||
formData.append("plaque", PlateNumber);
|
||||
result.damage_picture1 !== defaultData.damage_picture1 &&
|
||||
formData.append("damage_picture1", result.damage_picture1);
|
||||
result.damage_picture2 !== defaultData.damage_picture2 &&
|
||||
formData.append("damage_picture2", result.damage_picture2);
|
||||
formData.append("lat", result.start_point.lat);
|
||||
formData.append("lng", result.start_point.lng);
|
||||
result.items_damage.map((item, index) => {
|
||||
formData.append(`damage_items[${index}][id]`, item.id);
|
||||
formData.append(`damage_items[${index}][value]`, item.value);
|
||||
formData.append(`damage_items[${index}][amount]`, item.amount);
|
||||
});
|
||||
if (result.radio_button === "report_base") {
|
||||
formData.append("report_base", 1);
|
||||
}
|
||||
if (result.radio_button === "police_file_checkbox") {
|
||||
formData.append("report_base", 0);
|
||||
result.police_file !== defaultData.police_file && formData.append("police_file", result.police_file);
|
||||
formData.append("police_file_date", result.police_file_date);
|
||||
formData.append("police_serial", result.police_serial);
|
||||
}
|
||||
await requestServer(`${UPDATE_DAMAGE_ITEM}/${rowId}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then(() => {
|
||||
mutate();
|
||||
setOpenEditDialog(false);
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
return (
|
||||
<>
|
||||
{damageItemDetailsLoading ? (
|
||||
<DialogLoading />
|
||||
) : (
|
||||
<CreateFormContent
|
||||
setOpen={setOpenEditDialog}
|
||||
SubmitDamage={HandleSubmit}
|
||||
defaultData={defaultData}
|
||||
mutate={mutate}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default EditController;
|
||||
@@ -0,0 +1,45 @@
|
||||
import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import BorderColorIcon from "@mui/icons-material/BorderColor";
|
||||
import EditController from "./EditController";
|
||||
|
||||
const EditForm = ({ row, mutate, rowId }) => {
|
||||
const [openEditDialog, setOpenEditDialog] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="ویرایش اطلاعات" arrow placement="right">
|
||||
<IconButton
|
||||
color="primary"
|
||||
sx={{ textTransform: "unset", alignSelf: "center" }}
|
||||
onClick={() => {
|
||||
setOpenEditDialog(true);
|
||||
}}
|
||||
>
|
||||
<BorderColorIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
maxWidth="sm"
|
||||
fullWidth
|
||||
open={openEditDialog}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
>
|
||||
{openEditDialog && (
|
||||
<EditController
|
||||
openEditDialog={openEditDialog}
|
||||
setOpenEditDialog={setOpenEditDialog}
|
||||
rowId={rowId}
|
||||
row={row}
|
||||
mutate={mutate}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default EditForm;
|
||||
@@ -0,0 +1,47 @@
|
||||
import { Grid, Stack, TextField } from "@mui/material";
|
||||
import { Controller } from "react-hook-form";
|
||||
import ImageUpload from "./ImageUpload";
|
||||
import NumberField from "@/core/components/NumberField";
|
||||
|
||||
const DaghiFile = ({ control }) => {
|
||||
return (
|
||||
<Stack spacing={3} mt={2}>
|
||||
<Stack>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={12} sm={12}>
|
||||
<Controller
|
||||
name="deposit_daghi_amount"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<NumberField
|
||||
{...field}
|
||||
value={field.value || ""}
|
||||
label="مبلغ داغی (ریال)"
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
size="small"
|
||||
error={error}
|
||||
helperText={error && error.message}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Stack>
|
||||
<Controller
|
||||
name="deposit_daghi_image"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<ImageUpload
|
||||
name={field.name}
|
||||
value={field.value}
|
||||
error={error}
|
||||
title={"تصویر صورتجلسه تحویل داغی به انبار"}
|
||||
onChange={field.onChange}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default DaghiFile;
|
||||
@@ -0,0 +1,53 @@
|
||||
import { useState } from "react";
|
||||
import { FormControlLabel, RadioGroup, Stack } from "@mui/material";
|
||||
import { Controller, useWatch } from "react-hook-form";
|
||||
import Radio from "@mui/material/Radio";
|
||||
import DaghiFile from "./DaghiFile";
|
||||
|
||||
const DaghiPayment = ({ control }) => {
|
||||
const watchedStatus = useWatch({ control, name: "deposit_daghi_status" });
|
||||
const [selectedOption, setSelectedOption] = useState(watchedStatus || null);
|
||||
|
||||
const handleOptionChange = (e) => {
|
||||
setSelectedOption(e.target.value);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<RadioGroup
|
||||
aria-label="file-options"
|
||||
name="file-options"
|
||||
value={selectedOption}
|
||||
onChange={handleOptionChange}
|
||||
>
|
||||
<Stack direction={"row"} alignItems={"center"} justifyContent={"center"}>
|
||||
<FormControlLabel
|
||||
value="no_daghi"
|
||||
control={
|
||||
<Controller
|
||||
control={control}
|
||||
name="deposit_daghi_status"
|
||||
render={({ field }) => <Radio {...field} value="no_daghi" />}
|
||||
/>
|
||||
}
|
||||
label="صورتجلسه تحویل داغی به انبار (بیمه) ندارد"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value="has_daghi"
|
||||
control={
|
||||
<Controller
|
||||
control={control}
|
||||
name="deposit_daghi_status"
|
||||
render={({ field }) => <Radio {...field} value="has_daghi" />}
|
||||
/>
|
||||
}
|
||||
label="صورتجلسه تحویل داغی به انبار (بیمه) دارد"
|
||||
/>
|
||||
</Stack>
|
||||
</RadioGroup>
|
||||
|
||||
{selectedOption === "has_daghi" && <DaghiFile control={control} />}
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DaghiPayment;
|
||||
@@ -0,0 +1,47 @@
|
||||
import { Grid, Stack, TextField } from "@mui/material";
|
||||
import { Controller } from "react-hook-form";
|
||||
import ImageUpload from "./ImageUpload";
|
||||
import NumberField from "@/core/components/NumberField";
|
||||
|
||||
const InsuranceFile = ({ control }) => {
|
||||
return (
|
||||
<Stack spacing={3} mt={2}>
|
||||
<Stack>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={12} sm={12}>
|
||||
<Controller
|
||||
name="deposit_insurance_amount"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<NumberField
|
||||
{...field}
|
||||
value={field.value || ""}
|
||||
label="مبلغ بیمه (ریال)"
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
size="small"
|
||||
error={error}
|
||||
helperText={error && error.message}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Stack>
|
||||
<Controller
|
||||
name="deposit_insurance_image"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<ImageUpload
|
||||
name={field.name}
|
||||
value={field.value}
|
||||
error={error}
|
||||
title={"تصویر فیش واریزی بیمه"}
|
||||
onChange={field.onChange}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default InsuranceFile;
|
||||
@@ -0,0 +1,52 @@
|
||||
import { FormControlLabel, FormHelperText, RadioGroup, Stack } from "@mui/material";
|
||||
import { Controller, useWatch } from "react-hook-form";
|
||||
import Radio from "@mui/material/Radio";
|
||||
import { useState } from "react";
|
||||
import InsuranceFile from "./InsuranceFile";
|
||||
|
||||
const InsurancePayment = ({ control }) => {
|
||||
const watchedStatus = useWatch({ control, name: "deposit_insurance_status" });
|
||||
const [selectedOption, setSelectedOption] = useState(watchedStatus || null);
|
||||
|
||||
const handleOptionChange = (e) => {
|
||||
setSelectedOption(e.target.value);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<RadioGroup
|
||||
aria-label="file-options"
|
||||
name="file-options"
|
||||
value={selectedOption}
|
||||
onChange={handleOptionChange}
|
||||
>
|
||||
<Stack direction={"row"} alignItems={"center"} justifyContent={"center"}>
|
||||
<FormControlLabel
|
||||
value="no_insurance"
|
||||
control={
|
||||
<Controller
|
||||
control={control}
|
||||
name="deposit_insurance_status"
|
||||
render={({ field }) => <Radio {...field} value="no_insurance" />}
|
||||
/>
|
||||
}
|
||||
label="فیش واریزی (بیمه) ندارد"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value="has_insurance"
|
||||
control={
|
||||
<Controller
|
||||
control={control}
|
||||
name="deposit_insurance_status"
|
||||
render={({ field }) => <Radio {...field} value="has_insurance" />}
|
||||
/>
|
||||
}
|
||||
label="فیش واریزی (بیمه) دارد"
|
||||
/>
|
||||
</Stack>
|
||||
</RadioGroup>
|
||||
{selectedOption === "has_insurance" && <InsuranceFile control={control} />}
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default InsurancePayment;
|
||||
@@ -0,0 +1,202 @@
|
||||
import { Box, Button, DialogActions, DialogContent, Tab, Tabs, Typography } from "@mui/material";
|
||||
import ExitToAppIcon from "@mui/icons-material/ExitToApp";
|
||||
import KeyboardDoubleArrowRightIcon from "@mui/icons-material/KeyboardDoubleArrowRight";
|
||||
import KeyboardDoubleArrowLeftIcon from "@mui/icons-material/KeyboardDoubleArrowLeft";
|
||||
import LocalPostOfficeIcon from "@mui/icons-material/LocalPostOffice";
|
||||
import BeenhereIcon from "@mui/icons-material/Beenhere";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import PaymentIcon from "@mui/icons-material/Payment";
|
||||
import React, { useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { mixed, object, string } from "yup";
|
||||
import InsurancePayment from "./InsurancePayment";
|
||||
import DaghiPayment from "./DaghiPayment";
|
||||
import { CONFIRM_PAYMENT_INFO } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
function TabPanel(props) {
|
||||
const { children, value, index } = props;
|
||||
return (
|
||||
<div role="tabpanel" hidden={value !== index}>
|
||||
{value === index && <Box>{children}</Box>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
const validationSchema = object({
|
||||
deposit_insurance_status: string().required("انتخاب یک گزینه الزامیست."),
|
||||
deposit_daghi_status: string().required("انتخاب یک گزینه الزامیست."),
|
||||
deposit_insurance_amount: string().when("deposit_insurance_status", {
|
||||
is: "has_insurance",
|
||||
then: (schema) => schema.required("مبلغ بیمه الزامی است."),
|
||||
otherwise: (schema) => schema.notRequired(),
|
||||
}),
|
||||
deposit_insurance_image: mixed().when("deposit_insurance_status", {
|
||||
is: "has_insurance",
|
||||
then: (schema) => schema.required("تصویر فیش واریزی بیمه الزامی است."),
|
||||
otherwise: (schema) => schema.notRequired(),
|
||||
}),
|
||||
deposit_daghi_amount: string()
|
||||
.when("deposit_daghi_status", {
|
||||
is: "has_daghi",
|
||||
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;
|
||||
}),
|
||||
deposit_daghi_image: mixed().when("deposit_daghi_status", {
|
||||
is: "has_daghi",
|
||||
then: (schema) => schema.required("تصویر صورتجلسه تحویل داغی به انبار الزامی است."),
|
||||
otherwise: (schema) => schema.notRequired(),
|
||||
}),
|
||||
}).test("total-amount-limit", "مجموع مبلغ بیمه و داغی نباید از کل مبلغ خسارت بیشتر باشد.", function (values) {
|
||||
const sum = this.options.context.sum || 0;
|
||||
const depositInsuranceAmount = parseFloat(values.deposit_insurance_amount) || 0;
|
||||
const depositDaghiAmount = parseFloat(values.deposit_daghi_amount) || 0;
|
||||
return depositInsuranceAmount + depositDaghiAmount <= sum;
|
||||
});
|
||||
|
||||
const RegisterInsuranceContent = ({ setOpenRegisterInsuranceDialog, row, mutate, rowId }) => {
|
||||
const [tabState, setTabState] = useState(0);
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const handleClose = () => setOpenRegisterInsuranceDialog(false);
|
||||
const handleChangeTab = (event, newValue) => setTabState(newValue);
|
||||
|
||||
const defaultValues = {
|
||||
deposit_insurance_status: "no_insurance",
|
||||
deposit_insurance_amount: "",
|
||||
deposit_insurance_image: null,
|
||||
deposit_daghi_status: "no_daghi",
|
||||
deposit_daghi_amount: "",
|
||||
deposit_daghi_image: null,
|
||||
};
|
||||
const handlePrev = () => {
|
||||
if (tabState === 0) {
|
||||
handleClose();
|
||||
} else {
|
||||
setTabState(tabState - 1);
|
||||
}
|
||||
};
|
||||
const handleNext = async () => {
|
||||
let fieldsToValidate = [];
|
||||
if (tabState === 0) {
|
||||
fieldsToValidate = ["deposit_insurance_status", "deposit_insurance_amount", "deposit_insurance_image"];
|
||||
}
|
||||
if (tabState === 1) {
|
||||
fieldsToValidate = ["deposit_daghi_status", "deposit_daghi_amount", "deposit_daghi_image"];
|
||||
}
|
||||
|
||||
const isValid = await trigger(fieldsToValidate);
|
||||
if (isValid) {
|
||||
setTabState(tabState + 1);
|
||||
}
|
||||
};
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
trigger,
|
||||
formState: { isSubmitting, errors },
|
||||
} = useForm({
|
||||
defaultValues,
|
||||
resolver: yupResolver(validationSchema),
|
||||
mode: "all",
|
||||
context: { sum: row?.original?.sum },
|
||||
});
|
||||
|
||||
const onSubmitBase = async (data) => {
|
||||
const formData = new FormData();
|
||||
const depositDaghiStatus = data.deposit_daghi_status === "no_daghi" ? 0 : 1;
|
||||
const depositInsuranceStatus = data.deposit_insurance_status === "no_insurance" ? 0 : 1;
|
||||
|
||||
if (data.deposit_daghi_status === "has_daghi") {
|
||||
formData.append("deposit_daghi_status", depositDaghiStatus);
|
||||
formData.append("deposit_daghi_amount", data.deposit_daghi_amount);
|
||||
formData.append("deposit_daghi_image", data.deposit_daghi_image);
|
||||
}
|
||||
if (data.deposit_insurance_status === "has_insurance") {
|
||||
formData.append("deposit_insurance_status", depositInsuranceStatus);
|
||||
formData.append("deposit_insurance_amount", data.deposit_insurance_amount);
|
||||
formData.append("deposit_insurance_image", data.deposit_insurance_image);
|
||||
}
|
||||
requestServer(`${CONFIRM_PAYMENT_INFO}/${rowId}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then(() => {
|
||||
mutate();
|
||||
setOpenRegisterInsuranceDialog(false);
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
return (
|
||||
<StyledForm onSubmit={handleSubmit(onSubmitBase)}>
|
||||
<Tabs
|
||||
allowScrollButtonsMobile
|
||||
value={tabState}
|
||||
onChange={handleChangeTab}
|
||||
variant="fullWidth"
|
||||
sx={{
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
width: "100%",
|
||||
backgroundColor: "#efefef",
|
||||
}}
|
||||
>
|
||||
<Tab icon={<PaymentIcon />} label="فیش واریزی بیمه" />
|
||||
<Tab disabled={tabState === 0} icon={<LocalPostOfficeIcon />} label="صورتجلسه تحویل داغی به انبار" />
|
||||
</Tabs>
|
||||
<DialogContent dividers sx={{ overflowY: "auto", maxHeight: "70vh" }}>
|
||||
<Box sx={{ flex: 1 }}>
|
||||
<TabPanel value={tabState} index={0}>
|
||||
<InsurancePayment control={control} />
|
||||
</TabPanel>
|
||||
<TabPanel value={tabState} index={1}>
|
||||
<DaghiPayment control={control} />
|
||||
</TabPanel>
|
||||
</Box>
|
||||
</DialogContent>
|
||||
{errors[""]?.message && (
|
||||
<Typography textAlign={"center"} color={"error.main"} sx={{ mt: 2 }}>
|
||||
{errors[""].message}
|
||||
</Typography>
|
||||
)}
|
||||
<DialogActions sx={{ alignItems: "center", justifyContent: "center" }}>
|
||||
<Button
|
||||
onClick={handlePrev}
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
size="large"
|
||||
startIcon={tabState === 0 ? <ExitToAppIcon /> : <KeyboardDoubleArrowRightIcon />}
|
||||
>
|
||||
{tabState === 0 ? "بستن" : "مرحله قبل"}
|
||||
</Button>
|
||||
{tabState !== 1 && (
|
||||
<Button
|
||||
type="button"
|
||||
onClick={handleNext}
|
||||
variant="contained"
|
||||
size="large"
|
||||
endIcon={<KeyboardDoubleArrowLeftIcon />}
|
||||
>
|
||||
مرحله بعد
|
||||
</Button>
|
||||
)}
|
||||
{tabState === 1 && (
|
||||
<Button
|
||||
type={"submit"}
|
||||
variant="contained"
|
||||
size="large"
|
||||
disabled={isSubmitting}
|
||||
endIcon={<BeenhereIcon />}
|
||||
>
|
||||
{isSubmitting ? "در حال ثبت فیش" : "ثبت فیش"}
|
||||
</Button>
|
||||
)}
|
||||
</DialogActions>
|
||||
</StyledForm>
|
||||
);
|
||||
};
|
||||
export default RegisterInsuranceContent;
|
||||
@@ -0,0 +1,37 @@
|
||||
import { Dialog, IconButton, Tooltip } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import ReceiptIcon from "@mui/icons-material/Receipt";
|
||||
import RegisterInsuranceContent from "./RegisterInsuranceContent";
|
||||
|
||||
const RegisterInsurance = ({ row, mutate, rowId }) => {
|
||||
const [openRegisterInsuranceDialog, setOpenRegisterInsuranceDialog] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="ثبت بیمه و داغی">
|
||||
<IconButton color="primary" onClick={() => setOpenRegisterInsuranceDialog(true)}>
|
||||
<ReceiptIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
fullWidth
|
||||
open={openRegisterInsuranceDialog}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
maxWidth={"sm"}
|
||||
scroll="paper"
|
||||
>
|
||||
<RegisterInsuranceContent
|
||||
rowId={rowId}
|
||||
mutate={mutate}
|
||||
row={row}
|
||||
setOpenRegisterInsuranceDialog={setOpenRegisterInsuranceDialog}
|
||||
/>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default RegisterInsurance;
|
||||
403
src/components/dashboard/damages/operator/OperatorList.jsx
Normal file
403
src/components/dashboard/damages/operator/OperatorList.jsx
Normal file
@@ -0,0 +1,403 @@
|
||||
"use client";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { Box, Stack, Typography } from "@mui/material";
|
||||
import DataTableWithAuth from "@/core/components/DataTableWithAuth";
|
||||
import Toolbar from "./Toolbar";
|
||||
import { GET_TECHNICAL_DAMAGE_OPERATOR_LIST } from "@/core/utils/routes";
|
||||
import moment from "jalali-moment";
|
||||
import RowActions from "./RowActions";
|
||||
import useProvinces from "@/lib/hooks/useProvince";
|
||||
import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency";
|
||||
import useEdaratLists from "@/lib/hooks/useEdaratLists";
|
||||
import ImageDialog from "./RowActions/ImageDialog";
|
||||
import LocationForm from "./RowActions/LocationForm";
|
||||
import ShowPlate from "./RowActions/ShowPlate";
|
||||
import DamageItemDialog from "@/components/dashboard/damages/operator/RowActions/DamageItemDialog";
|
||||
|
||||
const OperatorList = () => {
|
||||
const statusOptions = [
|
||||
{ value: 0, label: "بدون اقدام" },
|
||||
{ value: 1, label: "صدور نامه بیمه و کارشناسی داغی" },
|
||||
{ value: 2, label: "فیش ها ثبت شده است" },
|
||||
{ value: 3, label: "فاکتور صادر شده است" },
|
||||
{ value: 4, label: "فاکتور پرداخت شده است" },
|
||||
{ value: 5, label: "نامه پلیس راه صادر شده است" },
|
||||
];
|
||||
const columns = useMemo(() => {
|
||||
return [
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: "کد یکتا", // Unique Code
|
||||
id: "id",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
},
|
||||
{
|
||||
header: "اطلاعات تصادف",
|
||||
id: "accidentInfo",
|
||||
enableColumnFilter: false,
|
||||
enableSorting: false,
|
||||
grow: false,
|
||||
size: 50,
|
||||
columns: [
|
||||
{
|
||||
accessorKey: "province_id",
|
||||
header: "استان",
|
||||
id: "province_id",
|
||||
enableColumnFilter: true,
|
||||
datatype: "numeric",
|
||||
filterMode: "equals",
|
||||
grow: false,
|
||||
size: 130,
|
||||
ColumnSelectComponent: (props) => {
|
||||
const { provinces, errorProvinces, loadingProvinces } = useProvinces();
|
||||
const getColumnSelectOptions = useMemo(() => {
|
||||
if (loadingProvinces) {
|
||||
return [{ value: "loading", label: "در حال بارگذاری..." }];
|
||||
}
|
||||
if (errorProvinces) {
|
||||
return [{ value: "error", label: "خطا در بارگذاری" }];
|
||||
}
|
||||
return [
|
||||
{ value: "", label: "کل کشور" },
|
||||
...provinces.map((province) => ({
|
||||
value: province.id,
|
||||
label: province.name_fa,
|
||||
})),
|
||||
];
|
||||
}, [provinces, errorProvinces, loadingProvinces]);
|
||||
return (
|
||||
<CustomSelectByDependency
|
||||
{...props}
|
||||
value={loadingProvinces ? "loading" : props.filterParameters.value}
|
||||
columnSelectOption={getColumnSelectOptions}
|
||||
/>
|
||||
);
|
||||
},
|
||||
Cell: ({ row }) => <>{row.original.province_fa}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "city_id",
|
||||
header: "شهرستان", // Office
|
||||
id: "city_id",
|
||||
enableColumnFilter: true,
|
||||
datatype: "numeric",
|
||||
filterMode: "equals",
|
||||
dependencyId: "province_id",
|
||||
grow: false,
|
||||
size: 120,
|
||||
ColumnSelectComponent: (props) => {
|
||||
const { edaratList, loadingEdaratList, errorEdaratList } = useEdaratLists(
|
||||
props.dependencyFieldValue.value
|
||||
);
|
||||
const [prevDependency, setPrevDependency] = useState(props.dependencyFieldValue.value);
|
||||
|
||||
const getColumnSelectOptions = useMemo(() => {
|
||||
if (props.dependencyFieldValue.value === "") {
|
||||
return [{ value: "empty", label: "ابتدا استان را انتخاب کنید" }];
|
||||
}
|
||||
if (loadingEdaratList) {
|
||||
return [{ value: "loading", label: "در حال بارگذاری..." }];
|
||||
}
|
||||
if (errorEdaratList) {
|
||||
return [{ value: "error", label: "خطا در بارگذاری" }];
|
||||
}
|
||||
return [
|
||||
{ value: "", label: "شهر" },
|
||||
...edaratList.map((edare) => ({
|
||||
value: edare.id,
|
||||
label: edare.name_fa,
|
||||
})),
|
||||
];
|
||||
}, [edaratList, loadingEdaratList, errorEdaratList]);
|
||||
useEffect(() => {
|
||||
if (prevDependency === props.dependencyFieldValue?.value) return;
|
||||
props.handleChange({ ...props.filterParameters, value: "" });
|
||||
setPrevDependency(props.dependencyFieldValue?.value);
|
||||
}, [props.dependencyFieldValue?.value]);
|
||||
return (
|
||||
<CustomSelectByDependency
|
||||
{...props}
|
||||
value={
|
||||
props.dependencyFieldValue?.value === ""
|
||||
? "empty"
|
||||
: loadingEdaratList
|
||||
? "loading"
|
||||
: props.filterParameters.value
|
||||
}
|
||||
columnSelectOption={getColumnSelectOptions}
|
||||
/>
|
||||
);
|
||||
},
|
||||
Cell: ({ row }) => <>{row.original.city_fa}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "axis_name",
|
||||
header: "نام محور",
|
||||
id: "axis_name",
|
||||
enableColumnFilter: true,
|
||||
enableSorting: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 120,
|
||||
},
|
||||
{
|
||||
accessorKey: "accident_type",
|
||||
header: "نوع تصادف", // Value
|
||||
id: "accident_type",
|
||||
enableColumnFilter: true,
|
||||
enableSorting: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 120,
|
||||
Cell: ({ row }) => <>{row.original.accident_type_fa}</>,
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => {
|
||||
const formattedDate = moment(row.accident_date, "YYYY-MM-DD"); // تنظیم فرمت صحیح تاریخ
|
||||
const formattedTime = row.accident_time || "00:00:00"; // در صورت خالی بودن مقدار، مقدار پیشفرض داده شود
|
||||
return moment(`${formattedDate.format("YYYY-MM-DD")}T${formattedTime}`)
|
||||
.locale("fa")
|
||||
.format("HH:mm | YYYY/MM/DD");
|
||||
},
|
||||
header: "تاریخ تصادف",
|
||||
id: "accident_date",
|
||||
enableColumnFilter: true,
|
||||
datatype: "date",
|
||||
filterMode: "between",
|
||||
grow: false,
|
||||
size: 100,
|
||||
},
|
||||
{
|
||||
accessorKey: "files",
|
||||
header: "تصاویر",
|
||||
id: "files",
|
||||
enableColumnFilter: false,
|
||||
enableSorting: false,
|
||||
datatype: "array",
|
||||
grow: false,
|
||||
size: 100,
|
||||
muiTableBodyCellProps: {
|
||||
sx: {
|
||||
borderLeft: "1px solid #e1e1e1",
|
||||
py: 0,
|
||||
"&:first-of-type": {
|
||||
borderLeft: "unset",
|
||||
},
|
||||
},
|
||||
},
|
||||
Cell: ({ row }) => {
|
||||
if (row.original.damage_picture1) {
|
||||
const imagesList = [row.original.damage_picture1, row.original.damage_picture2];
|
||||
return (
|
||||
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||
<ImageDialog images={imagesList} />
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Typography textAlign={"center"} variant="body2">
|
||||
بدون تصویر
|
||||
</Typography>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "location",
|
||||
header: "موقعیت",
|
||||
id: "location",
|
||||
enableColumnFilter: false,
|
||||
enableSorting: false,
|
||||
datatype: "array",
|
||||
grow: false,
|
||||
size: 100,
|
||||
muiTableBodyCellProps: {
|
||||
sx: {
|
||||
borderLeft: "1px solid #e1e1e1",
|
||||
py: 0,
|
||||
"&:first-of-type": {
|
||||
borderLeft: "unset",
|
||||
},
|
||||
},
|
||||
},
|
||||
Cell: ({ row }) => {
|
||||
return (
|
||||
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||
<LocationForm start_lat={row.original.lat} start_lng={row.original.lng} />
|
||||
</Stack>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "plaque",
|
||||
header: "پلاک",
|
||||
id: "plaque",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: true,
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ renderedCellValue }) => <ShowPlate plate={renderedCellValue} />,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
header: "اطلاعات خسارت",
|
||||
id: "damagesInfo",
|
||||
enableColumnFilter: false,
|
||||
enableSorting: false,
|
||||
grow: false,
|
||||
size: 50,
|
||||
columns: [
|
||||
{
|
||||
header: "آیتم های خسارت",
|
||||
id: "damageItems",
|
||||
enableColumnFilter: false,
|
||||
enableSorting: false,
|
||||
datatype: "array",
|
||||
grow: false,
|
||||
size: 100,
|
||||
muiTableBodyCellProps: {
|
||||
sx: {
|
||||
borderLeft: "1px solid #e1e1e1",
|
||||
py: 0,
|
||||
"&:first-of-type": {
|
||||
borderLeft: "unset",
|
||||
},
|
||||
},
|
||||
},
|
||||
Cell: ({ row }) => {
|
||||
return (
|
||||
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||
<DamageItemDialog rowId={row.getValue("id")} />
|
||||
</Stack>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "sum",
|
||||
header: "مبلغ کل خسارت (ریال)",
|
||||
id: "sum",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
sortDescFirst: true,
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => (
|
||||
<Typography variant={"body2"} sx={{ margin: 1 }} component="span">
|
||||
{(row.original.sum / 1).toLocaleString()}
|
||||
</Typography>
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
header: "اطلاعات واریز",
|
||||
id: "items",
|
||||
enableColumnFilter: false,
|
||||
enableSorting: false,
|
||||
grow: false,
|
||||
size: 50,
|
||||
columns: [
|
||||
{
|
||||
header: "مبلغ فیش (ریال)",
|
||||
id: "final_amount",
|
||||
enableColumnFilter: false,
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => (
|
||||
<Typography variant={"body2"} sx={{ margin: 1 }} component="span">
|
||||
{(row.original.final_amount / 1).toLocaleString()}
|
||||
</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
header: "مبلغ بیمه (ریال)",
|
||||
id: "deposit_insurance_amount",
|
||||
enableColumnFilter: false,
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => (
|
||||
<Typography variant={"body2"} sx={{ margin: 1 }} component="span">
|
||||
{(row.original.deposit_insurance_amount / 1).toLocaleString()}
|
||||
</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
header: "مبلغ داغی (ریال)",
|
||||
id: "deposit_daghi_amount",
|
||||
enableColumnFilter: false,
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => (
|
||||
<Typography variant={"body2"} sx={{ margin: 1 }} component="span">
|
||||
{(row.original.deposit_daghi_amount / 1).toLocaleString()}
|
||||
</Typography>
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"),
|
||||
header: "تاریخ ثبت",
|
||||
id: "created_at",
|
||||
enableColumnFilter: true,
|
||||
datatype: "date",
|
||||
filterMode: "between",
|
||||
grow: false,
|
||||
size: 100,
|
||||
},
|
||||
{
|
||||
accessorKey: "status",
|
||||
header: "اخرین وضعیت",
|
||||
id: "status",
|
||||
enableColumnFilter: true,
|
||||
datatype: "numeric",
|
||||
filterMode: "equals",
|
||||
grow: false,
|
||||
size: 100,
|
||||
columnSelectOption: () => {
|
||||
return statusOptions.map((status) => ({
|
||||
value: status.value,
|
||||
label: status.label,
|
||||
}));
|
||||
},
|
||||
Cell: ({ row }) => {
|
||||
return <Typography variant={"body2"}>{row.original.status_fa}</Typography>;
|
||||
},
|
||||
},
|
||||
];
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box sx={{ p: 1, border: 1, borderColor: "divider", borderRadius: 1 }}>
|
||||
<DataTableWithAuth
|
||||
need_filter={true}
|
||||
columns={columns}
|
||||
table_url={GET_TECHNICAL_DAMAGE_OPERATOR_LIST}
|
||||
page_name={"operatorDamages"}
|
||||
table_name={"operatorList"}
|
||||
sorting={[{ id: "id", desc: true }]}
|
||||
TableToolbar={Toolbar}
|
||||
enableRowActions
|
||||
positionActionsColumn={"last"}
|
||||
RowActions={RowActions}
|
||||
/>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default OperatorList;
|
||||
@@ -0,0 +1,76 @@
|
||||
import DialogLoading from "@/core/components/DialogLoading";
|
||||
import { GET_DAMAGE_ITEM_DETAILS, GET_RAHDARAN_ROAD_ITEM } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import {
|
||||
DialogContent,
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableContainer,
|
||||
TableHead,
|
||||
TableRow,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
const DamageItemContent = ({ rowId }) => {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [data, setData] = useState(null);
|
||||
const request = useRequest();
|
||||
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await request(`${GET_DAMAGE_ITEM_DETAILS}/${rowId}`);
|
||||
setData(response.data.data.damages);
|
||||
} catch (error) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchData();
|
||||
}, [rowId]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
{loading ? (
|
||||
<DialogLoading />
|
||||
) : data ? (
|
||||
<TableContainer sx={{ maxHeight: 600 }}>
|
||||
<Table stickyHeader sx={{ minWidth: 800 }}>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>نوع خسارت</TableCell>
|
||||
<TableCell>میزان خسارت</TableCell>
|
||||
<TableCell>هزینه خسارت (ریال)</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{data.map((item) => {
|
||||
return (
|
||||
<TableRow
|
||||
key={item.id}
|
||||
sx={{ "&:last-child td, &:last-child th": { border: 0 } }}
|
||||
>
|
||||
<TableCell>{item?.title}</TableCell>
|
||||
<TableCell>
|
||||
{(item?.pivot?.value / 1).toLocaleString()} ({item?.pivot?.unit})
|
||||
</TableCell>
|
||||
<TableCell>{(item?.pivot?.amount / 1).toLocaleString()}</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
})}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
) : (
|
||||
<Typography textAlign={"center"}>اطلاعات یافت نشد</Typography>
|
||||
)}
|
||||
</DialogContent>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DamageItemContent;
|
||||
@@ -0,0 +1,43 @@
|
||||
import { Button, Dialog, DialogActions, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||
import MinorCrashIcon from "@mui/icons-material/MinorCrash";
|
||||
import { useState } from "react";
|
||||
import DamageItemContent from "./DamageItemContent";
|
||||
|
||||
const DamageItemDialog = ({ rowId }) => {
|
||||
const [openDamageItemDialog, setOpenDamageItemDialog] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="آیتم های خسارت">
|
||||
<IconButton color="primary" onClick={() => setOpenDamageItemDialog(true)}>
|
||||
<MinorCrashIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
fullWidth
|
||||
open={openDamageItemDialog}
|
||||
onClose={() => setOpenDamageItemDialog(false)}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
dir="rtl"
|
||||
maxWidth={"md"}
|
||||
>
|
||||
<DialogTitle sx={{ fontSize: "large" }}>آیتم های خسارت</DialogTitle>
|
||||
{openDamageItemDialog && <DamageItemContent rowId={rowId} />}
|
||||
<DialogActions>
|
||||
<Button
|
||||
onClick={() => setOpenDamageItemDialog(false)}
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
autoFocus
|
||||
>
|
||||
بستن
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DamageItemDialog;
|
||||
@@ -0,0 +1,39 @@
|
||||
import { Button, DialogActions, DialogContent, Stack, Typography } from "@mui/material";
|
||||
import React, { useState } from "react";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { DELETE_DAMAGE_ITEM } from "@/core/utils/routes";
|
||||
|
||||
const DeleteContent = ({ rowId, mutate, setOpenDeleteDialog }) => {
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const handleClick = () => {
|
||||
setSubmitting(true);
|
||||
requestServer(`${DELETE_DAMAGE_ITEM}/${rowId}`, "delete")
|
||||
.then(() => {
|
||||
mutate();
|
||||
setOpenDeleteDialog(false);
|
||||
setSubmitting(false);
|
||||
})
|
||||
.catch(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Stack alignItems="center" spacing={2}>
|
||||
<Typography mt={2}>آیا از حذف فعالیت اطمینان دارید؟</Typography>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions sx={{ justifyContent: "center", paddingBottom: 2, width: "100%" }}>
|
||||
<Button onClick={() => setOpenDeleteDialog(false)} variant="outlined" color="secondary">
|
||||
خیر !
|
||||
</Button>
|
||||
<Button onClick={handleClick} variant="contained" color="error" disabled={submitting}>
|
||||
{submitting ? "درحال حذف..." : "بله اطمینان دارم"}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DeleteContent;
|
||||
@@ -0,0 +1,32 @@
|
||||
import DeleteIcon from "@mui/icons-material/Delete";
|
||||
import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import DeleteContent from "./DeleteContent";
|
||||
const DeleteDialog = ({ rowId, mutate }) => {
|
||||
const [openDeleteDialog, setOpenDeleteDialog] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="حذف">
|
||||
<IconButton color="error" onClick={() => setOpenDeleteDialog(true)}>
|
||||
<DeleteIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
open={openDeleteDialog}
|
||||
onClose={() => setOpenDeleteDialog(false)}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
dir="rtl"
|
||||
maxWidth={"md"}
|
||||
>
|
||||
<DialogTitle>حذف فعالیت</DialogTitle>
|
||||
<DeleteContent rowId={rowId} mutate={mutate} setOpenDeleteDialog={setOpenDeleteDialog} />
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DeleteDialog;
|
||||
@@ -0,0 +1,41 @@
|
||||
import { Button, DialogActions, DialogContent, Stack, Typography } from "@mui/material";
|
||||
import React, { useState } from "react";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { GET_POLICERAH_PAGE } from "@/core/utils/routes";
|
||||
|
||||
const PoliceRahLetterContent = ({ setOpenPoliceRahDialog, rowId, mutate }) => {
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const handleClick = () => {
|
||||
setSubmitting(true);
|
||||
const url = `https://rms.witel.ir/v2/receipt/document-release/${rowId}`;
|
||||
requestServer(`${GET_POLICERAH_PAGE}/${rowId}`, "get")
|
||||
.then(() => {
|
||||
mutate();
|
||||
window.open(url, "_blank");
|
||||
setSubmitting(false);
|
||||
setOpenPoliceRahDialog(false);
|
||||
})
|
||||
.catch(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Stack spacing={2}>
|
||||
<Typography mt={2}>آیا از صدور نامه به پلیس راه اطمینان دارید؟</Typography>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => setOpenPoliceRahDialog(false)} variant="outlined" color="secondary">
|
||||
خیر !
|
||||
</Button>
|
||||
<Button onClick={handleClick} variant="contained" color="primary" disabled={submitting}>
|
||||
{submitting ? "درحال صدور نامه پلیس راه..." : "بله اطمینان دارم"}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default PoliceRahLetterContent;
|
||||
@@ -0,0 +1,32 @@
|
||||
import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||
import GarageIcon from "@mui/icons-material/Garage";
|
||||
import React, { useState } from "react";
|
||||
import PoliceRahLetterContent from "./PoliceRahLetterContent";
|
||||
|
||||
const PoliceRahLetter = ({ rowId, mutate }) => {
|
||||
const [openPoliceRahDialog, setOpenPoliceRahDialog] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="نامه پلیس راه">
|
||||
<IconButton color="primary" onClick={() => setOpenPoliceRahDialog(true)}>
|
||||
<GarageIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
open={openPoliceRahDialog}
|
||||
onClose={() => setOpenPoliceRahDialog(false)}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
maxWidth={"xs"}
|
||||
scroll="paper"
|
||||
>
|
||||
<DialogTitle sx={{ fontSize: "large" }}>صدور نامه پلیس راه</DialogTitle>
|
||||
<PoliceRahLetterContent mutate={mutate} rowId={rowId} setOpenPoliceRahDialog={setOpenPoliceRahDialog} />
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default PoliceRahLetter;
|
||||
@@ -0,0 +1,41 @@
|
||||
import { Button, DialogActions, DialogContent, Stack, Typography } from "@mui/material";
|
||||
import React, { useState } from "react";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { GET_INSURANCE_PAGE } from "@/core/utils/routes";
|
||||
|
||||
const SendToInsuranceContent = ({ setOpenSendInsuranceDialog, rowId, mutate }) => {
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const handleClick = () => {
|
||||
setSubmitting(true);
|
||||
const url = `https://rms.witel.ir/v2/receipt/send-to-insurance/${rowId}`;
|
||||
requestServer(`${GET_INSURANCE_PAGE}/${rowId}`, "get")
|
||||
.then(() => {
|
||||
mutate();
|
||||
window.open(url, "_blank");
|
||||
setSubmitting(false);
|
||||
setOpenSendInsuranceDialog(false);
|
||||
})
|
||||
.catch(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Stack spacing={2}>
|
||||
<Typography mt={2}>آیا از صدور نامه بیمه اطمینان دارید؟</Typography>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => setOpenSendInsuranceDialog(false)} variant="outlined" color="secondary">
|
||||
خیر !
|
||||
</Button>
|
||||
<Button onClick={handleClick} variant="contained" color="primary" disabled={submitting}>
|
||||
{submitting ? "درحال صدور نامه بیمه..." : "بله اطمینان دارم"}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default SendToInsuranceContent;
|
||||
@@ -0,0 +1,36 @@
|
||||
import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||
import EmailIcon from "@mui/icons-material/Email";
|
||||
import React, { useState } from "react";
|
||||
import SendToInsuranceContent from "./SendToInsuranceContent";
|
||||
|
||||
const SendToInsurance = ({ rowId, mutate }) => {
|
||||
const [openSendInsuranceDialog, setOpenSendInsuranceDialog] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="نامه بیمه">
|
||||
<IconButton color="primary" onClick={() => setOpenSendInsuranceDialog(true)}>
|
||||
<EmailIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
open={openSendInsuranceDialog}
|
||||
onClose={() => setOpenSendInsuranceDialog(false)}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
maxWidth={"xs"}
|
||||
scroll="paper"
|
||||
>
|
||||
<DialogTitle sx={{ fontSize: "large" }}>نامه بیمه</DialogTitle>
|
||||
<SendToInsuranceContent
|
||||
mutate={mutate}
|
||||
rowId={rowId}
|
||||
setOpenSendInsuranceDialog={setOpenSendInsuranceDialog}
|
||||
/>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default SendToInsurance;
|
||||
@@ -3,10 +3,10 @@ import { Stack } from "@mui/material";
|
||||
const ShowPlate = ({ plate }) => {
|
||||
return (
|
||||
<Stack sx={{ border: 1, borderColor: "divider", borderRadius: 1 }} direction={"row"}>
|
||||
<Stack sx={{ borderRight: 1, borderColor: "divider", textAlign: "center", width: "40%" }}>
|
||||
<Stack sx={{ borderRight: 1, borderColor: "divider", textAlign: "center", px: 1 }}>
|
||||
{plate.split("-")[3]}
|
||||
</Stack>
|
||||
<Stack direction={"row"} sx={{ width: "100%", px: 0.5 }}>
|
||||
<Stack direction={"row"} spacing={1} sx={{ width: "100%", px: 0.5 }}>
|
||||
<Stack
|
||||
sx={{
|
||||
textAlign: "center",
|
||||
@@ -0,0 +1,27 @@
|
||||
import { Box } from "@mui/material";
|
||||
import RegisterInsurance from "../Form/RegisterInsurance";
|
||||
import CreateFactor from "../Form/CreateFactor";
|
||||
import DeleteDialog from "./DeleteDialog";
|
||||
import SendToInsurance from "./SendToInsurance";
|
||||
import PoliceRahLetter from "./PoliceRahLetter";
|
||||
import EditForm from "../Form/EditForm";
|
||||
|
||||
const RowActions = ({ row, mutate }) => {
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
{[0, 1, 2].includes(row.original?.status) && <SendToInsurance mutate={mutate} rowId={row.getValue("id")} />}
|
||||
{[1, 2].includes(row.original?.status) && (
|
||||
<RegisterInsurance mutate={mutate} row={row} rowId={row.getValue("id")} />
|
||||
)}
|
||||
{[2, 3].includes(row.original?.status) && (
|
||||
<CreateFactor row={row} rowId={row.getValue("id")} mutate={mutate} />
|
||||
)}
|
||||
{[4, 5].includes(row.original?.status) && <PoliceRahLetter mutate={mutate} rowId={row.getValue("id")} />}
|
||||
{[0, 1, 2].includes(row.original?.status) && (
|
||||
<EditForm row={row} mutate={mutate} rowId={row.getValue("id")} />
|
||||
)}
|
||||
<DeleteDialog mutate={mutate} rowId={row.getValue("id")} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
export default RowActions;
|
||||
@@ -1,9 +1,11 @@
|
||||
import { Box } from "@mui/material";
|
||||
import OperatorCreate from "./Actions/create";
|
||||
import PrintExcel from "./ExcelPrint";
|
||||
|
||||
const Toolbar = ({ table, filterData, mutate }) => {
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
<PrintExcel table={table} filterData={filterData} />
|
||||
<OperatorCreate mutate={mutate} />
|
||||
</Box>
|
||||
);
|
||||
@@ -43,7 +43,7 @@ const TableInfo = ({ specialFilter, setTabState, setItemInfo }) => {
|
||||
},
|
||||
{
|
||||
accessorKey: "item_name",
|
||||
header: "نام ایتم",
|
||||
header: "نام آیتم",
|
||||
id: "item_name",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
|
||||
@@ -44,7 +44,7 @@ const PrintExcel = ({ table, filterData }) => {
|
||||
requestOptions: { responseType: "blob" },
|
||||
})
|
||||
.then((response) => {
|
||||
const filename = `خروجی کارتابل گزارشات فعالیت روزانه براساس ایتم تاریخ_${moment().format("jYYYY_jMM_jDD")}.xlsx`;
|
||||
const filename = `خروجی کارتابل گزارشات فعالیت روزانه براساس آیتم تاریخ_${moment().format("jYYYY_jMM_jDD")}.xlsx`;
|
||||
FileSaver.saveAs(response.data, filename);
|
||||
})
|
||||
.catch(() => {})
|
||||
|
||||
@@ -66,7 +66,7 @@ const ReportLists = ({ itemsList, data, specialFilter }) => {
|
||||
},
|
||||
},
|
||||
{
|
||||
header: "ایتم های فعالیت روزانه",
|
||||
header: "آیتم های فعالیت روزانه",
|
||||
id: "items",
|
||||
enableColumnFilter: false,
|
||||
enableSorting: false,
|
||||
|
||||
@@ -157,7 +157,7 @@ const ReportPage = () => {
|
||||
});
|
||||
return (
|
||||
<Stack spacing={1}>
|
||||
<PageTitle title={"گزارش تعداد فعالیت ها به تفکیک ایتم"} />
|
||||
<PageTitle title={"گزارش تعداد فعالیت ها به تفکیک آیتم"} />
|
||||
<SearchReportList
|
||||
control={control}
|
||||
hasProvincesPermission={hasProvincesPermission}
|
||||
|
||||
@@ -12,13 +12,13 @@ const SelectProvince = ({ control }) => {
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<FormControl error={!!error} size="small" fullWidth>
|
||||
<InputLabel id="demo-error-label">ایتم</InputLabel>
|
||||
<InputLabel id="demo-error-label">آیتم</InputLabel>
|
||||
<Select
|
||||
{...field}
|
||||
labelId="demo-error-label"
|
||||
id="item"
|
||||
value={loadingItemsList ? "loading" : field.value || ""}
|
||||
label="ایتم"
|
||||
label="آیتم"
|
||||
onChange={field.onChange}
|
||||
>
|
||||
{loadingItemsList ? (
|
||||
|
||||
@@ -232,7 +232,7 @@ const SubItemsReports = () => {
|
||||
.matches(/^\d{4}-\d{2}-\d{2}$/, "تاریخ پایان الزامی است!")
|
||||
.test("is-valid-date", "تاریخ پایان معتبر نیست!", (value) => moment(value, "YYYY-MM-DD", true).isValid()),
|
||||
province_id: yup.string().nullable(),
|
||||
item: yup.number().required("ایتم مورد نظر را وارد کنید!!!"),
|
||||
item: yup.number().required("آیتم مورد نظر را وارد کنید!!!"),
|
||||
});
|
||||
|
||||
const { control, handleSubmit } = useForm({
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
import { Box, Card, IconButton, Stack, Typography } from "@mui/material";
|
||||
import DeleteIcon from "@mui/icons-material/Delete";
|
||||
import React from "react";
|
||||
import MinorCrashIcon from "@mui/icons-material/MinorCrash";
|
||||
|
||||
const DamageItemInfo = ({ deleteDamageItem, selectedDamageItem, damageItemList }) => {
|
||||
const itemDamageId = damageItemList.find((item) => item.id == selectedDamageItem.items_damge_id);
|
||||
return (
|
||||
<Card
|
||||
elevation={0}
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
border: 1,
|
||||
borderColor: "divider",
|
||||
px: 1,
|
||||
py: 1,
|
||||
}}
|
||||
>
|
||||
<Box sx={{ display: "flex" }}>
|
||||
<MinorCrashIcon color="primary" sx={{ width: "50px", height: "50px" }} />
|
||||
<Stack sx={{ ml: 1, justifyContent: "center" }}>
|
||||
<Typography variant="body1" sx={{ letterSpacing: "1px", fontWeight: 500 }}>
|
||||
{itemDamageId.title}
|
||||
</Typography>
|
||||
<Typography variant="caption">
|
||||
میزان خسارت ({itemDamageId.unit}): {selectedDamageItem.items_damge_value}
|
||||
</Typography>
|
||||
<Typography variant="caption">
|
||||
هزینه خسارت (ریال): {selectedDamageItem.items_damge_amount}
|
||||
</Typography>
|
||||
</Stack>
|
||||
</Box>
|
||||
<Box>
|
||||
<IconButton color="error" onClick={() => deleteDamageItem(selectedDamageItem.items_damge_id)}>
|
||||
<DeleteIcon />
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
export default DamageItemInfo;
|
||||
@@ -1,12 +0,0 @@
|
||||
"use client";
|
||||
import { Dialog } from "@mui/material";
|
||||
import CreateFormContent from "@/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/CreateFormContent";
|
||||
|
||||
const OperatorCreateForm = ({ open, setOpen, mutate }) => {
|
||||
return (
|
||||
<Dialog open={open} fullWidth maxWidth="md">
|
||||
<CreateFormContent setOpen={setOpen} mutate={mutate} />
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
export default OperatorCreateForm;
|
||||
@@ -1,356 +0,0 @@
|
||||
"use client";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { Box, Stack, Typography } from "@mui/material";
|
||||
import DataTableWithAuth from "@/core/components/DataTableWithAuth";
|
||||
import Toolbar from "./Toolbar";
|
||||
import { GET_TECHNICAL_DAMAGE_OPERATOR_LIST } from "@/core/utils/routes";
|
||||
import moment from "jalali-moment";
|
||||
import RowActions from "./RowActions";
|
||||
import useProvinces from "@/lib/hooks/useProvince";
|
||||
import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency";
|
||||
import useEdaratLists from "@/lib/hooks/useEdaratLists";
|
||||
import ImageDialog from "./RowActions/ImageDialog";
|
||||
import LocationForm from "./RowActions/LocationForm";
|
||||
import ShowPlate from "./RowActions/ShowPlate";
|
||||
|
||||
const OperatorList = () => {
|
||||
const statusOptions = [
|
||||
{ value: 0, label: "بدون اقدام" },
|
||||
{ value: 1, label: "صدور نامه بیمه و کارشناسی داغی" },
|
||||
{ value: 2, label: "فیش ها ثبت شده است" },
|
||||
{ value: 3, label: "فاکتور صادر شده است" },
|
||||
{ value: 4, label: "فاکتور پرداخت شده است" },
|
||||
{ value: 5, label: "نامه پلیس راه صادر شده است" },
|
||||
];
|
||||
const columns = useMemo(() => {
|
||||
return [
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: "کد یکتا", // Unique Code
|
||||
id: "id",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
},
|
||||
{
|
||||
accessorKey: "province_id",
|
||||
header: "استان",
|
||||
id: "province_id",
|
||||
enableColumnFilter: true,
|
||||
datatype: "numeric",
|
||||
filterMode: "equals",
|
||||
grow: false,
|
||||
size: 130,
|
||||
ColumnSelectComponent: (props) => {
|
||||
const { provinces, errorProvinces, loadingProvinces } = useProvinces();
|
||||
const getColumnSelectOptions = useMemo(() => {
|
||||
if (loadingProvinces) {
|
||||
return [{ value: "loading", label: "در حال بارگذاری..." }];
|
||||
}
|
||||
if (errorProvinces) {
|
||||
return [{ value: "error", label: "خطا در بارگذاری" }];
|
||||
}
|
||||
return [
|
||||
{ value: "", label: "کل کشور" },
|
||||
...provinces.map((province) => ({
|
||||
value: province.id,
|
||||
label: province.name_fa,
|
||||
})),
|
||||
];
|
||||
}, [provinces, errorProvinces, loadingProvinces]);
|
||||
return (
|
||||
<CustomSelectByDependency
|
||||
{...props}
|
||||
value={loadingProvinces ? "loading" : props.filterParameters.value}
|
||||
columnSelectOption={getColumnSelectOptions}
|
||||
/>
|
||||
);
|
||||
},
|
||||
Cell: ({ row }) => <>{row.original.province_fa}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "city_id",
|
||||
header: "شهرستان", // Office
|
||||
id: "city_id",
|
||||
enableColumnFilter: true,
|
||||
datatype: "numeric",
|
||||
filterMode: "equals",
|
||||
dependencyId: "province_id",
|
||||
grow: false,
|
||||
size: 120,
|
||||
ColumnSelectComponent: (props) => {
|
||||
const { edaratList, loadingEdaratList, errorEdaratList } = useEdaratLists(
|
||||
props.dependencyFieldValue.value
|
||||
);
|
||||
const [prevDependency, setPrevDependency] = useState(props.dependencyFieldValue.value);
|
||||
|
||||
const getColumnSelectOptions = useMemo(() => {
|
||||
if (props.dependencyFieldValue.value === "") {
|
||||
return [{ value: "empty", label: "ابتدا استان را انتخاب کنید" }];
|
||||
}
|
||||
if (loadingEdaratList) {
|
||||
return [{ value: "loading", label: "در حال بارگذاری..." }];
|
||||
}
|
||||
if (errorEdaratList) {
|
||||
return [{ value: "error", label: "خطا در بارگذاری" }];
|
||||
}
|
||||
return [
|
||||
{ value: "", label: "شهر" },
|
||||
...edaratList.map((edare) => ({
|
||||
value: edare.id,
|
||||
label: edare.name_fa,
|
||||
})),
|
||||
];
|
||||
}, [edaratList, loadingEdaratList, errorEdaratList]);
|
||||
useEffect(() => {
|
||||
if (prevDependency === props.dependencyFieldValue?.value) return;
|
||||
props.handleChange({ ...props.filterParameters, value: "" });
|
||||
setPrevDependency(props.dependencyFieldValue?.value);
|
||||
}, [props.dependencyFieldValue?.value]);
|
||||
return (
|
||||
<CustomSelectByDependency
|
||||
{...props}
|
||||
value={
|
||||
props.dependencyFieldValue?.value === ""
|
||||
? "empty"
|
||||
: loadingEdaratList
|
||||
? "loading"
|
||||
: props.filterParameters.value
|
||||
}
|
||||
columnSelectOption={getColumnSelectOptions}
|
||||
/>
|
||||
);
|
||||
},
|
||||
Cell: ({ row }) => <>{row.original.city_fa}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "axis_name",
|
||||
header: "نام محور",
|
||||
id: "axis_name",
|
||||
enableColumnFilter: true,
|
||||
enableSorting: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 120,
|
||||
},
|
||||
{
|
||||
accessorKey: "accident_type",
|
||||
header: "نوع تصادف", // Value
|
||||
id: "accident_type",
|
||||
enableColumnFilter: true,
|
||||
enableSorting: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 120,
|
||||
Cell: ({ row }) => <>{row.original.accident_type_fa}</>,
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => {
|
||||
const formattedDate = moment(row.accident_date, "YYYY-MM-DD"); // تنظیم فرمت صحیح تاریخ
|
||||
const formattedTime = row.accident_time || "00:00:00"; // در صورت خالی بودن مقدار، مقدار پیشفرض داده شود
|
||||
return moment(`${formattedDate.format("YYYY-MM-DD")}T${formattedTime}`)
|
||||
.locale("fa")
|
||||
.format("HH:mm | YYYY/MM/DD");
|
||||
},
|
||||
header: "تاریخ تصادف",
|
||||
id: "accident_date",
|
||||
enableColumnFilter: true,
|
||||
datatype: "date",
|
||||
filterMode: "between",
|
||||
grow: false,
|
||||
size: 100,
|
||||
},
|
||||
{
|
||||
accessorKey: "files",
|
||||
header: "تصاویر",
|
||||
id: "files",
|
||||
enableColumnFilter: false,
|
||||
enableSorting: false,
|
||||
datatype: "array",
|
||||
grow: false,
|
||||
size: 100,
|
||||
muiTableBodyCellProps: {
|
||||
sx: {
|
||||
borderLeft: "1px solid #e1e1e1",
|
||||
py: 0,
|
||||
"&:first-of-type": {
|
||||
borderLeft: "unset",
|
||||
},
|
||||
},
|
||||
},
|
||||
Cell: ({ row }) => {
|
||||
if (row.original.damage_picture1) {
|
||||
const imagesList = [row.original.damage_picture1, row.original.damage_picture2];
|
||||
return (
|
||||
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||
<ImageDialog images={imagesList} />
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Typography textAlign={"center"} variant="body2">
|
||||
بدون تصویر
|
||||
</Typography>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "location",
|
||||
header: "موقعیت",
|
||||
id: "location",
|
||||
enableColumnFilter: false,
|
||||
enableSorting: false,
|
||||
datatype: "array",
|
||||
grow: false,
|
||||
size: 100,
|
||||
muiTableBodyCellProps: {
|
||||
sx: {
|
||||
borderLeft: "1px solid #e1e1e1",
|
||||
py: 0,
|
||||
"&:first-of-type": {
|
||||
borderLeft: "unset",
|
||||
},
|
||||
},
|
||||
},
|
||||
Cell: ({ row }) => {
|
||||
return (
|
||||
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||
<LocationForm start_lat={row.original.lat} start_lng={row.original.lng} />
|
||||
</Stack>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "sum",
|
||||
header: "مبلغ کل خسارت (ریال)",
|
||||
id: "sum",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
sortDescFirst: true,
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => (
|
||||
<Typography variant={"body2"} sx={{ margin: 1 }} component="span">
|
||||
{(row.original.sum / 1).toLocaleString()}
|
||||
</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "plaque",
|
||||
header: "پلاک",
|
||||
id: "plaque",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: true,
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ renderedCellValue }) => <ShowPlate plate={renderedCellValue} />,
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"),
|
||||
header: "تاریخ ثبت",
|
||||
id: "created_at",
|
||||
enableColumnFilter: true,
|
||||
datatype: "date",
|
||||
filterMode: "between",
|
||||
grow: false,
|
||||
size: 100,
|
||||
},
|
||||
{
|
||||
accessorKey: "status",
|
||||
header: "اخرین وضعیت",
|
||||
id: "status",
|
||||
enableColumnFilter: true,
|
||||
datatype: "numeric",
|
||||
filterMode: "equals",
|
||||
grow: false,
|
||||
size: 100,
|
||||
columnSelectOption: () => {
|
||||
return statusOptions.map((status) => ({
|
||||
value: status.value,
|
||||
label: status.label,
|
||||
}));
|
||||
},
|
||||
Cell: ({ row }) => {
|
||||
return <Typography variant={"body2"}>{row.original.status_fa}</Typography>;
|
||||
},
|
||||
},
|
||||
{
|
||||
header: "اطلاعات واریز",
|
||||
id: "items",
|
||||
enableColumnFilter: false,
|
||||
enableSorting: false,
|
||||
grow: false,
|
||||
size: 50,
|
||||
columns: [
|
||||
{
|
||||
header: "مبلغ فیش (ریال)",
|
||||
id: "final_amount",
|
||||
enableColumnFilter: false,
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => (
|
||||
<Typography variant={"body2"} sx={{ margin: 1 }} component="span">
|
||||
{(row.original.final_amount / 1).toLocaleString()}
|
||||
</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
header: "مبلغ بیمه (ریال)",
|
||||
id: "deposit_insurance_amount",
|
||||
enableColumnFilter: false,
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => (
|
||||
<Typography variant={"body2"} sx={{ margin: 1 }} component="span">
|
||||
{(row.original.deposit_insurance_amount / 1).toLocaleString()}
|
||||
</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
header: "مبلغ داغی (ریال)",
|
||||
id: "deposit_daghi_amount",
|
||||
enableColumnFilter: false,
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => (
|
||||
<Typography variant={"body2"} sx={{ margin: 1 }} component="span">
|
||||
{(row.original.deposit_daghi_amount / 1).toLocaleString()}
|
||||
</Typography>
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box sx={{ p: 1, border: 1, borderColor: "divider", borderRadius: 1 }}>
|
||||
<DataTableWithAuth
|
||||
need_filter={true}
|
||||
columns={columns}
|
||||
table_url={GET_TECHNICAL_DAMAGE_OPERATOR_LIST}
|
||||
page_name={"operatorTechnicalBuildingDamage"}
|
||||
table_name={"operatorList"}
|
||||
TableToolbar={Toolbar}
|
||||
enableRowActions
|
||||
positionActionsColumn={"last"}
|
||||
RowActions={RowActions}
|
||||
/>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default OperatorList;
|
||||
@@ -1,6 +0,0 @@
|
||||
import { Box } from "@mui/material";
|
||||
|
||||
const RowActions = ({ row }) => {
|
||||
return <Box sx={{ display: "flex", gap: 1 }}></Box>;
|
||||
};
|
||||
export default RowActions;
|
||||
@@ -154,7 +154,7 @@ export const pageMenu = [
|
||||
Subitems: [
|
||||
{
|
||||
id: "roadItemManagmentReportProvince",
|
||||
label: "تعداد فعالیت ها به تفکیک ایتم",
|
||||
label: "تعداد فعالیت ها به تفکیک آیتم",
|
||||
type: "page",
|
||||
route: "/dashboard/road-items/reports/items-report",
|
||||
permissions: [
|
||||
@@ -468,7 +468,7 @@ export const pageMenu = [
|
||||
id: "receiptManagmentOparationCartable",
|
||||
label: "کارتابل",
|
||||
type: "page",
|
||||
route: "/dashboard/technical-building-damage/operator",
|
||||
route: "/dashboard/damages/operator",
|
||||
permissions: ["all"],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -87,7 +87,18 @@ export const ATIVITY_RECEIPT_DAMAGE_ITEMS = api + "/api/v3/damages/activate";
|
||||
|
||||
// damage receipt
|
||||
export const GET_TECHNICAL_DAMAGE_OPERATOR_LIST = api + "/api/v3/receipts";
|
||||
export const CREATE_DAMAGE = api + "/api/v3/receipts";
|
||||
export const GET_DAMAGE_ITEM_LIST = api + "/api/v3/damages/list";
|
||||
export const DELETE_DAMAGE_ITEM = api + "/api/v3/receipts";
|
||||
export const CREATE_FACTOR_DAMAGE = api + "/api/v3/receipts/submit_invoice";
|
||||
export const CONFIRM_PAYMENT_INFO = api + "/api/v3/receipts/confirm_payment_info";
|
||||
export const CHECK_PAYMENT_STATUS = api + "/api/v3/receipts/check_payment_status";
|
||||
export const SEND_SMS_AGAIN = api + "/api/v3/receipts/send_sms_again";
|
||||
export const EXPORT_DAMAGES_OPERATOR_LIST = api + "/api/v3/receipts/excel_report";
|
||||
export const GET_DAMAGE_ITEM_DETAILS = api + "/api/v3/receipts";
|
||||
export const UPDATE_DAMAGE_ITEM = api + "/api/v3/receipts";
|
||||
export const GET_INSURANCE_PAGE = api + "/api/v3/receipts/generate_insurance_letter";
|
||||
export const GET_POLICERAH_PAGE = api + "/api/v3/receipts/generate_police_document";
|
||||
|
||||
// recept report
|
||||
export const GET_COUNTRY_RECEIPT_REPORT = api + "/api/v3/receipt_reports/country_report";
|
||||
|
||||
Reference in New Issue
Block a user