From 9fccf770d51d9a526199787e26dc54e4929b5da6 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Sun, 15 Dec 2024 18:27:27 +0330 Subject: [PATCH 1/9] work on phone validation part and complete structure with timeline --- .../dashboard/road-patrols/operator/page.js | 2 +- .../operator/Actions/Create/index.jsx | 33 +++++ .../roadPatrols/operator/ExcelPrint/index.jsx | 26 ++-- .../Forms/CreatePatrol/PatrolForms.jsx | 80 +++++++++++ .../Forms/CreatePatrol/PatrolTimeLine.jsx | 122 ++++++++++++++++ .../Forms/CreatePatrol/PhoneValidation.jsx | 130 ++++++++++++++++++ .../operator/Forms/CreatePatrol/index.jsx | 17 +++ .../roadPatrols/operator/Toolbar.jsx | 11 +- .../dashboard/roadPatrols/operator/index.jsx | 8 +- .../roadPatrols/supervisor/SupervisorList.jsx | 28 ++-- .../roadPatrols/supervisor/index.jsx | 8 +- src/core/utils/pageMenu.js | 87 ++++++------ src/core/utils/routes.js | 1 + 13 files changed, 466 insertions(+), 87 deletions(-) create mode 100644 src/components/dashboard/roadPatrols/operator/Actions/Create/index.jsx create mode 100644 src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx create mode 100644 src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolTimeLine.jsx create mode 100644 src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PhoneValidation.jsx create mode 100644 src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/index.jsx diff --git a/src/app/(withAuth)/dashboard/road-patrols/operator/page.js b/src/app/(withAuth)/dashboard/road-patrols/operator/page.js index 73fa9cf..ce319b9 100644 --- a/src/app/(withAuth)/dashboard/road-patrols/operator/page.js +++ b/src/app/(withAuth)/dashboard/road-patrols/operator/page.js @@ -4,7 +4,7 @@ import OperatorPage from "@/components/dashboard/roadPatrols/operator"; const Page = () => { return ( - + ); }; diff --git a/src/components/dashboard/roadPatrols/operator/Actions/Create/index.jsx b/src/components/dashboard/roadPatrols/operator/Actions/Create/index.jsx new file mode 100644 index 0000000..63347f0 --- /dev/null +++ b/src/components/dashboard/roadPatrols/operator/Actions/Create/index.jsx @@ -0,0 +1,33 @@ +"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 CreatePatrol from "../../Forms/CreatePatrol"; + +const OperatorCreate = ({mutate}) => { + const theme = useTheme(); + const isMobile = useMediaQuery(theme.breakpoints.down("sm")); + const [open, setOpen] = useState(false); + + const handleOpen = () => { + setOpen(true); + }; + + return ( + <> + {isMobile ? ( + + + + ) : ( + + )} + {open && } + + ); +}; +export default OperatorCreate; diff --git a/src/components/dashboard/roadPatrols/operator/ExcelPrint/index.jsx b/src/components/dashboard/roadPatrols/operator/ExcelPrint/index.jsx index 8fdc753..9148331 100644 --- a/src/components/dashboard/roadPatrols/operator/ExcelPrint/index.jsx +++ b/src/components/dashboard/roadPatrols/operator/ExcelPrint/index.jsx @@ -1,18 +1,18 @@ -import { Button, CircularProgress } from "@mui/material"; -import { useMemo, useState } from "react"; +import {Button, CircularProgress} 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 { EXPORT_OPERATOR_LIST } from "@/core/utils/routes"; +import {EXPORT_OPERATOR_LIST} from "@/core/utils/routes"; -const PrintExcel = ({ table, filterData }) => { +const PrintExcel = ({table, filterData}) => { const [loading, setLoading] = useState(false); const requestServer = useRequest(); const activeFilters = Object.entries(filterData).reduce((acc, [key, filter]) => { if (filter.value) { // Check if there's an active filter - acc.push({ id: key, value: filter.value }); + acc.push({id: key, value: filter.value}); } return acc; }, []); @@ -20,22 +20,23 @@ const PrintExcel = ({ table, filterData }) => { const filterParams = useMemo(() => { const params = new URLSearchParams(); activeFilters.length > 0 && - activeFilters.map((filter, index) => { - params.set(`${filter.id}`, filter.value); - }); + activeFilters.map((filter, index) => { + params.set(`${filter.id}`, filter.value); + }); return params; }, [activeFilters]); const clickHandler = () => { setLoading(true); requestServer(`${EXPORT_OPERATOR_LIST}?${filterParams}`, "get", { - requestOptions: { responseType: "blob" }, + requestOptions: {responseType: "blob"}, }) .then((response) => { const filename = `خروجی کارتابل عملیات تاریخ_${moment().format("jYYYY_jMM_jDD")}.xlsx`; FileSaver.saveAs(response.data, filename); }) - .catch(() => {}) + .catch(() => { + }) .finally(() => { setLoading(false); }); @@ -45,10 +46,9 @@ const PrintExcel = ({ table, filterData }) => { + + + + + کد پیامک شده + + + + + + + ); +}; + +export default PhoneValidation; \ No newline at end of file diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/index.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/index.jsx new file mode 100644 index 0000000..46eac78 --- /dev/null +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/index.jsx @@ -0,0 +1,17 @@ +"use client"; + +import {Dialog} from "@mui/material"; +import PatrolForms from "@/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms"; + +const CreatePatrol = ({open, setOpen, mutate, rowId}) => { + return ( + + + + ); +}; +export default CreatePatrol; diff --git a/src/components/dashboard/roadPatrols/operator/Toolbar.jsx b/src/components/dashboard/roadPatrols/operator/Toolbar.jsx index 32c4395..f652e04 100644 --- a/src/components/dashboard/roadPatrols/operator/Toolbar.jsx +++ b/src/components/dashboard/roadPatrols/operator/Toolbar.jsx @@ -1,10 +1,13 @@ import PrintExcel from "./ExcelPrint"; +import OperatorCreate from "./Actions/Create"; +import {Box} from "@mui/material"; -const Toolbar = ({ table, filterData }) => { +const Toolbar = ({table, filterData, mutate}) => { return ( - <> - - + + + + ); }; export default Toolbar; diff --git a/src/components/dashboard/roadPatrols/operator/index.jsx b/src/components/dashboard/roadPatrols/operator/index.jsx index 7835954..dcf34af 100644 --- a/src/components/dashboard/roadPatrols/operator/index.jsx +++ b/src/components/dashboard/roadPatrols/operator/index.jsx @@ -1,13 +1,13 @@ "use client"; import PageTitle from "@/core/components/PageTitle"; -import { Stack } from "@mui/material"; -import OperatorList from "@/components/dashboard/roadPatrols/operator/OperatorList"; +import {Stack} from "@mui/material"; +import OperatorList from "./OperatorList"; const OperatorPage = () => { return ( - - + + ); }; diff --git a/src/components/dashboard/roadPatrols/supervisor/SupervisorList.jsx b/src/components/dashboard/roadPatrols/supervisor/SupervisorList.jsx index d568c46..9478939 100644 --- a/src/components/dashboard/roadPatrols/supervisor/SupervisorList.jsx +++ b/src/components/dashboard/roadPatrols/supervisor/SupervisorList.jsx @@ -1,15 +1,15 @@ "use client"; -import { useMemo } from "react"; -import { Box, Typography } from "@mui/material"; +import {useMemo} from "react"; +import {Box, Typography} from "@mui/material"; import DataTableWithAuth from "@/core/components/DataTableWithAuth"; import Toolbar from "./Toolbar"; -import { GET_SUPERVISOR_LIST } from "@/core/utils/routes"; +import {GET_SUPERVISOR_LIST} from "@/core/utils/routes"; import moment from "jalali-moment"; import RowActions from "./RowActions"; import useProvinces from "@/lib/hooks/useProvince"; -const OperatorList = () => { - const { provinces, errorProvinces, loadingProvinces } = useProvinces(); +const SuperviserList = () => { + const {provinces, errorProvinces, loadingProvinces} = useProvinces(); const citiesListApi = "https://rms.rmto.ir/public/contents/edarate_shahri_by_province"; const columns = useMemo( () => [ @@ -31,11 +31,11 @@ const OperatorList = () => { filterFn: "equals", columnSelectOption: () => { if (loadingProvinces) { - return [{ value: "", label: "در حال بارگذاری..." }]; + return [{value: "", label: "در حال بارگذاری..."}]; } if (errorProvinces) { - return [{ value: "", label: "خطا در بارگذاری" }]; + return [{value: "", label: "خطا در بارگذاری"}]; } return provinces.map((province) => ({ @@ -54,10 +54,10 @@ const OperatorList = () => { dependencyId: "province", columnSelectOption: (dependencyField) => { if (dependencyField.value === "") { - return [{ value: "", label: "ابتدا استان را انتخاب کنید" }]; + return [{value: "", label: "ابتدا استان را انتخاب کنید"}]; } - return [{ value: dependencyField.value, label: dependencyField.value }]; + return [{value: dependencyField.value, label: dependencyField.value}]; }, }, { @@ -95,7 +95,7 @@ const OperatorList = () => { datatype: "date", filterFn: "equals", columnFilterModeOptions: ["equals", "contains"], - Cell: ({ renderedCellValue }) => ( + Cell: ({renderedCellValue}) => ( {renderedCellValue ? moment(renderedCellValue).locale("fa").format("YYYY/MM/DD") : "-"} @@ -109,7 +109,7 @@ const OperatorList = () => { datatype: "date", filterFn: "equals", columnFilterModeOptions: ["equals", "contains"], - Cell: ({ renderedCellValue }) => ( + Cell: ({renderedCellValue}) => ( {renderedCellValue ? moment(renderedCellValue).locale("fa").format("YYYY/MM/DD") : "-"} @@ -123,7 +123,7 @@ const OperatorList = () => { datatype: "date", filterFn: "equals", columnFilterModeOptions: ["equals", "contains"], - Cell: ({ renderedCellValue }) => ( + Cell: ({renderedCellValue}) => ( {renderedCellValue ? moment(renderedCellValue).locale("fa").format("YYYY/MM/DD") : "-"} @@ -135,7 +135,7 @@ const OperatorList = () => { return ( <> - + { ); }; -export default OperatorList; +export default SuperviserList; diff --git a/src/components/dashboard/roadPatrols/supervisor/index.jsx b/src/components/dashboard/roadPatrols/supervisor/index.jsx index 3fa490b..5e2001d 100644 --- a/src/components/dashboard/roadPatrols/supervisor/index.jsx +++ b/src/components/dashboard/roadPatrols/supervisor/index.jsx @@ -1,13 +1,13 @@ "use client"; import PageTitle from "@/core/components/PageTitle"; -import { Stack } from "@mui/material"; -import SupervisorList from "./SupervisorList"; +import {Stack} from "@mui/material"; +import SuperviserList from "./SupervisorList"; const SupervisorPage = () => { return ( - - + + ); }; diff --git a/src/core/utils/pageMenu.js b/src/core/utils/pageMenu.js index 6000f64..5fd062d 100644 --- a/src/core/utils/pageMenu.js +++ b/src/core/utils/pageMenu.js @@ -28,7 +28,7 @@ export const pageMenu = [ label: "پیشخوان", type: "page", route: "/dashboard", - icon: , + icon: , permissions: ["all"], }, { @@ -36,14 +36,14 @@ export const pageMenu = [ label: "مدیریت کاربران", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/user_management", - icon: , + icon: , permissions: ["full-user-management", "limited-user-management"], }, { id: "projectsManagment", label: "پروژه های راهداری", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { @@ -51,7 +51,7 @@ export const pageMenu = [ label: "ثبت قرارداد و پروژه", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/finance", - icon: , + icon: , permissions: ["show-contract", "show-contract-province"], }, { @@ -59,7 +59,7 @@ export const pageMenu = [ label: "لیست پروژه ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/projects_list", - icon: , + icon: , permissions: ["all"], }, { @@ -67,7 +67,7 @@ export const pageMenu = [ label: "پروژه های پیشنهادی", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/proposal", - icon: , + icon: , permissions: ["show-proposal", "show-proposal-province"], }, { @@ -75,7 +75,7 @@ export const pageMenu = [ label: "درخواست نمایندگان", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/rahdari_projects/lawmakers", - icon: , + icon: , permissions: ["show-lawmaker", "show-lawmaker-province"], }, { @@ -83,7 +83,7 @@ export const pageMenu = [ label: "پراکندگی بر روی نقشه", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=rahdari_projects", - icon: , + icon: , permissions: ["all"], }, ], @@ -92,7 +92,7 @@ export const pageMenu = [ id: "roadItemManagment", label: "فعالیت های روزانه", type: "menu", - icon: , + icon: , hasSubitems: true, badges: ["road_items.total"], Subitems: [ @@ -100,7 +100,7 @@ export const pageMenu = [ id: "roadItemManagmentSupervisor", label: "ارزیابی", type: "menu", - icon: , + icon: , hasSubitems: true, badges: ["road_items.supervise_cnt"], Subitems: [ @@ -120,7 +120,7 @@ export const pageMenu = [ id: "roadItemManagmentOparation", label: "عملیات", type: "menu", - icon: , + icon: , hasSubitems: true, badges: ["road_items.operation_cnt"], Subitems: [ @@ -145,7 +145,7 @@ export const pageMenu = [ label: "پراکندگی بر روی نقشه", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=road_items", - icon: , + icon: , permissions: [ "show-road-item-supervise-cartable", "show-road-item-supervise-cartable-province", @@ -157,7 +157,7 @@ export const pageMenu = [ label: "گزارش ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_items/report", - icon: , + icon: , permissions: [ "show-road-item-supervise-cartable", "show-road-item-supervise-cartable-province", @@ -170,7 +170,7 @@ export const pageMenu = [ id: "roadPatrolManagment", label: "گشت راهداری و ترابری", type: "menu", - icon: , + icon: , hasSubitems: true, badges: ["road_patrols.total"], Subitems: [ @@ -178,7 +178,7 @@ export const pageMenu = [ id: "roadPatrolManagmentSupervisor", label: "ارزیابی", type: "menu", - icon: , + icon: , hasSubitems: true, badges: ["road_patrols.supervise_cnt"], Subitems: [ @@ -198,22 +198,15 @@ export const pageMenu = [ id: "roadPatrolManagmentOparation", label: "عملیات", type: "menu", - icon: , + icon: , hasSubitems: true, badges: ["road_patrols.operation_cnt"], Subitems: [ - { - id: "roadPatrolManagmentOparationCreate", - label: "ثبت اقدام", - type: "page", - route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_patrols/operator/create", - permissions: ["add-road-patrol"], - }, { id: "roadPatrolManagmentOparationCartable", label: "کارتابل", type: "page", - route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_patrols/operator/cartable", + route: "/dashboard/road-patrols/operator", permissions: ["add-road-patrol"], }, ], @@ -223,7 +216,7 @@ export const pageMenu = [ label: "پراکندگی بر روی نقشه", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=road_patrols", - icon: , + icon: , permissions: [ "add-road-patrol", "show-road-patrol-supervise-cartable", @@ -235,7 +228,7 @@ export const pageMenu = [ label: "گزارش ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_patrols/report", - icon: , + icon: , permissions: [ "add-road-patrol", "show-road-patrol-supervise-cartable", @@ -248,7 +241,7 @@ export const pageMenu = [ id: "inquiryPrivacyManagment", label: "استعلام حریم راه", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { @@ -285,7 +278,7 @@ export const pageMenu = [ id: "safetyAndPrivacyManagment", label: "نگهداری حریم راه", type: "menu", - icon: , + icon: , hasSubitems: true, badges: ["safety_and_privacy.step_one", "safety_and_privacy.step_two"], Subitems: [ @@ -293,7 +286,7 @@ export const pageMenu = [ id: "safetyAndPrivacyManagmentOparation", label: "عملیات", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { @@ -321,7 +314,7 @@ export const pageMenu = [ label: "پراکندگی بر روی نقشه", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=safety_and_privacy", - icon: , + icon: , permissions: [ "show-safety-and-privacy-operator-cartable", "show-safety-and-privacy-operator-cartable-province", @@ -334,7 +327,7 @@ export const pageMenu = [ label: "گزارش ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/safety_and_privacy/report", - icon: , + icon: , permissions: [ "show-safety-and-privacy-operator-cartable", "show-safety-and-privacy-operator-cartable-province", @@ -348,7 +341,7 @@ export const pageMenu = [ id: "roadObservationsManagment", label: "واکنش سریع", type: "menu", - icon: , + icon: , hasSubitems: true, badges: ["road_observations.total"], Subitems: [ @@ -356,7 +349,7 @@ export const pageMenu = [ id: "roadObservationsManagmentSupervisor", label: "ارزیابی", type: "menu", - icon: , + icon: , hasSubitems: true, badges: ["road_observations.supervise_cnt"], Subitems: [ @@ -374,14 +367,14 @@ export const pageMenu = [ label: "رسیدگی به شکایات", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations", - icon: , + icon: , permissions: ["show-fast-react", "show-fast-react-province", "show-fast-react-edarate-shahri"], }, { id: "roadObservationsManagmentOparation", label: "عملیات", type: "menu", - icon: , + icon: , hasSubitems: true, badges: ["road_observations.operation_cnt"], Subitems: [ @@ -399,7 +392,7 @@ export const pageMenu = [ label: "پراکندگی بر روی نقشه", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=road_observations", - icon: , + icon: , permissions: ["all"], }, { @@ -407,7 +400,7 @@ export const pageMenu = [ label: "گزارش ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations/report/index", - icon: , + icon: , permissions: ["all"], }, ], @@ -416,7 +409,7 @@ export const pageMenu = [ id: "winterCampManagment", label: "قرارگاه زمستانی", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { @@ -424,7 +417,7 @@ export const pageMenu = [ label: "محور های انسدادی", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/winter_camp", - icon: , + icon: , permissions: ["show-camp", "show-camp-province"], }, { @@ -432,7 +425,7 @@ export const pageMenu = [ label: "محور های حلقه اول", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=camp", - icon: , + icon: , permissions: ["show-camp", "show-camp-province"], }, { @@ -440,7 +433,7 @@ export const pageMenu = [ label: "گزارش ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/map?type=campNew", - icon: , + icon: , permissions: ["show-camp", "show-camp-province"], }, ], @@ -449,14 +442,14 @@ export const pageMenu = [ id: "receiptManagment", label: "خسارات وارده بر ابنیه فنی و تاسیسات راه", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { id: "receiptManagmentOparation", label: "عملیات", type: "menu", - icon: , + icon: , hasSubitems: true, Subitems: [ { @@ -473,7 +466,7 @@ export const pageMenu = [ label: "گزارش ها", type: "page", route: process.env.NEXT_PUBLIC_API_URL + "/v2/receipt/report", - icon: , + icon: , permissions: ["all"], }, ], @@ -483,7 +476,7 @@ export const pageMenu = [ label: "آزمایشات (OPTS)", type: "page", route: "/dashboard/azmayesh", - icon: , + icon: , permissions: ["azmayesh-management"], }, { @@ -491,7 +484,7 @@ export const pageMenu = [ label: "نوع آزمایشات", type: "page", route: "/dashboard/azmayesh_type", - icon: , + icon: , permissions: ["azmayesh-type-management"], }, { @@ -499,7 +492,7 @@ export const pageMenu = [ label: "اطلاعات خودرو", type: "page", route: "/dashboard/car-details", - icon: , + icon: , permissions: [""], }, ]; diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index db24fd6..c9ee515 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -31,3 +31,4 @@ export const GET_OPERATOR_LIST = "/v3/api/fake-operator-list"; export const EXPORT_OPERATOR_LIST = "https://rms.rmto.ir/v2/road_patrols/operator/cartable/report"; export const GET_SUPERVISOR_LIST = "/v3/api/fake-supervisor-list"; export const EXPORT_SUPERVISOR_LIST = "https://rms.rmto.ir/v2/road_patrols/supervisor/cartable/report"; +export const GET_OTP_TOKEN = "https://rms.rmto.ir/v2/get_otp_token"; From aedeb62849ee9542d01f056ce37268638b4fb48c Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Wed, 18 Dec 2024 11:34:21 +0330 Subject: [PATCH 2/9] work on car code --- .../Forms/CreatePatrol/PatrolDetail.jsx | 32 +++++++ .../Forms/CreatePatrol/PatrolForms.jsx | 5 +- .../Forms/CreatePatrol/PhoneValidation.jsx | 49 ++++++++--- src/core/components/CarCode.jsx | 86 +++++++++++++++++++ src/core/utils/formatCounter.js | 5 ++ src/core/utils/routes.js | 3 + src/lib/hooks/useRequest.js | 9 +- 7 files changed, 168 insertions(+), 21 deletions(-) create mode 100644 src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx create mode 100644 src/core/components/CarCode.jsx create mode 100644 src/core/utils/formatCounter.js diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx new file mode 100644 index 0000000..38631e5 --- /dev/null +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx @@ -0,0 +1,32 @@ +"use client"; + +import {Box, Slide} from "@mui/material"; +import {useState} from "react"; +import CarCode from "@/core/components/CarCode"; + +const PatrolDetail = ({tabState, setTabState}) => { + const [patrolFounded, setPatrolFounded] = useState(false); + const [carCode, setCarCode] = useState(null); + + return ( + + + + + + + + + + ); +}; + +export default PatrolDetail; \ No newline at end of file diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx index 4146808..4d51f65 100644 --- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx @@ -10,6 +10,7 @@ import HandymanIcon from '@mui/icons-material/Handyman'; import VerifiedIcon from '@mui/icons-material/Verified'; import PatrolTimeLine from "./PatrolTimeLine"; import PhoneValidation from "./PhoneValidation"; +import PatrolDetail from "./PatrolDetail"; function TabPanel(props) { const {children, value, index} = props; @@ -53,10 +54,10 @@ const PatrolForms = () => { - + - <>moshakhasat gasht + <>moshakhasat rahdar diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PhoneValidation.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PhoneValidation.jsx index 0310d02..a60ba22 100644 --- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PhoneValidation.jsx +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PhoneValidation.jsx @@ -5,15 +5,18 @@ import React, {useEffect, useState} from "react"; import ForwardToInboxIcon from '@mui/icons-material/ForwardToInbox'; import QrCodeIcon from '@mui/icons-material/QrCode'; import useRequest from "@/lib/hooks/useRequest"; -import {GET_OTP_TOKEN} from "@/core/utils/routes"; +import {GET_OTP_TOKEN, VERIFY_OTP} from "@/core/utils/routes"; +import {formatCounter} from "@/core/utils/formatCounter"; -const PhoneValidation = () => { +const PhoneValidation = ({tabState, setTabState}) => { const requestServer = useRequest({auth: true}); const [phoneNumber, setPhoneNumber] = useState(""); + const [verificationCode, setVerificationCode] = useState(""); const [validPhone, setValidPhone] = useState(false); const [delayPerRequest, setDelayPerRequest] = useState(false); const [counter, setCounter] = useState(120); const [otpSended, setOtpSended] = useState(false); + const [readyToVerify, setReadyToVerify] = useState(false); const handleNumericInput = (e) => { e.target.value = e.target.value.replace(/[^0-9]/g, ''); @@ -21,18 +24,22 @@ const PhoneValidation = () => { useEffect(() => { if (phoneNumber.length === 11) { - setValidPhone(true) + setValidPhone(true); } else { - setValidPhone(false) + setValidPhone(false); } - }, [phoneNumber]); + if (verificationCode.length === 6 && phoneNumber.length === 11) { + setReadyToVerify(true); + } else { + setReadyToVerify(false); + } + }, [phoneNumber, verificationCode]); useEffect(() => { if (counter === 0) { setDelayPerRequest(false); return; } - if (delayPerRequest && counter > 0) { const timer = setInterval(() => { setCounter(prevCounter => prevCounter - 1); @@ -55,12 +62,23 @@ const PhoneValidation = () => { setDelayPerRequest(true); }; - // Format counter as MM:SS - const formatCounter = (counter) => { - const minutes = Math.floor(counter / 60).toString().padStart(2, '0'); - const seconds = (counter % 60).toString().padStart(2, '0'); - return `${minutes}:${seconds}`; - }; + const phoneRegister = () => { + const formData = new FormData(); + formData.append("phone_number", phoneNumber); + formData.append("verification_code", verificationCode); + + for (var pair of formData.entries()) { + console.log(pair[0] + ', ' + pair[1]); + } + setTabState(tabState + 1) + requestServer(VERIFY_OTP, "post", { + data: formData, + }) + .then(() => { + }) + .catch(() => { + }); + } return ( { autoComplete="off" size="small" fullWidth - type="text" + value={verificationCode} + onChange={(e) => setVerificationCode(e.target.value)} onInput={handleNumericInput} + type="text" inputProps={{ maxLength: 6, inputMode: "numeric", @@ -118,7 +138,8 @@ const PhoneValidation = () => { }} /> - diff --git a/src/core/components/CarCode.jsx b/src/core/components/CarCode.jsx new file mode 100644 index 0000000..503a826 --- /dev/null +++ b/src/core/components/CarCode.jsx @@ -0,0 +1,86 @@ +"use client"; + +import {Autocomplete, CircularProgress, TextField} from "@mui/material"; +import {useEffect, useState} from "react"; +import useRequest from "@/lib/hooks/useRequest"; +import {debounce} from "@mui/material/utils"; + +const CarCode = ({carCode, setCarCode}) => { + const [inputValue, setInputValue] = useState(''); + const [options, setOptions] = useState([]); + const [loading, setLoading] = useState(false); + const requestServer = useRequest(); + + const fetchCarCodes = (inputValue, controller) => { + const debouncer = debounce((query) => { + if (query.length < 2) { + setOptions([]); + return; + } + setLoading(true); + requestServer(`car-code/api?${query}`, "get", { + requestOptions: {signal: controller.signal} + }) + .then((response) => { + setOptions(response || []); + }) + .catch(() => { + setOptions([]); + }) + .finally(() => { + setLoading(false); + }); + }, 500) + debouncer(inputValue) + } + + useEffect(() => { + const controller = new AbortController(); + fetchCarCodes(inputValue, controller); + return () => controller.abort(); + }, [inputValue]); + + return ( + { + setCarCode(newValue); + }} + inputValue={inputValue} + onInputChange={(event, newInputValue) => { + setInputValue(newInputValue); + }} + options={options} + getOptionLabel={(option) => + typeof option === 'string' ? option : option.name || option.code + } + loading={loading} + loadingText="درحال جستجوی کد خودرو" + noOptionsText={ + inputValue.length < 2 + ? "حداقل دو رقم از کد خودرو را وارد کنید" + : "کد خودرویی یافت نشد" + } + sx={{width: 300}} + renderInput={(params) => ( + + {loading ? : null} + {params.InputProps.endAdornment} + + ), + }} + /> + )} + /> + ); +}; + +export default CarCode; \ No newline at end of file diff --git a/src/core/utils/formatCounter.js b/src/core/utils/formatCounter.js new file mode 100644 index 0000000..72b021a --- /dev/null +++ b/src/core/utils/formatCounter.js @@ -0,0 +1,5 @@ +export const formatCounter = (counter) => { + const minutes = Math.floor(counter / 60).toString().padStart(2, '0'); + const seconds = (counter % 60).toString().padStart(2, '0'); + return `${minutes}:${seconds}`; +}; \ No newline at end of file diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index c9ee515..1cd95f7 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -31,4 +31,7 @@ export const GET_OPERATOR_LIST = "/v3/api/fake-operator-list"; export const EXPORT_OPERATOR_LIST = "https://rms.rmto.ir/v2/road_patrols/operator/cartable/report"; export const GET_SUPERVISOR_LIST = "/v3/api/fake-supervisor-list"; export const EXPORT_SUPERVISOR_LIST = "https://rms.rmto.ir/v2/road_patrols/supervisor/cartable/report"; + +////**** mohammad check here ****//// export const GET_OTP_TOKEN = "https://rms.rmto.ir/v2/get_otp_token"; +export const VERIFY_OTP = "https://rms.rmto.ir/v2/verify_otp"; diff --git a/src/lib/hooks/useRequest.js b/src/lib/hooks/useRequest.js index eb30a18..1efa7de 100644 --- a/src/lib/hooks/useRequest.js +++ b/src/lib/hooks/useRequest.js @@ -1,7 +1,7 @@ -import { errorResponse } from "@/core/utils/errorResponse"; -import { successRequest } from "@/core/utils/successRequest"; +import {errorResponse} from "@/core/utils/errorResponse"; +import {successRequest} from "@/core/utils/successRequest"; import axios from "axios"; -import { useAuth } from "../contexts/auth"; +import {useAuth} from "../contexts/auth"; const defaultOptions = { data: {}, @@ -16,13 +16,12 @@ const defaultOptions = { }; const useRequest = (initOptions) => { - const { logout } = useAuth(); + const {logout} = useAuth(); const _options = Object.assign({}, defaultOptions, initOptions); return async (url = "", method = "get", options) => { const mergedOptions = Object.assign({}, _options, options); - try { const response = await axios({ url, From d650e556048a256793069df50062ec0bbe89bf32 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Mon, 23 Dec 2024 12:59:19 +0330 Subject: [PATCH 3/9] working on gasht detail part --- .../Forms/CreatePatrol/PatrolDetail.jsx | 10 ++++++++-- src/core/components/MuiDatePicker.jsx | 18 +++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx index 38631e5..24d59bb 100644 --- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx @@ -1,8 +1,9 @@ "use client"; -import {Box, Slide} from "@mui/material"; +import {Box, Button, Chip, Divider, Slide} from "@mui/material"; import {useState} from "react"; import CarCode from "@/core/components/CarCode"; +import SearchIcon from '@mui/icons-material/Search'; const PatrolDetail = ({tabState, setTabState}) => { const [patrolFounded, setPatrolFounded] = useState(false); @@ -18,9 +19,14 @@ const PatrolDetail = ({tabState, setTabState}) => { my: 3 }} > - + + + + + + diff --git a/src/core/components/MuiDatePicker.jsx b/src/core/components/MuiDatePicker.jsx index 1be8fdb..35bfe01 100644 --- a/src/core/components/MuiDatePicker.jsx +++ b/src/core/components/MuiDatePicker.jsx @@ -1,14 +1,14 @@ -import { LocalizationProvider, MobileDateTimePicker } from "@mui/x-date-pickers"; -import { AdapterDateFnsJalali } from "@mui/x-date-pickers/AdapterDateFnsJalali"; +import {LocalizationProvider, MobileDateTimePicker} from "@mui/x-date-pickers"; +import {AdapterDateFnsJalali} from "@mui/x-date-pickers/AdapterDateFnsJalali"; import moment from "jalali-moment"; -import { faIR } from "@mui/x-date-pickers/locales"; -import { Box, IconButton, FormControl, FormHelperText, InputAdornment, Stack } from "@mui/material"; +import {faIR} from "@mui/x-date-pickers/locales"; +import {FormControl, IconButton, InputAdornment, Stack} from "@mui/material"; import ClearIcon from "@mui/icons-material/Clear"; -export default function PickerWithButtonField({ formik, name, value, error, touched, disabled }) { +export default function PickerWithButtonField({formik, name, value, error, touched, disabled}) { return ( - + formik.setFieldValue(name, null)} > - + ), From 753c6e8076c731ee8d4a296daa42d50338fc1a87 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Wed, 25 Dec 2024 15:04:20 +0330 Subject: [PATCH 4/9] working on patrol details and do some update on timeline --- .../Forms/CreatePatrol/PatrolDetail.jsx | 247 +++++++++++++++++- .../Forms/CreatePatrol/PatrolForms.jsx | 4 +- .../Forms/CreatePatrol/PatrolTimeLine.jsx | 34 +-- src/core/utils/routes.js | 4 +- 4 files changed, 259 insertions(+), 30 deletions(-) diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx index 24d59bb..008997b 100644 --- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx @@ -1,13 +1,69 @@ "use client"; -import {Box, Button, Chip, Divider, Slide} from "@mui/material"; -import {useState} from "react"; +import { + Box, + Button, + Card, + CardContent, + Chip, + Divider, + IconButton, + InputAdornment, + Slide, + Stack, + Typography +} from "@mui/material"; +import React, {useEffect, useState} from "react"; import CarCode from "@/core/components/CarCode"; import SearchIcon from '@mui/icons-material/Search'; +import {AdapterDateFnsJalali} from "@mui/x-date-pickers/AdapterDateFnsJalali"; +import {faIR} from "@mui/x-date-pickers/locales"; +import {LocalizationProvider, MobileDateTimePicker} from "@mui/x-date-pickers"; +import ClearIcon from "@mui/icons-material/Clear"; +import moment from "jalali-moment"; +import dynamic from "next/dynamic"; +import MapLoading from "@/core/components/MapLayer/Loading"; +import LocalGasStationIcon from '@mui/icons-material/LocalGasStation'; +import DirectionsCarFilledIcon from '@mui/icons-material/DirectionsCarFilled'; +import WatchLaterIcon from '@mui/icons-material/WatchLater'; +import AddRoadIcon from '@mui/icons-material/AddRoad'; +import ShareLocationIcon from '@mui/icons-material/ShareLocation'; +import KeyboardDoubleArrowLeftIcon from "@mui/icons-material/KeyboardDoubleArrowLeft"; +import KeyboardDoubleArrowRightIcon from "@mui/icons-material/KeyboardDoubleArrowRight"; + +const MapLayer = dynamic(() => import("@/core/components/MapLayer"), { + loading: () => , + ssr: false, +}); const PatrolDetail = ({tabState, setTabState}) => { const [patrolFounded, setPatrolFounded] = useState(false); const [carCode, setCarCode] = useState(null); + const [dateFrom, setDateFrom] = useState(null); + const [dateTo, setDateTo] = useState(null); + const [readyToRequest, setReadyToRequest] = useState(false); + const [data, setData] = useState({ + machine_code: "12-213-21", + distance: "23", + time: "04:45", + stop: "2", + fuel_amount: "21" + }) + + const requestPatrolInfo = () => { + setPatrolFounded(true) + setReadyToRequest(false) + } + + useEffect(() => { + console.log("data", carCode?.id, dateFrom, dateTo) + if (carCode !== null && dateFrom !== null && dateTo !== null) { + setReadyToRequest(true); + } else { + setReadyToRequest(false); + } + }, [carCode, dateFrom, dateTo]); + return ( { my: 3 }} > - - - - + + + + + + + { + const date = new Date(dateFrom); + const formattedDate = moment(date).locale("en").format("YYYY-MM-DD HH:mm"); + setDateFrom(formattedDate); + }} + slotProps={{ + textField: { + size: "small", + placeholder: "تاریخ و ساعت شروع گشت", + InputProps: { + endAdornment: ( + + { + event.stopPropagation(); + setDateFrom(null); + }} + sx={{ + color: "#bfbfbf", + "&:hover": { + backgroundColor: "rgba(189, 189, 189, 0.1)", + color: "#363434", + }, + }} + > + + + + ), + }, + }, + }} label="تاریخ و ساعت شروع گشت" + /> + { + const date = new Date(dateTo); + const formattedDate = moment(date).locale("en").format("YYYY-MM-DD HH:mm"); + setDateTo(formattedDate); + }} + slotProps={{ + textField: { + size: "small", + placeholder: "تاریخ و ساعت پایان گشت", + InputProps: { + endAdornment: ( + + { + event.stopPropagation(); + setDateTo(null); + }} + sx={{ + color: "#bfbfbf", + "&:hover": { + backgroundColor: "rgba(189, 189, 189, 0.1)", + color: "#363434", + }, + }} + > + + + + ), + }, + }, + }} label="تاریخ و ساعت پایان گشت"/> + + + - + - - - - + {patrolFounded && + + + + + }/> + + + {data.machine_code} + + + + }/> + + + {data.time} + + + + }/> + + + {data.distance} + + + + }/> + + + {data.stop} + + + + }/> + + + {data.fuel_amount} + + + + + + + + + + + + + + + } + + + + ); }; diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx index 4d51f65..da6690e 100644 --- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx @@ -24,7 +24,7 @@ function TabPanel(props) { const PatrolForms = () => { const theme = useTheme(); - const isMobile = useMediaQuery(theme.breakpoints.down("sm")); + const isMobile = useMediaQuery(theme.breakpoints.down("md")); const [tabState, setTabState] = useState(0); const handleChangeTab = (event, newValue) => { @@ -71,7 +71,7 @@ const PatrolForms = () => { {!isMobile && ( - + )} diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolTimeLine.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolTimeLine.jsx index 5343e33..ba33a31 100644 --- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolTimeLine.jsx +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolTimeLine.jsx @@ -1,6 +1,6 @@ "use client"; -import {Box, Typography} from "@mui/material"; +import {Box, CircularProgress, Typography} from "@mui/material"; import TapAndPlayIcon from '@mui/icons-material/TapAndPlay'; import TaxiAlertIcon from '@mui/icons-material/TaxiAlert'; import EngineeringIcon from '@mui/icons-material/Engineering'; @@ -17,6 +17,8 @@ import { } from "@mui/lab"; const PatrolTimeLine = ({tabState}) => { + + console.log("tabState", tabState) return ( { - : 0 ? "success" : "error"} sx={{width: "1.5rem", height: "1.5rem"}} - /> + />} @@ -47,10 +49,10 @@ const PatrolTimeLine = ({tabState}) => { - : 1 ? "success" : "error"} sx={{width: "1.5rem", height: "1.5rem"}} - /> + />} @@ -65,10 +67,10 @@ const PatrolTimeLine = ({tabState}) => { - : 2 ? "success" : "error"} sx={{width: "1.5rem", height: "1.5rem"}} - /> + />} @@ -83,10 +85,10 @@ const PatrolTimeLine = ({tabState}) => { - : 3 ? "success" : "error"} sx={{width: "1.5rem", height: "1.5rem"}} - /> + />} @@ -101,10 +103,10 @@ const PatrolTimeLine = ({tabState}) => { - : 4 ? "success" : "error"} sx={{width: "1.5rem", height: "1.5rem"}} - /> + />} diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index 9548f91..09719e6 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -33,6 +33,8 @@ export const GET_ROAD_PATROL_OPERATOR_LIST = "/v3/api/fake-road-patrol/operator" export const EXPORT_ROAD_PATROL_OPERATOR_LIST = "https://rms.rmto.ir/v2/road_patrols/operator/cartable/report"; export const GET_ROAD_PATROL_SUPERVISOR_LIST = "/v3/api/fake-road-patrol/supervisor"; export const EXPORT_ROAD_PATROL_SUPERVISOR_LIST = "https://rms.rmto.ir/v2/road_patrols/supervisor/cartable/report"; +export const GET_OTP_TOKEN = "fake/api"; +export const VERIFY_OTP = "fake/api"; // road items export const GET_ROAD_ITEMS_SUPERVISOR_LIST = api + "/api/v3/road_items/supervisor_index"; @@ -48,4 +50,4 @@ export const REJECT_BY_SUPERVISOR = api + "/api/v3/road_items/verify_by_supervis export const DELETE_BY_SUPERVISOR = api + "/api/v3/road_items/delete"; export const RESTORE_BY_SUPERVISOR = api + "/api/v3/road_items/restore"; export const GET_CAR_LIST_SEARCH = api + "/api/v3/cmms_machines/search"; -export const GET_RAHDARANS_LIST_SEARCH = api + "/api/v3/rahdaran/search"; +export const GET_RAHDARANS_LIST_SEARCH = api + "/api/v3/rahdaran/search"; \ No newline at end of file From d68e7d5e59566ce08368fe7a0b250362a6f99b7a Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Mon, 30 Dec 2024 10:38:53 +0330 Subject: [PATCH 5/9] working on partrol form part 4 --- .../Forms/CreatePatrol/PatrolDetail.jsx | 148 +++++++++--------- .../Forms/CreatePatrol/PatrolForms.jsx | 25 ++- .../Forms/CreatePatrol/PatrolTimeLine.jsx | 12 +- .../Forms/CreatePatrol/SuperVisorsDetail.jsx | 94 +++++++++++ 4 files changed, 193 insertions(+), 86 deletions(-) create mode 100644 src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorsDetail.jsx diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx index 008997b..aa74c7b 100644 --- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx @@ -56,7 +56,6 @@ const PatrolDetail = ({tabState, setTabState}) => { } useEffect(() => { - console.log("data", carCode?.id, dateFrom, dateTo) if (carCode !== null && dateFrom !== null && dateTo !== null) { setReadyToRequest(true); } else { @@ -170,88 +169,93 @@ const PatrolDetail = ({tabState, setTabState}) => { - {patrolFounded && - - - - - }/> - - - {data.machine_code} - - - - }/> - - - {data.time} - - - - }/> - - - {data.distance} - - - - }/> - - - {data.stop} - - - - }/> - - - {data.fuel_amount} - - - - - - + {patrolFounded ? + + + + + }/> + + + {data.machine_code} + + + + }/> + + + {data.time} + + + + }/> + + + {data.distance} + + + + }/> + + + {data.stop} + + + + }/> + + + {data.fuel_amount} + + + + + - - + + + + - - - - - } + + + + : + + + ابتدا اطلاعات بالا را تکمیل نمایید + + } - diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx index da6690e..e87151b 100644 --- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx @@ -2,7 +2,7 @@ import {Box, DialogContent, Tab, Tabs, useMediaQuery} from "@mui/material"; import {useTheme} from "@emotion/react"; -import React, {useState} from "react"; +import React, {useEffect, useState} from "react"; import TapAndPlayIcon from '@mui/icons-material/TapAndPlay'; import TaxiAlertIcon from '@mui/icons-material/TaxiAlert'; import EngineeringIcon from '@mui/icons-material/Engineering'; @@ -11,6 +11,7 @@ import VerifiedIcon from '@mui/icons-material/Verified'; import PatrolTimeLine from "./PatrolTimeLine"; import PhoneValidation from "./PhoneValidation"; import PatrolDetail from "./PatrolDetail"; +import SuperVisorsDetail from "@/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorsDetail"; function TabPanel(props) { const {children, value, index} = props; @@ -26,11 +27,19 @@ const PatrolForms = () => { const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down("md")); const [tabState, setTabState] = useState(0); + const [activeUpTo, setActiveUpTo] = useState(0); const handleChangeTab = (event, newValue) => { setTabState(newValue); }; + useEffect(() => { + if (activeUpTo < tabState) { + setActiveUpTo(tabState); + } + }, [tabState]); + + return ( <> { backgroundColor: "#efefef", }} > - } label="تایید هویت"> - } label="مشخصات گشت"> - } label="مشخصات راهداران"> - } label="اقدامات حین گشت"> - } label="تکمیل درخواست"> + = 0)} icon={} label="تایید هویت"> + = 1)} icon={} label="مشخصات گشت"> + = 2)} icon={} label="مشخصات راهداران"> + = 3)} icon={} label="اقدامات حین گشت"> + = 4)} icon={} label="تکمیل درخواست"> @@ -57,10 +66,10 @@ const PatrolForms = () => { - + - <>moshakhasat rahdar + <>eghdamat heine gasht diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolTimeLine.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolTimeLine.jsx index ba33a31..4bf75c1 100644 --- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolTimeLine.jsx +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolTimeLine.jsx @@ -31,7 +31,7 @@ const PatrolTimeLine = ({tabState}) => { - {tabState === 0 ? : : 0 ? "success" : "error"} sx={{width: "1.5rem", height: "1.5rem"}} />} @@ -49,7 +49,7 @@ const PatrolTimeLine = ({tabState}) => { - {tabState === 1 ? : : 1 ? "success" : "error"} sx={{width: "1.5rem", height: "1.5rem"}} />} @@ -67,7 +67,7 @@ const PatrolTimeLine = ({tabState}) => { - {tabState === 2 ? : : 2 ? "success" : "error"} sx={{width: "1.5rem", height: "1.5rem"}} />} @@ -77,7 +77,7 @@ const PatrolTimeLine = ({tabState}) => { مشخصات راهداران - راهدار/راهداران حاظر در گشت + راهدار / راهداران حاظر در گشت @@ -85,7 +85,7 @@ const PatrolTimeLine = ({tabState}) => { - {tabState === 3 ? : : 3 ? "success" : "error"} sx={{width: "1.5rem", height: "1.5rem"}} />} @@ -103,7 +103,7 @@ const PatrolTimeLine = ({tabState}) => { - {tabState === 4 ? : : 4 ? "success" : "error"} sx={{width: "1.5rem", height: "1.5rem"}} />} diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorsDetail.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorsDetail.jsx new file mode 100644 index 0000000..070bdcf --- /dev/null +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorsDetail.jsx @@ -0,0 +1,94 @@ +"use client"; + +import {Box, Button, Card, Chip, Divider, IconButton, TextField, Typography} from "@mui/material"; +import SaveAltIcon from '@mui/icons-material/SaveAlt'; +import AccountCircleIcon from '@mui/icons-material/AccountCircle'; +import DeleteIcon from '@mui/icons-material/Delete'; +import React, {useState} from "react"; + +const SuperVisorsDetail = ({tabState, setTabState}) => { + const [patrolFounded, setPatrolFounded] = useState(false); + const [rahdarsCode, setRahdarsCode] = useState(null); + const [readyToRequest, setReadyToRequest] = useState(false); + + const requestPatrolInfo = () => { + setPatrolFounded(true) + setReadyToRequest(false) + } + + return ( + + + + {/**/} + + + + + + + + + + + + + محمد حسین + کد راهدار: 893 + + + + + + + + + + + حسین تقی + کد راهدار: 123 + + + + + + + + + ); +}; + +export default SuperVisorsDetail; \ No newline at end of file From bc3db055b1d8c04ae455b49ff1803c3614d49602 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Sat, 4 Jan 2025 18:33:55 +0330 Subject: [PATCH 6/9] working on supervisor list --- .../Forms/CreatePatrol/PatrolDetail.jsx | 214 ++++++------------ .../Forms/CreatePatrol/PatrolDetailInfo.jsx | 147 ++++++++++++ .../Forms/CreatePatrol/PatrolForms.jsx | 105 +++++++-- .../Forms/CreatePatrol/PatrolMapFeatures.jsx | 38 ++++ .../CreatePatrol/PatrolResultCodeErrors.jsx | 25 ++ .../Forms/CreatePatrol/SuperVisorsDetail.jsx | 31 ++- .../operator/Forms/CreatePatrol/index.jsx | 5 +- src/core/components/CarCode.jsx | 17 +- src/core/utils/routes.js | 5 +- 9 files changed, 398 insertions(+), 189 deletions(-) create mode 100644 src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetailInfo.jsx create mode 100644 src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolMapFeatures.jsx create mode 100644 src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolResultCodeErrors.jsx diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx index d8cfee6..442640c 100644 --- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetail.jsx @@ -1,19 +1,6 @@ "use client"; -import { - Box, - Button, - Card, - CardActions, - CardContent, - Chip, - Divider, - IconButton, - InputAdornment, - Slide, - Stack, - Typography -} from "@mui/material"; +import {Box, Button, Chip, Divider, IconButton, InputAdornment, Stack} from "@mui/material"; import React, {useEffect, useState} from "react"; import CarCode from "@/core/components/CarCode"; import SearchIcon from '@mui/icons-material/Search'; @@ -24,46 +11,51 @@ import ClearIcon from "@mui/icons-material/Clear"; import moment from "jalali-moment"; import dynamic from "next/dynamic"; import MapLoading from "@/core/components/MapLayer/Loading"; -import LocalGasStationIcon from '@mui/icons-material/LocalGasStation'; -import DirectionsCarFilledIcon from '@mui/icons-material/DirectionsCarFilled'; -import WatchLaterIcon from '@mui/icons-material/WatchLater'; -import AddRoadIcon from '@mui/icons-material/AddRoad'; -import ShareLocationIcon from '@mui/icons-material/ShareLocation'; -import KeyboardDoubleArrowLeftIcon from "@mui/icons-material/KeyboardDoubleArrowLeft"; -import KeyboardDoubleArrowRightIcon from "@mui/icons-material/KeyboardDoubleArrowRight"; +import {Controller} from "react-hook-form"; +import {GET_FMS_DATA} from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import PatrolDetailInfo from "./PatrolDetailInfo"; +import PatrolResultCodeErrors from "./PatrolResultCodeErrors"; const MapLayer = dynamic(() => import("@/core/components/MapLayer"), { loading: () => , ssr: false, }); -const PatrolDetail = ({tabState, setTabState}) => { - const [patrolFounded, setPatrolFounded] = useState(false); - const [carCode, setCarCode] = useState(null); - const [dateFrom, setDateFrom] = useState(null); - const [dateTo, setDateTo] = useState(null); +const PatrolDetail = ({control, watch, setValue, tabState, setTabState}) => { + const requestServer = useRequest({notificationSuccess: true}); + const [patrolResultStatus, setPatrolResultStatus] = useState(null) const [readyToRequest, setReadyToRequest] = useState(false); - const [data, setData] = useState({ - machine_code: "12-213-21", - distance: "23", - time: "04:45", - stop: "2", - fuel_amount: "21" - }) + const [patrolData, setPatrolData] = useState(null); - const requestPatrolInfo = () => { - setPatrolFounded(true) - setReadyToRequest(false) + const requestPatrolInfo = async () => { + const formData = new FormData(); + formData.append("machineCode", watch("road_patrol_machines_id").machine_code); + formData.append("startDT", moment(watch("start_time")).format("YYYY-MM-DDTHH:mm")); + formData.append("endDT", moment(watch("end_time")).format("YYYY-MM-DDTHH:mm")); + await requestServer(GET_FMS_DATA, "post", { + data: formData, + }).then((response) => { + const data = response.data.data; + setPatrolData({ + ...data, + roadPatrolMachinesId: watch("road_patrol_machines_id"), + start_time: watch("start_time"), + end_time: watch("end_time") + }); + setPatrolResultStatus(data.resultCode); + }).catch((error) => { + }); } useEffect(() => { - if (carCode !== null && dateFrom !== null && dateTo !== null) { - setReadyToRequest(true); - } else { - setReadyToRequest(false); - } - }, [carCode, dateFrom, dateTo]); + const roadPatrolMachinesId = watch("road_patrol_machines_id"); + const startTime = watch("start_time"); + const endTime = watch("end_time"); + const isReady = roadPatrolMachinesId !== null && startTime !== "" && endTime !== ""; + setReadyToRequest(isReady); + }, [watch("road_patrol_machines_id"), watch("start_time"), watch("end_time")]); return ( { }} > - - - + + { + return ( + field.onChange(value || [])} + error={error} + /> + ); + }} + name={"road_patrol_machines_id"} + /> + - { - const date = new Date(dateFrom); + maxDateTime={watch("end_time") ? new Date(watch("end_time")) : null} + onChange={(start_time) => { + const date = new Date(start_time); const formattedDate = moment(date).locale("en").format("YYYY-MM-DD HH:mm"); - setDateFrom(formattedDate); + setValue("start_time", formattedDate); }} slotProps={{ textField: { @@ -105,7 +109,7 @@ const PatrolDetail = ({tabState, setTabState}) => { size="small" onClick={(event) => { event.stopPropagation(); - setDateFrom(null); + setValue("start_time", ""); }} sx={{ color: "#bfbfbf", @@ -123,15 +127,15 @@ const PatrolDetail = ({tabState, setTabState}) => { }, }} label="تاریخ و ساعت شروع گشت" /> - { - const date = new Date(dateTo); + minDateTime={watch("start_time") ? new Date(watch("start_time")) : null} + onChange={(end_time) => { + const date = new Date(end_time); const formattedDate = moment(date).locale("en").format("YYYY-MM-DD HH:mm"); - setDateTo(formattedDate); + setValue("end_time", formattedDate); }} slotProps={{ textField: { @@ -144,7 +148,7 @@ const PatrolDetail = ({tabState, setTabState}) => { size="small" onClick={(event) => { event.stopPropagation(); - setDateTo(null); + setValue("end_time", ""); }} sx={{ color: "#bfbfbf", @@ -170,99 +174,9 @@ const PatrolDetail = ({tabState, setTabState}) => { - {patrolFounded ? - - - - - }/> - - - {data.machine_code} - - - - }/> - - - {data.time} - - - - }/> - - - {data.distance} - - - - }/> - - - {data.stop} - - - - }/> - - - {data.fuel_amount} - - - - - - - - - - - - - - - - - - - - - : - - - ابتدا اطلاعات بالا را تکمیل نمایید - - } + {patrolResultStatus === 0 ? + : + } ); }; diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetailInfo.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetailInfo.jsx new file mode 100644 index 0000000..6ad3417 --- /dev/null +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetailInfo.jsx @@ -0,0 +1,147 @@ +"use client"; + +import {Box, Button, Card, CardActions, CardContent, Chip, Divider, Slide, Stack, Typography} from "@mui/material"; +import React from "react"; +import dynamic from "next/dynamic"; +import MapLoading from "@/core/components/MapLayer/Loading"; +import LocalGasStationIcon from '@mui/icons-material/LocalGasStation'; +import DirectionsCarFilledIcon from '@mui/icons-material/DirectionsCarFilled'; +import WatchLaterIcon from '@mui/icons-material/WatchLater'; +import QueryBuilderIcon from '@mui/icons-material/QueryBuilder'; +import AddRoadIcon from '@mui/icons-material/AddRoad'; +import ShareLocationIcon from '@mui/icons-material/ShareLocation'; +import KeyboardDoubleArrowLeftIcon from "@mui/icons-material/KeyboardDoubleArrowLeft"; +import QrCode2Icon from '@mui/icons-material/QrCode2'; +import moment from "jalali-moment"; +import PatrolMapFeatures from "./PatrolMapFeatures"; + +const MapLayer = dynamic(() => import("@/core/components/MapLayer"), { + loading: () => , + ssr: false, +}); + +const PatrolDetailInfo = ({patrolData, tabState, setTabState}) => { + const bound = patrolData.stopPoints.map(point => [point.latitude, point.longitude]); + + return ( + + + + + + }/> + + + {Math.floor(patrolData.accOnDuration / 60)} دقیقه + + + + }/> + + + {patrolData.roadPatrolMachinesId.car_name} + + + + }/> + + + {patrolData.roadPatrolMachinesId.machine_code} + + + + }/> + + + {patrolData.roadPatrolMachinesId.plak_number} + + + + }/> + + + {moment(patrolData.start_time).locale("fa").format("HH:mm | YYYY/MM/DD")} + + + + }/> + + + {moment(patrolData.end_time).locale("fa").format("HH:mm | YYYY/MM/DD")} + + + + }/> + + + {(patrolData.mileage / 1000).toFixed(1)} کیلومتر + + + + }/> + + + {Math.round(patrolData.fuelConsumption * 10) / 10} لیتر + + + + }/> + + + {patrolData.stopPoints.length} مورد + + + + + + + + + {patrolData.stopPoints.map((stopPoint, index) => { + return ( + + + + ) + })} + + + + + + + + + + + + + ); +}; + +export default PatrolDetailInfo; \ No newline at end of file diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx index b8f681e..90d3c67 100644 --- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx @@ -3,16 +3,19 @@ import {Box, DialogContent, Tab, Tabs, useMediaQuery} from "@mui/material"; import {useTheme} from "@emotion/react"; import React, {useEffect, useState} from "react"; -import TapAndPlayIcon from '@mui/icons-material/TapAndPlay'; import TaxiAlertIcon from '@mui/icons-material/TaxiAlert'; import EngineeringIcon from '@mui/icons-material/Engineering'; import HandymanIcon from '@mui/icons-material/Handyman'; import VerifiedIcon from '@mui/icons-material/Verified'; import PatrolTimeLine from "./PatrolTimeLine"; -import PhoneValidation from "./PhoneValidation"; import PatrolDetail from "./PatrolDetail"; import SuperVisorsDetail from "./SuperVisorsDetail"; import ActionsDuringPatrol from "./ActionsDurigPatrol"; +import {array, object, string} from "yup"; +import {useForm} from "react-hook-form"; +import {yupResolver} from "@hookform/resolvers/yup"; +import StyledForm from "@/core/components/StyledForm"; +import useRequest from "@/lib/hooks/useRequest"; function TabPanel(props) { const {children, value, index} = props; @@ -24,7 +27,32 @@ function TabPanel(props) { ); } -const PatrolForms = () => { +const defaultValues = { + road_patrol_rahdaran_id: null, + road_patrol_machines_id: null, + start_time: "", + end_time: "", + stop_points: null, + vehicle_runtime: "", + fuel_consumption: "", + distance: "", + observed_items: null +}; + +const validationSchema = object({ + road_patrol_rahdaran_id: array().required("حداقل یک راهدار باید وارد کنید!"), + road_patrol_machines_id: array().required("وارد کردن کد خودرو الزامیست!").min(1, "وارد کردن کد خودرو الزامیست!"), + start_time: string().required("لطفا زمان شروع گشت را انتخاب کنید!"), + end_time: string().required("لطفا زمان پایان گشت را انتخاب کنید!"), + stop_points: array().required("وجود نقاط توقف اجباری است!").min(1, "حداقل یک نقطه توقف باید وجود داشته باشد!"), + vehicle_runtime: string().required("وجود میزان زمان روشن بودن خودرو الزامیست!"), + fuel_consumption: string().required("وجود مقدار سوخت مصرفی الزامیست!"), + distance: string().required("وارد کردن مقدار الزامیست!"), + observed_items: array().required("وجود نقاط توقف اجباری است!").min(1, "حداقل یک نقطه توقف باید وجود داشته باشد!"), +}); + +const PatrolForms = ({mutate}) => { + const requestServer = useRequest({notificationSuccess: true}); const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down("md")); const [tabState, setTabState] = useState(0); @@ -40,9 +68,45 @@ const PatrolForms = () => { } }, [tabState]); + const { + control, + watch, + getValues, + register, + handleSubmit, + setValue, + resetField, + formState: {errors, isSubmitting}, + } = useForm({ + defaultValues, + resolver: yupResolver(validationSchema), + mode: "onBlur" + }); + + const onSubmit = async (data) => { + console.log("data", data); + const formData = new FormData(); + // formData.append("road_patrol_rahdaran_id", myData); + // formData.append("road_patrol_machines_id", myData); + // formData.append("start_time", moment(new Date(myData)).format("YYYY-MM-DD")); + // formData.append("end_time", moment(new Date(myData)).format("YYYY-MM-DD")); + // formData.append("stop_points", myData); + // formData.append("vehicle_runtime", myData); + // formData.append("fuel_consumption", myData); + // formData.append("distance", myData); + // formData.append("observed_items", myData); + // try { + // await requestServer(CREATE_PATROL, "post", { + // data: formData, + // }); + // mutate(); + // handleClose(); + // } catch (error) { + // } + }; return ( - <> + { backgroundColor: "#efefef", }} > - = 0)} icon={} label="تایید هویت"> - = 1)} icon={} label="مشخصات گشت"> - = 2)} icon={} label="مشخصات راهداران"> - = 3)} icon={} label="اقدامات حین گشت"> - = 4)} icon={} label="تکمیل درخواست"> + = 0)} icon={} label="مشخصات گشت"> + = 1)} icon={} label="مشخصات راهداران"> + = 2)} icon={} label="اقدامات حین گشت"> + = 3)} icon={} label="تکمیل درخواست"> - + - + - - - - + <>taiidie @@ -85,7 +158,7 @@ const PatrolForms = () => { )} - + ); }; export default PatrolForms; diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolMapFeatures.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolMapFeatures.jsx new file mode 100644 index 0000000..a72ce56 --- /dev/null +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolMapFeatures.jsx @@ -0,0 +1,38 @@ +"use client"; + +import {Typography} from "@mui/material"; +import React, {useRef} from "react"; +import {Marker, Popup} from "react-leaflet"; +import AzmayeshIcon from "@/assets/images/examine_marker.png"; + +const PatrolMapFeatures = ({stopPoint}) => { + const position = [stopPoint.latitude, stopPoint.longitude]; + const mapPatrolMarker = useRef(); + const createCustomIcon = (size, iconUrl) => { + return L.icon({ + iconUrl: iconUrl, + iconSize: size, + iconAnchor: [size[0] / 2, size[1]], + popupAnchor: [0, -size[1]], + }); + }; + + return ( + + + مدت زمان + توقف: {stopPoint.duration} ثانیه + + + ); +}; + +export default PatrolMapFeatures; \ No newline at end of file diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolResultCodeErrors.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolResultCodeErrors.jsx new file mode 100644 index 0000000..c470da6 --- /dev/null +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolResultCodeErrors.jsx @@ -0,0 +1,25 @@ +"use client"; + +import {Box, Typography} from "@mui/material"; +import React from "react"; + +const PatrolResultCodeErrors = ({ResultCode}) => { + const errorMessages = { + [-1]: "نام کاربری یا کلمه عبور صحیح نمیباشد", + [-2]: "ردیاب به خودرو انتخابی متصل نیست", + [-3]: "کاربر دسترسی لازم به اطلاعات خودرو انتخابی را ندارد", + [-4]: "خطای درخواست مکرر", + }; + + const message = errorMessages[ResultCode] || "ابتدا اطلاعات بالا را تکمیل نمایید"; + + return ( + + + {message} + + + ); +}; + +export default PatrolResultCodeErrors; \ No newline at end of file diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorsDetail.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorsDetail.jsx index cf53f07..5586a97 100644 --- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorsDetail.jsx +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorsDetail.jsx @@ -1,22 +1,22 @@ "use client"; -import {Box, Button, Chip, Divider, Grid, Typography} from "@mui/material"; +import {Box, Button, Chip, Divider, Grid, Stack, Typography} from "@mui/material"; import SaveAltIcon from '@mui/icons-material/SaveAlt'; import React, {useEffect, useState} from "react"; import RahdarCode from "@/core/components/RahdarCode"; import SuperVisorInfo from "@/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorInfo"; import KeyboardDoubleArrowRightIcon from "@mui/icons-material/KeyboardDoubleArrowRight"; import KeyboardDoubleArrowLeftIcon from "@mui/icons-material/KeyboardDoubleArrowLeft"; +import {Controller} from "react-hook-form"; -const SuperVisorsDetail = ({tabState, setTabState}) => { +const SuperVisorsDetail = ({control, watch, setValue, tabState, setTabState}) => { const [SuperVisorList, setSuperVisorList] = useState([]); - const [rahdarsCode, setRahdarsCode] = useState(null); const [readyToRequest, setReadyToRequest] = useState(false); const requestPatrolInfo = () => { - setSuperVisorList((prev) => [...prev, rahdarsCode]); + setSuperVisorList((prev) => [...prev, watch("road_patrol_rahdaran_id")]); setReadyToRequest(false); - setRahdarsCode(null); + setValue("road_patrol_rahdaran_id", null); } const deleteSuperVisor = (id) => { @@ -24,8 +24,8 @@ const SuperVisorsDetail = ({tabState, setTabState}) => { }; useEffect(() => { - setReadyToRequest(rahdarsCode != null); - }, [rahdarsCode]); + setReadyToRequest(watch("road_patrol_rahdaran_id") != null); + }, [watch("road_patrol_rahdaran_id")]); return ( { - + + { + return ( + field.onChange(value || [])} + error={error} + multiple={false} + /> + ); + }} + name={"road_patrol_rahdaran_id"} + /> + + + ); }; diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/EditActionDuringPatrol.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/EditActionDuringPatrol.jsx new file mode 100644 index 0000000..3098d06 --- /dev/null +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/EditActionDuringPatrol.jsx @@ -0,0 +1,52 @@ +"use client"; + +import React, {useState} from "react"; +import dynamic from "next/dynamic"; +import MapLoading from "@/core/components/MapLayer/Loading"; +import {Dialog, DialogTitle, IconButton} from "@mui/material"; +import EditIcon from "@mui/icons-material/Edit"; +import EditFormContent from "@/components/dashboard/roadItems/operator/RowActions/EditForm/EditFormContent"; + +const MapLayer = dynamic(() => import("@/core/components/MapLayer"), { + loading: () => , + ssr: false, +}); + +const EditActionDuringPatrol = ({action}) => { + + console.log("action", action) + + const [open, setOpen] = useState(false); + + const handleOpen = () => { + setOpen(true); + }; + + const HandleSubmit = async (data, result) => { + setActionsList((prev) => [...prev, data]); + setOpen(false); + } + + return ( + <> + + + + + ویرایش اطلاعات + + + + ); +}; + +export default EditActionDuringPatrol; \ No newline at end of file diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetailInfo.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetailInfo.jsx index 6ad3417..f7b8f00 100644 --- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetailInfo.jsx +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolDetailInfo.jsx @@ -10,6 +10,7 @@ import WatchLaterIcon from '@mui/icons-material/WatchLater'; import QueryBuilderIcon from '@mui/icons-material/QueryBuilder'; import AddRoadIcon from '@mui/icons-material/AddRoad'; import ShareLocationIcon from '@mui/icons-material/ShareLocation'; +import ElectricCarIcon from '@mui/icons-material/ElectricCar'; import KeyboardDoubleArrowLeftIcon from "@mui/icons-material/KeyboardDoubleArrowLeft"; import QrCode2Icon from '@mui/icons-material/QrCode2'; import moment from "jalali-moment"; @@ -36,65 +37,65 @@ const PatrolDetailInfo = ({patrolData, tabState, setTabState}) => { }}> - }/> + }/> - + {Math.floor(patrolData.accOnDuration / 60)} دقیقه }/> - + {patrolData.roadPatrolMachinesId.car_name} }/> - + {patrolData.roadPatrolMachinesId.machine_code} }/> - + {patrolData.roadPatrolMachinesId.plak_number} }/> - + {moment(patrolData.start_time).locale("fa").format("HH:mm | YYYY/MM/DD")} }/> - + {moment(patrolData.end_time).locale("fa").format("HH:mm | YYYY/MM/DD")} }/> - + {(patrolData.mileage / 1000).toFixed(1)} کیلومتر }/> - + {Math.round(patrolData.fuelConsumption * 10) / 10} لیتر }/> - + {patrolData.stopPoints.length} مورد diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx index 90d3c67..fdafddf 100644 --- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/PatrolForms.jsx @@ -55,7 +55,7 @@ const PatrolForms = ({mutate}) => { const requestServer = useRequest({notificationSuccess: true}); const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down("md")); - const [tabState, setTabState] = useState(0); + const [tabState, setTabState] = useState(2); const [activeUpTo, setActiveUpTo] = useState(0); const handleChangeTab = (event, newValue) => { diff --git a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorsDetail.jsx b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorsDetail.jsx index 5586a97..e1b8d43 100644 --- a/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorsDetail.jsx +++ b/src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/SuperVisorsDetail.jsx @@ -44,10 +44,11 @@ const SuperVisorsDetail = ({control, watch, setValue, tabState, setTabState}) => { + console.log("field.value", field.value) return ( field.onChange(value || [])} + rahdarsCode={field.value} + setRahdarsCode={(value) => field.onChange(value)} error={error} multiple={false} /> From 637163038099fcb5e4fcb4e9148094f0ac27bafb Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Mon, 6 Jan 2025 13:08:47 +0330 Subject: [PATCH 8/9] work on patrol form instead sending request --- .../Create/Forms/CreateFormContent.jsx | 95 ++++---- .../Actions/Create/Forms/GetItemInfo.jsx | 66 +++--- .../Actions/Create/Forms/ImageUpload.jsx | 44 ++-- .../RowActions/EditForm/EditFormContent.jsx | 31 ++- .../RowActions/EditForm/EditFormCreate.jsx | 36 +-- .../roadPatrols/operator/ExcelPrint/index.jsx | 26 +-- .../Forms/CreatePatrol/ActionInfo.jsx | 92 +------- .../Forms/CreatePatrol/ActionsDurigPatrol.jsx | 13 +- .../Forms/CreatePatrol/CompeleteRequest.jsx | 218 ++++++++++++++++++ .../CreatePatrol/EditActionDuringPatrol.jsx | 19 +- .../CreatePatrol/ModalActionsDuringPatrol.jsx | 2 +- .../Forms/CreatePatrol/PatrolDetail.jsx | 3 +- .../Forms/CreatePatrol/PatrolDetailInfo.jsx | 45 +++- .../Forms/CreatePatrol/PatrolForms.jsx | 99 ++++---- .../Forms/CreatePatrol/PatrolTimeLine.jsx | 37 +-- .../Forms/CreatePatrol/PhoneValidation.jsx | 39 +--- .../Forms/CreatePatrol/SuperVisorsDetail.jsx | 8 +- src/core/utils/routes.js | 1 + 18 files changed, 539 insertions(+), 335 deletions(-) create mode 100644 src/components/dashboard/roadPatrols/operator/Forms/CreatePatrol/CompeleteRequest.jsx diff --git a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/CreateFormContent.jsx b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/CreateFormContent.jsx index 7f47a7d..cfb5a36 100644 --- a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/CreateFormContent.jsx +++ b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/CreateFormContent.jsx @@ -1,10 +1,9 @@ -import React, { useState } from "react"; -import { useForm } from "react-hook-form"; -import { yupResolver } from "@hookform/resolvers/yup"; -import { array, mixed, number, object, string } from "yup"; -import { useTheme } from "@emotion/react"; -import useRequest from "@/lib/hooks/useRequest"; -import { Box, Button, DialogActions, DialogContent, Tab, Tabs, useMediaQuery } from "@mui/material"; +import React, {useState} from "react"; +import {useForm} from "react-hook-form"; +import {yupResolver} from "@hookform/resolvers/yup"; +import {array, mixed, number, object, string} from "yup"; +import {useTheme} from "@emotion/react"; +import {Box, Button, DialogActions, DialogContent, Tab, Tabs, useMediaQuery} from "@mui/material"; import StyledForm from "@/core/components/StyledForm"; import InsertDriveFileIcon from "@mui/icons-material/InsertDriveFile"; import FileCopyIcon from "@mui/icons-material/FileCopy"; @@ -15,10 +14,9 @@ import BeenhereIcon from "@mui/icons-material/Beenhere"; import GetItemsForm from "@/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemsForm"; import GetSubItemsForm from "@/components/dashboard/roadItems/operator/Actions/Create/Forms/GetSubItemsForm"; import GetItemInfo from "@/components/dashboard/roadItems/operator/Actions/Create/Forms/GetItemInfo"; -import { CREATE_ROAD_ITEMS } from "@/core/utils/routes"; function TabPanel(props) { - const { children, value, index } = props; + const {children, value, index} = props; return (