From 390bd2fd7cf4a9abedfd833daadacf3fa47b02b9 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Sun, 16 Jul 2023 11:00:57 +0330 Subject: [PATCH] machinary office implement --- .../machinary-office/Form/ConfirmForm.jsx | 16 +++--- .../machinary-office/Form/RejectForm.jsx | 16 +++--- .../machinary-office/TableRowActions.jsx | 51 ++++++++++--------- .../dashboard/machinary-office/index.jsx | 4 +- .../passenger-office/TableRowActions.jsx | 9 ++-- src/core/data/apiRoutes.js | 11 ++++ src/lib/app/hooks/useDatatable.jsx | 4 +- 7 files changed, 67 insertions(+), 44 deletions(-) diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx index 5fd3f3b..702ce9b 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx @@ -1,3 +1,4 @@ +import { CONFIRM_MACHINARY_OFFICE } from "@/core/data/apiRoutes"; import { Dialog, DialogTitle, @@ -13,24 +14,25 @@ const ConfirmForm = ({ handleClose, handleDelete, rowId, - deleteData, + confirmData, }) => { const t = useTranslations(); - const handleDeleteExpert = () => { + const handleConfirm = () => { handleDelete(); + confirmData(CONFIRM_MACHINARY_OFFICE, rowId); }; return ( - {t("delete-dialog.confirm")} + {t("ConfirmDialog.confirm")} - {t("delete-dialog.context")} + {t("ConfirmDialog.context")} - diff --git a/src/components/dashboard/machinary-office/Form/RejectForm.jsx b/src/components/dashboard/machinary-office/Form/RejectForm.jsx index cf551a8..4fce632 100644 --- a/src/components/dashboard/machinary-office/Form/RejectForm.jsx +++ b/src/components/dashboard/machinary-office/Form/RejectForm.jsx @@ -1,3 +1,4 @@ +import { REJECT_MACHINARY_OFFICE } from "@/core/data/apiRoutes"; import { Dialog, DialogTitle, @@ -8,23 +9,24 @@ import { } from "@mui/material"; import { useTranslations } from "next-intl"; -const RejectForm = ({ open, handleClose, handleDelete, rowId, deleteData }) => { +const RejectForm = ({ open, handleClose, handleDelete, rowId, rejectData }) => { const t = useTranslations(); - const handleDeleteExpert = () => { + const handleRejectRequest = () => { handleDelete(); + rejectData(REJECT_MACHINARY_OFFICE, rowId); }; return ( - {t("delete-dialog.confirm")} + {t("RejectDialog.reject")} - {t("delete-dialog.context")} + {t("RejectDialog.context")} - diff --git a/src/components/dashboard/machinary-office/TableRowActions.jsx b/src/components/dashboard/machinary-office/TableRowActions.jsx index 832e77e..f5ec46b 100644 --- a/src/components/dashboard/machinary-office/TableRowActions.jsx +++ b/src/components/dashboard/machinary-office/TableRowActions.jsx @@ -6,39 +6,42 @@ import { DataTableContext } from "@/lib/app/contexts/DataTableContext"; import ConfirmForm from "./Form/ConfirmForm"; import RejectForm from "./Form/RejectForm"; -// import DeleteForm from "./Form/DeleteForm"; - const TableRowActions = ({ row }) => { - // const { - // openDeleteDialog, - // handleOpenDeleteDialog, - // handleCloseDeleteDialog, - // handleDeleteDialog, - // rowId, - // deleteData, - // } = useContext(DataTableContext); + const { + openConfirmDialog, + openRejectDialog, + handleOpenConfirmDialog, + handleOpenRejectDialog, + handleCloseConfirmDialog, + handleCloseRejectDialog, + handleConfirmDialog, + handleRejectDialog, + rowId, + confirmData, + rejectData, + } = useContext(DataTableContext); return ( - handleOpenDeleteDialog(row)}> + handleOpenConfirmDialog(row)}> - {/* */} - handleOpenDeleteDialog(row)}> + open={openConfirmDialog} + handleClose={handleCloseConfirmDialog} + handleDelete={handleConfirmDialog} + confirmData={confirmData} + /> + handleOpenRejectDialog(row)}> - {/* */} + open={openRejectDialog} + handleClose={handleCloseRejectDialog} + handleDelete={handleRejectDialog} + rejectData={rejectData} + /> ); }; diff --git a/src/components/dashboard/machinary-office/index.jsx b/src/components/dashboard/machinary-office/index.jsx index a9af448..8a88f5f 100644 --- a/src/components/dashboard/machinary-office/index.jsx +++ b/src/components/dashboard/machinary-office/index.jsx @@ -3,7 +3,7 @@ import DashboardLayouts from "@/layouts/dashboardLayouts"; import { Box, Typography } from "@mui/material"; import { useMemo } from "react"; // import TableToolbar from "./TableTollbar"; -import { GET_PASSENGER_OFFICE } from "@/core/data/apiRoutes"; +import { GET_MACHINARY_OFFICE } from "@/core/data/apiRoutes"; import { useTranslations } from "next-intl"; import TableRowActions from "./TableRowActions"; @@ -153,7 +153,7 @@ function DashboardMachinaryOfficeComponent() { { const { openConfirmDialog, @@ -24,7 +22,12 @@ const TableRowActions = ({ row }) => { } = useContext(DataTableContext); return ( - handleOpenConfirmDialog(row)}> + { + handleOpenConfirmDialog(row); + }} + > { dispatch({ type: "CONFIRM_DATA", url: url, rowID: rowID }); axios .post(`${url}/${rowID}`, { - headers: { authorization: `Bearer ${token}` }, + headers: { + Authorization: `Bearer ${token}`, + }, }) .then(() => { setReloadDataTable(true);