diff --git a/src/app/(withAuth)/dashboard/damage-items/page.js b/src/app/(withAuth)/dashboard/damage-items/page.js index 23e0190..1a222ae 100644 --- a/src/app/(withAuth)/dashboard/damage-items/page.js +++ b/src/app/(withAuth)/dashboard/damage-items/page.js @@ -3,9 +3,7 @@ import WithPermission from "@/core/middlewares/withPermission"; const Page = () => { return ( - + ); diff --git a/src/app/(withAuth)/dashboard/technical-building-damage/operator/page.js b/src/app/(withAuth)/dashboard/damages/operator/page.js similarity index 81% rename from src/app/(withAuth)/dashboard/technical-building-damage/operator/page.js rename to src/app/(withAuth)/dashboard/damages/operator/page.js index 42644d6..8715b11 100644 --- a/src/app/(withAuth)/dashboard/technical-building-damage/operator/page.js +++ b/src/app/(withAuth)/dashboard/damages/operator/page.js @@ -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 ( diff --git a/src/components/dashboard/damageItems/RowActions/Activity/index.jsx b/src/components/dashboard/damageItems/RowActions/Activity/index.jsx index 4f64584..3683899 100644 --- a/src/components/dashboard/damageItems/RowActions/Activity/index.jsx +++ b/src/components/dashboard/damageItems/RowActions/Activity/index.jsx @@ -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 ; diff --git a/src/components/dashboard/damageItems/RowActions/index.jsx b/src/components/dashboard/damageItems/RowActions/index.jsx index 18aa6ea..8fbaea1 100644 --- a/src/components/dashboard/damageItems/RowActions/index.jsx +++ b/src/components/dashboard/damageItems/RowActions/index.jsx @@ -4,7 +4,7 @@ import Edit from "./Edit"; const RowActions = ({ row, mutate }) => { return ( - + diff --git a/src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/CityController.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/CityController.jsx similarity index 100% rename from src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/CityController.jsx rename to src/components/dashboard/damages/operator/Actions/create/Forms/CityController.jsx diff --git a/src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/CreateFormContent.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx similarity index 77% rename from src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/CreateFormContent.jsx rename to src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx index d7ae67c..bf369b0 100644 --- a/src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/CreateFormContent.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/CreateFormContent.jsx @@ -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 }) => { > } label="اطلاعات تصادف" /> } label="گزارش میزان خسارت" /> - } label="ایتم خسارت" /> + } label="آیتم خسارت" /> @@ -189,7 +188,13 @@ const CreateFormContent = ({ setOpen, mutate }) => { name={"items_damage"} control={control} render={({ field, fieldState: { error } }) => { - return ; + return ( + + ); }} /> @@ -198,6 +203,7 @@ const CreateFormContent = ({ setOpen, mutate }) => { )} diff --git a/src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/DamageAmount.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/DamageAmount.jsx similarity index 87% rename from src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/DamageAmount.jsx rename to src/components/dashboard/damages/operator/Actions/create/Forms/DamageAmount.jsx index b2c7b90..bd8c646 100644 --- a/src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/DamageAmount.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/DamageAmount.jsx @@ -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 ( { return ( { + const StartPoint = useWatch({ control, name: "start_point" }); const { provinces, errorProvinces, loadingProvinces } = useProvinces(); return ( @@ -263,6 +264,7 @@ const DamageInfo = ({ control, setValue, errors }) => { diff --git a/src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/DamageItem.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/DamageItem.jsx similarity index 75% rename from src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/DamageItem.jsx rename to src/components/dashboard/damages/operator/Actions/create/Forms/DamageItem.jsx index 3a5de73..e52c280 100644 --- a/src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/DamageItem.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/DamageItem.jsx @@ -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 }) => { <> ( { )} - + {selectedDamageItemList.length === 0 && ( @@ -118,7 +143,12 @@ const DamageItem = ({ baseOnChange, getValues }) => { overflowY: "auto", }} > - {selectedDamageItemList.length !== 0 && + {loadingDamageItemList ? ( + + + + ) : ( + selectedDamageItemList.length !== 0 && selectedDamageItemList.map((selectedDamageItem, index) => ( { deleteDamageItem={deleteDamageItem} /> - ))} + )) + )} diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/DamageItemInfo.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/DamageItemInfo.jsx new file mode 100644 index 0000000..ca95574 --- /dev/null +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/DamageItemInfo.jsx @@ -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 ( + + + + + + {itemDamageId.title} + + + + میزان خسارت ({itemDamageId.unit}) :{" "} + + {(selectedDamageItem.value / 1).toLocaleString()} + + + + + هزینه خسارت (ریال) :{" "} + + {(selectedDamageItem.amount / 1).toLocaleString()} + + + + + + + deleteDamageItem(selectedDamageItem.id)}> + + + + + ); +}; +export default DamageItemInfo; diff --git a/src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/DamagePrice.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/DamagePrice.jsx similarity index 91% rename from src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/DamagePrice.jsx rename to src/components/dashboard/damages/operator/Actions/create/Forms/DamagePrice.jsx index 02fe21a..96ff80a 100644 --- a/src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/DamagePrice.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/DamagePrice.jsx @@ -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 ( <> { 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))) { diff --git a/src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/DamageReport.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/DamageReport.jsx similarity index 79% rename from src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/DamageReport.jsx rename to src/components/dashboard/damages/operator/Actions/create/Forms/DamageReport.jsx index a649b14..d994aff 100644 --- a/src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/DamageReport.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/DamageReport.jsx @@ -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 }) => { } - /> - } - label="کروکی یا نامه پلیس راه (معرفی فرد به اداره)" - /> - } /> } label="بازدید عوامل و کارشناسان راهداری" /> + } + /> + } + label="کروکی یا نامه پلیس راه (معرفی فرد به اداره)" + /> {selectedOption === "police_file_checkbox" && } diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/ImageUpload.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/ImageUpload.jsx new file mode 100644 index 0000000..5186a4b --- /dev/null +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/ImageUpload.jsx @@ -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 ( + + + {title} + + + {error ? error.message : null} + + ); +}; +export default ImageUpload; diff --git a/src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/PoliceFileReport.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/PoliceFileReport.jsx similarity index 83% rename from src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/PoliceFileReport.jsx rename to src/components/dashboard/damages/operator/Actions/create/Forms/PoliceFileReport.jsx index 9a93566..64f1067 100644 --- a/src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/PoliceFileReport.jsx +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/PoliceFileReport.jsx @@ -49,15 +49,17 @@ const PoliceFileReport = ({ control }) => { ( - - )} + render={({ field, fieldState: { error } }) => { + return ( + + ); + }} /> ); diff --git a/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx b/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx new file mode 100644 index 0000000..4a25e69 --- /dev/null +++ b/src/components/dashboard/damages/operator/Actions/create/Forms/index.jsx @@ -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 ( + + + + ); +}; +export default OperatorCreateForm; diff --git a/src/components/dashboard/technicalBuildingDamage/operator/Actions/create/index.jsx b/src/components/dashboard/damages/operator/Actions/create/index.jsx similarity index 100% rename from src/components/dashboard/technicalBuildingDamage/operator/Actions/create/index.jsx rename to src/components/dashboard/damages/operator/Actions/create/index.jsx diff --git a/src/components/dashboard/damages/operator/ExcelPrint/index.jsx b/src/components/dashboard/damages/operator/ExcelPrint/index.jsx new file mode 100644 index 0000000..f38d451 --- /dev/null +++ b/src/components/dashboard/damages/operator/ExcelPrint/index.jsx @@ -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 ? ( + + + + ) : ( + + )} + + ); +}; +export default PrintExcel; diff --git a/src/components/dashboard/damages/operator/Form/CreateFactor/CreateFactorContent.jsx b/src/components/dashboard/damages/operator/Form/CreateFactor/CreateFactorContent.jsx new file mode 100644 index 0000000..e33e5f8 --- /dev/null +++ b/src/components/dashboard/damages/operator/Form/CreateFactor/CreateFactorContent.jsx @@ -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 ( + <> + + + + + } + label={ + + مبلغ کسری بیمه + + } + /> + + + + {(row.original?.deposit_insurance_amount / 1).toLocaleString() || "0"} ریال + + + + + } + label={ + + مبلغ کسری داغی + + } + /> + + + + {(row.original?.deposit_daghi_amount / 1).toLocaleString() || "0"} ریال + + + + + } + label={ + + مبلغ کل خسارت برآورد شده + + } + /> + + + + {(row.original?.sum / 1).toLocaleString() || "0"} ریال + + + + + } + label={ + + مبلغ قابل پرداخت + + } + /> + + + + {(row.original?.sum / 1).toLocaleString() || "0"} ریال + + + {!factorCreated && ( + + + * + + پس از ایجاد فاکتور امکان تغییر در اطلاعات کاربر و مبالغ وجود نخواهد داشت. + + + + * + + لینک پرداخت فاکتور به شماره {row.original?.driver_phone_number} ارسال خواهد شد. + + + + )} + + + + {factorCreated ? ( + <> + + + + + ) : ( + <> + + + + )} + + + ); +}; +export default CreateFactorContent; diff --git a/src/components/dashboard/damages/operator/Form/CreateFactor/index.jsx b/src/components/dashboard/damages/operator/Form/CreateFactor/index.jsx new file mode 100644 index 0000000..e245e0c --- /dev/null +++ b/src/components/dashboard/damages/operator/Form/CreateFactor/index.jsx @@ -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 ( + <> + + setOpenCreateFactorDialog(true)}> + + + + 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" + > + مدیریت پرداخت + + + + ); +}; +export default CreateFactor; diff --git a/src/components/dashboard/damages/operator/Form/EditForm/EditController.jsx b/src/components/dashboard/damages/operator/Form/EditForm/EditController.jsx new file mode 100644 index 0000000..f545cc6 --- /dev/null +++ b/src/components/dashboard/damages/operator/Form/EditForm/EditController.jsx @@ -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 ? ( + + ) : ( + + )} + + ); +}; +export default EditController; diff --git a/src/components/dashboard/damages/operator/Form/EditForm/index.jsx b/src/components/dashboard/damages/operator/Form/EditForm/index.jsx new file mode 100644 index 0000000..9b1b17f --- /dev/null +++ b/src/components/dashboard/damages/operator/Form/EditForm/index.jsx @@ -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 ( + <> + + { + setOpenEditDialog(true); + }} + > + + + + + {openEditDialog && ( + + )} + + + ); +}; +export default EditForm; diff --git a/src/components/dashboard/damages/operator/Form/RegisterInsurance/DaghiFile.jsx b/src/components/dashboard/damages/operator/Form/RegisterInsurance/DaghiFile.jsx new file mode 100644 index 0000000..939e534 --- /dev/null +++ b/src/components/dashboard/damages/operator/Form/RegisterInsurance/DaghiFile.jsx @@ -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 ( + + + + + ( + + )} + /> + + + + ( + + )} + /> + + ); +}; +export default DaghiFile; diff --git a/src/components/dashboard/damages/operator/Form/RegisterInsurance/DaghiPayment.jsx b/src/components/dashboard/damages/operator/Form/RegisterInsurance/DaghiPayment.jsx new file mode 100644 index 0000000..c21dda6 --- /dev/null +++ b/src/components/dashboard/damages/operator/Form/RegisterInsurance/DaghiPayment.jsx @@ -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 ( + <> + + + } + /> + } + label="صورتجلسه تحویل داغی به انبار (بیمه) ندارد" + /> + } + /> + } + label="صورتجلسه تحویل داغی به انبار (بیمه) دارد" + /> + + + + {selectedOption === "has_daghi" && } + + ); +}; +export default DaghiPayment; diff --git a/src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/ImageUpload.jsx b/src/components/dashboard/damages/operator/Form/RegisterInsurance/ImageUpload.jsx similarity index 100% rename from src/components/dashboard/technicalBuildingDamage/operator/Actions/create/Forms/ImageUpload.jsx rename to src/components/dashboard/damages/operator/Form/RegisterInsurance/ImageUpload.jsx diff --git a/src/components/dashboard/damages/operator/Form/RegisterInsurance/InsuranceFile.jsx b/src/components/dashboard/damages/operator/Form/RegisterInsurance/InsuranceFile.jsx new file mode 100644 index 0000000..e96521a --- /dev/null +++ b/src/components/dashboard/damages/operator/Form/RegisterInsurance/InsuranceFile.jsx @@ -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 ( + + + + + ( + + )} + /> + + + + ( + + )} + /> + + ); +}; +export default InsuranceFile; diff --git a/src/components/dashboard/damages/operator/Form/RegisterInsurance/InsurancePayment.jsx b/src/components/dashboard/damages/operator/Form/RegisterInsurance/InsurancePayment.jsx new file mode 100644 index 0000000..50ee912 --- /dev/null +++ b/src/components/dashboard/damages/operator/Form/RegisterInsurance/InsurancePayment.jsx @@ -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 ( + <> + + + } + /> + } + label="فیش واریزی (بیمه) ندارد" + /> + } + /> + } + label="فیش واریزی (بیمه) دارد" + /> + + + {selectedOption === "has_insurance" && } + + ); +}; +export default InsurancePayment; diff --git a/src/components/dashboard/damages/operator/Form/RegisterInsurance/RegisterInsuranceContent.jsx b/src/components/dashboard/damages/operator/Form/RegisterInsurance/RegisterInsuranceContent.jsx new file mode 100644 index 0000000..090609b --- /dev/null +++ b/src/components/dashboard/damages/operator/Form/RegisterInsurance/RegisterInsuranceContent.jsx @@ -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 ( + + ); +} +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 ( + + + } label="فیش واریزی بیمه" /> + } label="صورتجلسه تحویل داغی به انبار" /> + + + + + + + + + + + + {errors[""]?.message && ( + + {errors[""].message} + + )} + + + {tabState !== 1 && ( + + )} + {tabState === 1 && ( + + )} + + + ); +}; +export default RegisterInsuranceContent; diff --git a/src/components/dashboard/damages/operator/Form/RegisterInsurance/index.jsx b/src/components/dashboard/damages/operator/Form/RegisterInsurance/index.jsx new file mode 100644 index 0000000..8a02fdf --- /dev/null +++ b/src/components/dashboard/damages/operator/Form/RegisterInsurance/index.jsx @@ -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 ( + <> + + setOpenRegisterInsuranceDialog(true)}> + + + + + + + + ); +}; +export default RegisterInsurance; diff --git a/src/components/dashboard/damages/operator/OperatorList.jsx b/src/components/dashboard/damages/operator/OperatorList.jsx new file mode 100644 index 0000000..4bc0359 --- /dev/null +++ b/src/components/dashboard/damages/operator/OperatorList.jsx @@ -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 ( + + ); + }, + 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 ( + + ); + }, + 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 ( + + + + ); + } + return ( + + بدون تصویر + + ); + }, + }, + { + 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 ( + + + + ); + }, + }, + { + accessorKey: "plaque", + header: "پلاک", + id: "plaque", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + sortDescFirst: true, + grow: false, + size: 100, + Cell: ({ 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 ( + + + + ); + }, + }, + { + accessorKey: "sum", + header: "مبلغ کل خسارت (ریال)", + id: "sum", + enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + columnFilterModeOptions: ["equals", "contains"], + sortDescFirst: true, + grow: false, + size: 100, + Cell: ({ row }) => ( + + {(row.original.sum / 1).toLocaleString()} + + ), + }, + ], + }, + { + header: "اطلاعات واریز", + id: "items", + enableColumnFilter: false, + enableSorting: false, + grow: false, + size: 50, + columns: [ + { + header: "مبلغ فیش (ریال)", + id: "final_amount", + enableColumnFilter: false, + grow: false, + size: 100, + Cell: ({ row }) => ( + + {(row.original.final_amount / 1).toLocaleString()} + + ), + }, + { + header: "مبلغ بیمه (ریال)", + id: "deposit_insurance_amount", + enableColumnFilter: false, + grow: false, + size: 100, + Cell: ({ row }) => ( + + {(row.original.deposit_insurance_amount / 1).toLocaleString()} + + ), + }, + { + header: "مبلغ داغی (ریال)", + id: "deposit_daghi_amount", + enableColumnFilter: false, + grow: false, + size: 100, + Cell: ({ row }) => ( + + {(row.original.deposit_daghi_amount / 1).toLocaleString()} + + ), + }, + ], + }, + { + 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 {row.original.status_fa}; + }, + }, + ]; + }, []); + + return ( + <> + + + + + ); +}; +export default OperatorList; diff --git a/src/components/dashboard/damages/operator/RowActions/DamageItemDialog/DamageItemContent.jsx b/src/components/dashboard/damages/operator/RowActions/DamageItemDialog/DamageItemContent.jsx new file mode 100644 index 0000000..e9a76e5 --- /dev/null +++ b/src/components/dashboard/damages/operator/RowActions/DamageItemDialog/DamageItemContent.jsx @@ -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 ( + <> + + {loading ? ( + + ) : data ? ( + + + + + نوع خسارت + میزان خسارت + هزینه خسارت (ریال) + + + + {data.map((item) => { + return ( + + {item?.title} + + {(item?.pivot?.value / 1).toLocaleString()} ({item?.pivot?.unit}) + + {(item?.pivot?.amount / 1).toLocaleString()} + + ); + })} + +
+
+ ) : ( + اطلاعات یافت نشد + )} +
+ + ); +}; +export default DamageItemContent; diff --git a/src/components/dashboard/damages/operator/RowActions/DamageItemDialog/index.jsx b/src/components/dashboard/damages/operator/RowActions/DamageItemDialog/index.jsx new file mode 100644 index 0000000..6164de2 --- /dev/null +++ b/src/components/dashboard/damages/operator/RowActions/DamageItemDialog/index.jsx @@ -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 ( + <> + + setOpenDamageItemDialog(true)}> + + + + 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"} + > + آیتم های خسارت + {openDamageItemDialog && } + + + + + + ); +}; +export default DamageItemDialog; diff --git a/src/components/dashboard/damages/operator/RowActions/DeleteDialog/DeleteContent.jsx b/src/components/dashboard/damages/operator/RowActions/DeleteDialog/DeleteContent.jsx new file mode 100644 index 0000000..28791c7 --- /dev/null +++ b/src/components/dashboard/damages/operator/RowActions/DeleteDialog/DeleteContent.jsx @@ -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 ( + <> + + + آیا از حذف فعالیت اطمینان دارید؟ + + + + + + + + ); +}; +export default DeleteContent; diff --git a/src/components/dashboard/damages/operator/RowActions/DeleteDialog/index.jsx b/src/components/dashboard/damages/operator/RowActions/DeleteDialog/index.jsx new file mode 100644 index 0000000..b7f6d4b --- /dev/null +++ b/src/components/dashboard/damages/operator/RowActions/DeleteDialog/index.jsx @@ -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 ( + <> + + setOpenDeleteDialog(true)}> + + + + 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"} + > + حذف فعالیت + + + + ); +}; +export default DeleteDialog; diff --git a/src/components/dashboard/technicalBuildingDamage/operator/RowActions/ImageDialog/ImageFormContent.jsx b/src/components/dashboard/damages/operator/RowActions/ImageDialog/ImageFormContent.jsx similarity index 100% rename from src/components/dashboard/technicalBuildingDamage/operator/RowActions/ImageDialog/ImageFormContent.jsx rename to src/components/dashboard/damages/operator/RowActions/ImageDialog/ImageFormContent.jsx diff --git a/src/components/dashboard/technicalBuildingDamage/operator/RowActions/ImageDialog/index.jsx b/src/components/dashboard/damages/operator/RowActions/ImageDialog/index.jsx similarity index 100% rename from src/components/dashboard/technicalBuildingDamage/operator/RowActions/ImageDialog/index.jsx rename to src/components/dashboard/damages/operator/RowActions/ImageDialog/index.jsx diff --git a/src/components/dashboard/technicalBuildingDamage/operator/RowActions/LocationForm/LocationFormContent.jsx b/src/components/dashboard/damages/operator/RowActions/LocationForm/LocationFormContent.jsx similarity index 100% rename from src/components/dashboard/technicalBuildingDamage/operator/RowActions/LocationForm/LocationFormContent.jsx rename to src/components/dashboard/damages/operator/RowActions/LocationForm/LocationFormContent.jsx diff --git a/src/components/dashboard/technicalBuildingDamage/operator/RowActions/LocationForm/index.jsx b/src/components/dashboard/damages/operator/RowActions/LocationForm/index.jsx similarity index 100% rename from src/components/dashboard/technicalBuildingDamage/operator/RowActions/LocationForm/index.jsx rename to src/components/dashboard/damages/operator/RowActions/LocationForm/index.jsx diff --git a/src/components/dashboard/damages/operator/RowActions/PoliceRahLetter/PoliceRahLetterContent.jsx b/src/components/dashboard/damages/operator/RowActions/PoliceRahLetter/PoliceRahLetterContent.jsx new file mode 100644 index 0000000..8495455 --- /dev/null +++ b/src/components/dashboard/damages/operator/RowActions/PoliceRahLetter/PoliceRahLetterContent.jsx @@ -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 ( + <> + + + آیا از صدور نامه به پلیس راه اطمینان دارید؟ + + + + + + + + ); +}; +export default PoliceRahLetterContent; diff --git a/src/components/dashboard/damages/operator/RowActions/PoliceRahLetter/index.jsx b/src/components/dashboard/damages/operator/RowActions/PoliceRahLetter/index.jsx new file mode 100644 index 0000000..cbdb3c6 --- /dev/null +++ b/src/components/dashboard/damages/operator/RowActions/PoliceRahLetter/index.jsx @@ -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 ( + <> + + setOpenPoliceRahDialog(true)}> + + + + 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" + > + صدور نامه پلیس راه + + + + ); +}; +export default PoliceRahLetter; diff --git a/src/components/dashboard/damages/operator/RowActions/SendToInsurance/SendToInsuranceContent.jsx b/src/components/dashboard/damages/operator/RowActions/SendToInsurance/SendToInsuranceContent.jsx new file mode 100644 index 0000000..704f517 --- /dev/null +++ b/src/components/dashboard/damages/operator/RowActions/SendToInsurance/SendToInsuranceContent.jsx @@ -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 ( + <> + + + آیا از صدور نامه بیمه اطمینان دارید؟ + + + + + + + + ); +}; +export default SendToInsuranceContent; diff --git a/src/components/dashboard/damages/operator/RowActions/SendToInsurance/index.jsx b/src/components/dashboard/damages/operator/RowActions/SendToInsurance/index.jsx new file mode 100644 index 0000000..e32a85b --- /dev/null +++ b/src/components/dashboard/damages/operator/RowActions/SendToInsurance/index.jsx @@ -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 ( + <> + + setOpenSendInsuranceDialog(true)}> + + + + 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" + > + نامه بیمه + + + + ); +}; +export default SendToInsurance; diff --git a/src/components/dashboard/technicalBuildingDamage/operator/RowActions/ShowPlate/index.jsx b/src/components/dashboard/damages/operator/RowActions/ShowPlate/index.jsx similarity index 90% rename from src/components/dashboard/technicalBuildingDamage/operator/RowActions/ShowPlate/index.jsx rename to src/components/dashboard/damages/operator/RowActions/ShowPlate/index.jsx index 90d3ad0..af1f495 100644 --- a/src/components/dashboard/technicalBuildingDamage/operator/RowActions/ShowPlate/index.jsx +++ b/src/components/dashboard/damages/operator/RowActions/ShowPlate/index.jsx @@ -3,10 +3,10 @@ import { Stack } from "@mui/material"; const ShowPlate = ({ plate }) => { return ( - + {plate.split("-")[3]} - + { + return ( + + {[0, 1, 2].includes(row.original?.status) && } + {[1, 2].includes(row.original?.status) && ( + + )} + {[2, 3].includes(row.original?.status) && ( + + )} + {[4, 5].includes(row.original?.status) && } + {[0, 1, 2].includes(row.original?.status) && ( + + )} + + + ); +}; +export default RowActions; diff --git a/src/components/dashboard/technicalBuildingDamage/operator/Toolbar.jsx b/src/components/dashboard/damages/operator/Toolbar.jsx similarity index 73% rename from src/components/dashboard/technicalBuildingDamage/operator/Toolbar.jsx rename to src/components/dashboard/damages/operator/Toolbar.jsx index b774945..7c3ea62 100644 --- a/src/components/dashboard/technicalBuildingDamage/operator/Toolbar.jsx +++ b/src/components/dashboard/damages/operator/Toolbar.jsx @@ -1,9 +1,11 @@ import { Box } from "@mui/material"; import OperatorCreate from "./Actions/create"; +import PrintExcel from "./ExcelPrint"; const Toolbar = ({ table, filterData, mutate }) => { return ( + ); diff --git a/src/components/dashboard/technicalBuildingDamage/operator/index.jsx b/src/components/dashboard/damages/operator/index.jsx similarity index 100% rename from src/components/dashboard/technicalBuildingDamage/operator/index.jsx rename to src/components/dashboard/damages/operator/index.jsx diff --git a/src/components/dashboard/roadItems/operator/Actions/ObservedGashtCreate/TableInfo.jsx b/src/components/dashboard/roadItems/operator/Actions/ObservedGashtCreate/TableInfo.jsx index 73f9cdd..ca60b84 100644 --- a/src/components/dashboard/roadItems/operator/Actions/ObservedGashtCreate/TableInfo.jsx +++ b/src/components/dashboard/roadItems/operator/Actions/ObservedGashtCreate/TableInfo.jsx @@ -43,7 +43,7 @@ const TableInfo = ({ specialFilter, setTabState, setItemInfo }) => { }, { accessorKey: "item_name", - header: "نام ایتم", + header: "نام آیتم", id: "item_name", enableColumnFilter: false, datatype: "text", diff --git a/src/components/dashboard/roadItems/reports/ItemsReports/ExcelPrint/index.jsx b/src/components/dashboard/roadItems/reports/ItemsReports/ExcelPrint/index.jsx index 0e70403..bf00587 100644 --- a/src/components/dashboard/roadItems/reports/ItemsReports/ExcelPrint/index.jsx +++ b/src/components/dashboard/roadItems/reports/ItemsReports/ExcelPrint/index.jsx @@ -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(() => {}) diff --git a/src/components/dashboard/roadItems/reports/ItemsReports/ReportLists.jsx b/src/components/dashboard/roadItems/reports/ItemsReports/ReportLists.jsx index 80821f8..b739780 100644 --- a/src/components/dashboard/roadItems/reports/ItemsReports/ReportLists.jsx +++ b/src/components/dashboard/roadItems/reports/ItemsReports/ReportLists.jsx @@ -66,7 +66,7 @@ const ReportLists = ({ itemsList, data, specialFilter }) => { }, }, { - header: "ایتم های فعالیت روزانه", + header: "آیتم های فعالیت روزانه", id: "items", enableColumnFilter: false, enableSorting: false, diff --git a/src/components/dashboard/roadItems/reports/ItemsReports/index.jsx b/src/components/dashboard/roadItems/reports/ItemsReports/index.jsx index 528be1a..f485c51 100644 --- a/src/components/dashboard/roadItems/reports/ItemsReports/index.jsx +++ b/src/components/dashboard/roadItems/reports/ItemsReports/index.jsx @@ -157,7 +157,7 @@ const ReportPage = () => { }); return ( - + { control={control} render={({ field, fieldState: { error } }) => ( - ایتم + آیتم