From 05dc5505cd173da61cf8944a36194cdbf8f3fe2d Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Sat, 13 Jun 2026 11:16:48 +0330 Subject: [PATCH] exit station time --- .../Actions/CreateViolation/Form/index.jsx | 2 +- .../CreateWithoutProcess/Form/index.jsx | 10 +- .../Actions/EditViolation/EditController.jsx | 6 +- .../EditViolation/MissionDates/index.jsx | 1 - .../violations/ViolationsList.jsx | 213 +++++++++++++----- 5 files changed, 160 insertions(+), 72 deletions(-) diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/index.jsx index ad34476..5d94b1f 100644 --- a/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/index.jsx +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateViolation/Form/index.jsx @@ -20,7 +20,7 @@ const ViolationForm = ({ setOpenMachinesDialog, mutate, openMachinesDialog }) => data: { machine_code: result.machinesId.machine_code, km: result.km, - exit_time: `${result.start_date} ${moment(result.start_time).format("HH:mm")}`, + exit_station: `${result.start_date} ${moment(result.start_time).format("HH:mm")}`, }, }) .then((response) => { diff --git a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx index 76230ad..5460b5a 100644 --- a/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx +++ b/src/components/dashboard/roadMissions/violations/Actions/CreateWithoutProcess/Form/index.jsx @@ -1,7 +1,6 @@ -import { AccessTime, Engineering, InsertDriveFile, Person, Verified } from "@mui/icons-material"; +import { Engineering, InsertDriveFile, Person, Verified } from "@mui/icons-material"; import { Box, Tab, Tabs } from "@mui/material"; import { useReducer, useState } from "react"; -import GetDateTime from "./GetDateTime"; import GetItemInfo from "./GetItemInfo"; import MachineAndDriver from "./MachineAndDriver"; import Rahdaran from "./Rahdaran"; @@ -42,7 +41,6 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { setTabState((t) => t - 1); } }; - return ( <> { setTabState={setTabState} /> - + { @@ -83,7 +81,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { setTabState={setTabState} /> - + { @@ -93,7 +91,7 @@ const CreateForm = ({ defaultValues, submitForm, setOpen, submitting }) => { setTabState={setTabState} /> - + diff --git a/src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditController.jsx b/src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditController.jsx index ab16760..6b3bfa3 100644 --- a/src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditController.jsx +++ b/src/components/dashboard/roadMissions/violations/Actions/EditViolation/EditController.jsx @@ -7,17 +7,17 @@ import moment from "jalali-moment"; const EditController = ({ rowId, mutate, setOpen, row }) => { const requestServer = useRequest({ notificationSuccess: true }); - const [endDate] = row?.original?.enter_time?.split(" ") || [null]; + const [endDate] = row?.original?.enter_station?.split(" ") || [null]; const defaultData = { end_date: endDate, - end_time: row?.original?.enter_time ? new Date(row.original.enter_time) : null, + end_time: row?.original?.enter_station ? new Date(row.original.enter_station) : null, }; const handleSubmit = async (result) => { const payload = {}; if (result.end_date && result.end_time) { - payload.enter_time = `${result.end_date} ${moment(result.end_time).format("HH:mm")}`; + payload.enter_station = `${result.end_date} ${moment(result.end_time).format("HH:mm")}`; } await requestServer(`${EDIT_VIOLATION}/${rowId}`, "post", { diff --git a/src/components/dashboard/roadMissions/violations/Actions/EditViolation/MissionDates/index.jsx b/src/components/dashboard/roadMissions/violations/Actions/EditViolation/MissionDates/index.jsx index ba07a09..8b0eaa5 100644 --- a/src/components/dashboard/roadMissions/violations/Actions/EditViolation/MissionDates/index.jsx +++ b/src/components/dashboard/roadMissions/violations/Actions/EditViolation/MissionDates/index.jsx @@ -41,7 +41,6 @@ const MissionDates = ({ control }) => { name="end_time" error={error} value={field.value} - views={["hours"]} placeholder={"زمان پایان ماموریت را وارد کنید"} label={"زمان پایان ماموریت"} setFieldValue={(name, value) => field.onChange(value || null)} diff --git a/src/components/dashboard/roadMissions/violations/ViolationsList.jsx b/src/components/dashboard/roadMissions/violations/ViolationsList.jsx index c78d6cc..11ccd46 100644 --- a/src/components/dashboard/roadMissions/violations/ViolationsList.jsx +++ b/src/components/dashboard/roadMissions/violations/ViolationsList.jsx @@ -7,75 +7,166 @@ import { useMemo } from "react"; import RowActions from "./RowActions"; import Toolbar from "./Toolbar"; import { violationsCategoryStatus } from "@/core/utils/violationsCategoryStatus"; +import useProvinces from "@/lib/hooks/useProvince"; +import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency"; +import useCities from "@/lib/hooks/useCities"; const ViolationsList = () => { const columns = useMemo( - () => [ - { - accessorKey: "id", - header: "کد یکتا", - id: "id", - enableColumnFilter: true, - datatype: "text", - filterMode: "equals", - columnFilterModeOptions: ["equals", "contains"], - grow: false, - }, - { - accessorKey: "status", - header: "وضعیت", - id: "status", + () => { + const dynamicColumns = { + header: "استان", + id: "province_id", enableColumnFilter: true, datatype: "numeric", filterMode: "equals", - sortDescFirst: true, grow: false, - columnSelectOption: () => { - return violationsCategoryStatus.map((category) => ({ - value: category.id, - label: category.name_fa, - })); + size: 130, + ColumnSelectComponent: (props) => { + const { provinces, errorProvinces, loadingProvinces } = useProvinces(); + const getColumnSelectOptions = useMemo(() => { + if (loadingProvinces) { + return [{ value: "loading", label: "در حال بارگذاری..." }]; + } + if (errorProvinces) { + return [{ value: "error", label: "خطا در بارگذاری" }]; + } + return [ + { value: "", label: "کل کشور" }, + ...provinces.map((province) => ({ + value: province.id, + label: province.name_fa, + })), + ]; + }, [provinces, errorProvinces, loadingProvinces]); + return ( + + ); }, - Cell: ({ row }) => (row.original.type === 1 ? "خروج بدون مجوز" : "عدم تحرک"), - }, - { - accessorKey: "machine_code", - header: "کد خودرو", - id: "machine_code", - datatype: "text", - columnFilterModeOptions: ["equals", "contains"], - grow: false, - }, - { - 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: ({ 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"), + }, + ]; + }, [] );