From 624e453084ce5cf704e4f745ca9469a6bf9d60de Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Sun, 20 Apr 2025 16:32:10 +0330 Subject: [PATCH] fixed bug --- .../infrastructure/toll-house/page.js | 2 +- .../roadPatrols/operator/OperatorList.jsx | 15 ++--- .../RahdaranForm/RahdaranContent.jsx | 58 +++++++++++++------ .../RowActions/RahdaranForm/index.jsx | 4 +- .../infrastructure/tollHouse/index.jsx | 2 +- src/core/utils/routes.js | 1 + 6 files changed, 52 insertions(+), 30 deletions(-) diff --git a/src/app/(withAuth)/(dashboardLayout)/infrastructure/toll-house/page.js b/src/app/(withAuth)/(dashboardLayout)/infrastructure/toll-house/page.js index dec7c50..ca84816 100644 --- a/src/app/(withAuth)/(dashboardLayout)/infrastructure/toll-house/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/infrastructure/toll-house/page.js @@ -2,7 +2,7 @@ import WithPermission from "@/core/middlewares/withPermission"; import TollHousePage from "@/components/infrastructure/tollHouse"; export const metadata = { - title: "فهرست راهدارخانه ها", + title: "لیست راهدارخانه ها", }; const Page = () => { diff --git a/src/components/dashboard/roadPatrols/operator/OperatorList.jsx b/src/components/dashboard/roadPatrols/operator/OperatorList.jsx index 4548072..2de63a8 100644 --- a/src/components/dashboard/roadPatrols/operator/OperatorList.jsx +++ b/src/components/dashboard/roadPatrols/operator/OperatorList.jsx @@ -71,15 +71,12 @@ const OperatorList = () => { }, }, }, - Cell: ({ renderedCellValue }) => { - if (renderedCellValue) { - return ( - - - - ); - } - return -; + Cell: ({ renderedCellValue, row }) => { + return ( + + + + ); }, }, { diff --git a/src/components/dashboard/roadPatrols/operator/RowActions/RahdaranForm/RahdaranContent.jsx b/src/components/dashboard/roadPatrols/operator/RowActions/RahdaranForm/RahdaranContent.jsx index d1e9b15..1a31ce8 100644 --- a/src/components/dashboard/roadPatrols/operator/RowActions/RahdaranForm/RahdaranContent.jsx +++ b/src/components/dashboard/roadPatrols/operator/RowActions/RahdaranForm/RahdaranContent.jsx @@ -1,22 +1,44 @@ -import { DialogContent, Paper, Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from "@mui/material"; +import DialogLoading from "@/core/components/DialogLoading"; +import { GET_RAHDARAN_ROAD_POTROL } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { + DialogContent, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + Typography, +} from "@mui/material"; +import { useEffect, useState } from "react"; + +const RahdaranContent = ({ rowId }) => { + const [loading, setLoading] = useState(true); + const [data, setData] = useState(null); + const request = useRequest(); + + useEffect(() => { + const fetchData = async () => { + try { + setLoading(true); + const response = await request(`${GET_RAHDARAN_ROAD_POTROL}/${rowId}`); + setData(response.data.data); + } catch (error) { + } finally { + setLoading(false); + } + }; + + fetchData(); + }, [rowId]); -const RahdaranContent = ({ rahdarLists }) => { return ( <> - + {loading ? ( + + ) : data ? ( @@ -26,7 +48,7 @@ const RahdaranContent = ({ rahdarLists }) => { - {rahdarLists.map((rahdar) => { + {data.map((rahdar) => { return ( {
-
+ ) : ( + اطلاعات راهداران در سامانه یافت نشد + )}
); diff --git a/src/components/dashboard/roadPatrols/operator/RowActions/RahdaranForm/index.jsx b/src/components/dashboard/roadPatrols/operator/RowActions/RahdaranForm/index.jsx index 2c73d80..e3a2efc 100644 --- a/src/components/dashboard/roadPatrols/operator/RowActions/RahdaranForm/index.jsx +++ b/src/components/dashboard/roadPatrols/operator/RowActions/RahdaranForm/index.jsx @@ -3,7 +3,7 @@ import GroupsIcon from "@mui/icons-material/Groups"; import { useState } from "react"; import RahdaranContent from "./RahdaranContent"; -const RahdaranDialog = ({ rahdarLists }) => { +const RahdaranDialog = ({ rowId }) => { const [openRahdaranDialog, setOpenRahdaranDialog] = useState(false); return ( <> @@ -25,7 +25,7 @@ const RahdaranDialog = ({ rahdarLists }) => { maxWidth={"md"} > لیست راهداران - + {openRahdaranDialog && }