diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index d263ce5..1a505df 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -48,6 +48,7 @@ "Dashboard": { "dashboard_page": "داشبورد", "passenger_office_page": "اداره مسافر", + "machinary_office_page": "ماشین آلات", "change_password": "تغییر رمز عبور", "edit_profile": "ویرایش پروفایل" }, @@ -100,6 +101,16 @@ "vehicle_type": "نوع ماشین", "state_name": "وضعیت درخواست" }, + "MachinaryOffice": { + "name": "نام", + "id": "کد ملی", + "phone_number": "موبایل", + "created_at": "تاریخ درخواست", + "updated_at": "تاریخ بروزرسانی", + "navgan_id": "کد ناوگان", + "vehicle_type": "نوع ماشین", + "state_name": "وضعیت درخواست" + }, "ConfirmDialog": { "confirm": "تایید", "context": "آیا از تایید این آیتم اطمینان دارید", diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx new file mode 100644 index 0000000..5fd3f3b --- /dev/null +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx @@ -0,0 +1,39 @@ +import { + Dialog, + DialogTitle, + DialogContent, + DialogContentText, + DialogActions, + Button, +} from "@mui/material"; +import { useTranslations } from "next-intl"; + +const ConfirmForm = ({ + open, + handleClose, + handleDelete, + rowId, + deleteData, +}) => { + const t = useTranslations(); + const handleDeleteExpert = () => { + handleDelete(); + }; + return ( + + {t("delete-dialog.confirm")} + + {t("delete-dialog.context")} + + + + + + + ); +}; +export default ConfirmForm; diff --git a/src/components/dashboard/machinary-office/Form/RejectForm.jsx b/src/components/dashboard/machinary-office/Form/RejectForm.jsx new file mode 100644 index 0000000..cf551a8 --- /dev/null +++ b/src/components/dashboard/machinary-office/Form/RejectForm.jsx @@ -0,0 +1,33 @@ +import { + Dialog, + DialogTitle, + DialogContent, + DialogContentText, + DialogActions, + Button, +} from "@mui/material"; +import { useTranslations } from "next-intl"; + +const RejectForm = ({ open, handleClose, handleDelete, rowId, deleteData }) => { + const t = useTranslations(); + const handleDeleteExpert = () => { + handleDelete(); + }; + return ( + + {t("delete-dialog.confirm")} + + {t("delete-dialog.context")} + + + + + + + ); +}; +export default RejectForm; diff --git a/src/components/dashboard/machinary-office/TableRowActions.jsx b/src/components/dashboard/machinary-office/TableRowActions.jsx new file mode 100644 index 0000000..832e77e --- /dev/null +++ b/src/components/dashboard/machinary-office/TableRowActions.jsx @@ -0,0 +1,46 @@ +import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; +import ThumbDownIcon from "@mui/icons-material/ThumbDown"; +import { Box, IconButton } from "@mui/material"; +import { useContext } from "react"; +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); + return ( + + handleOpenDeleteDialog(row)}> + + + {/* */} + handleOpenDeleteDialog(row)}> + + + {/* */} + + ); +}; + +export default TableRowActions; diff --git a/src/components/dashboard/machinary-office/TableTolbar.jsx b/src/components/dashboard/machinary-office/TableTolbar.jsx new file mode 100644 index 0000000..3f06d3b --- /dev/null +++ b/src/components/dashboard/machinary-office/TableTolbar.jsx @@ -0,0 +1,13 @@ +import { Stack, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; + +function TableToolbar() { + const t = useTranslations(); + return ( + + + + ); +} + +export default TableToolbar; diff --git a/src/components/dashboard/machinary-office/index.jsx b/src/components/dashboard/machinary-office/index.jsx new file mode 100644 index 0000000..a9af448 --- /dev/null +++ b/src/components/dashboard/machinary-office/index.jsx @@ -0,0 +1,177 @@ +import DataTableStructure from "@/core/components/DatatableStructure"; +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 { useTranslations } from "next-intl"; +import TableRowActions from "./TableRowActions"; + +function DashboardMachinaryOfficeComponent() { + const t = useTranslations(); + const columns = useMemo( + () => [ + { + accessorFn: (row) => row.name, + id: "name", + header: t("MachinaryOffice.name"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.id, + id: "id", + header: t("MachinaryOffice.id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.phone_number, + id: "phone_number", + header: t("MachinaryOffice.phone_number"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.created_at, + id: "created_at", + header: t("MachinaryOffice.created_at"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.updated_at, + id: "updated_at", + header: t("MachinaryOffice.updated_at"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.navgan_id, + id: "navgan_id", + header: t("MachinaryOffice.navgan_id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.vehicle_type, + id: "vehicle_type", + header: t("MachinaryOffice.vehicle_type"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.state_name, + id: "state_id", + header: t("MachinaryOffice.state_name"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + filterSelectOptions: [ + { text: "Active", value: "0" }, + { text: "Deactive", value: "1" }, + ], + filterVariant: "select", + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + ], + [] + ); + return ( + + + } + enableLastUpdate={true} + enablePinning={true} + enableDensityToggle={true} + enableColumnFilters={true} + enableHiding={true} + enableFullScreenToggle={false} + enableGlobalFilter={false} + enableColumnResizing={false} // if you want true this you shold change renderRowActions props ** see https://www.material-react-table.com/docs/guides/row-actions + enableRowActions={true} + renderRowActions={({ row }) => } + /> + + + ); +} + +export default DashboardMachinaryOfficeComponent; diff --git a/src/components/login-expert/index.jsx b/src/components/login-expert/index.jsx index bcc3b1a..4d6af4a 100644 --- a/src/components/login-expert/index.jsx +++ b/src/components/login-expert/index.jsx @@ -41,12 +41,10 @@ const LoginComponent = () => { password: values.password, }) .then(function (response) { - console.log(response); setToken(response.data.token); }) .catch(function (error) { // Notifications(directionApp, error.response, t); - console.log(error); props.setSubmitting(false); }); }; diff --git a/src/pages/dashboard/machinary-office/index.jsx b/src/pages/dashboard/machinary-office/index.jsx new file mode 100644 index 0000000..0bb3553 --- /dev/null +++ b/src/pages/dashboard/machinary-office/index.jsx @@ -0,0 +1,23 @@ +import DashboardMachinaryOfficeComponent from "@/components/dashboard/machinary-office"; +import TitlePage from "@/core/components/TitlePage"; +import WithAuthMiddleware from "@/middlewares/WithAuth"; +import { parse } from "next-useragent"; + +export default function PassengerOffice() { + return ( + + + + + ); +} + +export async function getServerSideProps({ req, locale }) { + const { isBot } = parse(req.headers["user-agent"]); + return { + props: { + messages: (await import(`&/locales/${locale}/app.json`)).default, + isBot, + }, + }; +}