From e5ab3f75d089c9922dce212419e9c1949a51f961 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Sat, 27 Dec 2025 13:29:45 +0330 Subject: [PATCH 1/3] delete edare id from rahdaran --- .../dashboard/road-missions/violation/page.js | 9 ++++++++- .../rahdaran/Actions/Create/Form/CreateFormContent.jsx | 1 - .../rahdaran/Actions/Create/Form/LogesticController.jsx | 3 --- .../dashboard/rahdaran/Actions/Create/Form/index.jsx | 2 -- .../dashboard/rahdaran/Actions/Edit/EditController.jsx | 2 -- .../operator/RowActions/Edit/EditController/index.jsx | 7 +++++-- src/core/utils/pageMenu.js | 7 ++++++- src/core/utils/pageMenuDev.js | 7 ++++++- 8 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/violation/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/violation/page.js index 2f810e0..4101687 100644 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/violation/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/violation/page.js @@ -6,7 +6,14 @@ export const metadata = { const Page = () => { return ( <> - + {/* */} diff --git a/src/components/dashboard/rahdaran/Actions/Create/Form/CreateFormContent.jsx b/src/components/dashboard/rahdaran/Actions/Create/Form/CreateFormContent.jsx index b42727e..52a4e71 100644 --- a/src/components/dashboard/rahdaran/Actions/Create/Form/CreateFormContent.jsx +++ b/src/components/dashboard/rahdaran/Actions/Create/Form/CreateFormContent.jsx @@ -19,7 +19,6 @@ import LogesticController from "./LogesticController"; const validationSchema = object({ provinceId: string().required("لطفا استان را وارد کنید!!!"), - edarehShahriId: string().required("لطفا اداره را وارد کنید!!!"), name: string().required("وارد کردن نام و نام خانوادگی الزامیست!"), code: string() .required("لطفا کد ملی را وارد کنید!!!") diff --git a/src/components/dashboard/rahdaran/Actions/Create/Form/LogesticController.jsx b/src/components/dashboard/rahdaran/Actions/Create/Form/LogesticController.jsx index 69ea8ca..23d7285 100644 --- a/src/components/dashboard/rahdaran/Actions/Create/Form/LogesticController.jsx +++ b/src/components/dashboard/rahdaran/Actions/Create/Form/LogesticController.jsx @@ -33,9 +33,6 @@ const LogesticController = ({ control }) => { /> ) : null} - - - ); }; diff --git a/src/components/dashboard/rahdaran/Actions/Create/Form/index.jsx b/src/components/dashboard/rahdaran/Actions/Create/Form/index.jsx index 08fbd66..b51bbda 100644 --- a/src/components/dashboard/rahdaran/Actions/Create/Form/index.jsx +++ b/src/components/dashboard/rahdaran/Actions/Create/Form/index.jsx @@ -17,7 +17,6 @@ const CreateForm = ({ open, setOpen, mutate }) => { isDriver: "0", isProvince: !hasCountryPermission, provinceId: !hasCountryPermission ? user.province_id : "", - edarehShahriId: "", name: "", code: "", phone_number: "", @@ -26,7 +25,6 @@ const CreateForm = ({ open, setOpen, mutate }) => { const formData = new FormData(); formData.append("is_driver", result.isDriver); formData.append("province_id", result.provinceId); - formData.append("edareh_shahri_id", result.edarehShahriId); formData.append("name", result.name); formData.append("code", result.code); formData.append("mobile", result.phone_number); diff --git a/src/components/dashboard/rahdaran/Actions/Edit/EditController.jsx b/src/components/dashboard/rahdaran/Actions/Edit/EditController.jsx index 0813975..9f01563 100644 --- a/src/components/dashboard/rahdaran/Actions/Edit/EditController.jsx +++ b/src/components/dashboard/rahdaran/Actions/Edit/EditController.jsx @@ -10,7 +10,6 @@ const EditController = ({ rowId, mutate, setOpen, row }) => { const defaultData = { isDriver: `${row.original?.is_driver}` || "0", provinceId: row.original?.province_id || "", - edarehShahriId: row.original?.edareh_shahri_id || "", name: row.original?.name || "", code: row.original?.code || "", phone_number: row.original?.mobile || "", @@ -19,7 +18,6 @@ const EditController = ({ rowId, mutate, setOpen, row }) => { const formData = new FormData(); formData.append("is_driver", result.isDriver); formData.append("province_id", result.provinceId); - formData.append("edareh_shahri_id", result.edarehShahriId); formData.append("name", result.name); formData.append("code", result.code); formData.append("mobile", result.phone_number); diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Edit/EditController/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Edit/EditController/index.jsx index 949fbaa..57db6f6 100644 --- a/src/components/dashboard/roadMissions/operator/RowActions/Edit/EditController/index.jsx +++ b/src/components/dashboard/roadMissions/operator/RowActions/Edit/EditController/index.jsx @@ -35,8 +35,11 @@ const EditController = ({ row, mutate, openEditDialog, setOpenEditDialog }) => { const submitForm = async (result) => { setSubmitting(true); - const bound = result.bound.getLatLngs(); - let area = bound.map((ring) => ring.map((latlng) => [latlng.lat, latlng.lng])); + const latlngs = result.bound.getLatLngs(); + + const normalized = result.bound_type === "polygon" ? latlngs : [latlngs]; + + const area = normalized.map((ring) => ring.map(({ lat, lng }) => [lat, lng])); await requestServer(`${UPDATE_REQUEST_MISSION}/${row.original.id}`, "post", { data: { explanation: result.explanation, diff --git a/src/core/utils/pageMenu.js b/src/core/utils/pageMenu.js index 97c7001..0a04951 100644 --- a/src/core/utils/pageMenu.js +++ b/src/core/utils/pageMenu.js @@ -157,7 +157,12 @@ export const pageMenu = [ icon: , route: "/dashboard/road-missions/violation", // badges: [{ key: "mission.control" }], // TODO: add badge and permission - permissions: ["all"], + permissions: [ + "manage-violation-city", + "manage-violation-country", + "manage-violation-province", + "manage-violation-station", + ], }, // { // id: "roadMissionsReports", diff --git a/src/core/utils/pageMenuDev.js b/src/core/utils/pageMenuDev.js index 90ae25f..c887a41 100644 --- a/src/core/utils/pageMenuDev.js +++ b/src/core/utils/pageMenuDev.js @@ -156,7 +156,12 @@ export const pageMenuDev = [ icon: , route: "/dashboard/road-missions/violation", // badges: [{ key: "mission.control" }], // TODO: add badge and permission - permissions: ["all"], + permissions: [ + "manage-violation-city", + "manage-violation-country", + "manage-violation-province", + "manage-violation-station", + ], }, // { // id: "roadMissionsReports", From a4a03120739d7a8438c37ce436dbc92c9610b0e9 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Sun, 28 Dec 2025 11:10:07 +0330 Subject: [PATCH 2/3] edit missions pages --- .../dashboard/road-missions/control/page.js | 2 +- .../road-missions/transportation/page.js | 2 +- .../dashboard/rahdaran/RahdaranList.jsx | 62 +- .../roadItems/supervisor/SupervisorList.jsx | 4 +- .../roadMissions/control/ControlList.jsx | 106 ++- .../MachineAndDriver/MachinesDialog/index.jsx | 27 +- .../roadMissions/operator/OperatorList.jsx | 617 ++++++++++-------- .../transportation/TransportationList.jsx | 364 +++++++---- .../CreateViolation/Form/CreateForm.jsx | 54 ++ .../Actions/CreateViolation/Form/index.jsx | 39 ++ .../Actions/CreateViolation/index.jsx | 50 ++ .../Actions/EditViolation/EditController.jsx | 51 ++ .../EditViolation/EditViolationForm.jsx | 95 +++ .../EditViolation/MissionDates/index.jsx | 99 +++ .../Actions/EditViolation/index.jsx | 51 ++ .../violations/RowActions/index.jsx | 10 +- .../roadMissions/violations/Toolbar.jsx | 11 + .../violations/ViolationsList.jsx | 2 + src/core/utils/routes.js | 2 + 19 files changed, 1169 insertions(+), 479 deletions(-) create mode 100644 src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/CreateForm.jsx create mode 100644 src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/index.jsx create mode 100644 src/components/dashboard/roadMissions/violations/Actions/CreateViolation/index.jsx create mode 100644 src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditController.jsx create mode 100644 src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditViolationForm.jsx create mode 100644 src/components/dashboard/roadMissions/violations/Actions/EditViolation/MissionDates/index.jsx create mode 100644 src/components/dashboard/roadMissions/violations/Actions/EditViolation/index.jsx create mode 100644 src/components/dashboard/roadMissions/violations/Toolbar.jsx diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/control/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/control/page.js index 708e125..a172e18 100644 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/control/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-missions/control/page.js @@ -9,7 +9,7 @@ const Page = () => { <> { <> { const { data: userPermissions } = usePermissions(); - const { user } = useAuth(); const hasCountryPermission = userPermissions?.includes("manage-rahdaran-country"); const columns = useMemo(() => { const provinceColumn = { @@ -66,63 +63,6 @@ const RahdaranList = () => { size: 100, }, ...(hasCountryPermission ? [provinceColumn] : []), - { - header: "اداره", - id: "edareh_shahri_id", - enableColumnFilter: true, - datatype: "numeric", - filterMode: "equals", - dependencyId: hasCountryPermission ? "province_id" : null, - grow: false, - size: 120, - ColumnSelectComponent: (props) => { - const { edaratList, loadingEdaratList, errorEdaratList } = useEdaratLists( - hasCountryPermission ? props.dependencyFieldValue.value : user.province_id - ); - const [prevDependency, setPrevDependency] = useState( - hasCountryPermission ? props.dependencyFieldValue.value : user.province_id - ); - - const getColumnSelectOptions = useMemo(() => { - if (hasCountryPermission && props.dependencyFieldValue.value === "") { - return [{ value: "empty", label: "ابتدا استان را انتخاب کنید" }]; - } - if (loadingEdaratList) { - return [{ value: "loading", label: "در حال بارگذاری..." }]; - } - if (errorEdaratList) { - return [{ value: "error", label: "خطا در بارگذاری" }]; - } - return [ - { value: "", label: "کل ادارات" }, - ...edaratList.map((edare) => ({ - value: edare.id, - label: edare.name_fa, - })), - ]; - }, [edaratList, loadingEdaratList, errorEdaratList]); - useEffect(() => { - if (hasCountryPermission) return; - if (prevDependency === props.dependencyFieldValue?.value) return; - props.handleChange({ ...props.filterParameters, value: "" }); - setPrevDependency(props.dependencyFieldValue?.value); - }, [props.dependencyFieldValue?.value, hasCountryPermission]); - return ( - - ); - }, - Cell: ({ renderedCellValue, row }) => <>{row.original.edareh_shahri_name}, - }, { accessorKey: "name", header: "نام و نام خانوادگی", diff --git a/src/components/dashboard/roadItems/supervisor/SupervisorList.jsx b/src/components/dashboard/roadItems/supervisor/SupervisorList.jsx index 69cc288..73e504c 100644 --- a/src/components/dashboard/roadItems/supervisor/SupervisorList.jsx +++ b/src/components/dashboard/roadItems/supervisor/SupervisorList.jsx @@ -12,8 +12,6 @@ import { Box, Stack, Typography } from "@mui/material"; import moment from "jalali-moment"; import { useEffect, useMemo, useState } from "react"; import ImageDialog from "../operator/RowActions/ImageForm"; -import MachinesCodeDialog from "../operator/RowActions/MachinesCodeForm"; -import RahdaranDialog from "../operator/RowActions/RahdaranForm"; import RowActions from "./RowActions"; import LocationForm from "./RowActions/LocationForm"; import Toolbar from "./Toolbar"; @@ -364,7 +362,7 @@ const SupervisorList = () => { label: status.label, })); }, - Cell: ({ renderedCellValue, row }) => <>{row.original.status_fa}, + Cell: ({ row }) => <>{row.original.status_fa}, }, ]; }, [hasCountryPermission]); diff --git a/src/components/dashboard/roadMissions/control/ControlList.jsx b/src/components/dashboard/roadMissions/control/ControlList.jsx index be2443d..b746a8d 100644 --- a/src/components/dashboard/roadMissions/control/ControlList.jsx +++ b/src/components/dashboard/roadMissions/control/ControlList.jsx @@ -7,10 +7,50 @@ import { useMemo } from "react"; import MachinesDialog from "./RowActions/Machines"; import RowActions from "./RowActions"; import RahdaranDialog from "./RowActions/Rahdaran"; +import useProvinces from "@/lib/hooks/useProvince"; +import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency"; +import useCities from "@/lib/hooks/useCities"; const ControlList = () => { - const columns = useMemo( - () => [ + const columns = useMemo(() => { + const dynamicColumns = { + header: "استان", + id: "province_id", + enableColumnFilter: true, + datatype: "numeric", + filterMode: "equals", + grow: false, + size: 130, + ColumnSelectComponent: (props) => { + const { provinces, errorProvinces, loadingProvinces } = useProvinces(); + const getColumnSelectOptions = useMemo(() => { + if (loadingProvinces) { + return [{ value: "loading", label: "در حال بارگذاری..." }]; + } + if (errorProvinces) { + return [{ value: "error", label: "خطا در بارگذاری" }]; + } + return [ + { value: "", label: "کل کشور" }, + ...provinces.map((province) => ({ + value: province.id, + label: province.name_fa, + })), + ]; + }, [provinces, errorProvinces, loadingProvinces]); + return ( + + ); + }, + Cell: ({ renderedCellValue, row }) => { + return <>{row.original.province_name}; + }, + }; + return [ { accessorKey: "id", header: "کد یکتا", @@ -22,6 +62,63 @@ const ControlList = () => { grow: false, size: 100, }, + ...[dynamicColumns], + { + header: "شهر", + id: "city_id", + enableColumnFilter: true, + datatype: "numeric", + filterMode: "equals", + dependencyId: "province_id", + grow: false, + size: 120, + ColumnSelectComponent: (props) => { + const { cityList, loadingCityList, errorCityList } = useCities(props.dependencyFieldValue.value); + + const getColumnSelectOptions = useMemo(() => { + if (props.dependencyFieldValue.value === "") { + return [{ value: "empty", label: "ابتدا استان را انتخاب کنید" }]; + } + if (loadingCityList) { + return [{ value: "loading", label: "در حال بارگذاری..." }]; + } + if (errorCityList) { + return [{ value: "error", label: "خطا در بارگذاری" }]; + } + return [ + { value: "", label: "کل ادارات" }, + ...cityList.map((edare) => ({ + value: edare.id, + label: edare.name_fa, + })), + ]; + }, [cityList, loadingCityList, errorCityList]); + return ( + + ); + }, + Cell: ({ row }) => <>{row.original.city_name}, + }, + { + accessorKey: "station_name", + header: "راهدارخانه", + id: "station_name", + enableColumnFilter: false, + datatype: "text", + filterMode: "equals", + grow: false, + size: 100, + }, { accessorFn: (row) => row.type == 1 @@ -113,9 +210,8 @@ const ControlList = () => { grow: false, size: 100, }, - ], - [] - ); + ]; + }, []); return ( <> diff --git a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/index.jsx index b85b6f6..e121e29 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/CreateWithoutProcess/Form/MachineAndDriver/MachinesDialog/index.jsx @@ -2,6 +2,8 @@ import LtrTextField from "@/core/components/LtrTextField"; import { Close, Edit } from "@mui/icons-material"; import { Button, Dialog, IconButton, Stack } from "@mui/material"; import { useState } from "react"; +import { Controller } from "react-hook-form"; +import CarCode from "@/core/components/CarCode"; const MachinesDialog = ({ setMachine, mode, machineCode, setShowMachineCodeDialog }) => { const [openMachinesDialog, setOpenMachinesDialog] = useState(false); @@ -33,23 +35,14 @@ const MachinesDialog = ({ setMachine, mode, machineCode, setShowMachineCodeDialo {openMachinesDialog && ( - { - setMachine(event.target.value); - }} - variant="outlined" - fullWidth - /> + + { + setMachine(value.machine_code); + }} + /> + + + + + + ); +}; +export default CreateViolationForm \ No newline at end of file diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/index.jsx new file mode 100644 index 0000000..260b0d9 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/index.jsx @@ -0,0 +1,39 @@ +import { DialogTitle } from "@mui/material"; +import { DialogHeader } from "next/dist/client/components/react-dev-overlay/internal/components/Dialog"; +import useRequest from "@/lib/hooks/useRequest"; +import { CREATE_VIOLATION } from "@/core/utils/routes"; +import CreateViolationForm from "@/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/CreateForm"; + +const ViolationForm = ({ setOpenMachinesDialog, mutate, openMachinesDialog }) => { + const requestServer = useRequest({ notificationSuccess: true }); + + const defaultValues = { + machinesId: null, + }; + + const submitForm = async (result) => { + await requestServer(CREATE_VIOLATION, "post", { + data: { + machine_code: result.machinesId.machine_code, + }, + }) + .then((response) => { + setOpenMachinesDialog(false); + mutate(); + }) + .catch((error) => {}); + }; + return ( + <> + + ثبت تخلف + + + + ); +}; +export default ViolationForm; diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/index.jsx new file mode 100644 index 0000000..eb431f4 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/index.jsx @@ -0,0 +1,50 @@ +import { AddCircle, Close } from "@mui/icons-material"; +import { Button, Dialog, IconButton, Tooltip } from "@mui/material"; +import { useState } from "react"; +import ViolationForm from "./Form"; + + +const CreateViolation = ({ mutate }) => { + const [openMachinesDialog, setOpenMachinesDialog] = useState(false); + + return ( + <> + + + + + + setOpenMachinesDialog(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + + {openMachinesDialog && ( + + )} + + + ); +}; +export default CreateViolation; diff --git a/src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditController.jsx b/src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditController.jsx new file mode 100644 index 0000000..97ae1e2 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditController.jsx @@ -0,0 +1,51 @@ +import { EDIT_VIOLATION } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { DialogTitle } from "@mui/material"; +import { DialogHeader } from "next/dist/client/components/react-dev-overlay/internal/components/Dialog"; +import EditViolationForm from "./EditViolationForm"; +import moment from "jalali-moment"; + +const EditController = ({ rowId, mutate, setOpen }) => { + const requestServer = useRequest({ notificationSuccess: true }); + + const defaultData = { + start_date: null, + start_time: null, + end_date: null, + end_time: null, + }; + const handleSubmit = async (result) => { + const payload = {}; + + if (result.start_date && result.start_time) { + payload.enter_time = `${result.start_date} ${moment(result.start_time).format("HH:mm")}`; + } + + if (result.end_date && result.end_time) { + payload.exit_time = `${result.end_date} ${moment(result.end_time).format("HH:mm")}`; + } + + await requestServer(`${EDIT_VIOLATION}/${rowId}`, "post", { + data: payload, + }) + .then(() => { + mutate(); + setOpen(false); + }) + .catch(() => {}); + }; + + return ( + <> + + ثبت تردد + + + + ); +}; +export default EditController; diff --git a/src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditViolationForm.jsx b/src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditViolationForm.jsx new file mode 100644 index 0000000..0c07e7b --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditViolationForm.jsx @@ -0,0 +1,95 @@ +import { useForm } from "react-hook-form"; +import { yupResolver } from "@hookform/resolvers/yup"; +import StyledForm from "@/core/components/StyledForm"; +import { Box, Button, DialogActions, DialogContent, Grid, Stack } from "@mui/material"; +import MissionDates from "./MissionDates"; +import * as yup from "yup"; + +export const schema = yup + .object({ + start_date: yup.string().nullable(), + start_time: yup.string().nullable(), + end_date: yup.string().nullable(), + end_time: yup.string().nullable(), + }) + .test("valid-dates", function (values) { + if (!values) return false; + + const hasStartDate = !!values.start_date; + const hasStartTime = !!values.start_time; + const hasEndDate = !!values.end_date; + const hasEndTime = !!values.end_time; + + if (hasStartDate !== hasStartTime) { + return this.createError({ + message: "تاریخ و زمان شروع باید هر دو وارد شوند", + }); + } + + if (hasEndDate !== hasEndTime) { + return this.createError({ + message: "تاریخ و زمان پایان باید هر دو وارد شوند", + }); + } + + if (!((hasStartDate && hasStartTime) || (hasEndDate && hasEndTime))) { + return this.createError({ + message: "حداقل تاریخ و زمان شروع یا پایان باید مشخص شود", + }); + } + + return true; + }); + +const EditViolationForm = ({ setOpenMachinesDialog, defaultValues, onSubmitBase }) => { + const { + control, + handleSubmit, + formState: { isSubmitting, errors }, + } = useForm({ defaultValues, resolver: yupResolver(schema), mode: "all" }); + + const handleOnSubmit = async (data) => { + await onSubmitBase(data); + }; + return ( + <> + + + + + + + + {errors?.[""]?.message && ( + + {errors?.[""]?.message} + + )} + + + + + + + + + + ); +}; +export default EditViolationForm \ No newline at end of file diff --git a/src/components/dashboard/roadMissions/violations/Actions/EditViolation/MissionDates/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/EditViolation/MissionDates/index.jsx new file mode 100644 index 0000000..225ab8f --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/EditViolation/MissionDates/index.jsx @@ -0,0 +1,99 @@ +import MuiDatePicker from "@/core/components/MuiDatePicker"; +import MuiTimePicker from "@/core/components/MuiTimePicker"; +import { makeDateTime } from "@/core/utils/makeDateTime"; +import { Grid } from "@mui/material"; +import { Controller, useWatch } from "react-hook-form"; + +const MissionDates = ({ control }) => { + const start_date = useWatch({ control, name: "start_date" }); + const end_date = useWatch({ control, name: "end_date" }); + const now = new Date(); + + return ( + <> + + { + return ( + field.onChange(value || [])} + helperText={error ? error.message : null} + /> + ); + }} + /> + + + { + return ( + field.onChange(value || null)} + helperText={error ? error.message : null} + /> + ); + }} + /> + + + { + return ( + field.onChange(value || [])} + helperText={error ? error.message : null} + /> + ); + }} + /> + + + { + return ( + field.onChange(value || null)} + helperText={error ? error.message : null} + /> + ); + }} + /> + + + ); +}; +export default MissionDates; diff --git a/src/components/dashboard/roadMissions/violations/Actions/EditViolation/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/EditViolation/index.jsx new file mode 100644 index 0000000..506d325 --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Actions/EditViolation/index.jsx @@ -0,0 +1,51 @@ +import CloseIcon from "@mui/icons-material/Close"; +import { Dialog, IconButton, Tooltip } from "@mui/material"; +import { useState } from "react"; +import BookmarkAddIcon from "@mui/icons-material/BookmarkAdd"; +import EditController from "./EditController"; + +const EditViolation = ({ mutate, row, rowId }) => { + const [open, setOpen] = useState(false); + + return ( + <> + + { + setOpen(true); + }} + > + + + + + setOpen(false)} + sx={(theme) => ({ + position: "absolute", + right: 8, + top: 8, + zIndex: 50, + color: theme.palette.grey[500], + })} + > + + + {open && } + + + ); +}; +export default EditViolation; diff --git a/src/components/dashboard/roadMissions/violations/RowActions/index.jsx b/src/components/dashboard/roadMissions/violations/RowActions/index.jsx index 0451883..01c8254 100644 --- a/src/components/dashboard/roadMissions/violations/RowActions/index.jsx +++ b/src/components/dashboard/roadMissions/violations/RowActions/index.jsx @@ -1,7 +1,15 @@ import CreateWithoutProcess from "../Actions/CreateWithoutProcess"; +import EditViolation from "../Actions/EditViolation"; const RowActions = ({ row, mutate }) => { const canEdit = row.original.status === 0 && row.original.type === 1; - return canEdit && ; + return ( + <> + {!row.original.mileage && + } + {canEdit && } + + ); + }; export default RowActions; diff --git a/src/components/dashboard/roadMissions/violations/Toolbar.jsx b/src/components/dashboard/roadMissions/violations/Toolbar.jsx new file mode 100644 index 0000000..1edd6cd --- /dev/null +++ b/src/components/dashboard/roadMissions/violations/Toolbar.jsx @@ -0,0 +1,11 @@ +import { Stack } from "@mui/material"; +import CreateViolation from "./Actions/CreateViolation"; + +const Toolbar = ({ mutate }) => { + return ( + + + + ); +}; +export default Toolbar; diff --git a/src/components/dashboard/roadMissions/violations/ViolationsList.jsx b/src/components/dashboard/roadMissions/violations/ViolationsList.jsx index f7a3719..dfbc013 100644 --- a/src/components/dashboard/roadMissions/violations/ViolationsList.jsx +++ b/src/components/dashboard/roadMissions/violations/ViolationsList.jsx @@ -5,6 +5,7 @@ import { Box } from "@mui/material"; import moment from "jalali-moment"; import { useMemo } from "react"; import RowActions from "./RowActions"; +import Toolbar from "./Toolbar"; const ViolationsList = () => { const columns = useMemo( @@ -68,6 +69,7 @@ const ViolationsList = () => { Date: Sun, 28 Dec 2025 11:11:37 +0330 Subject: [PATCH 3/3] build and format --- .../roadMissions/operator/OperatorList.jsx | 683 +++++++++--------- .../RowActions/Edit/EditController/index.jsx | 2 +- .../transportation/TransportationList.jsx | 428 ++++++----- .../CreateViolation/Form/CreateForm.jsx | 58 +- .../Actions/CreateViolation/index.jsx | 1 - .../EditViolation/EditViolationForm.jsx | 2 +- .../violations/RowActions/index.jsx | 4 +- .../roadMissions/violations/Toolbar.jsx | 2 +- 8 files changed, 586 insertions(+), 594 deletions(-) diff --git a/src/components/dashboard/roadMissions/operator/OperatorList.jsx b/src/components/dashboard/roadMissions/operator/OperatorList.jsx index fb866da..e343866 100644 --- a/src/components/dashboard/roadMissions/operator/OperatorList.jsx +++ b/src/components/dashboard/roadMissions/operator/OperatorList.jsx @@ -18,379 +18,374 @@ import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsT import useCities from "@/lib/hooks/useCities"; const OperatorList = () => { - const columns = useMemo( - () =>{ - const dynamicColumns = { - header: "استان", - id: "province_id", + const columns = useMemo(() => { + const dynamicColumns = { + header: "استان", + id: "province_id", + enableColumnFilter: true, + datatype: "numeric", + filterMode: "equals", + grow: false, + size: 130, + ColumnSelectComponent: (props) => { + const { provinces, errorProvinces, loadingProvinces } = useProvinces(); + const getColumnSelectOptions = useMemo(() => { + if (loadingProvinces) { + return [{ value: "loading", label: "در حال بارگذاری..." }]; + } + if (errorProvinces) { + return [{ value: "error", label: "خطا در بارگذاری" }]; + } + return [ + { value: "", label: "کل کشور" }, + ...provinces.map((province) => ({ + value: province.id, + label: province.name_fa, + })), + ]; + }, [provinces, errorProvinces, loadingProvinces]); + return ( + + ); + }, + Cell: ({ renderedCellValue, row }) => { + return <>{row.original.province_name}; + }, + }; + return [ + { + accessorKey: "id", + header: "کد یکتا", + id: "id", enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + }, + { + accessorKey: "code", + header: "کد خروج", + id: "code", + enableColumnFilter: false, datatype: "numeric", filterMode: "equals", grow: false, - size: 130, + size: 100, + }, + ...[dynamicColumns], + { + header: "شهر", + id: "city_id", + enableColumnFilter: true, + datatype: "numeric", + filterMode: "equals", + dependencyId: "province_id", + grow: false, + size: 120, ColumnSelectComponent: (props) => { - const { provinces, errorProvinces, loadingProvinces } = useProvinces(); + const { cityList, loadingCityList, errorCityList } = useCities(props.dependencyFieldValue.value); + const getColumnSelectOptions = useMemo(() => { - if (loadingProvinces) { + if (props.dependencyFieldValue.value === "") { + return [{ value: "empty", label: "ابتدا استان را انتخاب کنید" }]; + } + if (loadingCityList) { return [{ value: "loading", label: "در حال بارگذاری..." }]; } - if (errorProvinces) { + if (errorCityList) { return [{ value: "error", label: "خطا در بارگذاری" }]; } return [ - { value: "", label: "کل کشور" }, - ...provinces.map((province) => ({ - value: province.id, - label: province.name_fa, + { value: "", label: "کل ادارات" }, + ...cityList.map((edare) => ({ + value: edare.id, + label: edare.name_fa, })), ]; - }, [provinces, errorProvinces, loadingProvinces]); + }, [cityList, loadingCityList, errorCityList]); return ( ); }, + Cell: ({ row }) => <>{row.original.city_name}, + }, + { + accessorKey: "station_name", + header: "راهدارخانه", + id: "station_name", + enableColumnFilter: false, + datatype: "text", + filterMode: "equals", + grow: false, + size: 100, + }, + { + accessorKey: "state_name", + header: "وضعیت", + id: "state_name", + enableColumnFilter: false, + datatype: "numeric", + filterMode: "equals", + grow: false, + size: 100, + }, + { + accessorKey: "explanation", + header: "موضوع", + id: "explanation", + enableColumnFilter: false, + datatype: "numeric", + filterMode: "equals", + grow: false, + size: 100, + }, + { + accessorKey: "category_id", + header: "نوع", + id: "category_id", + enableColumnFilter: true, + datatype: "numeric", + filterMode: "equals", + sortDescFirst: true, + grow: false, + size: 100, + columnSelectOption: () => { + return missionCategoryTypes.map((category) => ({ + value: category.id, + label: category.name_fa, + })); + }, + Cell: ({ row }) => row.original.category_name, + }, + { + accessorKey: "zone", + header: "محدوده", + id: "zone", + enableColumnFilter: true, + datatype: "numeric", + filterMode: "equals", + sortDescFirst: true, + grow: false, + size: 100, + columnSelectOption: () => { + return missionRegions.map((region) => ({ + value: region.id, + label: region.name_fa, + })); + }, + Cell: ({ row }) => row.original.zone_fa, + }, + { + accessorKey: "type", + header: "نوع زمانبندی", + id: "type", + enableColumnFilter: true, + datatype: "numeric", + filterMode: "equals", + sortDescFirst: true, + grow: false, + size: 100, + columnSelectOption: () => { + return missionTypes.map((type) => ({ + value: type.id, + label: type.name_fa, + })); + }, + Cell: ({ row }) => row.original.type_fa, + }, + { + accessorFn: (row) => + row.type == 1 + ? moment(row.start_date).locale("fa").format("HH:mm | yyyy/MM/DD") + : moment(row.start_date).locale("fa").format("yyyy/MM/DD"), + header: "تاریخ شروع", + id: "start_date", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + size: 100, + }, + { + accessorFn: (row) => + row.type == 1 + ? moment(row.end_date).locale("fa").format("HH:mm | yyyy/MM/DD") + : moment(row.end_date).locale("fa").format("yyyy/MM/DD"), + header: "تاریخ پایان", + id: "end_date", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + size: 100, + }, + { + accessorKey: "end_point", + header: "مقصد", + id: "end_point", + enableColumnFilter: false, + datatype: "numeric", + filterMode: "equals", + grow: false, + size: 100, + }, + { + header: "منطقه عملیاتی", + id: "area", + enableColumnFilter: false, + datatype: "numeric", + filterMode: "equals", + grow: false, + size: 100, + muiTableBodyCellProps: { + sx: { + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ row }) => + row.original.area ? ( + + + + ) : ( + "-" + ), + }, + { + header: "خودرو", + id: "cmmsMachines__machine_code", + enableColumnFilter: true, + datatype: "text", + filterMode: "contains", + enableSorting: false, + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + muiTableBodyCellProps: { + sx: { + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, Cell: ({ renderedCellValue, row }) => { - return <>{row.original.province_name}; + return ( + + + + ); }, - }; - return [ - { - accessorKey: "id", - header: "کد یکتا", - id: "id", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - }, - { - accessorKey: "code", - header: "کد خروج", - id: "code", - enableColumnFilter: false, - datatype: "numeric", - filterMode: "equals", - grow: false, - size: 100, - }, - ...[dynamicColumns], - { - header: "شهر", - id: "city_id", - enableColumnFilter: true, - datatype: "numeric", - filterMode: "equals", - dependencyId: "province_id", - grow: false, - size: 120, - ColumnSelectComponent: (props) => { - const { cityList, loadingCityList, errorCityList } = useCities( - props.dependencyFieldValue.value - ); - - const getColumnSelectOptions = useMemo(() => { - if (props.dependencyFieldValue.value === "") { - return [{ value: "empty", label: "ابتدا استان را انتخاب کنید" }]; - } - if (loadingCityList) { - return [{ value: "loading", label: "در حال بارگذاری..." }]; - } - if (errorCityList) { - return [{ value: "error", label: "خطا در بارگذاری" }]; - } - return [ - { value: "", label: "کل ادارات" }, - ...cityList.map((edare) => ({ - value: edare.id, - label: edare.name_fa, - })), - ]; - }, [cityList, loadingCityList, errorCityList]); - return ( - - ); - }, - Cell: ({ row }) => <>{row.original.city_name}, - }, - { - accessorKey: "station_name", - header: "راهدارخانه", - id: "station_name", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - grow: false, - size: 100, - }, - { - accessorKey: "state_name", - header: "وضعیت", - id: "state_name", - enableColumnFilter: false, - datatype: "numeric", - filterMode: "equals", - grow: false, - size: 100, - }, - { - accessorKey: "explanation", - header: "موضوع", - id: "explanation", - enableColumnFilter: false, - datatype: "numeric", - filterMode: "equals", - grow: false, - size: 100, - }, - { - accessorKey: "category_id", - header: "نوع", - id: "category_id", - enableColumnFilter: true, - datatype: "numeric", - filterMode: "equals", - sortDescFirst: true, - grow: false, - size: 100, - columnSelectOption: () => { - return missionCategoryTypes.map((category) => ({ - value: category.id, - label: category.name_fa, - })); - }, - Cell: ({ row }) => row.original.category_name, - }, - { - accessorKey: "zone", - header: "محدوده", - id: "zone", - enableColumnFilter: true, - datatype: "numeric", - filterMode: "equals", - sortDescFirst: true, - grow: false, - size: 100, - columnSelectOption: () => { - return missionRegions.map((region) => ({ - value: region.id, - label: region.name_fa, - })); - }, - Cell: ({ row }) => row.original.zone_fa, - }, - { - accessorKey: "type", - header: "نوع زمانبندی", - id: "type", - enableColumnFilter: true, - datatype: "numeric", - filterMode: "equals", - sortDescFirst: true, - grow: false, - size: 100, - columnSelectOption: () => { - return missionTypes.map((type) => ({ - value: type.id, - label: type.name_fa, - })); - }, - Cell: ({ row }) => row.original.type_fa, - }, - { - accessorFn: (row) => - row.type == 1 - ? moment(row.start_date).locale("fa").format("HH:mm | yyyy/MM/DD") - : moment(row.start_date).locale("fa").format("yyyy/MM/DD"), - header: "تاریخ شروع", - id: "start_date", - enableColumnFilter: true, - datatype: "date", - filterMode: "between", - grow: false, - size: 100, - }, - { - accessorFn: (row) => - row.type == 1 - ? moment(row.end_date).locale("fa").format("HH:mm | yyyy/MM/DD") - : moment(row.end_date).locale("fa").format("yyyy/MM/DD"), - header: "تاریخ پایان", - id: "end_date", - enableColumnFilter: true, - datatype: "date", - filterMode: "between", - grow: false, - size: 100, - }, - { - accessorKey: "end_point", - header: "مقصد", - id: "end_point", - enableColumnFilter: false, - datatype: "numeric", - filterMode: "equals", - grow: false, - size: 100, - }, - { - header: "منطقه عملیاتی", - id: "area", - enableColumnFilter: false, - datatype: "numeric", - filterMode: "equals", - grow: false, - size: 100, - muiTableBodyCellProps: { - sx: { - borderLeft: "1px solid #e1e1e1", - py: 0, - "&:first-of-type": { - borderLeft: "unset", - }, + }, + { + header: "افراد", + id: "rahdaran__code", + enableColumnFilter: true, + enableSorting: false, + datatype: "text", + filterMode: "contains", + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + muiTableBodyCellProps: { + sx: { + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", }, }, - Cell: ({ row }) => - row.original.area ? ( - - - - ) : ( - "-" - ), }, - { - header: "خودرو", - id: "cmmsMachines__machine_code", - enableColumnFilter: true, - datatype: "text", - filterMode: "contains", - enableSorting: false, - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - muiTableBodyCellProps: { - sx: { - borderLeft: "1px solid #e1e1e1", - py: 0, - "&:first-of-type": { - borderLeft: "unset", - }, + Cell: ({ row }) => { + return ( + + + + ); + }, + }, + { + header: "دلیل رد درخواست", + id: "description", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + filterMode: "contains", + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + muiTableBodyCellProps: { + sx: { + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", }, }, - Cell: ({ renderedCellValue, row }) => { - return ( - - - - ); - }, }, - { - header: "افراد", - id: "rahdaran__code", - enableColumnFilter: true, - enableSorting: false, - datatype: "text", - filterMode: "contains", - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - muiTableBodyCellProps: { - sx: { - borderLeft: "1px solid #e1e1e1", - py: 0, - "&:first-of-type": { - borderLeft: "unset", - }, - }, - }, - Cell: ({ row }) => { - return ( - - - - ); - }, + Cell: ({ row }) => { + return ( + + + + ); }, - { - header: "دلیل رد درخواست", - id: "description", - enableColumnFilter: false, - enableSorting: false, - datatype: "text", - filterMode: "contains", - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, - muiTableBodyCellProps: { - sx: { - borderLeft: "1px solid #e1e1e1", - py: 0, - "&:first-of-type": { - borderLeft: "unset", - }, - }, - }, - Cell: ({ row }) => { - return ( - - - - ); - }, - }, - { - accessorFn: (row) => - row.start_time ? moment(row.start_time).locale("fa").format("HH:mm | yyyy/MM/DD") : null, - header: "تاریخ خروج", - id: "start_time", - enableColumnFilter: true, - datatype: "date", - filterMode: "between", - grow: false, - size: 100, - }, - { - accessorFn: (row) => - row.finish_time ? moment(row.finish_time).locale("fa").format("HH:mm | yyyy/MM/DD") : null, - header: "تاریخ ورود", - id: "finish_time", - enableColumnFilter: true, - datatype: "date", - filterMode: "between", - grow: false, - size: 100, - }, - { - accessorFn: (row) => moment(row.request_date).locale("fa").format("HH:mm | yyyy/MM/DD"), - header: "تاریخ ثبت", - id: "request_date", - enableColumnFilter: true, - datatype: "date", - filterMode: "between", - grow: false, - size: 100, - }, - ]; - }, - [] - ); + }, + { + accessorFn: (row) => + row.start_time ? moment(row.start_time).locale("fa").format("HH:mm | yyyy/MM/DD") : null, + header: "تاریخ خروج", + id: "start_time", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + size: 100, + }, + { + accessorFn: (row) => + row.finish_time ? moment(row.finish_time).locale("fa").format("HH:mm | yyyy/MM/DD") : null, + header: "تاریخ ورود", + id: "finish_time", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + size: 100, + }, + { + accessorFn: (row) => moment(row.request_date).locale("fa").format("HH:mm | yyyy/MM/DD"), + header: "تاریخ ثبت", + id: "request_date", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + size: 100, + }, + ]; + }, []); return ( <> diff --git a/src/components/dashboard/roadMissions/operator/RowActions/Edit/EditController/index.jsx b/src/components/dashboard/roadMissions/operator/RowActions/Edit/EditController/index.jsx index 57db6f6..6d9cac7 100644 --- a/src/components/dashboard/roadMissions/operator/RowActions/Edit/EditController/index.jsx +++ b/src/components/dashboard/roadMissions/operator/RowActions/Edit/EditController/index.jsx @@ -35,7 +35,7 @@ const EditController = ({ row, mutate, openEditDialog, setOpenEditDialog }) => { const submitForm = async (result) => { setSubmitting(true); - const latlngs = result.bound.getLatLngs(); + const latlngs = result.bound.getLatLngs(); const normalized = result.bound_type === "polygon" ? latlngs : [latlngs]; diff --git a/src/components/dashboard/roadMissions/transportation/TransportationList.jsx b/src/components/dashboard/roadMissions/transportation/TransportationList.jsx index ec7800a..ab735d2 100644 --- a/src/components/dashboard/roadMissions/transportation/TransportationList.jsx +++ b/src/components/dashboard/roadMissions/transportation/TransportationList.jsx @@ -13,247 +13,243 @@ import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsT import useCities from "@/lib/hooks/useCities"; const TransportationList = () => { - const columns = useMemo( - () => { - const dynamicColumns = { - header: "استان", - id: "province_id", + const columns = useMemo(() => { + const dynamicColumns = { + header: "استان", + id: "province_id", + enableColumnFilter: true, + datatype: "numeric", + filterMode: "equals", + grow: false, + size: 130, + ColumnSelectComponent: (props) => { + const { provinces, errorProvinces, loadingProvinces } = useProvinces(); + const getColumnSelectOptions = useMemo(() => { + if (loadingProvinces) { + return [{ value: "loading", label: "در حال بارگذاری..." }]; + } + if (errorProvinces) { + return [{ value: "error", label: "خطا در بارگذاری" }]; + } + return [ + { value: "", label: "کل کشور" }, + ...provinces.map((province) => ({ + value: province.id, + label: province.name_fa, + })), + ]; + }, [provinces, errorProvinces, loadingProvinces]); + return ( + + ); + }, + Cell: ({ renderedCellValue, row }) => { + return <>{row.original.province_name}; + }, + }; + return [ + { + accessorKey: "id", + header: "کد یکتا", + id: "id", enableColumnFilter: true, + datatype: "text", + filterMode: "equals", + columnFilterModeOptions: ["equals", "contains"], + grow: false, + size: 100, + }, + { + accessorKey: "state_name", + header: "وضعیت", + id: "state_name", + enableColumnFilter: false, datatype: "numeric", filterMode: "equals", grow: false, - size: 130, + size: 100, + }, + ...[dynamicColumns], + { + header: "شهر", + id: "city_id", + enableColumnFilter: true, + datatype: "numeric", + filterMode: "equals", + dependencyId: "province_id", + grow: false, + size: 120, ColumnSelectComponent: (props) => { - const { provinces, errorProvinces, loadingProvinces } = useProvinces(); + const { cityList, loadingCityList, errorCityList } = useCities(props.dependencyFieldValue.value); + const getColumnSelectOptions = useMemo(() => { - if (loadingProvinces) { + if (props.dependencyFieldValue.value === "") { + return [{ value: "empty", label: "ابتدا استان را انتخاب کنید" }]; + } + if (loadingCityList) { return [{ value: "loading", label: "در حال بارگذاری..." }]; } - if (errorProvinces) { + if (errorCityList) { return [{ value: "error", label: "خطا در بارگذاری" }]; } return [ - { value: "", label: "کل کشور" }, - ...provinces.map((province) => ({ - value: province.id, - label: province.name_fa, + { value: "", label: "کل ادارات" }, + ...cityList.map((edare) => ({ + value: edare.id, + label: edare.name_fa, })), ]; - }, [provinces, errorProvinces, loadingProvinces]); + }, [cityList, loadingCityList, errorCityList]); return ( ); }, - Cell: ({ renderedCellValue, row }) => { - return <>{row.original.province_name}; + Cell: ({ row }) => <>{row.original.city_name}, + }, + { + accessorKey: "station_name", + header: "راهدارخانه", + id: "station_name", + enableColumnFilter: false, + datatype: "text", + filterMode: "equals", + grow: false, + size: 100, + }, + { + accessorKey: "explanation", + header: "موضوع", + id: "explanation", + enableColumnFilter: false, + datatype: "numeric", + filterMode: "equals", + grow: false, + size: 100, + }, + { + accessorKey: "zone", + header: "محدوده", + id: "zone", + enableColumnFilter: true, + datatype: "numeric", + filterMode: "equals", + sortDescFirst: true, + grow: false, + size: 100, + columnSelectOption: () => { + return missionRegions.map((region) => ({ + value: region.id, + label: region.name_fa, + })); }, - }; - return [ - { - accessorKey: "id", - header: "کد یکتا", - id: "id", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - columnFilterModeOptions: ["equals", "contains"], - grow: false, - size: 100, + Cell: ({ row }) => row.original.zone_fa, + }, + { + accessorKey: "type", + header: "نوع زمانبندی", + id: "type", + enableColumnFilter: true, + datatype: "numeric", + filterMode: "equals", + sortDescFirst: true, + grow: false, + size: 100, + columnSelectOption: () => { + return missionTypes.map((type) => ({ + value: type.id, + label: type.name_fa, + })); }, - { - accessorKey: "state_name", - header: "وضعیت", - id: "state_name", - enableColumnFilter: false, - datatype: "numeric", - filterMode: "equals", - grow: false, - size: 100, - }, - ...[dynamicColumns], - { - header: "شهر", - id: "city_id", - enableColumnFilter: true, - datatype: "numeric", - filterMode: "equals", - dependencyId: "province_id", - grow: false, - size: 120, - ColumnSelectComponent: (props) => { - const { cityList, loadingCityList, errorCityList } = useCities( - props.dependencyFieldValue.value - ); - - const getColumnSelectOptions = useMemo(() => { - if (props.dependencyFieldValue.value === "") { - return [{ value: "empty", label: "ابتدا استان را انتخاب کنید" }]; - } - if (loadingCityList) { - return [{ value: "loading", label: "در حال بارگذاری..." }]; - } - if (errorCityList) { - return [{ value: "error", label: "خطا در بارگذاری" }]; - } - return [ - { value: "", label: "کل ادارات" }, - ...cityList.map((edare) => ({ - value: edare.id, - label: edare.name_fa, - })), - ]; - }, [cityList, loadingCityList, errorCityList]); - return ( - - ); - }, - Cell: ({ row }) => <>{row.original.city_name}, - }, - { - accessorKey: "station_name", - header: "راهدارخانه", - id: "station_name", - enableColumnFilter: false, - datatype: "text", - filterMode: "equals", - grow: false, - size: 100, - }, - { - accessorKey: "explanation", - header: "موضوع", - id: "explanation", - enableColumnFilter: false, - datatype: "numeric", - filterMode: "equals", - grow: false, - size: 100, - }, - { - accessorKey: "zone", - header: "محدوده", - id: "zone", - enableColumnFilter: true, - datatype: "numeric", - filterMode: "equals", - sortDescFirst: true, - grow: false, - size: 100, - columnSelectOption: () => { - return missionRegions.map((region) => ({ - value: region.id, - label: region.name_fa, - })); - }, - Cell: ({ row }) => row.original.zone_fa, - }, - { - accessorKey: "type", - header: "نوع زمانبندی", - id: "type", - enableColumnFilter: true, - datatype: "numeric", - filterMode: "equals", - sortDescFirst: true, - grow: false, - size: 100, - columnSelectOption: () => { - return missionTypes.map((type) => ({ - value: type.id, - label: type.name_fa, - })); - }, - Cell: ({ row }) => row.original.type_fa, - }, - { - accessorFn: (row) => - row.type == 1 - ? moment(row.start_date).locale("fa").format("HH:mm | yyyy/MM/DD") - : moment(row.start_date).locale("fa").format("yyyy/MM/DD"), - header: "تاریخ شروع", - id: "start_date", - enableColumnFilter: true, - datatype: "date", - filterMode: "between", - grow: false, - size: 100, - }, - { - accessorFn: (row) => - row.type == 1 - ? moment(row.end_date).locale("fa").format("HH:mm | yyyy/MM/DD") - : moment(row.end_date).locale("fa").format("yyyy/MM/DD"), - header: "تاریخ پایان", - id: "end_date", - enableColumnFilter: true, - datatype: "date", - filterMode: "between", - grow: false, - size: 100, - }, - { - accessorKey: "end_point", - header: "مقصد", - id: "end_point", - enableColumnFilter: false, - datatype: "numeric", - filterMode: "equals", - grow: false, - size: 100, - }, - { - header: "منطقه عملیاتی", - id: "area", - enableColumnFilter: false, - datatype: "numeric", - filterMode: "equals", - grow: false, - size: 100, - muiTableBodyCellProps: { - sx: { - borderLeft: "1px solid #e1e1e1", - py: 0, - "&:first-of-type": { - borderLeft: "unset", - }, + Cell: ({ row }) => row.original.type_fa, + }, + { + accessorFn: (row) => + row.type == 1 + ? moment(row.start_date).locale("fa").format("HH:mm | yyyy/MM/DD") + : moment(row.start_date).locale("fa").format("yyyy/MM/DD"), + header: "تاریخ شروع", + id: "start_date", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + size: 100, + }, + { + accessorFn: (row) => + row.type == 1 + ? moment(row.end_date).locale("fa").format("HH:mm | yyyy/MM/DD") + : moment(row.end_date).locale("fa").format("yyyy/MM/DD"), + header: "تاریخ پایان", + id: "end_date", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + size: 100, + }, + { + accessorKey: "end_point", + header: "مقصد", + id: "end_point", + enableColumnFilter: false, + datatype: "numeric", + filterMode: "equals", + grow: false, + size: 100, + }, + { + header: "منطقه عملیاتی", + id: "area", + enableColumnFilter: false, + datatype: "numeric", + filterMode: "equals", + grow: false, + size: 100, + muiTableBodyCellProps: { + sx: { + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", }, }, - Cell: ({ row }) => - row.original.area ? ( - - - - ) : ( - "-" - ), }, - { - accessorFn: (row) => moment(row.request_date).locale("fa").format("HH:mm | yyyy/MM/DD"), - header: "تاریخ ثبت", - id: "request_date", - enableColumnFilter: true, - datatype: "date", - filterMode: "between", - grow: false, - size: 100, - }, - ];}, - [] - ); + Cell: ({ row }) => + row.original.area ? ( + + + + ) : ( + "-" + ), + }, + { + accessorFn: (row) => moment(row.request_date).locale("fa").format("HH:mm | yyyy/MM/DD"), + header: "تاریخ ثبت", + id: "request_date", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + size: 100, + }, + ]; + }, []); return ( <> diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/CreateForm.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/CreateForm.jsx index 2aacad1..eca6626 100644 --- a/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/CreateForm.jsx +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/CreateForm.jsx @@ -9,7 +9,6 @@ const schema = yup.object().shape({ }); const CreateViolationForm = ({ setOpenMachinesDialog, defaultValues, onSubmitBase }) => { - const { control, handleSubmit, @@ -22,33 +21,38 @@ const CreateViolationForm = ({ setOpenMachinesDialog, defaultValues, onSubmitBas return ( <> - - - { - return ( - field.onChange(value)} - error={error} - /> - ); - }} - name={"machinesId"} - /> - - - - - - + + + { + return ( + field.onChange(value)} + error={error} + /> + ); + }} + name={"machinesId"} + /> + + + + + + ); }; -export default CreateViolationForm \ No newline at end of file +export default CreateViolationForm; diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/index.jsx index eb431f4..10815d3 100644 --- a/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/index.jsx +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/index.jsx @@ -3,7 +3,6 @@ import { Button, Dialog, IconButton, Tooltip } from "@mui/material"; import { useState } from "react"; import ViolationForm from "./Form"; - const CreateViolation = ({ mutate }) => { const [openMachinesDialog, setOpenMachinesDialog] = useState(false); diff --git a/src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditViolationForm.jsx b/src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditViolationForm.jsx index 0c07e7b..4beac95 100644 --- a/src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditViolationForm.jsx +++ b/src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditViolationForm.jsx @@ -92,4 +92,4 @@ const EditViolationForm = ({ setOpenMachinesDialog, defaultValues, onSubmitBase ); }; -export default EditViolationForm \ No newline at end of file +export default EditViolationForm; diff --git a/src/components/dashboard/roadMissions/violations/RowActions/index.jsx b/src/components/dashboard/roadMissions/violations/RowActions/index.jsx index 01c8254..aafa0f6 100644 --- a/src/components/dashboard/roadMissions/violations/RowActions/index.jsx +++ b/src/components/dashboard/roadMissions/violations/RowActions/index.jsx @@ -5,11 +5,9 @@ const RowActions = ({ row, mutate }) => { const canEdit = row.original.status === 0 && row.original.type === 1; return ( <> - {!row.original.mileage && - } + {!row.original.mileage && } {canEdit && } ); - }; export default RowActions; diff --git a/src/components/dashboard/roadMissions/violations/Toolbar.jsx b/src/components/dashboard/roadMissions/violations/Toolbar.jsx index 1edd6cd..e85e4bb 100644 --- a/src/components/dashboard/roadMissions/violations/Toolbar.jsx +++ b/src/components/dashboard/roadMissions/violations/Toolbar.jsx @@ -4,7 +4,7 @@ import CreateViolation from "./Actions/CreateViolation"; const Toolbar = ({ mutate }) => { return ( - + ); };