Feature/amiriis missions
This commit is contained in:
@@ -1,33 +1,33 @@
|
||||
import SelectBox from "@/core/components/SelectBox";
|
||||
import useCities from "@/lib/hooks/useCities";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
const CityContent = ({ provinceID, field, fieldState: { error } }) => {
|
||||
const { cityList, loadingCityList, errorCityList } = useCities(provinceID);
|
||||
const [prevDependency, setPrevDependency] = useState(provinceID);
|
||||
|
||||
useEffect(() => {
|
||||
if (prevDependency === provinceID) return;
|
||||
field.onChange(null);
|
||||
setPrevDependency(provinceID);
|
||||
}, [provinceID]);
|
||||
|
||||
return (
|
||||
<SelectBox
|
||||
value={
|
||||
!provinceID ? "dependency" : errorCityList ? "error" : loadingCityList ? "loading" : field.value || ""
|
||||
}
|
||||
label={"شهرستان"}
|
||||
selectors={cityList}
|
||||
schema={{ name: "name_fa", value: "id" }}
|
||||
error={error}
|
||||
onChange={field.onChange}
|
||||
helperText={error?.message}
|
||||
isLoading={loadingCityList}
|
||||
errorEcured={errorCityList}
|
||||
isDependency={!provinceID}
|
||||
dependencyLabel={"ابتدا استان را انتخاب کنید"}
|
||||
/>
|
||||
);
|
||||
};
|
||||
export default CityContent;
|
||||
import SelectBox from "@/core/components/SelectBox";
|
||||
import useCities from "@/lib/hooks/useCities";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
const CityContent = ({ provinceID, field, fieldState: { error } }) => {
|
||||
const { cityList, loadingCityList, errorCityList } = useCities(provinceID);
|
||||
const [prevDependency, setPrevDependency] = useState(provinceID);
|
||||
|
||||
useEffect(() => {
|
||||
if (prevDependency === provinceID) return;
|
||||
field.onChange(null);
|
||||
setPrevDependency(provinceID);
|
||||
}, [provinceID]);
|
||||
|
||||
return (
|
||||
<SelectBox
|
||||
value={
|
||||
!provinceID ? "dependency" : errorCityList ? "error" : loadingCityList ? "loading" : field.value || ""
|
||||
}
|
||||
label={"شهرستان"}
|
||||
selectors={cityList}
|
||||
schema={{ name: "name_fa", value: "id" }}
|
||||
error={error}
|
||||
onChange={field.onChange}
|
||||
helperText={error?.message}
|
||||
isLoading={loadingCityList}
|
||||
errorEcured={errorCityList}
|
||||
isDependency={!provinceID}
|
||||
dependencyLabel={"ابتدا استان را انتخاب کنید"}
|
||||
/>
|
||||
);
|
||||
};
|
||||
export default CityContent;
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import SelectBox from "@/core/components/SelectBox";
|
||||
import useEdaratLists from "@/lib/hooks/useEdaratLists";
|
||||
import { Controller, useWatch } from "react-hook-form";
|
||||
import CityContent from "./CityContent";
|
||||
|
||||
const CityController = ({ control }) => {
|
||||
const provinceID = useWatch({ control, name: "province_id" });
|
||||
return (
|
||||
<Controller
|
||||
name="city_id"
|
||||
control={control}
|
||||
render={(props) => <CityContent provinceID={provinceID} {...props} />}
|
||||
/>
|
||||
);
|
||||
};
|
||||
export default CityController;
|
||||
import SelectBox from "@/core/components/SelectBox";
|
||||
import useEdaratLists from "@/lib/hooks/useEdaratLists";
|
||||
import { Controller, useWatch } from "react-hook-form";
|
||||
import CityContent from "./CityContent";
|
||||
|
||||
const CityController = ({ control }) => {
|
||||
const provinceID = useWatch({ control, name: "province_id" });
|
||||
return (
|
||||
<Controller
|
||||
name="city_id"
|
||||
control={control}
|
||||
render={(props) => <CityContent provinceID={provinceID} {...props} />}
|
||||
/>
|
||||
);
|
||||
};
|
||||
export default CityController;
|
||||
|
||||
@@ -1,262 +1,262 @@
|
||||
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 { Box, Button, DialogActions, DialogContent, Tab, Tabs } from "@mui/material";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import InfoIcon from "@mui/icons-material/Info";
|
||||
import ExitToAppIcon from "@mui/icons-material/ExitToApp";
|
||||
import KeyboardDoubleArrowRightIcon from "@mui/icons-material/KeyboardDoubleArrowRight";
|
||||
import BeenhereIcon from "@mui/icons-material/Beenhere";
|
||||
import MinorCrashIcon from "@mui/icons-material/MinorCrash";
|
||||
import DamageInfo from "./DamageInfo";
|
||||
import KeyboardDoubleArrowLeftIcon from "@mui/icons-material/KeyboardDoubleArrowLeft";
|
||||
import DamageReport from "./DamageReport";
|
||||
import DamageItem from "./DamageItem";
|
||||
import validateNationalCode from "@/core/utils/nationalCodeValidation";
|
||||
import AssessmentIcon from "@mui/icons-material/Assessment";
|
||||
|
||||
function TabPanel(props) {
|
||||
const { children, value, index } = props;
|
||||
return (
|
||||
<div role="tabpanel" hidden={value !== index}>
|
||||
{value === index && <Box>{children}</Box>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const validationSchema = object({
|
||||
accident_date: string().required("لطفا تاریخ تصادف را وارد کنید!!!"),
|
||||
accident_time: string().required("لطفا زمان تصادف را وارد کنید!!!"),
|
||||
accident_type: string().required("لطفا نوع تصادف را وارد کنید!!!"),
|
||||
province_id: number().required("لطفا استان را وارد کنید!!!"),
|
||||
city_id: number().required("لطفا شهرستان را وارد کنید!!!"),
|
||||
axis_name: string().required("لطفا نام محور را وارد کنید!!!"),
|
||||
driver_name: string().when("isForeign", {
|
||||
is: "0",
|
||||
then: (schema) => schema.required("لطفا نام و نام خانوادگی را وارد کنید!!!"),
|
||||
}),
|
||||
phone_number: string().when("isForeign", {
|
||||
is: "0",
|
||||
then: (schema) =>
|
||||
schema
|
||||
.matches(/^09\d{9}$/, "شماره موبایل باید با 09 شروع شده و 11 رقم باشد")
|
||||
.required("لطفا تلفن همراه را وارد کنید!!!"),
|
||||
}),
|
||||
national_code: mixed().when("isForeign", {
|
||||
is: "0",
|
||||
then: (schema) =>
|
||||
schema
|
||||
.test("max", "کد ملی باید شامل 10 رقم باشد", (value) => value.toString().length === 10)
|
||||
.test("validation", "کد ملی صحیح نمی باشد", (value) => validateNationalCode(value))
|
||||
.required("لطفا کد ملی را وارد کنید!!!"),
|
||||
}),
|
||||
start_point: mixed()
|
||||
.test("start-point-required", "لطفاً نقطه تصادف را مشخص کنید!", function (value) {
|
||||
return !!value;
|
||||
})
|
||||
.required("لطفاً نقطه تصادف را مشخص کنید!"),
|
||||
plate_part1: mixed().when("isForeign", {
|
||||
is: "0",
|
||||
then: (schema) =>
|
||||
schema.test("max", "2رقم", (value) => value.toString().length === 2).required("plate_part1 الزامیست"),
|
||||
}),
|
||||
plate_part2: mixed().when("isForeign", {
|
||||
is: "0",
|
||||
then: (schema) => schema.required("plate_part2 الزامیست"),
|
||||
}),
|
||||
plate_part3: mixed().when("isForeign", {
|
||||
is: "0",
|
||||
then: (schema) =>
|
||||
schema.test("max", "3رقم", (value) => value.toString().length === 3).required("plate_part3الزامیست"),
|
||||
}),
|
||||
|
||||
plate_part4: mixed().when("isForeign", {
|
||||
is: "0",
|
||||
then: (schema) =>
|
||||
schema.test("max", "2رقم", (value) => value.toString().length === 2).required("plate_part4الزامیست"),
|
||||
}),
|
||||
damage_picture1: mixed().nullable().required("لطفا عکس تصادف را بارگذاری کنید!"),
|
||||
damage_picture2: mixed().nullable().required("لطفا عکس تصادف را بارگذاری کنید!"),
|
||||
police_serial: string().when("radio_button", {
|
||||
is: "police_file_checkbox", // زمانی که گزینه "police_file_checkbox" انتخاب شده باشد
|
||||
then: (schema) => schema.required("شماره کروکی یا نامه پلیس راه الزامی است"),
|
||||
}),
|
||||
police_file_date: string().when("radio_button", {
|
||||
is: "police_file_checkbox", // زمانی که گزینه "police_file_checkbox" انتخاب شده باشد
|
||||
then: (schema) => schema.required("تاریخ کروکی یا نامه پلیس راه الزامی است"),
|
||||
}),
|
||||
police_file: mixed().when("radio_button", {
|
||||
is: "police_file_checkbox", // زمانی که گزینه "police_file_checkbox" انتخاب شده باشد
|
||||
then: (schema) => schema.nullable().required("تصویر کروکی یا نامه پلیس راه الزامی است"),
|
||||
otherwise: (schema) => schema.notRequired(),
|
||||
}),
|
||||
items_damage: array().min(1, "حداقل یک آیتم خسارت ضروریست!!!"),
|
||||
});
|
||||
|
||||
const CreateFormContent = ({ setOpen, SubmitDamage, defaultData }) => {
|
||||
const defaultValues = {
|
||||
isForeign: defaultData.isForeign,
|
||||
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,
|
||||
is_province: defaultData.is_province,
|
||||
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(0);
|
||||
const handleClose = () => setOpen(false);
|
||||
const handleChangeTab = (event, newValue) => setTabState(newValue);
|
||||
const handlePrev = () => {
|
||||
if (tabState === 0) {
|
||||
handleClose();
|
||||
} else {
|
||||
setTabState(tabState - 1);
|
||||
}
|
||||
};
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
setValue,
|
||||
trigger,
|
||||
formState: { errors, isSubmitting, isValid },
|
||||
} = useForm({
|
||||
defaultValues,
|
||||
resolver: yupResolver(validationSchema),
|
||||
mode: "all",
|
||||
});
|
||||
const onSubmitBase = async (data) => {
|
||||
await SubmitDamage(data);
|
||||
};
|
||||
const handleNext = async () => {
|
||||
let fieldsToValidate = [];
|
||||
if (tabState === 0) {
|
||||
fieldsToValidate = [
|
||||
"phone_number",
|
||||
"start_point",
|
||||
"plate_part1",
|
||||
"plate_part2",
|
||||
"plate_part3",
|
||||
"plate_part4",
|
||||
"accident_date",
|
||||
"accident_type",
|
||||
"national_code",
|
||||
"accident_time",
|
||||
"province_id",
|
||||
"city_id",
|
||||
"axis_name",
|
||||
"driver_name",
|
||||
"damage_picture1",
|
||||
"damage_picture2",
|
||||
];
|
||||
} else if (tabState === 1) {
|
||||
fieldsToValidate = ["report_base", "police_file", "police_file_date", "police_serial"];
|
||||
} else if (tabState === 2) {
|
||||
fieldsToValidate = ["items_damage"];
|
||||
}
|
||||
const isValid = await trigger(fieldsToValidate);
|
||||
if (isValid) {
|
||||
setTabState(tabState + 1);
|
||||
}
|
||||
};
|
||||
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={<InfoIcon />} label="اطلاعات تصادف" />
|
||||
<Tab disabled={tabState === 0} icon={<AssessmentIcon />} label="گزارش خسارت" />
|
||||
<Tab disabled={tabState === 0 || tabState === 1} icon={<MinorCrashIcon />} label="آیتم خسارت" />
|
||||
</Tabs>
|
||||
<DialogContent dividers sx={{ overflowY: "auto", maxHeight: "70vh" }}>
|
||||
<Box sx={{ flex: 1 }}>
|
||||
<TabPanel value={tabState} index={0}>
|
||||
<DamageInfo setValue={setValue} errors={errors} control={control} />
|
||||
</TabPanel>
|
||||
<TabPanel value={tabState} index={1}>
|
||||
<DamageReport setValue={setValue} control={control} />
|
||||
</TabPanel>
|
||||
<TabPanel value={tabState} index={2}>
|
||||
<Controller
|
||||
name={"items_damage"}
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<DamageItem
|
||||
baseDamageItems={defaultData.items_damage}
|
||||
baseControl={control}
|
||||
baseOnChange={field.onChange}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</TabPanel>
|
||||
</Box>
|
||||
</DialogContent>
|
||||
<DialogActions sx={{ alignItems: "center", justifyContent: "center" }}>
|
||||
<Button
|
||||
onClick={handlePrev}
|
||||
key={"handlePrev"}
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
size="large"
|
||||
startIcon={tabState === 0 ? <ExitToAppIcon /> : <KeyboardDoubleArrowRightIcon />}
|
||||
>
|
||||
{tabState === 0 ? "بستن" : "مرحله قبل"}
|
||||
</Button>
|
||||
{tabState !== 2 ? (
|
||||
<Button
|
||||
onClick={handleNext}
|
||||
key={"handleNext"}
|
||||
variant="contained"
|
||||
size="large"
|
||||
endIcon={<KeyboardDoubleArrowLeftIcon />}
|
||||
>
|
||||
مرحله بعد
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
variant="contained"
|
||||
size="large"
|
||||
key={"Submit"}
|
||||
disabled={!isValid || isSubmitting}
|
||||
type={"submit"}
|
||||
endIcon={!isValid ? null : <BeenhereIcon />}
|
||||
>
|
||||
{!isValid ? "حداقل یک آیتم خسارت ضروریست" : isSubmitting ? "در حال ثبت خسارت" : "ثبت خسارت"}
|
||||
</Button>
|
||||
)}
|
||||
</DialogActions>
|
||||
</StyledForm>
|
||||
);
|
||||
};
|
||||
export default CreateFormContent;
|
||||
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 { Box, Button, DialogActions, DialogContent, Tab, Tabs } from "@mui/material";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import InfoIcon from "@mui/icons-material/Info";
|
||||
import ExitToAppIcon from "@mui/icons-material/ExitToApp";
|
||||
import KeyboardDoubleArrowRightIcon from "@mui/icons-material/KeyboardDoubleArrowRight";
|
||||
import BeenhereIcon from "@mui/icons-material/Beenhere";
|
||||
import MinorCrashIcon from "@mui/icons-material/MinorCrash";
|
||||
import DamageInfo from "./DamageInfo";
|
||||
import KeyboardDoubleArrowLeftIcon from "@mui/icons-material/KeyboardDoubleArrowLeft";
|
||||
import DamageReport from "./DamageReport";
|
||||
import DamageItem from "./DamageItem";
|
||||
import validateNationalCode from "@/core/utils/nationalCodeValidation";
|
||||
import AssessmentIcon from "@mui/icons-material/Assessment";
|
||||
|
||||
function TabPanel(props) {
|
||||
const { children, value, index } = props;
|
||||
return (
|
||||
<div role="tabpanel" hidden={value !== index}>
|
||||
{value === index && <Box>{children}</Box>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const validationSchema = object({
|
||||
accident_date: string().required("لطفا تاریخ تصادف را وارد کنید!!!"),
|
||||
accident_time: string().required("لطفا زمان تصادف را وارد کنید!!!"),
|
||||
accident_type: string().required("لطفا نوع تصادف را وارد کنید!!!"),
|
||||
province_id: number().required("لطفا استان را وارد کنید!!!"),
|
||||
city_id: number().required("لطفا شهرستان را وارد کنید!!!"),
|
||||
axis_name: string().required("لطفا نام محور را وارد کنید!!!"),
|
||||
driver_name: string().when("isForeign", {
|
||||
is: "0",
|
||||
then: (schema) => schema.required("لطفا نام و نام خانوادگی را وارد کنید!!!"),
|
||||
}),
|
||||
phone_number: string().when("isForeign", {
|
||||
is: "0",
|
||||
then: (schema) =>
|
||||
schema
|
||||
.matches(/^09\d{9}$/, "شماره موبایل باید با 09 شروع شده و 11 رقم باشد")
|
||||
.required("لطفا تلفن همراه را وارد کنید!!!"),
|
||||
}),
|
||||
national_code: mixed().when("isForeign", {
|
||||
is: "0",
|
||||
then: (schema) =>
|
||||
schema
|
||||
.test("max", "کد ملی باید شامل 10 رقم باشد", (value) => value.toString().length === 10)
|
||||
.test("validation", "کد ملی صحیح نمی باشد", (value) => validateNationalCode(value))
|
||||
.required("لطفا کد ملی را وارد کنید!!!"),
|
||||
}),
|
||||
start_point: mixed()
|
||||
.test("start-point-required", "لطفاً نقطه تصادف را مشخص کنید!", function (value) {
|
||||
return !!value;
|
||||
})
|
||||
.required("لطفاً نقطه تصادف را مشخص کنید!"),
|
||||
plate_part1: mixed().when("isForeign", {
|
||||
is: "0",
|
||||
then: (schema) =>
|
||||
schema.test("max", "2رقم", (value) => value.toString().length === 2).required("plate_part1 الزامیست"),
|
||||
}),
|
||||
plate_part2: mixed().when("isForeign", {
|
||||
is: "0",
|
||||
then: (schema) => schema.required("plate_part2 الزامیست"),
|
||||
}),
|
||||
plate_part3: mixed().when("isForeign", {
|
||||
is: "0",
|
||||
then: (schema) =>
|
||||
schema.test("max", "3رقم", (value) => value.toString().length === 3).required("plate_part3الزامیست"),
|
||||
}),
|
||||
|
||||
plate_part4: mixed().when("isForeign", {
|
||||
is: "0",
|
||||
then: (schema) =>
|
||||
schema.test("max", "2رقم", (value) => value.toString().length === 2).required("plate_part4الزامیست"),
|
||||
}),
|
||||
damage_picture1: mixed().nullable().required("لطفا عکس تصادف را بارگذاری کنید!"),
|
||||
damage_picture2: mixed().nullable().required("لطفا عکس تصادف را بارگذاری کنید!"),
|
||||
police_serial: string().when("radio_button", {
|
||||
is: "police_file_checkbox", // زمانی که گزینه "police_file_checkbox" انتخاب شده باشد
|
||||
then: (schema) => schema.required("شماره کروکی یا نامه پلیس راه الزامی است"),
|
||||
}),
|
||||
police_file_date: string().when("radio_button", {
|
||||
is: "police_file_checkbox", // زمانی که گزینه "police_file_checkbox" انتخاب شده باشد
|
||||
then: (schema) => schema.required("تاریخ کروکی یا نامه پلیس راه الزامی است"),
|
||||
}),
|
||||
police_file: mixed().when("radio_button", {
|
||||
is: "police_file_checkbox", // زمانی که گزینه "police_file_checkbox" انتخاب شده باشد
|
||||
then: (schema) => schema.nullable().required("تصویر کروکی یا نامه پلیس راه الزامی است"),
|
||||
otherwise: (schema) => schema.notRequired(),
|
||||
}),
|
||||
items_damage: array().min(1, "حداقل یک آیتم خسارت ضروریست!!!"),
|
||||
});
|
||||
|
||||
const CreateFormContent = ({ setOpen, SubmitDamage, defaultData }) => {
|
||||
const defaultValues = {
|
||||
isForeign: defaultData.isForeign,
|
||||
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,
|
||||
is_province: defaultData.is_province,
|
||||
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(0);
|
||||
const handleClose = () => setOpen(false);
|
||||
const handleChangeTab = (event, newValue) => setTabState(newValue);
|
||||
const handlePrev = () => {
|
||||
if (tabState === 0) {
|
||||
handleClose();
|
||||
} else {
|
||||
setTabState(tabState - 1);
|
||||
}
|
||||
};
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
setValue,
|
||||
trigger,
|
||||
formState: { errors, isSubmitting, isValid },
|
||||
} = useForm({
|
||||
defaultValues,
|
||||
resolver: yupResolver(validationSchema),
|
||||
mode: "all",
|
||||
});
|
||||
const onSubmitBase = async (data) => {
|
||||
await SubmitDamage(data);
|
||||
};
|
||||
const handleNext = async () => {
|
||||
let fieldsToValidate = [];
|
||||
if (tabState === 0) {
|
||||
fieldsToValidate = [
|
||||
"phone_number",
|
||||
"start_point",
|
||||
"plate_part1",
|
||||
"plate_part2",
|
||||
"plate_part3",
|
||||
"plate_part4",
|
||||
"accident_date",
|
||||
"accident_type",
|
||||
"national_code",
|
||||
"accident_time",
|
||||
"province_id",
|
||||
"city_id",
|
||||
"axis_name",
|
||||
"driver_name",
|
||||
"damage_picture1",
|
||||
"damage_picture2",
|
||||
];
|
||||
} else if (tabState === 1) {
|
||||
fieldsToValidate = ["report_base", "police_file", "police_file_date", "police_serial"];
|
||||
} else if (tabState === 2) {
|
||||
fieldsToValidate = ["items_damage"];
|
||||
}
|
||||
const isValid = await trigger(fieldsToValidate);
|
||||
if (isValid) {
|
||||
setTabState(tabState + 1);
|
||||
}
|
||||
};
|
||||
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={<InfoIcon />} label="اطلاعات تصادف" />
|
||||
<Tab disabled={tabState === 0} icon={<AssessmentIcon />} label="گزارش خسارت" />
|
||||
<Tab disabled={tabState === 0 || tabState === 1} icon={<MinorCrashIcon />} label="آیتم خسارت" />
|
||||
</Tabs>
|
||||
<DialogContent dividers sx={{ overflowY: "auto", maxHeight: "70vh" }}>
|
||||
<Box sx={{ flex: 1 }}>
|
||||
<TabPanel value={tabState} index={0}>
|
||||
<DamageInfo setValue={setValue} errors={errors} control={control} />
|
||||
</TabPanel>
|
||||
<TabPanel value={tabState} index={1}>
|
||||
<DamageReport setValue={setValue} control={control} />
|
||||
</TabPanel>
|
||||
<TabPanel value={tabState} index={2}>
|
||||
<Controller
|
||||
name={"items_damage"}
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<DamageItem
|
||||
baseDamageItems={defaultData.items_damage}
|
||||
baseControl={control}
|
||||
baseOnChange={field.onChange}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</TabPanel>
|
||||
</Box>
|
||||
</DialogContent>
|
||||
<DialogActions sx={{ alignItems: "center", justifyContent: "center" }}>
|
||||
<Button
|
||||
onClick={handlePrev}
|
||||
key={"handlePrev"}
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
size="large"
|
||||
startIcon={tabState === 0 ? <ExitToAppIcon /> : <KeyboardDoubleArrowRightIcon />}
|
||||
>
|
||||
{tabState === 0 ? "بستن" : "مرحله قبل"}
|
||||
</Button>
|
||||
{tabState !== 2 ? (
|
||||
<Button
|
||||
onClick={handleNext}
|
||||
key={"handleNext"}
|
||||
variant="contained"
|
||||
size="large"
|
||||
endIcon={<KeyboardDoubleArrowLeftIcon />}
|
||||
>
|
||||
مرحله بعد
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
variant="contained"
|
||||
size="large"
|
||||
key={"Submit"}
|
||||
disabled={!isValid || isSubmitting}
|
||||
type={"submit"}
|
||||
endIcon={!isValid ? null : <BeenhereIcon />}
|
||||
>
|
||||
{!isValid ? "حداقل یک آیتم خسارت ضروریست" : isSubmitting ? "در حال ثبت خسارت" : "ثبت خسارت"}
|
||||
</Button>
|
||||
)}
|
||||
</DialogActions>
|
||||
</StyledForm>
|
||||
);
|
||||
};
|
||||
export default CreateFormContent;
|
||||
|
||||
@@ -1,56 +1,56 @@
|
||||
import { Controller, useWatch } from "react-hook-form";
|
||||
import { Grid } from "@mui/material";
|
||||
import NumberField from "@/core/components/NumberField";
|
||||
import { useEffect } from "react";
|
||||
|
||||
const DamageAmount = ({ control, damageItemList, setValue }) => {
|
||||
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("amount", calculatedValue);
|
||||
}
|
||||
}, [itemValue, itemDamageId, isDisabled, setValue]);
|
||||
return (
|
||||
<Grid item xs={12} sm={6}>
|
||||
<Controller
|
||||
name="amount"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<NumberField
|
||||
value={isDisabled ? calculatedValue : field.value || ""}
|
||||
variant="outlined"
|
||||
name="amount"
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
if (!isDisabled) {
|
||||
field.onChange(inputValue);
|
||||
}
|
||||
}}
|
||||
label={`هزینه خسارت (ریال)`}
|
||||
placeholder="هزینه خسارت را وارد کنید"
|
||||
fullWidth
|
||||
size="small"
|
||||
disabled={isDisabled || itemDamage === null}
|
||||
error={error}
|
||||
helperText={error?.message}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</Grid>
|
||||
);
|
||||
};
|
||||
export default DamageAmount;
|
||||
import { Controller, useWatch } from "react-hook-form";
|
||||
import { Grid } from "@mui/material";
|
||||
import NumberField from "@/core/components/NumberField";
|
||||
import { useEffect } from "react";
|
||||
|
||||
const DamageAmount = ({ control, damageItemList, setValue }) => {
|
||||
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("amount", calculatedValue);
|
||||
}
|
||||
}, [itemValue, itemDamageId, isDisabled, setValue]);
|
||||
return (
|
||||
<Grid item xs={12} sm={6}>
|
||||
<Controller
|
||||
name="amount"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<NumberField
|
||||
value={isDisabled ? calculatedValue : field.value || ""}
|
||||
variant="outlined"
|
||||
name="amount"
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
if (!isDisabled) {
|
||||
field.onChange(inputValue);
|
||||
}
|
||||
}}
|
||||
label={`هزینه خسارت (ریال)`}
|
||||
placeholder="هزینه خسارت را وارد کنید"
|
||||
fullWidth
|
||||
size="small"
|
||||
disabled={isDisabled || itemDamage === null}
|
||||
error={error}
|
||||
helperText={error?.message}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</Grid>
|
||||
);
|
||||
};
|
||||
export default DamageAmount;
|
||||
|
||||
@@ -1,253 +1,253 @@
|
||||
import { Controller, useWatch } from "react-hook-form";
|
||||
import { Grid, Stack, TextField, ToggleButton, ToggleButtonGroup } from "@mui/material";
|
||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||
import MuiTimePicker from "@/core/components/MuiTimePicker";
|
||||
import SelectBox from "@/core/components/SelectBox";
|
||||
import PlateNumber from "@/core/components/PlateNumber";
|
||||
import ImageUpload from "./ImageUpload";
|
||||
import MapInfoOneMarker from "@/core/components/MapInfoOneMarker";
|
||||
import PersianTextField from "@/core/components/PersianTextField";
|
||||
import LogesticController from "./LogesticController";
|
||||
|
||||
const DamageInfo = ({ control, setValue, errors }) => {
|
||||
const StartPoint = useWatch({ control, name: "start_point" });
|
||||
const IsForeign = useWatch({ control, name: "isForeign" });
|
||||
|
||||
return (
|
||||
<Stack>
|
||||
<LogesticController control={control} />
|
||||
<Stack sx={{ mt: 2 }} alignItems={"center"} justifyContent={"center"}>
|
||||
<Controller
|
||||
name="isForeign"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<ToggleButtonGroup
|
||||
value={field.value}
|
||||
exclusive
|
||||
onChange={(event, newAlignment) => field.onChange(newAlignment)}
|
||||
>
|
||||
<ToggleButton value="0">ناوگان داخلی</ToggleButton>
|
||||
<ToggleButton value="1">ناوگان خارجی</ToggleButton>
|
||||
</ToggleButtonGroup>
|
||||
)}
|
||||
/>
|
||||
</Stack>
|
||||
{IsForeign == "0" && (
|
||||
<>
|
||||
<Grid sx={{ mt: 2 }} container spacing={2}>
|
||||
<Grid item xs={12} md={6}>
|
||||
<Controller
|
||||
name="driver_name"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<PersianTextField
|
||||
value={field.value}
|
||||
variant="outlined"
|
||||
name="driver_name"
|
||||
onChange={field.onChange}
|
||||
label="نام و نام خانوادگی راننده"
|
||||
placeholder={"نام و نام خانوادگی فارسی را وارد کنید"}
|
||||
fullWidth
|
||||
size="small"
|
||||
error={error}
|
||||
helperText={error?.message}
|
||||
InputLabelProps={{ shrink: true }}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={6}>
|
||||
<Controller
|
||||
name="national_code"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<TextField
|
||||
value={field.value}
|
||||
variant="outlined"
|
||||
name="national_code"
|
||||
type={"tel"}
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
field.onChange(inputValue);
|
||||
}}
|
||||
label="کد ملی راننده"
|
||||
placeholder={"کد ملی راننده را وارد کنید"}
|
||||
fullWidth
|
||||
size="small"
|
||||
error={error}
|
||||
helperText={error?.message}
|
||||
InputLabelProps={{ shrink: true }}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid sx={{ mt: 2 }} container spacing={2}>
|
||||
<Grid item xs={12} md={6}>
|
||||
<Controller
|
||||
name="phone_number"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<TextField
|
||||
value={field.value}
|
||||
variant="outlined"
|
||||
name="phone_number"
|
||||
type={"tel"}
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
field.onChange(inputValue);
|
||||
}}
|
||||
label="شماره موبایل راننده"
|
||||
placeholder={"شماره موبایل راننده را وارد کنید"}
|
||||
fullWidth
|
||||
size="small"
|
||||
error={error}
|
||||
helperText={error?.message}
|
||||
InputLabelProps={{ shrink: true }}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={6}>
|
||||
<PlateNumber control={control} />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</>
|
||||
)}
|
||||
<Grid sx={{ mt: 1 }} container spacing={2}>
|
||||
<Grid item xs={12} md={4}>
|
||||
<Controller
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<MuiDatePicker
|
||||
name="accident_date"
|
||||
error={error}
|
||||
value={field.value}
|
||||
placeholder={"تاریخ تصادف را وارد کنید"}
|
||||
label={"تاریخ تصادف"}
|
||||
setFieldValue={(name, value) => field.onChange(value || [])}
|
||||
helperText={error ? error.message : null}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
name={"accident_date"}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={4}>
|
||||
<Controller
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<MuiTimePicker
|
||||
name="accident_time"
|
||||
error={error}
|
||||
value={field.value}
|
||||
placeholder={"زمان تصادف را وارد کنید"}
|
||||
label={"زمان تصادف"}
|
||||
setFieldValue={(name, value) => field.onChange(value || null)}
|
||||
helperText={error ? error.message : null}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
name={"accident_time"}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={4}>
|
||||
<Controller
|
||||
name="accident_type"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<SelectBox
|
||||
value={field.value}
|
||||
label="نوع خسارت"
|
||||
selectors={[
|
||||
{
|
||||
id: 1,
|
||||
value: "1",
|
||||
name: "خسارتی",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
value: "2",
|
||||
name: "جرحی",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
value: "3",
|
||||
name: "فوتی",
|
||||
},
|
||||
]}
|
||||
schema={{ name: "name", value: "value" }}
|
||||
error={error}
|
||||
onChange={field.onChange}
|
||||
helperText={error?.message}
|
||||
isLoading={false}
|
||||
errorEcured={false}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid sx={{ mt: 2 }} container spacing={2}>
|
||||
<Grid item xs={12} md={6}>
|
||||
<Controller
|
||||
name="damage_picture1"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<ImageUpload
|
||||
name={field.name}
|
||||
value={field.value}
|
||||
error={error}
|
||||
onChange={field.onChange}
|
||||
title={"تصویر تصادف"}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={6}>
|
||||
<Controller
|
||||
name="damage_picture2"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<ImageUpload
|
||||
name={field.name}
|
||||
value={field.value}
|
||||
error={error}
|
||||
onChange={field.onChange}
|
||||
title={"تصویر تصادف"}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Stack sx={{ mt: 2 }}>
|
||||
<MapInfoOneMarker
|
||||
setValue={setValue}
|
||||
StartPoint={StartPoint}
|
||||
errors={errors}
|
||||
title={"برای ثبت محل تصادف، لطفاً نقشه را بیشتر زوم کنید."}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default DamageInfo;
|
||||
import { Controller, useWatch } from "react-hook-form";
|
||||
import { Grid, Stack, TextField, ToggleButton, ToggleButtonGroup } from "@mui/material";
|
||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||
import MuiTimePicker from "@/core/components/MuiTimePicker";
|
||||
import SelectBox from "@/core/components/SelectBox";
|
||||
import PlateNumber from "@/core/components/PlateNumber";
|
||||
import ImageUpload from "./ImageUpload";
|
||||
import MapInfoOneMarker from "@/core/components/MapInfoOneMarker";
|
||||
import PersianTextField from "@/core/components/PersianTextField";
|
||||
import LogesticController from "./LogesticController";
|
||||
|
||||
const DamageInfo = ({ control, setValue, errors }) => {
|
||||
const StartPoint = useWatch({ control, name: "start_point" });
|
||||
const IsForeign = useWatch({ control, name: "isForeign" });
|
||||
|
||||
return (
|
||||
<Stack>
|
||||
<LogesticController control={control} />
|
||||
<Stack sx={{ mt: 2 }} alignItems={"center"} justifyContent={"center"}>
|
||||
<Controller
|
||||
name="isForeign"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<ToggleButtonGroup
|
||||
value={field.value}
|
||||
exclusive
|
||||
onChange={(event, newAlignment) => field.onChange(newAlignment)}
|
||||
>
|
||||
<ToggleButton value="0">ناوگان داخلی</ToggleButton>
|
||||
<ToggleButton value="1">ناوگان خارجی</ToggleButton>
|
||||
</ToggleButtonGroup>
|
||||
)}
|
||||
/>
|
||||
</Stack>
|
||||
{IsForeign == "0" && (
|
||||
<>
|
||||
<Grid sx={{ mt: 2 }} container spacing={2}>
|
||||
<Grid item xs={12} md={6}>
|
||||
<Controller
|
||||
name="driver_name"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<PersianTextField
|
||||
value={field.value}
|
||||
variant="outlined"
|
||||
name="driver_name"
|
||||
onChange={field.onChange}
|
||||
label="نام و نام خانوادگی راننده"
|
||||
placeholder={"نام و نام خانوادگی فارسی را وارد کنید"}
|
||||
fullWidth
|
||||
size="small"
|
||||
error={error}
|
||||
helperText={error?.message}
|
||||
InputLabelProps={{ shrink: true }}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={6}>
|
||||
<Controller
|
||||
name="national_code"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<TextField
|
||||
value={field.value}
|
||||
variant="outlined"
|
||||
name="national_code"
|
||||
type={"tel"}
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
field.onChange(inputValue);
|
||||
}}
|
||||
label="کد ملی راننده"
|
||||
placeholder={"کد ملی راننده را وارد کنید"}
|
||||
fullWidth
|
||||
size="small"
|
||||
error={error}
|
||||
helperText={error?.message}
|
||||
InputLabelProps={{ shrink: true }}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid sx={{ mt: 2 }} container spacing={2}>
|
||||
<Grid item xs={12} md={6}>
|
||||
<Controller
|
||||
name="phone_number"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<TextField
|
||||
value={field.value}
|
||||
variant="outlined"
|
||||
name="phone_number"
|
||||
type={"tel"}
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
field.onChange(inputValue);
|
||||
}}
|
||||
label="شماره موبایل راننده"
|
||||
placeholder={"شماره موبایل راننده را وارد کنید"}
|
||||
fullWidth
|
||||
size="small"
|
||||
error={error}
|
||||
helperText={error?.message}
|
||||
InputLabelProps={{ shrink: true }}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={6}>
|
||||
<PlateNumber control={control} />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</>
|
||||
)}
|
||||
<Grid sx={{ mt: 1 }} container spacing={2}>
|
||||
<Grid item xs={12} md={4}>
|
||||
<Controller
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<MuiDatePicker
|
||||
name="accident_date"
|
||||
error={error}
|
||||
value={field.value}
|
||||
placeholder={"تاریخ تصادف را وارد کنید"}
|
||||
label={"تاریخ تصادف"}
|
||||
setFieldValue={(name, value) => field.onChange(value || [])}
|
||||
helperText={error ? error.message : null}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
name={"accident_date"}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={4}>
|
||||
<Controller
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<MuiTimePicker
|
||||
name="accident_time"
|
||||
error={error}
|
||||
value={field.value}
|
||||
placeholder={"زمان تصادف را وارد کنید"}
|
||||
label={"زمان تصادف"}
|
||||
setFieldValue={(name, value) => field.onChange(value || null)}
|
||||
helperText={error ? error.message : null}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
name={"accident_time"}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={4}>
|
||||
<Controller
|
||||
name="accident_type"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<SelectBox
|
||||
value={field.value}
|
||||
label="نوع خسارت"
|
||||
selectors={[
|
||||
{
|
||||
id: 1,
|
||||
value: "1",
|
||||
name: "خسارتی",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
value: "2",
|
||||
name: "جرحی",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
value: "3",
|
||||
name: "فوتی",
|
||||
},
|
||||
]}
|
||||
schema={{ name: "name", value: "value" }}
|
||||
error={error}
|
||||
onChange={field.onChange}
|
||||
helperText={error?.message}
|
||||
isLoading={false}
|
||||
errorEcured={false}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid sx={{ mt: 2 }} container spacing={2}>
|
||||
<Grid item xs={12} md={6}>
|
||||
<Controller
|
||||
name="damage_picture1"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<ImageUpload
|
||||
name={field.name}
|
||||
value={field.value}
|
||||
error={error}
|
||||
onChange={field.onChange}
|
||||
title={"تصویر تصادف"}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={6}>
|
||||
<Controller
|
||||
name="damage_picture2"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<ImageUpload
|
||||
name={field.name}
|
||||
value={field.value}
|
||||
error={error}
|
||||
onChange={field.onChange}
|
||||
title={"تصویر تصادف"}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Stack sx={{ mt: 2 }}>
|
||||
<MapInfoOneMarker
|
||||
setValue={setValue}
|
||||
StartPoint={StartPoint}
|
||||
errors={errors}
|
||||
title={"برای ثبت محل تصادف، لطفاً نقشه را بیشتر زوم کنید."}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default DamageInfo;
|
||||
|
||||
@@ -1,167 +1,167 @@
|
||||
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";
|
||||
import { number, object } from "yup";
|
||||
import useDamageItemList from "@/lib/hooks/useDamageItemList";
|
||||
import DamagePrice from "./DamagePrice";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
|
||||
const schema = object({
|
||||
id: number().required("لطفا نوع خسارت را وارد کنید!!!"),
|
||||
value: number().required("لطفا میزان خسارت را وارد کنید!!!"),
|
||||
amount: number().required("لطفا هزینه خسارت را وارد کنید!!!"),
|
||||
});
|
||||
const defaultValues = {
|
||||
id: null,
|
||||
value: null,
|
||||
amount: null,
|
||||
};
|
||||
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,
|
||||
resolver: yupResolver(schema),
|
||||
mode: "all",
|
||||
});
|
||||
const deleteDamageItem = (id) => {
|
||||
setSelectedDamageItemList((prev) => prev.filter((DamageItem) => DamageItem.id !== id));
|
||||
};
|
||||
useEffect(() => {
|
||||
baseOnChange(selectedDamageItemList);
|
||||
}, [selectedDamageItemList]);
|
||||
const handleCreateDamage = (data) => {
|
||||
setSelectedDamageItemList((prev) => {
|
||||
const isDuplicate = prev.some((item) => item.id === data.id);
|
||||
if (!isDuplicate) {
|
||||
return [...prev, data];
|
||||
} else {
|
||||
return prev;
|
||||
}
|
||||
});
|
||||
reset();
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={2}>
|
||||
{loadingDamageItemList ? (
|
||||
<Box sx={{ width: "100%" }}>
|
||||
<LinearProgress />
|
||||
</Box>
|
||||
) : (
|
||||
<>
|
||||
<Stack sx={{ minWidth: "200px" }}>
|
||||
<Controller
|
||||
name="id"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<Autocomplete
|
||||
options={damageItemList || []}
|
||||
size={"small"}
|
||||
getOptionLabel={(option) => option.title}
|
||||
isOptionEqualToValue={(option, value) => option.id === value.id}
|
||||
loading={loadingDamageItemList}
|
||||
renderInput={(params) => (
|
||||
<TextField
|
||||
{...params}
|
||||
label="نوع خسارت"
|
||||
error={!!error}
|
||||
helperText={error?.message}
|
||||
/>
|
||||
)}
|
||||
onChange={(_, value) => field.onChange(value?.id)}
|
||||
value={damageItemList.find((item) => item.id === field.value) || null}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<Grid container columnSpacing={1}>
|
||||
<DamagePrice setValue={setValue} control={control} damageItemList={damageItemList} />
|
||||
</Grid>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<Button
|
||||
variant="contained"
|
||||
fullWidth
|
||||
onClick={handleSubmit(handleCreateDamage)}
|
||||
sx={{ textWrap: "nowrap" }}
|
||||
>
|
||||
افزودن آیتم خسارت
|
||||
</Button>
|
||||
</Stack>
|
||||
</>
|
||||
)}
|
||||
</Stack>
|
||||
<Divider sx={{ my: 2, width: "100%" }}>
|
||||
<Chip variant="outlined" label="لیست آیتم های خسارت" />
|
||||
</Divider>
|
||||
{selectedDamageItemList.length === 0 && (
|
||||
<Box sx={{ my: 4, width: "100%", textAlign: "center" }}>
|
||||
<Typography variant="h6" sx={{ letterSpacing: "2px", color: "#606060" }}>
|
||||
ابتدا اطلاعات بالا را تکمیل نمایید
|
||||
</Typography>
|
||||
</Box>
|
||||
)}
|
||||
<Fade in={selectedDamageItemList.length !== 0} sx={{ width: "100%" }}>
|
||||
<Grid
|
||||
container
|
||||
spacing={2}
|
||||
sx={{
|
||||
p: 1,
|
||||
mt: 2,
|
||||
minHeight: 150,
|
||||
maxHeight: 300,
|
||||
overflowY: "auto",
|
||||
}}
|
||||
>
|
||||
{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
|
||||
damageItemList={damageItemList}
|
||||
selectedDamageItem={selectedDamageItem}
|
||||
deleteDamageItem={deleteDamageItem}
|
||||
/>
|
||||
</Grid>
|
||||
))
|
||||
)}
|
||||
</Grid>
|
||||
</Fade>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DamageItem;
|
||||
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";
|
||||
import { number, object } from "yup";
|
||||
import useDamageItemList from "@/lib/hooks/useDamageItemList";
|
||||
import DamagePrice from "./DamagePrice";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
|
||||
const schema = object({
|
||||
id: number().required("لطفا نوع خسارت را وارد کنید!!!"),
|
||||
value: number().required("لطفا میزان خسارت را وارد کنید!!!"),
|
||||
amount: number().required("لطفا هزینه خسارت را وارد کنید!!!"),
|
||||
});
|
||||
const defaultValues = {
|
||||
id: null,
|
||||
value: null,
|
||||
amount: null,
|
||||
};
|
||||
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,
|
||||
resolver: yupResolver(schema),
|
||||
mode: "all",
|
||||
});
|
||||
const deleteDamageItem = (id) => {
|
||||
setSelectedDamageItemList((prev) => prev.filter((DamageItem) => DamageItem.id !== id));
|
||||
};
|
||||
useEffect(() => {
|
||||
baseOnChange(selectedDamageItemList);
|
||||
}, [selectedDamageItemList]);
|
||||
const handleCreateDamage = (data) => {
|
||||
setSelectedDamageItemList((prev) => {
|
||||
const isDuplicate = prev.some((item) => item.id === data.id);
|
||||
if (!isDuplicate) {
|
||||
return [...prev, data];
|
||||
} else {
|
||||
return prev;
|
||||
}
|
||||
});
|
||||
reset();
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={2}>
|
||||
{loadingDamageItemList ? (
|
||||
<Box sx={{ width: "100%" }}>
|
||||
<LinearProgress />
|
||||
</Box>
|
||||
) : (
|
||||
<>
|
||||
<Stack sx={{ minWidth: "200px" }}>
|
||||
<Controller
|
||||
name="id"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<Autocomplete
|
||||
options={damageItemList || []}
|
||||
size={"small"}
|
||||
getOptionLabel={(option) => option.title}
|
||||
isOptionEqualToValue={(option, value) => option.id === value.id}
|
||||
loading={loadingDamageItemList}
|
||||
renderInput={(params) => (
|
||||
<TextField
|
||||
{...params}
|
||||
label="نوع خسارت"
|
||||
error={!!error}
|
||||
helperText={error?.message}
|
||||
/>
|
||||
)}
|
||||
onChange={(_, value) => field.onChange(value?.id)}
|
||||
value={damageItemList.find((item) => item.id === field.value) || null}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<Grid container columnSpacing={1}>
|
||||
<DamagePrice setValue={setValue} control={control} damageItemList={damageItemList} />
|
||||
</Grid>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<Button
|
||||
variant="contained"
|
||||
fullWidth
|
||||
onClick={handleSubmit(handleCreateDamage)}
|
||||
sx={{ textWrap: "nowrap" }}
|
||||
>
|
||||
افزودن آیتم خسارت
|
||||
</Button>
|
||||
</Stack>
|
||||
</>
|
||||
)}
|
||||
</Stack>
|
||||
<Divider sx={{ my: 2, width: "100%" }}>
|
||||
<Chip variant="outlined" label="لیست آیتم های خسارت" />
|
||||
</Divider>
|
||||
{selectedDamageItemList.length === 0 && (
|
||||
<Box sx={{ my: 4, width: "100%", textAlign: "center" }}>
|
||||
<Typography variant="h6" sx={{ letterSpacing: "2px", color: "#606060" }}>
|
||||
ابتدا اطلاعات بالا را تکمیل نمایید
|
||||
</Typography>
|
||||
</Box>
|
||||
)}
|
||||
<Fade in={selectedDamageItemList.length !== 0} sx={{ width: "100%" }}>
|
||||
<Grid
|
||||
container
|
||||
spacing={2}
|
||||
sx={{
|
||||
p: 1,
|
||||
mt: 2,
|
||||
minHeight: 150,
|
||||
maxHeight: 300,
|
||||
overflowY: "auto",
|
||||
}}
|
||||
>
|
||||
{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
|
||||
damageItemList={damageItemList}
|
||||
selectedDamageItem={selectedDamageItem}
|
||||
deleteDamageItem={deleteDamageItem}
|
||||
/>
|
||||
</Grid>
|
||||
))
|
||||
)}
|
||||
</Grid>
|
||||
</Fade>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DamageItem;
|
||||
|
||||
@@ -1,60 +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;
|
||||
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;
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
import { Controller, useWatch } from "react-hook-form";
|
||||
import { Grid, TextField } from "@mui/material";
|
||||
import DamageAmount from "./DamageAmount";
|
||||
|
||||
const DamagePrice = ({ damageItemList, control, setValue }) => {
|
||||
const itemDamage = useWatch({ control, name: "id" });
|
||||
const itemDamageId = damageItemList.find((damageItem) => damageItem.id === itemDamage);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<Controller
|
||||
name="value"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<TextField
|
||||
value={field.value || ""}
|
||||
variant="outlined"
|
||||
disabled={itemDamage === null}
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
name="value"
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
field.onChange(inputValue);
|
||||
}}
|
||||
label={`میزان خسارت ${itemDamageId?.unit ? `(${itemDamageId?.unit})` : ""}`}
|
||||
fullWidth
|
||||
size="small"
|
||||
error={error}
|
||||
helperText={error?.message}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</Grid>
|
||||
<DamageAmount setValue={setValue} damageItemList={damageItemList} control={control} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DamagePrice;
|
||||
import { Controller, useWatch } from "react-hook-form";
|
||||
import { Grid, TextField } from "@mui/material";
|
||||
import DamageAmount from "./DamageAmount";
|
||||
|
||||
const DamagePrice = ({ damageItemList, control, setValue }) => {
|
||||
const itemDamage = useWatch({ control, name: "id" });
|
||||
const itemDamageId = damageItemList.find((damageItem) => damageItem.id === itemDamage);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<Controller
|
||||
name="value"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<TextField
|
||||
value={field.value || ""}
|
||||
variant="outlined"
|
||||
disabled={itemDamage === null}
|
||||
inputProps={{
|
||||
inputMode: "number",
|
||||
min: 0,
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
name="value"
|
||||
onChange={(event) => {
|
||||
const inputValue = event.target.value;
|
||||
if (isNaN(Number(inputValue))) {
|
||||
return;
|
||||
}
|
||||
field.onChange(inputValue);
|
||||
}}
|
||||
label={`میزان خسارت ${itemDamageId?.unit ? `(${itemDamageId?.unit})` : ""}`}
|
||||
fullWidth
|
||||
size="small"
|
||||
error={error}
|
||||
helperText={error?.message}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</Grid>
|
||||
<DamageAmount setValue={setValue} damageItemList={damageItemList} control={control} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DamagePrice;
|
||||
|
||||
@@ -1,51 +1,51 @@
|
||||
import { FormControlLabel, RadioGroup, Stack } from "@mui/material";
|
||||
import { Controller, useWatch } from "react-hook-form";
|
||||
import { useState } from "react";
|
||||
import PoliceFileReport from "./PoliceFileReport";
|
||||
import Radio from "@mui/material/Radio";
|
||||
|
||||
const DamageReport = ({ control }) => {
|
||||
const watchedStatus = useWatch({ control, name: "radio_button" });
|
||||
const [selectedOption, setSelectedOption] = useState(watchedStatus || null);
|
||||
// const [selectedOption, setSelectedOption] = useState("report_base");
|
||||
|
||||
const handleOptionChange = (e) => {
|
||||
setSelectedOption(e.target.value);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<RadioGroup
|
||||
aria-label="file-options"
|
||||
name="file-options"
|
||||
value={selectedOption}
|
||||
onChange={handleOptionChange}
|
||||
>
|
||||
<Stack direction={"row"} alignItems={"center"} justifyContent={"center"}>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Controller
|
||||
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} />}
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DamageReport;
|
||||
import { FormControlLabel, RadioGroup, Stack } from "@mui/material";
|
||||
import { Controller, useWatch } from "react-hook-form";
|
||||
import { useState } from "react";
|
||||
import PoliceFileReport from "./PoliceFileReport";
|
||||
import Radio from "@mui/material/Radio";
|
||||
|
||||
const DamageReport = ({ control }) => {
|
||||
const watchedStatus = useWatch({ control, name: "radio_button" });
|
||||
const [selectedOption, setSelectedOption] = useState(watchedStatus || null);
|
||||
// const [selectedOption, setSelectedOption] = useState("report_base");
|
||||
|
||||
const handleOptionChange = (e) => {
|
||||
setSelectedOption(e.target.value);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<RadioGroup
|
||||
aria-label="file-options"
|
||||
name="file-options"
|
||||
value={selectedOption}
|
||||
onChange={handleOptionChange}
|
||||
>
|
||||
<Stack direction={"row"} alignItems={"center"} justifyContent={"center"}>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Controller
|
||||
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} />}
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DamageReport;
|
||||
|
||||
@@ -1,77 +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;
|
||||
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;
|
||||
|
||||
@@ -1,64 +1,64 @@
|
||||
import { Controller, useWatch } from "react-hook-form";
|
||||
import SelectBox from "@/core/components/SelectBox";
|
||||
import useProvinces from "@/lib/hooks/useProvince";
|
||||
import { Grid } from "@mui/material";
|
||||
import CityController from "./CityController";
|
||||
import PersianTextField from "@/core/components/PersianTextField";
|
||||
|
||||
const LogesticController = ({ control }) => {
|
||||
const { provinces, errorProvinces, loadingProvinces } = useProvinces();
|
||||
const isProvince = useWatch({ control, name: "is_province" });
|
||||
return (
|
||||
<Grid sx={{ mt: 1 }} container spacing={2}>
|
||||
{!isProvince ? (
|
||||
<Grid item xs={12} md={4}>
|
||||
<Controller
|
||||
name="province_id"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<SelectBox
|
||||
value={errorProvinces ? "error" : loadingProvinces ? "loading" : field.value || ""}
|
||||
label="استان"
|
||||
selectors={provinces}
|
||||
schema={{ name: "name_fa", value: "id" }}
|
||||
error={error}
|
||||
disabled={isProvince}
|
||||
onChange={field.onChange}
|
||||
helperText={error?.message}
|
||||
isLoading={loadingProvinces}
|
||||
errorEcured={errorProvinces}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</Grid>
|
||||
) : null}
|
||||
<Grid item xs={12} md={isProvince ? 6 : 4}>
|
||||
<CityController control={control} />
|
||||
</Grid>
|
||||
<Grid item xs={12} md={isProvince ? 6 : 4}>
|
||||
<Controller
|
||||
name="axis_name"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<PersianTextField
|
||||
value={field.value}
|
||||
variant="outlined"
|
||||
name="axis_name"
|
||||
onChange={field.onChange}
|
||||
label="نام محور"
|
||||
placeholder={"نام محور فارسی را وارد کنید"}
|
||||
fullWidth
|
||||
size="small"
|
||||
error={error}
|
||||
helperText={error?.message}
|
||||
InputLabelProps={{ shrink: true }}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
);
|
||||
};
|
||||
export default LogesticController;
|
||||
import { Controller, useWatch } from "react-hook-form";
|
||||
import SelectBox from "@/core/components/SelectBox";
|
||||
import useProvinces from "@/lib/hooks/useProvince";
|
||||
import { Grid } from "@mui/material";
|
||||
import CityController from "./CityController";
|
||||
import PersianTextField from "@/core/components/PersianTextField";
|
||||
|
||||
const LogesticController = ({ control }) => {
|
||||
const { provinces, errorProvinces, loadingProvinces } = useProvinces();
|
||||
const isProvince = useWatch({ control, name: "is_province" });
|
||||
return (
|
||||
<Grid sx={{ mt: 1 }} container spacing={2}>
|
||||
{!isProvince ? (
|
||||
<Grid item xs={12} md={4}>
|
||||
<Controller
|
||||
name="province_id"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<SelectBox
|
||||
value={errorProvinces ? "error" : loadingProvinces ? "loading" : field.value || ""}
|
||||
label="استان"
|
||||
selectors={provinces}
|
||||
schema={{ name: "name_fa", value: "id" }}
|
||||
error={error}
|
||||
disabled={isProvince}
|
||||
onChange={field.onChange}
|
||||
helperText={error?.message}
|
||||
isLoading={loadingProvinces}
|
||||
errorEcured={errorProvinces}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</Grid>
|
||||
) : null}
|
||||
<Grid item xs={12} md={isProvince ? 6 : 4}>
|
||||
<CityController control={control} />
|
||||
</Grid>
|
||||
<Grid item xs={12} md={isProvince ? 6 : 4}>
|
||||
<Controller
|
||||
name="axis_name"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<PersianTextField
|
||||
value={field.value}
|
||||
variant="outlined"
|
||||
name="axis_name"
|
||||
onChange={field.onChange}
|
||||
label="نام محور"
|
||||
placeholder={"نام محور فارسی را وارد کنید"}
|
||||
fullWidth
|
||||
size="small"
|
||||
error={error}
|
||||
helperText={error?.message}
|
||||
InputLabelProps={{ shrink: true }}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
);
|
||||
};
|
||||
export default LogesticController;
|
||||
|
||||
@@ -1,67 +1,67 @@
|
||||
import { Controller } from "react-hook-form";
|
||||
import { Grid, Stack, TextField } from "@mui/material";
|
||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||
import ImageUpload from "./ImageUpload";
|
||||
|
||||
const PoliceFileReport = ({ control }) => {
|
||||
return (
|
||||
<Stack spacing={3} mt={2}>
|
||||
<Stack>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<Controller
|
||||
name="police_serial"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<TextField
|
||||
{...field}
|
||||
label="شماره کروکی یا نامه پلیس راه"
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
size="small"
|
||||
error={error}
|
||||
helperText={error && error.message}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<Controller
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<MuiDatePicker
|
||||
name="police_file_date"
|
||||
error={error}
|
||||
value={field.value}
|
||||
placeholder={"تاریخ کروکی یا نامه پلیس راه"}
|
||||
label={"تاریخ کروکی یا نامه پلیس راه"}
|
||||
setFieldValue={(name, value) => field.onChange(value || [])}
|
||||
helperText={error ? error.message : null}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
name={"police_file_date"}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Stack>
|
||||
<Controller
|
||||
name="police_file"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<ImageUpload
|
||||
name={field.name}
|
||||
value={field.value}
|
||||
error={error}
|
||||
title={"تصویر کروکی یا نامه پلیس راه"}
|
||||
onChange={field.onChange}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default PoliceFileReport;
|
||||
import { Controller } from "react-hook-form";
|
||||
import { Grid, Stack, TextField } from "@mui/material";
|
||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||
import ImageUpload from "./ImageUpload";
|
||||
|
||||
const PoliceFileReport = ({ control }) => {
|
||||
return (
|
||||
<Stack spacing={3} mt={2}>
|
||||
<Stack>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<Controller
|
||||
name="police_serial"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<TextField
|
||||
{...field}
|
||||
label="شماره کروکی یا نامه پلیس راه"
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
size="small"
|
||||
error={error}
|
||||
helperText={error && error.message}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<Controller
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<MuiDatePicker
|
||||
name="police_file_date"
|
||||
error={error}
|
||||
value={field.value}
|
||||
placeholder={"تاریخ کروکی یا نامه پلیس راه"}
|
||||
label={"تاریخ کروکی یا نامه پلیس راه"}
|
||||
setFieldValue={(name, value) => field.onChange(value || [])}
|
||||
helperText={error ? error.message : null}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
name={"police_file_date"}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Stack>
|
||||
<Controller
|
||||
name="police_file"
|
||||
control={control}
|
||||
render={({ field, fieldState: { error } }) => {
|
||||
return (
|
||||
<ImageUpload
|
||||
name={field.name}
|
||||
value={field.value}
|
||||
error={error}
|
||||
title={"تصویر کروکی یا نامه پلیس راه"}
|
||||
onChange={field.onChange}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default PoliceFileReport;
|
||||
|
||||
@@ -1,112 +1,112 @@
|
||||
"use client";
|
||||
import { Dialog, IconButton } 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";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
import { usePermissions } from "@/lib/hooks/usePermissions";
|
||||
import { useAuth } from "@/lib/contexts/auth";
|
||||
|
||||
const OperatorCreateForm = ({ open, setOpen, mutate }) => {
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const { user } = useAuth();
|
||||
const { data: userPermissions } = usePermissions();
|
||||
const hasCreateProvincePermission = userPermissions.some((item) => ["add-receipt"].includes(item));
|
||||
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("is_foreign", result.isForeign);
|
||||
if (result.isForeign == "0") {
|
||||
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 = {
|
||||
isForeign: "0",
|
||||
accident_date: "",
|
||||
accident_time: "",
|
||||
accident_type: "",
|
||||
province_id: !hasCreateProvincePermission ? user.province_id : null,
|
||||
is_province: !hasCreateProvincePermission,
|
||||
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">
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
onClick={() => setOpen(false)}
|
||||
sx={(theme) => ({
|
||||
position: "absolute",
|
||||
right: 8,
|
||||
top: 8,
|
||||
zIndex: 50,
|
||||
color: theme.palette.grey[500],
|
||||
})}
|
||||
>
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
{open && (
|
||||
<CreateFormContent
|
||||
defaultData={defaultData}
|
||||
SubmitDamage={SubmitCreateDamage}
|
||||
setOpen={setOpen}
|
||||
mutate={mutate}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
export default OperatorCreateForm;
|
||||
"use client";
|
||||
import { Dialog, IconButton } 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";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
import { usePermissions } from "@/lib/hooks/usePermissions";
|
||||
import { useAuth } from "@/lib/contexts/auth";
|
||||
|
||||
const OperatorCreateForm = ({ open, setOpen, mutate }) => {
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const { user } = useAuth();
|
||||
const { data: userPermissions } = usePermissions();
|
||||
const hasCreateProvincePermission = userPermissions.some((item) => ["add-receipt"].includes(item));
|
||||
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("is_foreign", result.isForeign);
|
||||
if (result.isForeign == "0") {
|
||||
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 = {
|
||||
isForeign: "0",
|
||||
accident_date: "",
|
||||
accident_time: "",
|
||||
accident_type: "",
|
||||
province_id: !hasCreateProvincePermission ? user.province_id : null,
|
||||
is_province: !hasCreateProvincePermission,
|
||||
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">
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
onClick={() => setOpen(false)}
|
||||
sx={(theme) => ({
|
||||
position: "absolute",
|
||||
right: 8,
|
||||
top: 8,
|
||||
zIndex: 50,
|
||||
color: theme.palette.grey[500],
|
||||
})}
|
||||
>
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
{open && (
|
||||
<CreateFormContent
|
||||
defaultData={defaultData}
|
||||
SubmitDamage={SubmitCreateDamage}
|
||||
setOpen={setOpen}
|
||||
mutate={mutate}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
export default OperatorCreateForm;
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
"use client";
|
||||
import { Button, IconButton, useMediaQuery } from "@mui/material";
|
||||
import { useTheme } from "@emotion/react";
|
||||
import { useState } from "react";
|
||||
import { AddCircle } from "@mui/icons-material";
|
||||
import OperatorCreateForm from "./Forms";
|
||||
|
||||
const OperatorCreate = ({ mutate }) => {
|
||||
const theme = useTheme();
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
const handleOpen = () => {
|
||||
setOpen(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{isMobile ? (
|
||||
<IconButton aria-label="ثبت خسارت" color="primary" onClick={handleOpen}>
|
||||
<AddCircle sx={{ fontSize: "25px" }} />
|
||||
</IconButton>
|
||||
) : (
|
||||
<Button
|
||||
size={"small"}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
startIcon={<AddCircle />}
|
||||
onClick={handleOpen}
|
||||
>
|
||||
ثبت خسارت
|
||||
</Button>
|
||||
)}
|
||||
<OperatorCreateForm open={open} setOpen={setOpen} mutate={mutate} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default OperatorCreate;
|
||||
"use client";
|
||||
import { Button, IconButton, useMediaQuery } from "@mui/material";
|
||||
import { useTheme } from "@emotion/react";
|
||||
import { useState } from "react";
|
||||
import { AddCircle } from "@mui/icons-material";
|
||||
import OperatorCreateForm from "./Forms";
|
||||
|
||||
const OperatorCreate = ({ mutate }) => {
|
||||
const theme = useTheme();
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
const handleOpen = () => {
|
||||
setOpen(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{isMobile ? (
|
||||
<IconButton aria-label="ثبت خسارت" color="primary" onClick={handleOpen}>
|
||||
<AddCircle sx={{ fontSize: "25px" }} />
|
||||
</IconButton>
|
||||
) : (
|
||||
<Button
|
||||
size={"small"}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
startIcon={<AddCircle />}
|
||||
onClick={handleOpen}
|
||||
>
|
||||
ثبت خسارت
|
||||
</Button>
|
||||
)}
|
||||
<OperatorCreateForm open={open} setOpen={setOpen} mutate={mutate} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default OperatorCreate;
|
||||
|
||||
@@ -1,75 +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;
|
||||
"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;
|
||||
|
||||
@@ -1,219 +1,219 @@
|
||||
import { CHECK_PAYMENT_STATUS, CREATE_FACTOR_DAMAGE, SEND_SMS_AGAIN } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import PaymentIcon from "@mui/icons-material/Payment";
|
||||
import ReceiptLongIcon from "@mui/icons-material/ReceiptLong";
|
||||
import RequestQuoteIcon from "@mui/icons-material/RequestQuote";
|
||||
import WebAssetIcon from "@mui/icons-material/WebAsset";
|
||||
import {
|
||||
Alert,
|
||||
Box,
|
||||
Button,
|
||||
Chip,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
Divider,
|
||||
Grid,
|
||||
Stack,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { useReducer, useState } from "react";
|
||||
|
||||
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 dividers>
|
||||
<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={<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={<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={<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 -
|
||||
(row.original?.deposit_insurance_amount + row.original?.deposit_daghi_amount)
|
||||
).toLocaleString() || "0"}{" "}
|
||||
ریال
|
||||
</Typography>
|
||||
</Grid>
|
||||
{!factorCreated && (
|
||||
<Grid item xs={12}>
|
||||
<Stack spacing={1}>
|
||||
<Alert severity="warning">
|
||||
پس از صدور فاکتور، امکان ویرایش مبالغ بیمه و داغی وجود نخواهد داشت
|
||||
</Alert>
|
||||
<Alert severity="info">
|
||||
لینک پرداخت فاکتور به شماره {row.original?.driver_phone_number} ارسال می شود.
|
||||
</Alert>
|
||||
</Stack>
|
||||
</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;
|
||||
import { CHECK_PAYMENT_STATUS, CREATE_FACTOR_DAMAGE, SEND_SMS_AGAIN } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import PaymentIcon from "@mui/icons-material/Payment";
|
||||
import ReceiptLongIcon from "@mui/icons-material/ReceiptLong";
|
||||
import RequestQuoteIcon from "@mui/icons-material/RequestQuote";
|
||||
import WebAssetIcon from "@mui/icons-material/WebAsset";
|
||||
import {
|
||||
Alert,
|
||||
Box,
|
||||
Button,
|
||||
Chip,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
Divider,
|
||||
Grid,
|
||||
Stack,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { useReducer, useState } from "react";
|
||||
|
||||
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 dividers>
|
||||
<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={<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={<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={<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 -
|
||||
(row.original?.deposit_insurance_amount + row.original?.deposit_daghi_amount)
|
||||
).toLocaleString() || "0"}{" "}
|
||||
ریال
|
||||
</Typography>
|
||||
</Grid>
|
||||
{!factorCreated && (
|
||||
<Grid item xs={12}>
|
||||
<Stack spacing={1}>
|
||||
<Alert severity="warning">
|
||||
پس از صدور فاکتور، امکان ویرایش مبالغ بیمه و داغی وجود نخواهد داشت
|
||||
</Alert>
|
||||
<Alert severity="info">
|
||||
لینک پرداخت فاکتور به شماره {row.original?.driver_phone_number} ارسال می شود.
|
||||
</Alert>
|
||||
</Stack>
|
||||
</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;
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
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={row.original?.status == 2 ? "صدور فاکتور" : "استعلام پرداخت"}>
|
||||
<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" }}>
|
||||
{row.original?.status == 2 ? "صدور فاکتور" : "استعلام پرداخت"}
|
||||
</DialogTitle>
|
||||
{openCreateFactorDialog && (
|
||||
<CreateFactorContent
|
||||
setOpenCreateFactorDialog={setOpenCreateFactorDialog}
|
||||
rowId={rowId}
|
||||
mutate={mutate}
|
||||
row={row}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default CreateFactor;
|
||||
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={row.original?.status == 2 ? "صدور فاکتور" : "استعلام پرداخت"}>
|
||||
<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" }}>
|
||||
{row.original?.status == 2 ? "صدور فاکتور" : "استعلام پرداخت"}
|
||||
</DialogTitle>
|
||||
{openCreateFactorDialog && (
|
||||
<CreateFactorContent
|
||||
setOpenCreateFactorDialog={setOpenCreateFactorDialog}
|
||||
rowId={rowId}
|
||||
mutate={mutate}
|
||||
row={row}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default CreateFactor;
|
||||
|
||||
@@ -1,123 +1,123 @@
|
||||
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";
|
||||
import { useAuth } from "@/lib/contexts/auth";
|
||||
import { usePermissions } from "@/lib/hooks/usePermissions";
|
||||
|
||||
const EditController = ({ rowId, mutate, setOpenEditDialog }) => {
|
||||
const requestServer = useRequest();
|
||||
const [damageItemDetails, setDamageItemDetails] = useState(null);
|
||||
const [damageItemDetailsLoading, setDamageItemDetailsLoading] = useState(false);
|
||||
const { user } = useAuth();
|
||||
const { data: userPermissions } = usePermissions();
|
||||
const hasCreateProvincePermission = userPermissions.some((item) => ["add-receipt"].includes(item));
|
||||
|
||||
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?.is_foreign == 0 ? damageItemDetails?.plaque.split("-") || [] : [];
|
||||
const defaultData = {
|
||||
isForeign: String(damageItemDetails?.is_foreign),
|
||||
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,
|
||||
is_province: !hasCreateProvincePermission,
|
||||
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("is_foreign", result.isForeign);
|
||||
if (result.isForeign == "0") {
|
||||
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;
|
||||
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";
|
||||
import { useAuth } from "@/lib/contexts/auth";
|
||||
import { usePermissions } from "@/lib/hooks/usePermissions";
|
||||
|
||||
const EditController = ({ rowId, mutate, setOpenEditDialog }) => {
|
||||
const requestServer = useRequest();
|
||||
const [damageItemDetails, setDamageItemDetails] = useState(null);
|
||||
const [damageItemDetailsLoading, setDamageItemDetailsLoading] = useState(false);
|
||||
const { user } = useAuth();
|
||||
const { data: userPermissions } = usePermissions();
|
||||
const hasCreateProvincePermission = userPermissions.some((item) => ["add-receipt"].includes(item));
|
||||
|
||||
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?.is_foreign == 0 ? damageItemDetails?.plaque.split("-") || [] : [];
|
||||
const defaultData = {
|
||||
isForeign: String(damageItemDetails?.is_foreign),
|
||||
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,
|
||||
is_province: !hasCreateProvincePermission,
|
||||
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("is_foreign", result.isForeign);
|
||||
if (result.isForeign == "0") {
|
||||
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;
|
||||
|
||||
@@ -1,59 +1,59 @@
|
||||
import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import BorderColorIcon from "@mui/icons-material/BorderColor";
|
||||
import EditController from "./EditController";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
|
||||
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="md"
|
||||
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",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
onClick={() => setOpenEditDialog(false)}
|
||||
sx={(theme) => ({
|
||||
position: "absolute",
|
||||
right: 8,
|
||||
top: 8,
|
||||
zIndex: 50,
|
||||
color: theme.palette.grey[500],
|
||||
})}
|
||||
>
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
{openEditDialog && (
|
||||
<EditController
|
||||
openEditDialog={openEditDialog}
|
||||
setOpenEditDialog={setOpenEditDialog}
|
||||
rowId={rowId}
|
||||
row={row}
|
||||
mutate={mutate}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default EditForm;
|
||||
import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import BorderColorIcon from "@mui/icons-material/BorderColor";
|
||||
import EditController from "./EditController";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
|
||||
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="md"
|
||||
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",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
onClick={() => setOpenEditDialog(false)}
|
||||
sx={(theme) => ({
|
||||
position: "absolute",
|
||||
right: 8,
|
||||
top: 8,
|
||||
zIndex: 50,
|
||||
color: theme.palette.grey[500],
|
||||
})}
|
||||
>
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
{openEditDialog && (
|
||||
<EditController
|
||||
openEditDialog={openEditDialog}
|
||||
setOpenEditDialog={setOpenEditDialog}
|
||||
rowId={rowId}
|
||||
row={row}
|
||||
mutate={mutate}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default EditForm;
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
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"
|
||||
placeholder="مبلغ داغی را وارد کنید"
|
||||
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;
|
||||
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"
|
||||
placeholder="مبلغ داغی را وارد کنید"
|
||||
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;
|
||||
|
||||
@@ -1,53 +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;
|
||||
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;
|
||||
|
||||
@@ -1,77 +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, beforeImage = null, title }) => {
|
||||
const [beforeImg, setBeforeImg] = useState(beforeImage ? beforeImage : null);
|
||||
const [beforeFileType, setBeforeFileType] = useState(beforeImage ? "image/" : null);
|
||||
const [beforeFileName, setBeforeFileName] = useState(null);
|
||||
const [showBeforeImage, setShowBeforeImage] = useState(!beforeImage);
|
||||
|
||||
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;
|
||||
import { FormControl, FormHelperText } from "@mui/material";
|
||||
import UploadSystem from "@/core/components/UploadSystem";
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
const ImageUpload = ({ name, value, onChange, error, beforeImage = null, title }) => {
|
||||
const [beforeImg, setBeforeImg] = useState(beforeImage ? beforeImage : null);
|
||||
const [beforeFileType, setBeforeFileType] = useState(beforeImage ? "image/" : null);
|
||||
const [beforeFileName, setBeforeFileName] = useState(null);
|
||||
const [showBeforeImage, setShowBeforeImage] = useState(!beforeImage);
|
||||
|
||||
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;
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
import NumberField from "@/core/components/NumberField";
|
||||
import { Grid, Stack } from "@mui/material";
|
||||
import { Controller } from "react-hook-form";
|
||||
import ImageUpload from "./ImageUpload";
|
||||
|
||||
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"
|
||||
placeholder="مبلغ بیمه را وارد کنید"
|
||||
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;
|
||||
import NumberField from "@/core/components/NumberField";
|
||||
import { Grid, Stack } from "@mui/material";
|
||||
import { Controller } from "react-hook-form";
|
||||
import ImageUpload from "./ImageUpload";
|
||||
|
||||
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"
|
||||
placeholder="مبلغ بیمه را وارد کنید"
|
||||
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;
|
||||
|
||||
@@ -1,52 +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;
|
||||
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;
|
||||
|
||||
@@ -1,203 +1,203 @@
|
||||
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);
|
||||
}
|
||||
try {
|
||||
await requestServer(`${CONFIRM_PAYMENT_INFO}/${rowId}`, "post", {
|
||||
data: formData,
|
||||
});
|
||||
mutate();
|
||||
setOpenRegisterInsuranceDialog(false);
|
||||
} catch (error) {}
|
||||
};
|
||||
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"
|
||||
key={"handleNext"}
|
||||
size="large"
|
||||
endIcon={<KeyboardDoubleArrowLeftIcon />}
|
||||
>
|
||||
مرحله بعد
|
||||
</Button>
|
||||
)}
|
||||
{tabState === 1 && (
|
||||
<Button
|
||||
type={"submit"}
|
||||
variant="contained"
|
||||
size="large"
|
||||
disabled={isSubmitting}
|
||||
key={"submit"}
|
||||
endIcon={<BeenhereIcon />}
|
||||
>
|
||||
{isSubmitting ? "در حال ثبت" : "ثبت"}
|
||||
</Button>
|
||||
)}
|
||||
</DialogActions>
|
||||
</StyledForm>
|
||||
);
|
||||
};
|
||||
export default RegisterInsuranceContent;
|
||||
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);
|
||||
}
|
||||
try {
|
||||
await requestServer(`${CONFIRM_PAYMENT_INFO}/${rowId}`, "post", {
|
||||
data: formData,
|
||||
});
|
||||
mutate();
|
||||
setOpenRegisterInsuranceDialog(false);
|
||||
} catch (error) {}
|
||||
};
|
||||
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"
|
||||
key={"handleNext"}
|
||||
size="large"
|
||||
endIcon={<KeyboardDoubleArrowLeftIcon />}
|
||||
>
|
||||
مرحله بعد
|
||||
</Button>
|
||||
)}
|
||||
{tabState === 1 && (
|
||||
<Button
|
||||
type={"submit"}
|
||||
variant="contained"
|
||||
size="large"
|
||||
disabled={isSubmitting}
|
||||
key={"submit"}
|
||||
endIcon={<BeenhereIcon />}
|
||||
>
|
||||
{isSubmitting ? "در حال ثبت" : "ثبت"}
|
||||
</Button>
|
||||
)}
|
||||
</DialogActions>
|
||||
</StyledForm>
|
||||
);
|
||||
};
|
||||
export default RegisterInsuranceContent;
|
||||
|
||||
@@ -1,53 +1,53 @@
|
||||
import { Dialog, IconButton, Tooltip } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import ReceiptIcon from "@mui/icons-material/Receipt";
|
||||
import RegisterInsuranceContent from "./RegisterInsuranceContent";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
|
||||
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"
|
||||
>
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
onClick={() => setOpenRegisterInsuranceDialog(false)}
|
||||
sx={(theme) => ({
|
||||
position: "absolute",
|
||||
right: 8,
|
||||
top: 8,
|
||||
zIndex: 50,
|
||||
color: theme.palette.grey[500],
|
||||
})}
|
||||
>
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
{openRegisterInsuranceDialog && (
|
||||
<RegisterInsuranceContent
|
||||
rowId={rowId}
|
||||
mutate={mutate}
|
||||
row={row}
|
||||
setOpenRegisterInsuranceDialog={setOpenRegisterInsuranceDialog}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default RegisterInsurance;
|
||||
import { Dialog, IconButton, Tooltip } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import ReceiptIcon from "@mui/icons-material/Receipt";
|
||||
import RegisterInsuranceContent from "./RegisterInsuranceContent";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
|
||||
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"
|
||||
>
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
onClick={() => setOpenRegisterInsuranceDialog(false)}
|
||||
sx={(theme) => ({
|
||||
position: "absolute",
|
||||
right: 8,
|
||||
top: 8,
|
||||
zIndex: 50,
|
||||
color: theme.palette.grey[500],
|
||||
})}
|
||||
>
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
{openRegisterInsuranceDialog && (
|
||||
<RegisterInsuranceContent
|
||||
rowId={rowId}
|
||||
mutate={mutate}
|
||||
row={row}
|
||||
setOpenRegisterInsuranceDialog={setOpenRegisterInsuranceDialog}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default RegisterInsurance;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,82 +1,82 @@
|
||||
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);
|
||||
} catch (error) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchData();
|
||||
}, [rowId]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
{loading ? (
|
||||
<DialogLoading />
|
||||
) : data.damages ? (
|
||||
<TableContainer sx={{ maxHeight: 600 }}>
|
||||
<Table stickyHeader sx={{ minWidth: 800 }}>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>نوع خسارت</TableCell>
|
||||
<TableCell>میزان خسارت</TableCell>
|
||||
<TableCell>هزینه خسارت (ریال)</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{data.damages.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>
|
||||
);
|
||||
})}
|
||||
<TableRow sx={{ "&:last-child td, &:last-child th": { border: 0 } }}>
|
||||
<TableCell colSpan={2} align="center">
|
||||
اجرت نصب
|
||||
</TableCell>
|
||||
<TableCell>{(data.ojrate_nasb / 1).toLocaleString()}</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
) : (
|
||||
<Typography textAlign={"center"}>اطلاعات یافت نشد</Typography>
|
||||
)}
|
||||
</DialogContent>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DamageItemContent;
|
||||
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);
|
||||
} catch (error) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchData();
|
||||
}, [rowId]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
{loading ? (
|
||||
<DialogLoading />
|
||||
) : data.damages ? (
|
||||
<TableContainer sx={{ maxHeight: 600 }}>
|
||||
<Table stickyHeader sx={{ minWidth: 800 }}>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>نوع خسارت</TableCell>
|
||||
<TableCell>میزان خسارت</TableCell>
|
||||
<TableCell>هزینه خسارت (ریال)</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{data.damages.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>
|
||||
);
|
||||
})}
|
||||
<TableRow sx={{ "&:last-child td, &:last-child th": { border: 0 } }}>
|
||||
<TableCell colSpan={2} align="center">
|
||||
اجرت نصب
|
||||
</TableCell>
|
||||
<TableCell>{(data.ojrate_nasb / 1).toLocaleString()}</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
) : (
|
||||
<Typography textAlign={"center"}>اطلاعات یافت نشد</Typography>
|
||||
)}
|
||||
</DialogContent>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DamageItemContent;
|
||||
|
||||
@@ -1,43 +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;
|
||||
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;
|
||||
|
||||
@@ -1,103 +1,103 @@
|
||||
import { Box, Button, Chip, DialogContent, Divider, Grid, Typography } from "@mui/material";
|
||||
import PaymentIcon from "@mui/icons-material/Payment";
|
||||
import moment from "jalali-moment";
|
||||
import DownloadIcon from "@mui/icons-material/Download";
|
||||
import FormatListNumberedIcon from "@mui/icons-material/FormatListNumbered";
|
||||
import EventNoteIcon from "@mui/icons-material/EventNote";
|
||||
import ImageIcon from "@mui/icons-material/Image";
|
||||
|
||||
const DamageReportContent = ({ damageReportDetails }) => {
|
||||
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" }}>
|
||||
{damageReportDetails?.report_base === 1
|
||||
? "بازدید عوامل و کارشناسان راهداری"
|
||||
: "کروکی یا نامه پلیس راه"}
|
||||
</Typography>
|
||||
</Grid>
|
||||
{damageReportDetails?.report_base === 0 && (
|
||||
<>
|
||||
<Grid item xs={12} sm={12} sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Chip
|
||||
icon={<FormatListNumberedIcon />}
|
||||
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" }}>
|
||||
{damageReportDetails?.police_serial}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={12} sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Chip
|
||||
icon={<EventNoteIcon />}
|
||||
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" }}>
|
||||
{moment(damageReportDetails?.police_file_date, "YYYY-MM-DD HH:mm:ss")
|
||||
.locale("fa")
|
||||
.format("YYYY/MM/DD")}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={12} sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Chip
|
||||
icon={<ImageIcon />}
|
||||
label={
|
||||
<Typography variant="body2" sx={{ fontWeight: 600, color: "grey.700" }}>
|
||||
تصویر کروکی یا نامه پلیس راه
|
||||
</Typography>
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
<Divider sx={{ flex: 1, mx: 2 }} />
|
||||
<Button
|
||||
variant="contained"
|
||||
color="primary"
|
||||
size="small"
|
||||
startIcon={<DownloadIcon />}
|
||||
onClick={() => {
|
||||
if (damageReportDetails?.police_file) {
|
||||
window.open(damageReportDetails.police_file, "_blank");
|
||||
} else {
|
||||
alert("فایلی برای دانلود موجود نیست.");
|
||||
}
|
||||
}}
|
||||
>
|
||||
دانلود فایل
|
||||
</Button>
|
||||
</Grid>
|
||||
</>
|
||||
)}
|
||||
</Grid>
|
||||
</DialogContent>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DamageReportContent;
|
||||
import { Box, Button, Chip, DialogContent, Divider, Grid, Typography } from "@mui/material";
|
||||
import PaymentIcon from "@mui/icons-material/Payment";
|
||||
import moment from "jalali-moment";
|
||||
import DownloadIcon from "@mui/icons-material/Download";
|
||||
import FormatListNumberedIcon from "@mui/icons-material/FormatListNumbered";
|
||||
import EventNoteIcon from "@mui/icons-material/EventNote";
|
||||
import ImageIcon from "@mui/icons-material/Image";
|
||||
|
||||
const DamageReportContent = ({ damageReportDetails }) => {
|
||||
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" }}>
|
||||
{damageReportDetails?.report_base === 1
|
||||
? "بازدید عوامل و کارشناسان راهداری"
|
||||
: "کروکی یا نامه پلیس راه"}
|
||||
</Typography>
|
||||
</Grid>
|
||||
{damageReportDetails?.report_base === 0 && (
|
||||
<>
|
||||
<Grid item xs={12} sm={12} sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Chip
|
||||
icon={<FormatListNumberedIcon />}
|
||||
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" }}>
|
||||
{damageReportDetails?.police_serial}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={12} sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Chip
|
||||
icon={<EventNoteIcon />}
|
||||
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" }}>
|
||||
{moment(damageReportDetails?.police_file_date, "YYYY-MM-DD HH:mm:ss")
|
||||
.locale("fa")
|
||||
.format("YYYY/MM/DD")}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={12} sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Chip
|
||||
icon={<ImageIcon />}
|
||||
label={
|
||||
<Typography variant="body2" sx={{ fontWeight: 600, color: "grey.700" }}>
|
||||
تصویر کروکی یا نامه پلیس راه
|
||||
</Typography>
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
<Divider sx={{ flex: 1, mx: 2 }} />
|
||||
<Button
|
||||
variant="contained"
|
||||
color="primary"
|
||||
size="small"
|
||||
startIcon={<DownloadIcon />}
|
||||
onClick={() => {
|
||||
if (damageReportDetails?.police_file) {
|
||||
window.open(damageReportDetails.police_file, "_blank");
|
||||
} else {
|
||||
alert("فایلی برای دانلود موجود نیست.");
|
||||
}
|
||||
}}
|
||||
>
|
||||
دانلود فایل
|
||||
</Button>
|
||||
</Grid>
|
||||
</>
|
||||
)}
|
||||
</Grid>
|
||||
</DialogContent>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DamageReportContent;
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { useEffect, useState } from "react";
|
||||
import { GET_DAMAGE_ITEM_DETAILS } from "@/core/utils/routes";
|
||||
import DialogLoading from "@/core/components/DialogLoading";
|
||||
import DamageReportContent from "./DamageReportContent";
|
||||
|
||||
const DamageReportController = ({ rowId }) => {
|
||||
const requestServer = useRequest();
|
||||
const [damageReportDetails, setDamageReportDetails] = useState(null);
|
||||
const [damageItemDetailsLoading, setDamageItemDetailsLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setDamageItemDetailsLoading(true);
|
||||
requestServer(`${GET_DAMAGE_ITEM_DETAILS}/${rowId}`, "get")
|
||||
.then((response) => {
|
||||
setDamageReportDetails(response.data.data);
|
||||
setDamageItemDetailsLoading(false);
|
||||
})
|
||||
.catch((e) => {
|
||||
setDamageItemDetailsLoading(false);
|
||||
});
|
||||
}, [rowId]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{damageItemDetailsLoading ? (
|
||||
<DialogLoading />
|
||||
) : (
|
||||
<DamageReportContent damageReportDetails={damageReportDetails} />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DamageReportController;
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { useEffect, useState } from "react";
|
||||
import { GET_DAMAGE_ITEM_DETAILS } from "@/core/utils/routes";
|
||||
import DialogLoading from "@/core/components/DialogLoading";
|
||||
import DamageReportContent from "./DamageReportContent";
|
||||
|
||||
const DamageReportController = ({ rowId }) => {
|
||||
const requestServer = useRequest();
|
||||
const [damageReportDetails, setDamageReportDetails] = useState(null);
|
||||
const [damageItemDetailsLoading, setDamageItemDetailsLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setDamageItemDetailsLoading(true);
|
||||
requestServer(`${GET_DAMAGE_ITEM_DETAILS}/${rowId}`, "get")
|
||||
.then((response) => {
|
||||
setDamageReportDetails(response.data.data);
|
||||
setDamageItemDetailsLoading(false);
|
||||
})
|
||||
.catch((e) => {
|
||||
setDamageItemDetailsLoading(false);
|
||||
});
|
||||
}, [rowId]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{damageItemDetailsLoading ? (
|
||||
<DialogLoading />
|
||||
) : (
|
||||
<DamageReportContent damageReportDetails={damageReportDetails} />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DamageReportController;
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
import React, { useState } from "react";
|
||||
import { Tooltip, IconButton, Dialog, DialogTitle, DialogActions, Button } from "@mui/material";
|
||||
import AssessmentIcon from "@mui/icons-material/Assessment";
|
||||
import DamageReportController from "./DamageReportController";
|
||||
const DamageReportDialog = ({ rowId }) => {
|
||||
const [openDamageReportDialog, setOpenDamageReportDialog] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="گزارش خسارت">
|
||||
<IconButton color="primary" onClick={() => setOpenDamageReportDialog(true)}>
|
||||
<AssessmentIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
open={openDamageReportDialog}
|
||||
onClose={() => setOpenDamageReportDialog(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={"sm"}
|
||||
fullWidth
|
||||
>
|
||||
<DialogTitle>گزارش خسارت</DialogTitle>
|
||||
{openDamageReportDialog && <DamageReportController rowId={rowId} />}
|
||||
<DialogActions>
|
||||
<Button onClick={() => setOpenDamageReportDialog(false)} variant="outlined" color="secondary">
|
||||
بستن
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DamageReportDialog;
|
||||
import React, { useState } from "react";
|
||||
import { Tooltip, IconButton, Dialog, DialogTitle, DialogActions, Button } from "@mui/material";
|
||||
import AssessmentIcon from "@mui/icons-material/Assessment";
|
||||
import DamageReportController from "./DamageReportController";
|
||||
const DamageReportDialog = ({ rowId }) => {
|
||||
const [openDamageReportDialog, setOpenDamageReportDialog] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="گزارش خسارت">
|
||||
<IconButton color="primary" onClick={() => setOpenDamageReportDialog(true)}>
|
||||
<AssessmentIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
open={openDamageReportDialog}
|
||||
onClose={() => setOpenDamageReportDialog(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={"sm"}
|
||||
fullWidth
|
||||
>
|
||||
<DialogTitle>گزارش خسارت</DialogTitle>
|
||||
{openDamageReportDialog && <DamageReportController rowId={rowId} />}
|
||||
<DialogActions>
|
||||
<Button onClick={() => setOpenDamageReportDialog(false)} variant="outlined" color="secondary">
|
||||
بستن
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DamageReportDialog;
|
||||
|
||||
@@ -1,39 +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;
|
||||
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;
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
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>
|
||||
{openDeleteDialog && (
|
||||
<DeleteContent rowId={rowId} mutate={mutate} setOpenDeleteDialog={setOpenDeleteDialog} />
|
||||
)}
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DeleteDialog;
|
||||
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>
|
||||
{openDeleteDialog && (
|
||||
<DeleteContent rowId={rowId} mutate={mutate} setOpenDeleteDialog={setOpenDeleteDialog} />
|
||||
)}
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default DeleteDialog;
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
import { Box, Stack, Typography, useTheme } from "@mui/material";
|
||||
import Image from "next/image";
|
||||
|
||||
const ImageFormContent = ({ image, title }) => {
|
||||
const theme = useTheme();
|
||||
return (
|
||||
<Stack
|
||||
spacing={2}
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
sx={{
|
||||
my: 2,
|
||||
padding: 2,
|
||||
borderRadius: "12px",
|
||||
border: `1px solid ${theme.palette.primary.main}`,
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="h6"
|
||||
sx={{
|
||||
color: theme.palette.primary.dark,
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{title}
|
||||
</Typography>
|
||||
<Box sx={{ width: "100%", position: "relative", aspectRatio: "16/9" }}>
|
||||
<Image
|
||||
src={image}
|
||||
alt="Image"
|
||||
fill={true}
|
||||
sizes="(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw"
|
||||
loading="lazy"
|
||||
style={{
|
||||
objectFit: "contain",
|
||||
marginBottom: "16px",
|
||||
borderRadius: "12px",
|
||||
border: `1px solid ${theme.palette.divider}`,
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default ImageFormContent;
|
||||
import { Box, Stack, Typography, useTheme } from "@mui/material";
|
||||
import Image from "next/image";
|
||||
|
||||
const ImageFormContent = ({ image, title }) => {
|
||||
const theme = useTheme();
|
||||
return (
|
||||
<Stack
|
||||
spacing={2}
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
sx={{
|
||||
my: 2,
|
||||
padding: 2,
|
||||
borderRadius: "12px",
|
||||
border: `1px solid ${theme.palette.primary.main}`,
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="h6"
|
||||
sx={{
|
||||
color: theme.palette.primary.dark,
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{title}
|
||||
</Typography>
|
||||
<Box sx={{ width: "100%", position: "relative", aspectRatio: "16/9" }}>
|
||||
<Image
|
||||
src={image}
|
||||
alt="Image"
|
||||
fill={true}
|
||||
sizes="(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw"
|
||||
loading="lazy"
|
||||
style={{
|
||||
objectFit: "contain",
|
||||
marginBottom: "16px",
|
||||
borderRadius: "12px",
|
||||
border: `1px solid ${theme.palette.divider}`,
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default ImageFormContent;
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, IconButton, Paper, Tooltip } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import PhotoLibraryIcon from "@mui/icons-material/PhotoLibrary";
|
||||
import ImageFormContent from "./ImageFormContent";
|
||||
|
||||
const ImageDialog = ({ images }) => {
|
||||
const [openImageDialog, setOpenImageDialog] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="تصاویر">
|
||||
<IconButton color="primary" onClick={() => setOpenImageDialog(true)}>
|
||||
<PhotoLibraryIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
fullWidth
|
||||
open={openImageDialog}
|
||||
onClose={() => setOpenImageDialog(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>
|
||||
{openImageDialog && (
|
||||
<DialogContent>
|
||||
<ImageFormContent image={images[1]} title={"تصویر تصادف"} />
|
||||
<ImageFormContent image={images[0]} title={"تصویر تصادف"} />
|
||||
</DialogContent>
|
||||
)}
|
||||
<DialogActions>
|
||||
<Button onClick={() => setOpenImageDialog(false)} variant="outlined" color="secondary">
|
||||
بستن
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default ImageDialog;
|
||||
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, IconButton, Paper, Tooltip } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import PhotoLibraryIcon from "@mui/icons-material/PhotoLibrary";
|
||||
import ImageFormContent from "./ImageFormContent";
|
||||
|
||||
const ImageDialog = ({ images }) => {
|
||||
const [openImageDialog, setOpenImageDialog] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="تصاویر">
|
||||
<IconButton color="primary" onClick={() => setOpenImageDialog(true)}>
|
||||
<PhotoLibraryIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
fullWidth
|
||||
open={openImageDialog}
|
||||
onClose={() => setOpenImageDialog(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>
|
||||
{openImageDialog && (
|
||||
<DialogContent>
|
||||
<ImageFormContent image={images[1]} title={"تصویر تصادف"} />
|
||||
<ImageFormContent image={images[0]} title={"تصویر تصادف"} />
|
||||
</DialogContent>
|
||||
)}
|
||||
<DialogActions>
|
||||
<Button onClick={() => setOpenImageDialog(false)} variant="outlined" color="secondary">
|
||||
بستن
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default ImageDialog;
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
"use client";
|
||||
import { Box, Button, DialogActions, DialogContent, Stack } from "@mui/material";
|
||||
import React from "react";
|
||||
import dynamic from "next/dynamic";
|
||||
import MapLoading from "@/core/components/MapLayer/Loading";
|
||||
import ShowLocationMarker from "@/core/components/ShowLocationMarker";
|
||||
const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
|
||||
loading: () => <MapLoading />,
|
||||
ssr: false,
|
||||
});
|
||||
|
||||
const LocationFormContent = ({ setOpenLocationDialog, start_lat, start_lng, end_lat, end_lng }) => {
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Box sx={{ width: "400px", height: "400px" }}>
|
||||
<MapLayer>
|
||||
<ShowLocationMarker
|
||||
start_lat={start_lat}
|
||||
start_lng={start_lng}
|
||||
end_lat={end_lat}
|
||||
end_lng={end_lng}
|
||||
/>
|
||||
</MapLayer>
|
||||
</Box>
|
||||
</DialogContent>
|
||||
<DialogActions sx={{ justifyContent: "center", paddingBottom: 2, width: "100%" }}>
|
||||
<Button onClick={() => setOpenLocationDialog(false)} variant="outlined" color="secondary">
|
||||
بستن
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default LocationFormContent;
|
||||
"use client";
|
||||
import { Box, Button, DialogActions, DialogContent, Stack } from "@mui/material";
|
||||
import React from "react";
|
||||
import dynamic from "next/dynamic";
|
||||
import MapLoading from "@/core/components/MapLayer/Loading";
|
||||
import ShowLocationMarker from "@/core/components/ShowLocationMarker";
|
||||
const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
|
||||
loading: () => <MapLoading />,
|
||||
ssr: false,
|
||||
});
|
||||
|
||||
const LocationFormContent = ({ setOpenLocationDialog, start_lat, start_lng, end_lat, end_lng }) => {
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Box sx={{ width: "400px", height: "400px" }}>
|
||||
<MapLayer>
|
||||
<ShowLocationMarker
|
||||
start_lat={start_lat}
|
||||
start_lng={start_lng}
|
||||
end_lat={end_lat}
|
||||
end_lng={end_lng}
|
||||
/>
|
||||
</MapLayer>
|
||||
</Box>
|
||||
</DialogContent>
|
||||
<DialogActions sx={{ justifyContent: "center", paddingBottom: 2, width: "100%" }}>
|
||||
<Button onClick={() => setOpenLocationDialog(false)} variant="outlined" color="secondary">
|
||||
بستن
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default LocationFormContent;
|
||||
|
||||
@@ -1,40 +1,40 @@
|
||||
import React, { useState } from "react";
|
||||
import { Tooltip, IconButton, Dialog, DialogTitle } from "@mui/material";
|
||||
import ExploreIcon from "@mui/icons-material/Explore";
|
||||
import LocationFormContent from "./LocationFormContent";
|
||||
const LocationForm = ({ start_lat, start_lng, end_lat, end_lng }) => {
|
||||
const [openLocationDialog, setOpenLocationDialog] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="موقعیت">
|
||||
<IconButton color="primary" onClick={() => setOpenLocationDialog(true)}>
|
||||
<ExploreIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
open={openLocationDialog}
|
||||
onClose={() => setOpenLocationDialog(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>
|
||||
{openLocationDialog && (
|
||||
<LocationFormContent
|
||||
start_lat={start_lat}
|
||||
start_lng={start_lng}
|
||||
end_lat={end_lat}
|
||||
end_lng={end_lng}
|
||||
setOpenLocationDialog={setOpenLocationDialog}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default LocationForm;
|
||||
import React, { useState } from "react";
|
||||
import { Tooltip, IconButton, Dialog, DialogTitle } from "@mui/material";
|
||||
import ExploreIcon from "@mui/icons-material/Explore";
|
||||
import LocationFormContent from "./LocationFormContent";
|
||||
const LocationForm = ({ start_lat, start_lng, end_lat, end_lng }) => {
|
||||
const [openLocationDialog, setOpenLocationDialog] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="موقعیت">
|
||||
<IconButton color="primary" onClick={() => setOpenLocationDialog(true)}>
|
||||
<ExploreIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
open={openLocationDialog}
|
||||
onClose={() => setOpenLocationDialog(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>
|
||||
{openLocationDialog && (
|
||||
<LocationFormContent
|
||||
start_lat={start_lat}
|
||||
start_lng={start_lng}
|
||||
end_lat={end_lat}
|
||||
end_lng={end_lng}
|
||||
setOpenLocationDialog={setOpenLocationDialog}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default LocationForm;
|
||||
|
||||
@@ -1,40 +1,40 @@
|
||||
import { Button, DialogActions, DialogContent, Stack, Typography } from "@mui/material";
|
||||
import React, { useState } from "react";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { GET_POLICERAH, GET_POLICERAH_PAGE } from "@/core/utils/routes";
|
||||
|
||||
const PoliceRahLetterContent = ({ setOpenPoliceRahDialog, rowId, mutate }) => {
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const requestServer = useRequest();
|
||||
const handleClick = () => {
|
||||
setSubmitting(true);
|
||||
requestServer(`${GET_POLICERAH}/${rowId}`, "get")
|
||||
.then(() => {
|
||||
mutate();
|
||||
window.open(`${GET_POLICERAH_PAGE}/${rowId}`, "_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;
|
||||
import { Button, DialogActions, DialogContent, Stack, Typography } from "@mui/material";
|
||||
import React, { useState } from "react";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { GET_POLICERAH, GET_POLICERAH_PAGE } from "@/core/utils/routes";
|
||||
|
||||
const PoliceRahLetterContent = ({ setOpenPoliceRahDialog, rowId, mutate }) => {
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const requestServer = useRequest();
|
||||
const handleClick = () => {
|
||||
setSubmitting(true);
|
||||
requestServer(`${GET_POLICERAH}/${rowId}`, "get")
|
||||
.then(() => {
|
||||
mutate();
|
||||
window.open(`${GET_POLICERAH_PAGE}/${rowId}`, "_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;
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
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>
|
||||
{openPoliceRahDialog && (
|
||||
<PoliceRahLetterContent
|
||||
mutate={mutate}
|
||||
rowId={rowId}
|
||||
setOpenPoliceRahDialog={setOpenPoliceRahDialog}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default PoliceRahLetter;
|
||||
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>
|
||||
{openPoliceRahDialog && (
|
||||
<PoliceRahLetterContent
|
||||
mutate={mutate}
|
||||
rowId={rowId}
|
||||
setOpenPoliceRahDialog={setOpenPoliceRahDialog}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default PoliceRahLetter;
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
import { Alert, Button, DialogActions, DialogContent, Stack, Typography } from "@mui/material";
|
||||
import React, { useState } from "react";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { GET_INSURANCE, GET_INSURANCE_PAGE } from "@/core/utils/routes";
|
||||
|
||||
const SendToInsuranceContent = ({ setOpenSendInsuranceDialog, rowId, mutate }) => {
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const requestServer = useRequest();
|
||||
const handleClick = () => {
|
||||
setSubmitting(true);
|
||||
requestServer(`${GET_INSURANCE}/${rowId}`, "get")
|
||||
.then(() => {
|
||||
mutate();
|
||||
window.open(`${GET_INSURANCE_PAGE}/${rowId}`, "_blank");
|
||||
setSubmitting(false);
|
||||
setOpenSendInsuranceDialog(false);
|
||||
})
|
||||
.catch(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Stack spacing={2}>
|
||||
<Typography mt={2}>آیا از صدور نامه بیمه اطمینان دارید؟</Typography>
|
||||
<Alert color="warning" icon={false}>
|
||||
در صورت صدور نامه بیمه، اطلاعات قابل ویرایش یا حذف نخواهند بود
|
||||
</Alert>
|
||||
</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;
|
||||
import { Alert, Button, DialogActions, DialogContent, Stack, Typography } from "@mui/material";
|
||||
import React, { useState } from "react";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { GET_INSURANCE, GET_INSURANCE_PAGE } from "@/core/utils/routes";
|
||||
|
||||
const SendToInsuranceContent = ({ setOpenSendInsuranceDialog, rowId, mutate }) => {
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const requestServer = useRequest();
|
||||
const handleClick = () => {
|
||||
setSubmitting(true);
|
||||
requestServer(`${GET_INSURANCE}/${rowId}`, "get")
|
||||
.then(() => {
|
||||
mutate();
|
||||
window.open(`${GET_INSURANCE_PAGE}/${rowId}`, "_blank");
|
||||
setSubmitting(false);
|
||||
setOpenSendInsuranceDialog(false);
|
||||
})
|
||||
.catch(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<Stack spacing={2}>
|
||||
<Typography mt={2}>آیا از صدور نامه بیمه اطمینان دارید؟</Typography>
|
||||
<Alert color="warning" icon={false}>
|
||||
در صورت صدور نامه بیمه، اطلاعات قابل ویرایش یا حذف نخواهند بود
|
||||
</Alert>
|
||||
</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;
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
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>
|
||||
{openSendInsuranceDialog && (
|
||||
<SendToInsuranceContent
|
||||
mutate={mutate}
|
||||
rowId={rowId}
|
||||
setOpenSendInsuranceDialog={setOpenSendInsuranceDialog}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default SendToInsurance;
|
||||
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>
|
||||
{openSendInsuranceDialog && (
|
||||
<SendToInsuranceContent
|
||||
mutate={mutate}
|
||||
rowId={rowId}
|
||||
setOpenSendInsuranceDialog={setOpenSendInsuranceDialog}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default SendToInsurance;
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
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", px: 1 }}>
|
||||
{plate.split("-")[3]}
|
||||
</Stack>
|
||||
<Stack direction={"row"} spacing={1} sx={{ width: "100%", px: 0.5 }}>
|
||||
<Stack
|
||||
sx={{
|
||||
textAlign: "center",
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
{plate.split("-")[2]}
|
||||
</Stack>
|
||||
<Stack
|
||||
sx={{
|
||||
textAlign: "center",
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
{plate.split("-")[1]}
|
||||
</Stack>
|
||||
<Stack
|
||||
sx={{
|
||||
textAlign: "center",
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
{plate.split("-")[0]}
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default ShowPlate;
|
||||
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", px: 1 }}>
|
||||
{plate.split("-")[3]}
|
||||
</Stack>
|
||||
<Stack direction={"row"} spacing={1} sx={{ width: "100%", px: 0.5 }}>
|
||||
<Stack
|
||||
sx={{
|
||||
textAlign: "center",
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
{plate.split("-")[2]}
|
||||
</Stack>
|
||||
<Stack
|
||||
sx={{
|
||||
textAlign: "center",
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
{plate.split("-")[1]}
|
||||
</Stack>
|
||||
<Stack
|
||||
sx={{
|
||||
textAlign: "center",
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
{plate.split("-")[0]}
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default ShowPlate;
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
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";
|
||||
import { usePermissions } from "@/lib/hooks/usePermissions";
|
||||
|
||||
const RowActions = ({ row, mutate }) => {
|
||||
const { data: userPermissions } = usePermissions();
|
||||
const hasDeletePermission = userPermissions.some((item) =>
|
||||
["delete-receipt", "delete-receipt-province"].includes(item)
|
||||
);
|
||||
const hasEditPermission = userPermissions.some((item) => ["edit-receipt", "edit-receipt-province"].includes(item));
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
{[4, 5].includes(row.original?.status) && <PoliceRahLetter mutate={mutate} rowId={row.getValue("id")} />}
|
||||
{[2, 3].includes(row.original?.status) && (
|
||||
<CreateFactor row={row} rowId={row.getValue("id")} mutate={mutate} />
|
||||
)}
|
||||
{[1, 2].includes(row.original?.status) && (
|
||||
<RegisterInsurance mutate={mutate} row={row} rowId={row.getValue("id")} />
|
||||
)}
|
||||
{[0, 1, 2].includes(row.original?.status) && <SendToInsurance mutate={mutate} rowId={row.getValue("id")} />}
|
||||
{hasEditPermission && [0].includes(row.original?.status) && (
|
||||
<EditForm row={row} mutate={mutate} rowId={row.getValue("id")} />
|
||||
)}
|
||||
{hasDeletePermission && [0].includes(row.original?.status) && (
|
||||
<DeleteDialog mutate={mutate} rowId={row.getValue("id")} />
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
export default RowActions;
|
||||
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";
|
||||
import { usePermissions } from "@/lib/hooks/usePermissions";
|
||||
|
||||
const RowActions = ({ row, mutate }) => {
|
||||
const { data: userPermissions } = usePermissions();
|
||||
const hasDeletePermission = userPermissions.some((item) =>
|
||||
["delete-receipt", "delete-receipt-province"].includes(item)
|
||||
);
|
||||
const hasEditPermission = userPermissions.some((item) => ["edit-receipt", "edit-receipt-province"].includes(item));
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
{[4, 5].includes(row.original?.status) && <PoliceRahLetter mutate={mutate} rowId={row.getValue("id")} />}
|
||||
{[2, 3].includes(row.original?.status) && (
|
||||
<CreateFactor row={row} rowId={row.getValue("id")} mutate={mutate} />
|
||||
)}
|
||||
{[1, 2].includes(row.original?.status) && (
|
||||
<RegisterInsurance mutate={mutate} row={row} rowId={row.getValue("id")} />
|
||||
)}
|
||||
{[0, 1, 2].includes(row.original?.status) && <SendToInsurance mutate={mutate} rowId={row.getValue("id")} />}
|
||||
{hasEditPermission && [0].includes(row.original?.status) && (
|
||||
<EditForm row={row} mutate={mutate} rowId={row.getValue("id")} />
|
||||
)}
|
||||
{hasDeletePermission && [0].includes(row.original?.status) && (
|
||||
<DeleteDialog mutate={mutate} rowId={row.getValue("id")} />
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
export default RowActions;
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { Box } from "@mui/material";
|
||||
import OperatorCreate from "./Actions/create";
|
||||
import PrintExcel from "./ExcelPrint";
|
||||
import { usePermissions } from "@/lib/hooks/usePermissions";
|
||||
|
||||
const Toolbar = ({ table, filterData, mutate }) => {
|
||||
const { data: userPermissions } = usePermissions();
|
||||
const hasAddPermission = userPermissions.some((item) => ["add-receipt", "add-receipt-province"].includes(item));
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
<PrintExcel table={table} filterData={filterData} />
|
||||
{hasAddPermission && <OperatorCreate mutate={mutate} />}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
export default Toolbar;
|
||||
import { Box } from "@mui/material";
|
||||
import OperatorCreate from "./Actions/create";
|
||||
import PrintExcel from "./ExcelPrint";
|
||||
import { usePermissions } from "@/lib/hooks/usePermissions";
|
||||
|
||||
const Toolbar = ({ table, filterData, mutate }) => {
|
||||
const { data: userPermissions } = usePermissions();
|
||||
const hasAddPermission = userPermissions.some((item) => ["add-receipt", "add-receipt-province"].includes(item));
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
<PrintExcel table={table} filterData={filterData} />
|
||||
{hasAddPermission && <OperatorCreate mutate={mutate} />}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
export default Toolbar;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
"use client";
|
||||
import PageTitle from "@/core/components/PageTitle";
|
||||
import { Stack } from "@mui/material";
|
||||
import OperatorList from "./OperatorList";
|
||||
|
||||
const OperatorPage = () => {
|
||||
return (
|
||||
<Stack spacing={1}>
|
||||
<PageTitle title={"کارتابل عملیات خسارات وارده بر ابنیه فنی و تاسیسات راه"} />
|
||||
<OperatorList />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default OperatorPage;
|
||||
"use client";
|
||||
import PageTitle from "@/core/components/PageTitle";
|
||||
import { Stack } from "@mui/material";
|
||||
import OperatorList from "./OperatorList";
|
||||
|
||||
const OperatorPage = () => {
|
||||
return (
|
||||
<Stack spacing={1}>
|
||||
<PageTitle title={"کارتابل عملیات خسارات وارده بر ابنیه فنی و تاسیسات راه"} />
|
||||
<OperatorList />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default OperatorPage;
|
||||
|
||||
Reference in New Issue
Block a user