From acc013ad8159f2503d211a2980e88bfb6698cf8e Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Sat, 13 Jun 2026 15:12:04 +0330 Subject: [PATCH] build and format --- .../operator/Actions/Violations/Dialog.jsx | 4 +- .../Actions/Violations/RowActions/index.jsx | 4 +- .../Form/MachinesDialog/MachineList/index.jsx | 18 +- .../violations/ViolationsList.jsx | 269 +++++++++--------- 4 files changed, 144 insertions(+), 151 deletions(-) diff --git a/src/components/dashboard/roadMissions/operator/Actions/Violations/Dialog.jsx b/src/components/dashboard/roadMissions/operator/Actions/Violations/Dialog.jsx index bd3849a..200b891 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/Violations/Dialog.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/Violations/Dialog.jsx @@ -19,9 +19,7 @@ const ViolationsDialog = ({ open, setOpen, mutate, row }) => { تخلفات - {open && ( - - )} + {open && } ); }; diff --git a/src/components/dashboard/roadMissions/operator/Actions/Violations/RowActions/index.jsx b/src/components/dashboard/roadMissions/operator/Actions/Violations/RowActions/index.jsx index d65dc1f..24e9532 100644 --- a/src/components/dashboard/roadMissions/operator/Actions/Violations/RowActions/index.jsx +++ b/src/components/dashboard/roadMissions/operator/Actions/Violations/RowActions/index.jsx @@ -1,9 +1,9 @@ import MissionCorrection from "./MissionCorrection"; -export default function RowActions({row, mutate}) { +export default function RowActions({ row, mutate }) { return ( <> ); -} \ No newline at end of file +} diff --git a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/MachinesDialog/MachineList/index.jsx b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/MachinesDialog/MachineList/index.jsx index 641d464..4173929 100644 --- a/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/MachinesDialog/MachineList/index.jsx +++ b/src/components/dashboard/roadMissions/transportation/RowActions/Allocation/Form/MachinesDialog/MachineList/index.jsx @@ -6,14 +6,14 @@ import { GET_MACHINES_TABLE_LIST } from "@/core/utils/routes"; import { useAuth } from "@/lib/contexts/auth"; const statusTypes = [ - {id : 1, name_fa : "آماده"}, - {id : 2, name_fa : "رزرو"}, - {id : 3, name_fa : "در ماموریت"}, - {id : 4, name_fa : "خارج از رده"}, - {id : 5, name_fa : "در تعمیر"}, - {id : 6, name_fa : "فروخته شده"}, - {id : 7, name_fa : "نیاز به تعمیر"}, -] + { id: 1, name_fa: "آماده" }, + { id: 2, name_fa: "رزرو" }, + { id: 3, name_fa: "در ماموریت" }, + { id: 4, name_fa: "خارج از رده" }, + { id: 5, name_fa: "در تعمیر" }, + { id: 6, name_fa: "فروخته شده" }, + { id: 7, name_fa: "نیاز به تعمیر" }, +]; const MachinesList = ({ machineType, setMachine, setOpenMachinesDialog }) => { const { @@ -61,7 +61,7 @@ const MachinesList = ({ machineType, setMachine, setOpenMachinesDialog }) => { }, Cell: ({ row }) => { const statusValue = row.original.status; - const statusItem = statusTypes.find(item => item.id === statusValue); + const statusItem = statusTypes.find((item) => item.id === statusValue); return statusItem ? statusItem.name_fa : statusValue; }, }, diff --git a/src/components/dashboard/roadMissions/violations/ViolationsList.jsx b/src/components/dashboard/roadMissions/violations/ViolationsList.jsx index 11ccd46..0f4f5fe 100644 --- a/src/components/dashboard/roadMissions/violations/ViolationsList.jsx +++ b/src/components/dashboard/roadMissions/violations/ViolationsList.jsx @@ -12,163 +12,158 @@ import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsT import useCities from "@/lib/hooks/useCities"; const ViolationsList = () => { - 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, + }, + { + accessorKey: "status", + header: "وضعیت", + id: "status", enableColumnFilter: true, datatype: "numeric", filterMode: "equals", + sortDescFirst: true, grow: false, - size: 130, + columnSelectOption: () => { + return violationsCategoryStatus.map((category) => ({ + value: category.id, + label: category.name_fa, + })); + }, + Cell: ({ row }) => (row.original.type === 1 ? "خروج بدون مجوز" : "عدم تحرک"), + }, + { + accessorKey: "machine_code", + header: "کد خودرو", + id: "machine_code", + datatype: "text", + columnFilterModeOptions: ["equals", "contains"], + grow: false, + }, + ...[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}; - }, - }; - return [ - { - accessorKey: "id", - header: "کد یکتا", - id: "id", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - columnFilterModeOptions: ["equals", "contains"], - grow: false, - }, - { - accessorKey: "status", - header: "وضعیت", - id: "status", - enableColumnFilter: true, - datatype: "numeric", - filterMode: "equals", - sortDescFirst: true, - grow: false, - columnSelectOption: () => { - return violationsCategoryStatus.map((category) => ({ - value: category.id, - label: category.name_fa, - })); - }, - Cell: ({ row }) => (row.original.type === 1 ? "خروج بدون مجوز" : "عدم تحرک"), - }, - { - accessorKey: "machine_code", - header: "کد خودرو", - id: "machine_code", - datatype: "text", - columnFilterModeOptions: ["equals", "contains"], - grow: false, - }, - ...[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: "machine", - header: "نام خودرو", - id: "machine", - datatype: "text", - columnFilterModeOptions: ["equals", "contains"], - grow: false, - Cell: ({ row }) => row.original.machine?.car_name || "-", - }, - { - accessorKey: "mission_id", - header: "کد ماموریت", - id: "mission_id", - enableColumnFilter: false, - datatype: "numeric", - filterMode: "equals", - grow: false, - Cell: ({ row }) => row.original.mission_id || "-", - }, - { - accessorKey: "request_date", - header: "تاریخ تخلف", - id: "request_date", - enableColumnFilter: true, - datatype: "date", - filterMode: "between", - grow: false, - Cell: ({ row }) => moment(row.original.request_date).locale("fa").format("YYYY/MM/DD"), - }, - ]; - }, - [] - ); + Cell: ({ row }) => <>{row.original.city_name}, + }, + { + accessorKey: "machine", + header: "نام خودرو", + id: "machine", + datatype: "text", + columnFilterModeOptions: ["equals", "contains"], + grow: false, + Cell: ({ row }) => row.original.machine?.car_name || "-", + }, + { + accessorKey: "mission_id", + header: "کد ماموریت", + id: "mission_id", + enableColumnFilter: false, + datatype: "numeric", + filterMode: "equals", + grow: false, + Cell: ({ row }) => row.original.mission_id || "-", + }, + { + accessorKey: "request_date", + header: "تاریخ تخلف", + id: "request_date", + enableColumnFilter: true, + datatype: "date", + filterMode: "between", + grow: false, + Cell: ({ row }) => moment(row.original.request_date).locale("fa").format("YYYY/MM/DD"), + }, + ]; + }, []); return ( <>