From 0ae316a72be4982148a9bc016a877a731c66689a Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Mon, 10 Jul 2023 14:39:15 +0330 Subject: [PATCH 001/134] first demo of login page --- public/locales/fa/app.json | 3 +- src/components/login-expert/index.jsx | 43 ++++++++++----------------- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 7d0f4ed..b34fc47 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -35,8 +35,7 @@ "link_routing_back_to": "بازگشت به", "link_routing_previuos_page": "صفحه قبل", "link_routing_main_page": "صفحه اصلی", - "error_message_required": "اجباری!", - "button_make_account": "ایجاد حساب" + "error_message_required": "اجباری!" }, "dashboard": { "dashboard_page": "داشبورد" diff --git a/src/components/login-expert/index.jsx b/src/components/login-expert/index.jsx index 92d4e36..65b1e1c 100644 --- a/src/components/login-expert/index.jsx +++ b/src/components/login-expert/index.jsx @@ -8,7 +8,6 @@ import FullPageLayout from "@/layouts/FullPageLayout"; import useDirection from "@/lib/app/hooks/useDirection"; import useUser from "@/lib/app/hooks/useUser"; import LoginIcon from "@mui/icons-material/Login"; -import PersonAddIcon from "@mui/icons-material/PersonAdd"; import { Box, Button, @@ -27,7 +26,7 @@ import * as Yup from "yup"; const LoginComponent = () => { const t = useTranslations(); - const { directionApp } = useDirection(); + // const { directionApp } = useDirection(); // should delete because we dont have direction anymore const { setToken } = useUser(); // pass token to set token // gettin url query @@ -35,20 +34,20 @@ const LoginComponent = () => { const backUrlDecodedPath = searchParams.get("back_url"); // formik properties -// const handleSubmit = async (values, props) => { -// await axios -// .post(GET_USER_TOKEN, { -// username: values.username, -// password: values.password, -// }) -// .then(function (response) { -// setToken(response.data.token); -// }) -// .catch(function (error) { -// Notifications(directionApp, error.response, t); -// props.setSubmitting(false); -// }); -// }; + // const handleSubmit = async (values, props) => { + // await axios + // .post(GET_USER_TOKEN, { + // username: values.username, + // password: values.password, + // }) + // .then(function (response) { + // setToken(response.data.token); + // }) + // .catch(function (error) { + // Notifications(directionApp, error.response, t); + // props.setSubmitting(false); + // }); + // }; const initialValues = { username: "", password: "", @@ -121,20 +120,10 @@ const LoginComponent = () => { justifyContent: "space-between", }} > - - - + + + ); +} + +export default TableToolbar; diff --git a/src/components/dashboard/passenger-office/index.jsx b/src/components/dashboard/passenger-office/index.jsx new file mode 100644 index 0000000..2d52dd3 --- /dev/null +++ b/src/components/dashboard/passenger-office/index.jsx @@ -0,0 +1,192 @@ +import DataTableStructure from "@/core/components/DatatableStructure"; +import DashboardLayouts from "@/layouts/dashboardLayouts"; +import { ContentCopy } from "@mui/icons-material"; +import { Box, Typography } from "@mui/material"; +import { DateTimePicker, LocalizationProvider } from "@mui/x-date-pickers"; +import { format } from "date-fns-jalali"; +import { useMemo } from "react"; +import TableToolbar from "./TableTollbar"; +import TableRowActions from "./TableRowActions"; + +function DashboardPassengerOfficeComponent() { + const columns = useMemo( + () => [ + { + accessorFn: (row) => row.id, + id: "id", + header: "Id", + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.username, + id: "username", + header: "Username", + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.name, + id: "name", + header: "Name", + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + muiTableBodyCellCopyButtonProps: { + fullWidth: true, + endIcon: , + sx: { justifyContent: "space-between" }, + }, + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.phone_number, + id: "phone_number", + header: "Phone Number", + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["equals", "notEquals", "contains"], + muiTableBodyCellCopyButtonProps: { + fullWidth: true, + endIcon: , + sx: { justifyContent: "space-between" }, + }, + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.status, + id: "status", + header: "Status", + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + filterSelectOptions: [ + { text: "Active", value: "0" }, + { text: "Deactive", value: "1" }, + ], + filterVariant: "select", + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.gender, + id: "gender", + header: "Gender", + enableColumnFilter: true, + datatype: "text", + filterFn: "equals", + filterSelectOptions: [ + { text: "Male", value: "male" }, + { text: "Female", value: "female" }, + ], + filterVariant: "select", + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.national_id_code, + id: "national_id_code", + header: "National Id Code", + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["equals", "notEquals", "contains"], + muiTableBodyCellCopyButtonProps: { + fullWidth: true, + endIcon: , + sx: { justifyContent: "space-between" }, + }, + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => new Date(row.updated_at), + id: "updated_at", + header: "Update Date", + enableColumnFilter: true, + datatype: "date", + filterFn: "lessThan", + columnFilterModeOptions: ["lessThan", "greaterThan"], + Cell: ({ renderedCellValue }) => { + const date = new Date(renderedCellValue); + const formattedDate = format(date, "MM/dd/yyyy HH:mm"); + return {formattedDate}; + }, + Header: ({ column }) => {column.columnDef.header}, + Filter: ({ column }) => { + return ( + + { + const date = new Date(newValue); + const formattedDate = format(date, "yyyy-MM-dd HH:mm"); + column.setFilterValue(formattedDate); + }} + slotProps={{ + textField: { + helperText: `Filter Mode: ${column.columnDef._filterFn}`, + sx: { minWidth: "120px" }, + variant: "standard", + }, + }} + value={column.getFilterValue()} + /> + + ); + }, + }, + ], + [] + ); + 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 DashboardPassengerOfficeComponent; diff --git a/src/core/components/ImageConvertor.jsx b/src/core/components/ImageConvertor.jsx index e69de29..667182e 100644 --- a/src/core/components/ImageConvertor.jsx +++ b/src/core/components/ImageConvertor.jsx @@ -0,0 +1,22 @@ +import ImageResize from "image-resize"; + +const ImageResizer = async (image) => { + const imageResize = new ImageResize({ + quality: 1, + format: "jpg", + outputType: "base64", + width: 400, + }); + + const get = await imageResize.get(image); + const resize = await imageResize.resize(get).then(); + const output = await imageResize.output(resize).then(); + + const avatar = await (await import("image-to-file-converter")) + .base64ToFile(output) + .then(); + + return avatar; +}; + +export default ImageResizer; diff --git a/src/pages/dashboard/passenger-office/index.jsx b/src/pages/dashboard/passenger-office/index.jsx new file mode 100644 index 0000000..78ec016 --- /dev/null +++ b/src/pages/dashboard/passenger-office/index.jsx @@ -0,0 +1,23 @@ +import DashboardPassengerOfficeComponent from "@/components/dashboard/passenger-office"; +import TitlePage from "@/core/components/TitlePage"; +import WithAuthMiddleware from "@/middlewares/WithoutAuth"; +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, + }, + }; +} From 77c0077638ed01c2ce3ec8666ebd950ec9906f60 Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Tue, 11 Jul 2023 11:52:12 +0330 Subject: [PATCH 011/134] edit_sidebar --- src/core/data/sidebarMenu.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/data/sidebarMenu.jsx b/src/core/data/sidebarMenu.jsx index 40f08c8..cf2aacb 100644 --- a/src/core/data/sidebarMenu.jsx +++ b/src/core/data/sidebarMenu.jsx @@ -47,12 +47,12 @@ const sidebarMenu = [ role: "transportation-assistance", }, { - key: "sidebar.master", + key: "sidebar.manager", type: "page", - route: "/dashboard/master", + route: "/dashboard/manager", icon: , selected: false, - role: "master", + role: "manager", }, ], ]; From 6a3735982a6343b9b1037fc4dfa26bcd9a29c9d5 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Tue, 11 Jul 2023 11:52:56 +0330 Subject: [PATCH 012/134] initialize first demo of passenger boss page --- public/locales/fa/app.json | 3 +- .../passenger-boss/TableRowActions.jsx | 50 +++++ .../dashboard/passenger-boss/TableTollbar.jsx | 32 +++ .../dashboard/passenger-boss/index.jsx | 195 ++++++++++++++++++ src/pages/dashboard/passenger-boss/index.jsx | 23 +++ 5 files changed, 302 insertions(+), 1 deletion(-) create mode 100644 src/components/dashboard/passenger-boss/TableRowActions.jsx create mode 100644 src/components/dashboard/passenger-boss/TableTollbar.jsx create mode 100644 src/components/dashboard/passenger-boss/index.jsx create mode 100644 src/pages/dashboard/passenger-boss/index.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 09654eb..4a9cf3f 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -43,7 +43,8 @@ "error_message_required": "اجباری!" }, "Dashboard": { - "dashboard_page": "داشبورد" + "dashboard_page": "داشبورد", + "passenger_boss": "رئیس مسافر" }, "MuiDatePicker": { "date_picker_birthday": "تاریخ" diff --git a/src/components/dashboard/passenger-boss/TableRowActions.jsx b/src/components/dashboard/passenger-boss/TableRowActions.jsx new file mode 100644 index 0000000..0290214 --- /dev/null +++ b/src/components/dashboard/passenger-boss/TableRowActions.jsx @@ -0,0 +1,50 @@ +import DeleteIcon from "@mui/icons-material/Delete"; +import EditIcon from "@mui/icons-material/Edit"; +import { Box, IconButton } from "@mui/material"; +// import EditForm from "./Form/EditForm"; +import { useContext } from "react"; +import { DataTableContext } from "@/lib/app/contexts/DataTableContext"; +// import DeleteForm from "./Form/DeleteForm"; + +const TableRowActions = ({ row }) => { + const { + toggleDrawer, + setDrawerContent, + openDeleteDialog, + handleOpenDeleteDialog, + handleCloseDeleteDialog, + handleDeleteDialog, + rowId, + deleteData, + } = useContext(DataTableContext); + return ( + + { + toggleDrawer(true); + // setDrawerContent(); + }} + > + + + handleOpenDeleteDialog(row)} + > + + + {/* */} + + ); +}; + +export default TableRowActions; diff --git a/src/components/dashboard/passenger-boss/TableTollbar.jsx b/src/components/dashboard/passenger-boss/TableTollbar.jsx new file mode 100644 index 0000000..0b29ba8 --- /dev/null +++ b/src/components/dashboard/passenger-boss/TableTollbar.jsx @@ -0,0 +1,32 @@ +import { DataTableContext } from "@/lib/app/contexts/DataTableContext"; +import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; +import { Button, Stack, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useContext } from "react"; +// import AddForm from "./Form/AddForm"; + +function TableToolbar() { + const t = useTranslations(); + const { toggleDrawer, setDrawerContent } = useContext(DataTableContext); + return ( + + + + + + ); +} + +export default TableToolbar; diff --git a/src/components/dashboard/passenger-boss/index.jsx b/src/components/dashboard/passenger-boss/index.jsx new file mode 100644 index 0000000..46de5ba --- /dev/null +++ b/src/components/dashboard/passenger-boss/index.jsx @@ -0,0 +1,195 @@ +import DataTableStructure from "@/core/components/DatatableStructure"; +import DashboardLayouts from "@/layouts/dashboardLayouts"; +import { ContentCopy } from "@mui/icons-material"; +import { Box, Typography } from "@mui/material"; +import { DateTimePicker, LocalizationProvider } from "@mui/x-date-pickers"; +import { useTranslations } from "next-intl"; +import { useMemo } from "react"; +import TableToolbar from "./TableTollbar"; +import TableRowActions from "./TableRowActions"; + +const DashboardPassengerBossComponent = () => { + const t = useTranslations(); + + const columns = useMemo( + () => [ + { + accessorFn: (row) => row.id, + id: "id", + header: "Id", + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.username, + id: "username", + header: "Username", + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.name, + id: "name", + header: "Name", + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + muiTableBodyCellCopyButtonProps: { + fullWidth: true, + endIcon: , + sx: { justifyContent: "space-between" }, + }, + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.phone_number, + id: "phone_number", + header: "Phone Number", + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["equals", "notEquals", "contains"], + muiTableBodyCellCopyButtonProps: { + fullWidth: true, + endIcon: , + sx: { justifyContent: "space-between" }, + }, + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.status, + id: "status", + header: "Status", + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + filterSelectOptions: [ + { text: "Active", value: "0" }, + { text: "Deactive", value: "1" }, + ], + filterVariant: "select", + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.gender, + id: "gender", + header: "Gender", + enableColumnFilter: true, + datatype: "text", + filterFn: "equals", + filterSelectOptions: [ + { text: "Male", value: "male" }, + { text: "Female", value: "female" }, + ], + filterVariant: "select", + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.national_id_code, + id: "national_id_code", + header: "National Id Code", + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["equals", "notEquals", "contains"], + muiTableBodyCellCopyButtonProps: { + fullWidth: true, + endIcon: , + sx: { justifyContent: "space-between" }, + }, + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => new Date(row.updated_at), + id: "updated_at", + header: "Update Date", + enableColumnFilter: true, + datatype: "date", + filterFn: "lessThan", + columnFilterModeOptions: ["lessThan", "greaterThan"], + Cell: ({ renderedCellValue }) => { + const date = new Date(renderedCellValue); + const formattedDate = format(date, "MM/dd/yyyy HH:mm"); + return {formattedDate}; + }, + Header: ({ column }) => {column.columnDef.header}, + Filter: ({ column }) => { + return ( + + { + const date = new Date(newValue); + const formattedDate = format(date, "yyyy-MM-dd HH:mm"); + column.setFilterValue(formattedDate); + }} + slotProps={{ + textField: { + helperText: `Filter Mode: ${column.columnDef._filterFn}`, + sx: { minWidth: "120px" }, + variant: "standard", + }, + }} + value={column.getFilterValue()} + /> + + ); + }, + }, + ], + [] + ); + + 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 DashboardPassengerBossComponent; diff --git a/src/pages/dashboard/passenger-boss/index.jsx b/src/pages/dashboard/passenger-boss/index.jsx new file mode 100644 index 0000000..0920933 --- /dev/null +++ b/src/pages/dashboard/passenger-boss/index.jsx @@ -0,0 +1,23 @@ +import DashboardPassengerBossComponent from "@/components/dashboard/passenger-boss"; +import TitlePage from "@/core/components/TitlePage"; +import WithAuthMiddleware from "@/middlewares/WithoutAuth"; +import { parse } from "next-useragent"; + +export default function PassengerBoss() { + 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, + }, + }; +} From 8419294277694e652971310ad86bf79f2b13c1fe Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Tue, 11 Jul 2023 12:02:44 +0330 Subject: [PATCH 013/134] edit side bar data --- public/locales/fa/app.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 09654eb..95ac1eb 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -22,7 +22,7 @@ "machinary-office": "ماشین آلات", "passenger-boss": "رئیس مسافر", "transportation-assistance": "معاونت حمل و نقل", - "master": "مدیر کل" + "manager": "مدیر کل" }, "Authorization": { "typography_your_login_is_valid_and_you_do_not_need_to_login_again": "شما دسترسی لازم به این صفحه را دارید نیاز به ورود مجدد نیست.", From a3e7bc72373584c2a7ccf43867385bcb5f46e35c Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Tue, 11 Jul 2023 14:58:44 +0330 Subject: [PATCH 014/134] implement change passwo --- public/locales/fa/app.json | 20 +- .../dashboard/change-password/index.jsx | 184 ++++++++++++++++++ src/core/data/apiRoutes.js | 6 + src/pages/dashboard/change-password/index.jsx | 23 +++ 4 files changed, 231 insertions(+), 2 deletions(-) create mode 100644 src/components/dashboard/change-password/index.jsx create mode 100644 src/pages/dashboard/change-password/index.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 95ac1eb..192ba78 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -22,7 +22,8 @@ "machinary-office": "ماشین آلات", "passenger-boss": "رئیس مسافر", "transportation-assistance": "معاونت حمل و نقل", - "manager": "مدیر کل" + "manager": "مدیر کل", + "change-password": "تغییر رمز عبور" }, "Authorization": { "typography_your_login_is_valid_and_you_do_not_need_to_login_again": "شما دسترسی لازم به این صفحه را دارید نیاز به ورود مجدد نیست.", @@ -43,9 +44,24 @@ "error_message_required": "اجباری!" }, "Dashboard": { - "dashboard_page": "داشبورد" + "dashboard_page": "داشبورد", + "change_password": "تغییر رمز عبور" }, "MuiDatePicker": { "date_picker_birthday": "تاریخ" + }, + "ChangePassword": { + "typography_change_password": "تغییر رمز عبور", + "label_current_password": "رمز عبور فعلی", + "label_new_password": "رمز عبور جدید", + "label_confirm_password": "تکرار رمز عبور جدید", + "error_message_required": "اجباری !", + "error_message_password_length": "رمز عبور باید حداقل 8 کاراکتر باشد.", + "error_message_password_match": "پسورد ها یکسان هستند", + "error_message_password_not_match": "پسورد و تکرار رمز عبور باید یکسان باشد" + }, + "SubmitButton": { + "button_while_submit": "در حال ثبت", + "button_submit": "ثبت" } } diff --git a/src/components/dashboard/change-password/index.jsx b/src/components/dashboard/change-password/index.jsx new file mode 100644 index 0000000..62d6fe3 --- /dev/null +++ b/src/components/dashboard/change-password/index.jsx @@ -0,0 +1,184 @@ +import CenterLayout from "@/layouts/CenterLayout"; +import DashboardLayouts from "@/layouts/dashboardLayouts"; +import { + Button, + Typography, + Stack, + Paper, + Container, + Box, +} from "@mui/material"; +import Image from "next/image"; +import { Formik } from "formik"; +import * as Yup from "yup"; +import { useTranslations } from "next-intl"; +import PasswordField from "@/core/components/PasswordField"; +import StyledForm from "@/core/components/StyledForm"; +import { CHANGE_PASSWORD } from "@/core/data/apiRoutes"; +import useUser from "@/lib/app/hooks/useUser"; +import axios from "axios"; +import Notifications from "@/core/components/notifications"; +import useDirection from "@/lib/app/hooks/useDirection"; +import { toast } from "react-toastify"; + +const DashboardChangePasswordComponent = () => { + const t = useTranslations(); + const { token } = useUser(); + const { directionApp } = useDirection(); + + const handleSubmit = (values, { setSubmitting, resetForm }) => { + toast.dismiss(); + const pendingToast = toast("Pending...", { + position: directionApp === "ltr" ? "top-left" : "top-right", + autoClose: false, + closeOnClick: false, + draggable: false, + }); + axios + .post( + CHANGE_PASSWORD, + { + current_password: values.current_password, + new_password: values.new_password, + new_password_confirmation: values.new_password_confirmation, + }, + { + headers: { authorization: `Bearer ${token}` }, + } + ) + .then((response) => { + toast.dismiss(pendingToast); // Dismiss the pending toast notification + Notifications(directionApp, response, t); + resetForm(); + }) + .catch((error) => { + toast.dismiss(pendingToast); // Dismiss the pending toast notification + Notifications(directionApp, error.response, t); + }) + .finally(() => { + setSubmitting(false); // Set `setSubmitting` to false after the API request completes + }); + }; + const initialValues = { + current_password: "", + new_password: "", + new_password_confirmation: "", + }; + const validationSchema = Yup.object().shape({ + current_password: Yup.string().required( + t("ChangePassword.error_message_required") + ), + new_password: Yup.string() + .min(8, t("ChangePassword.error_message_password_length")) + .required(t("ChangePassword.error_message_required")), + new_password_confirmation: Yup.string() + .required(t("ChangePassword.error_message_required")) + .test( + t("ChangePassword.error_message_password_match"), + t("ChangePassword.error_message_password_not_match"), + function (value) { + return this.parent.new_password === value; + } + ), + }); + + return ( + + + + + {(props) => ( + { + e.preventDefault(); + props.handleSubmit(); + }} + > + + + + + + + {t("ChangePassword.typography_change_password")} + + + + + + + + + + + + + + + )} + + + + + ); +}; +export default DashboardChangePasswordComponent; diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index e69de29..0877232 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -0,0 +1,6 @@ +const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL; + +//change password +export const CHANGE_PASSWORD = + BASE_URL + "/dashboard/profile/change_password"; +//end change password \ No newline at end of file diff --git a/src/pages/dashboard/change-password/index.jsx b/src/pages/dashboard/change-password/index.jsx new file mode 100644 index 0000000..85660ff --- /dev/null +++ b/src/pages/dashboard/change-password/index.jsx @@ -0,0 +1,23 @@ +import DashboardChangePasswordComponent from "@/components/dashboard/change-password"; +import TitlePage from "@/core/components/TitlePage"; +import WithAuthMiddleware from "@/middlewares/WithoutAuth"; +import { parse } from "next-useragent"; + +export default function LoanFollowUp() { + 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, + }, + }; +} From c0220a114f5ac94f680c0450bddb022df6d230b4 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Tue, 11 Jul 2023 17:17:45 +0330 Subject: [PATCH 015/134] interaction with back --- src/components/login-expert/index.jsx | 38 ++++++++++---------- src/core/data/apiRoutes.js | 5 +++ src/pages/dashboard/loan-follow-up/index.jsx | 2 +- src/pages/dashboard/loan-request/index.jsx | 2 +- 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/components/login-expert/index.jsx b/src/components/login-expert/index.jsx index 65b1e1c..bcc3b1a 100644 --- a/src/components/login-expert/index.jsx +++ b/src/components/login-expert/index.jsx @@ -2,7 +2,7 @@ import LinkRouting from "@/core/components/LinkRouting"; // import Notifications from "@/core/components/notifications"; import PasswordField from "@/core/components/PasswordField"; import StyledForm from "@/core/components/StyledForm"; -// import { GET_USER_TOKEN } from "@/core/data/apiRoutes"; +import { GET_USER_TOKEN } from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useDirection from "@/lib/app/hooks/useDirection"; @@ -17,7 +17,7 @@ import { TextField, Typography, } from "@mui/material"; -// import axios from "axios"; +import axios from "axios"; import { Field, Formik } from "formik"; import { useTranslations } from "next-intl"; import Image from "next/image"; @@ -33,21 +33,23 @@ const LoginComponent = () => { const searchParams = useSearchParams(); const backUrlDecodedPath = searchParams.get("back_url"); - // formik properties - // const handleSubmit = async (values, props) => { - // await axios - // .post(GET_USER_TOKEN, { - // username: values.username, - // password: values.password, - // }) - // .then(function (response) { - // setToken(response.data.token); - // }) - // .catch(function (error) { - // Notifications(directionApp, error.response, t); - // props.setSubmitting(false); - // }); - // }; + //formik properties + const handleSubmit = async (values, props) => { + await axios + .post(GET_USER_TOKEN, { + username: values.username, + 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); + }); + }; const initialValues = { username: "", password: "", @@ -64,7 +66,7 @@ const LoginComponent = () => { {(props) => ( diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index e69de29..2b4b463 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -0,0 +1,5 @@ +const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL; + +//login +export const GET_USER_TOKEN = BASE_URL + "/dashboard/login"; +//end login diff --git a/src/pages/dashboard/loan-follow-up/index.jsx b/src/pages/dashboard/loan-follow-up/index.jsx index fc299c4..6bab35f 100644 --- a/src/pages/dashboard/loan-follow-up/index.jsx +++ b/src/pages/dashboard/loan-follow-up/index.jsx @@ -6,7 +6,7 @@ import { parse } from "next-useragent"; export default function LoanFollowUp() { return ( - + ); diff --git a/src/pages/dashboard/loan-request/index.jsx b/src/pages/dashboard/loan-request/index.jsx index b76f172..ad64ce8 100644 --- a/src/pages/dashboard/loan-request/index.jsx +++ b/src/pages/dashboard/loan-request/index.jsx @@ -6,7 +6,7 @@ import { parse } from "next-useragent"; export default function LoanRequest() { return ( - + ); From a2b89204669a80812dbd1c44d7040ae9db9e02f3 Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Wed, 12 Jul 2023 10:18:36 +0330 Subject: [PATCH 016/134] implrement profile --- public/locales/fa/app.json | 9 +- .../dashboard/edit-profile/index.jsx | 190 ++++++++++++++++++ src/core/components/AvatarUpload.jsx | 128 ++++++++++++ src/pages/dashboard/edit-profile/index.jsx | 23 +++ 4 files changed, 349 insertions(+), 1 deletion(-) create mode 100644 src/components/dashboard/edit-profile/index.jsx create mode 100644 src/core/components/AvatarUpload.jsx create mode 100644 src/pages/dashboard/edit-profile/index.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 192ba78..8334094 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -23,7 +23,8 @@ "passenger-boss": "رئیس مسافر", "transportation-assistance": "معاونت حمل و نقل", "manager": "مدیر کل", - "change-password": "تغییر رمز عبور" + "change-password": "تغییر رمز عبور", + "edit-profile": "ویرایش پروفایل" }, "Authorization": { "typography_your_login_is_valid_and_you_do_not_need_to_login_again": "شما دسترسی لازم به این صفحه را دارید نیاز به ورود مجدد نیست.", @@ -63,5 +64,11 @@ "SubmitButton": { "button_while_submit": "در حال ثبت", "button_submit": "ثبت" + }, + "UpdateProfile": { + "error_invalid_email": "ایمیل نامعتبر است", + "typography_edit_profile": "ویرایش پروفایل", + "text_field_email": "ایمیل", + "text_field_enter_your_password": "رمز عبور خود را وارد کنید" } } diff --git a/src/components/dashboard/edit-profile/index.jsx b/src/components/dashboard/edit-profile/index.jsx new file mode 100644 index 0000000..3dd5468 --- /dev/null +++ b/src/components/dashboard/edit-profile/index.jsx @@ -0,0 +1,190 @@ +import StyledForm from "@/core/components/StyledForm"; +import CenterLayout from "@/layouts/CenterLayout"; +import DashboardLayouts from "@/layouts/dashboardLayouts"; +import useUser from "@/lib/app/hooks/useUser"; +import { + Box, + Button, + Container, + Paper, + Stack, + TextField, + Typography, +} from "@mui/material"; +import * as Yup from "yup"; +import { Field, Formik } from "formik"; +import { useTranslations } from "next-intl"; +import AvatarUpload from "@/core/components/AvatarUpload"; +import axios from "axios"; +import { UPDATE_PROFILE, UPDATE_AVATAR } from "@/core/data/apiRoutes"; +import useDirection from "@/lib/app/hooks/useDirection"; +import Notifications from "@/core/components/notifications"; +import ImageResizer from "@/core/components/ImageConvertor"; + +const DashboardEditProfile = () => { + const t = useTranslations(); + const { user, token, getUser, changeUser } = useUser(); + const { directionApp } = useDirection(); + + const editAvatar = async (avatar) => { + try { + const formData = new FormData(); + + if (avatar != null) { + var resizedAvatar; + resizedAvatar = await ImageResizer(avatar); + formData.append("avatar", resizedAvatar); + } + + await axios.post(UPDATE_AVATAR, formData, { + headers: { + authorization: `Bearer ${token}`, + "Content-Type": "multipart/form-data", + }, + }); + } catch (error) { + Notifications(directionApp, error.response, t); + throw error; + } + }; + const handleSubmit = (values, { setSubmitting }) => { + // const formData = new FormData(); + // formData.append("email", values.expert_email); + + // if (values.change_avatar !== false) { + // editAvatar(values.expert_avatar) + // .then(() => { + // return axios.post(UPDATE_PROFILE, formData, { + // headers: { + // authorization: `Bearer ${token}`, + // "Content-Type": "multipart/form-data", + // }, + // }); + // }) + // .then((response) => { + // Notifications(directionApp, response, t); + // getUser((data) => { + // changeUser(data); + // }); + // }) + // .catch((error) => { + // Notifications(directionApp, error.response, t); + // }) + // .finally(() => { + // setSubmitting(false); + // }); + // } else { + // axios + // .post(UPDATE_PROFILE, formData, { + // headers: { + // authorization: `Bearer ${token}`, + // "Content-Type": "multipart/form-data", + // }, + // }) + // .then((response) => { + // Notifications(directionApp, response, t); + // getUser((data) => { + // changeUser(data); + // }); + // }) + // .catch((error) => { + // Notifications(directionApp, error.response, t); + // }) + // .finally(() => { + // setSubmitting(false); + // }); + // } + }; + const initialValues = { + expert_avatar: null, + expert_email: user.expert_email, + change_avatar: false, + }; + const validationSchema = Yup.object().shape({ + expert_email: Yup.string().email(t("UpdateProfile.error_invalid_email")), + }); + + return ( + + + + + {(props) => ( + { + e.preventDefault(); + props.handleSubmit(); + }} + > + + + + {t("UpdateProfile.typography_edit_profile")} + + + + + + + + + + + + )} + + + + + ); +}; + +export default DashboardEditProfile; diff --git a/src/core/components/AvatarUpload.jsx b/src/core/components/AvatarUpload.jsx new file mode 100644 index 0000000..e1ade5c --- /dev/null +++ b/src/core/components/AvatarUpload.jsx @@ -0,0 +1,128 @@ +import { Avatar, Box, TextField } from "@mui/material"; +import { useState } from "react"; +import DeleteIcon from "@mui/icons-material/Delete"; +import AddIcon from "@mui/icons-material/Add"; + +const AvatarUpload = ({ user, setFieldValue, valueAvatar, changeFlag }) => { + const [selectedImage, setSelectedImage] = useState(user.expert_avatar); + const [isHovered, setIsHovered] = useState(false); + + const handleImageChange = (event) => { + const newImage = event.target?.files?.[0]; + if (newImage) { + setSelectedImage(URL.createObjectURL(newImage)); + setFieldValue(valueAvatar, newImage); + setFieldValue(changeFlag, true); + } else { + setSelectedImage(""); + setFieldValue(valueAvatar, null); + } + }; + + const handleDeleteImage = () => { + setSelectedImage(""); + setFieldValue(valueAvatar, null); + setFieldValue(changeFlag, true); + }; + + const handleMouseEnter = () => { + setIsHovered(true); + }; + + const handleMouseLeave = () => { + setIsHovered(false); + }; + + return ( + + + + + {isHovered && ( + + {selectedImage ? ( + + ) : ( + + )} + + )} + + + + + ); +}; + +export default AvatarUpload; diff --git a/src/pages/dashboard/edit-profile/index.jsx b/src/pages/dashboard/edit-profile/index.jsx new file mode 100644 index 0000000..1cf3b5c --- /dev/null +++ b/src/pages/dashboard/edit-profile/index.jsx @@ -0,0 +1,23 @@ +import DashboardEditProfile from "@/components/dashboard/edit-profile"; +import TitlePage from "@/core/components/TitlePage"; +import WithAuthMiddleware from "@/middlewares/WithoutAuth"; +import { parse } from "next-useragent"; + +export default function LoanFollowUp() { + 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, + }, + }; +} From 08672c0a1ebcafb20fc6c292c3fad3fca8c8b8f5 Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Wed, 12 Jul 2023 11:01:07 +0330 Subject: [PATCH 017/134] implement user profile --- .../dashboard/edit-profile/index.jsx | 142 +++++++++++++++--- 1 file changed, 117 insertions(+), 25 deletions(-) diff --git a/src/components/dashboard/edit-profile/index.jsx b/src/components/dashboard/edit-profile/index.jsx index 3dd5468..cfa16d7 100644 --- a/src/components/dashboard/edit-profile/index.jsx +++ b/src/components/dashboard/edit-profile/index.jsx @@ -6,6 +6,7 @@ import { Box, Button, Container, + Grid, Paper, Stack, TextField, @@ -50,7 +51,6 @@ const DashboardEditProfile = () => { const handleSubmit = (values, { setSubmitting }) => { // const formData = new FormData(); // formData.append("email", values.expert_email); - // if (values.change_avatar !== false) { // editAvatar(values.expert_avatar) // .then(() => { @@ -140,30 +140,122 @@ const DashboardEditProfile = () => { changeFlag="change_avatar" /> - - - + + + + + + + + + + + + + + + + + + + */} From f4bdf27098026fd508d7f5eb22ffb932e94725e0 Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Wed, 12 Jul 2023 14:27:31 +0330 Subject: [PATCH 022/134] notifications transalte --- public/locales/fa/app.json | 20 ++++++++++++++----- .../dashboard/change-password/index.jsx | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index d3817af..eedee80 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -70,11 +70,21 @@ "typography_edit_profile": "ویرایش پروفایل", "text_field_email": "ایمیل", "text_field_enter_your_password": "رمز عبور خود را وارد کنید", - "text_field_username":"نام کاربری", - "text_field_name":"نام", - "text_field_phone_number":"شماره تماس", - "text_field_position":"سمت", - "text_field_province_name":"نام استان", + "text_field_username": "نام کاربری", + "text_field_name": "نام", + "text_field_phone_number": "شماره تماس", + "text_field_position": "سمت", + "text_field_province_name": "نام استان", "error_message_required": "اجباری !" + }, + "notifications": { + "code": "کد", + "error": "خطا", + "warning": "خطر", + "success": "موفق", + "error_static_text": "عملیات شما با خطا مواجه شد", + "warning_static_text": "خطا سرور", + "success_static_text": "عملیات شما با موفقیت انجام شد", + "pending":"در حال انجام..." } } diff --git a/src/components/dashboard/change-password/index.jsx b/src/components/dashboard/change-password/index.jsx index 62d6fe3..c2b5fd4 100644 --- a/src/components/dashboard/change-password/index.jsx +++ b/src/components/dashboard/change-password/index.jsx @@ -28,7 +28,7 @@ const DashboardChangePasswordComponent = () => { const handleSubmit = (values, { setSubmitting, resetForm }) => { toast.dismiss(); - const pendingToast = toast("Pending...", { + const pendingToast = toast(t("notifications.pending"), { position: directionApp === "ltr" ? "top-left" : "top-right", autoClose: false, closeOnClick: false, From 3ef3cd063eb4f8fa63d383b1524378009cbc5068 Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Wed, 12 Jul 2023 14:40:02 +0330 Subject: [PATCH 023/134] debug site headers --- public/locales/fa/app.json | 5 +++-- src/pages/dashboard/edit-profile/index.jsx | 2 +- src/pages/dashboard/index.jsx | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index eedee80..576727e 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -46,7 +46,8 @@ }, "Dashboard": { "dashboard_page": "داشبورد", - "change_password": "تغییر رمز عبور" + "change_password": "تغییر رمز عبور", + "edit_profile": "ویرایش پروفایل" }, "MuiDatePicker": { "date_picker_birthday": "تاریخ" @@ -85,6 +86,6 @@ "error_static_text": "عملیات شما با خطا مواجه شد", "warning_static_text": "خطا سرور", "success_static_text": "عملیات شما با موفقیت انجام شد", - "pending":"در حال انجام..." + "pending": "در حال انجام..." } } diff --git a/src/pages/dashboard/edit-profile/index.jsx b/src/pages/dashboard/edit-profile/index.jsx index aacdc40..0adabf6 100644 --- a/src/pages/dashboard/edit-profile/index.jsx +++ b/src/pages/dashboard/edit-profile/index.jsx @@ -6,7 +6,7 @@ import { parse } from "next-useragent"; export default function LoanFollowUp() { return ( - + ); diff --git a/src/pages/dashboard/index.jsx b/src/pages/dashboard/index.jsx index 57a801a..c3c3933 100644 --- a/src/pages/dashboard/index.jsx +++ b/src/pages/dashboard/index.jsx @@ -6,7 +6,7 @@ import { parse } from "next-useragent"; export default function Dashboard() { return ( - + ); From 9090da80d85c1b63ac26d283fdd7ea4fa51e80e8 Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Wed, 12 Jul 2023 15:16:56 +0330 Subject: [PATCH 024/134] debug auth --- src/middlewares/WithAuth.jsx | 4 ++-- src/middlewares/WithoutAuth.jsx | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/middlewares/WithAuth.jsx b/src/middlewares/WithAuth.jsx index d158bf3..3fa5f43 100644 --- a/src/middlewares/WithAuth.jsx +++ b/src/middlewares/WithAuth.jsx @@ -16,7 +16,7 @@ const WithAuthMiddleware = ({ children }) => { text={ {t( - "typography_your_access_to_this_page_has_expired_Please_login_again" + "Authorization.typography_your_access_to_this_page_has_expired_Please_login_again" )} } @@ -26,7 +26,7 @@ const WithAuthMiddleware = ({ children }) => { variant="contained" component={NextLinkComposed} to={{ - pathname: "/login", + pathname: "/login-expert", query: { back_url: encodeURIComponent(router.asPath) }, }} > diff --git a/src/middlewares/WithoutAuth.jsx b/src/middlewares/WithoutAuth.jsx index 5fb4f93..cb8e571 100644 --- a/src/middlewares/WithoutAuth.jsx +++ b/src/middlewares/WithoutAuth.jsx @@ -37,14 +37,14 @@ const WithoutAuthMiddleware = ({ children }) => { {t( - "typography_your_login_is_valid_and_you_do_not_need_to_login_again" + "Authorization.typography_your_login_is_valid_and_you_do_not_need_to_login_again" )} - {t("typography_redirect_to")}{" "} + {t("Authorization.typography_redirect_to")}{" "} {backUrlDecodedPath - ? t("typography_routing_previuos_page") - : t("typography_routing_dashbaord_page")} + ? t("Authorization.typography_routing_previuos_page") + : t("Authorization.typography_routing_dashbaord_page")} } From 76164ed9c49ef588f21db7fc7a6b535e8365fd0b Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Thu, 13 Jul 2023 13:45:41 +0330 Subject: [PATCH 025/134] fix app.json bug --- public/locales/fa/app.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index e5a6462..79010f4 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -46,12 +46,9 @@ }, "Dashboard": { "dashboard_page": "داشبورد", -<<<<<<< HEAD - "passenger_office_page": "اداره مسافر" -======= + "passenger_office_page": "اداره مسافر", "change_password": "تغییر رمز عبور", "edit_profile": "ویرایش پروفایل" ->>>>>>> 135f6d1e2f3495abe68e3ca758870023dcd85d76 }, "MuiDatePicker": { "date_picker_birthday": "تاریخ" From 6b4a3e0c9b9da4da755b3affdd147b3082ad53bd Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Sat, 15 Jul 2023 11:03:02 +0330 Subject: [PATCH 026/134] loading page design --- public/images/loading_logo.svg | 1 + src/core/components/LoadingHardPage.jsx | 2 +- src/core/components/Messages.jsx | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 public/images/loading_logo.svg diff --git a/public/images/loading_logo.svg b/public/images/loading_logo.svg new file mode 100644 index 0000000..48fde43 --- /dev/null +++ b/public/images/loading_logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/core/components/LoadingHardPage.jsx b/src/core/components/LoadingHardPage.jsx index 5da632d..5a86af8 100644 --- a/src/core/components/LoadingHardPage.jsx +++ b/src/core/components/LoadingHardPage.jsx @@ -28,7 +28,7 @@ const LoadingHardPage = ({ children, loading }) => { > { Date: Sat, 15 Jul 2023 15:14:16 +0330 Subject: [PATCH 027/134] passenger office implement --- public/locales/fa/app.json | 11 + .../passenger-office/Form/ConfirmForm.jsx | 39 ++++ .../passenger-office/Form/RejectForm.jsx | 33 +++ .../passenger-office/TableRowActions.jsx | 54 ++--- .../passenger-office/TableTollbar.jsx | 23 +- .../dashboard/passenger-office/index.jsx | 221 ++++++++---------- src/core/data/apiRoutes.js | 15 +- src/lib/app/hooks/useDatatable.jsx | 6 +- .../dashboard/passenger-office/index.jsx | 2 +- 9 files changed, 230 insertions(+), 174 deletions(-) create mode 100644 src/components/dashboard/passenger-office/Form/ConfirmForm.jsx create mode 100644 src/components/dashboard/passenger-office/Form/RejectForm.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 79010f4..9d1409c 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -6,6 +6,7 @@ "login": "ورود", "login_expert": "ورود کارشناس", "expert": "کارشناس", + "last_updated_at": "اخرین بروز رسانی", "header": { "open_profile": "پروفایل", "edit_profile": "ویرایش پروفایل", @@ -88,5 +89,15 @@ "warning_static_text": "خطا سرور", "success_static_text": "عملیات شما با موفقیت انجام شد", "pending": "در حال انجام..." + }, + "PassengerOffice": { + "name": "نام", + "id": "کد ملی", + "phone_number": "موبایل", + "created_at": "تاریخ درخواست", + "updated_at": "تاریخ بروزرسانی", + "navgan_id": "کد ناوگان", + "vehicle_type": "نوع ماشین", + "state_name": "وضعیت درخواست" } } diff --git a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx new file mode 100644 index 0000000..5fd3f3b --- /dev/null +++ b/src/components/dashboard/passenger-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/passenger-office/Form/RejectForm.jsx b/src/components/dashboard/passenger-office/Form/RejectForm.jsx new file mode 100644 index 0000000..cf551a8 --- /dev/null +++ b/src/components/dashboard/passenger-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/passenger-office/TableRowActions.jsx b/src/components/dashboard/passenger-office/TableRowActions.jsx index 0290214..832e77e 100644 --- a/src/components/dashboard/passenger-office/TableRowActions.jsx +++ b/src/components/dashboard/passenger-office/TableRowActions.jsx @@ -1,42 +1,38 @@ -import DeleteIcon from "@mui/icons-material/Delete"; -import EditIcon from "@mui/icons-material/Edit"; +import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; +import ThumbDownIcon from "@mui/icons-material/ThumbDown"; import { Box, IconButton } from "@mui/material"; -// import EditForm from "./Form/EditForm"; 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 { - toggleDrawer, - setDrawerContent, - openDeleteDialog, - handleOpenDeleteDialog, - handleCloseDeleteDialog, - handleDeleteDialog, - rowId, - deleteData, - } = useContext(DataTableContext); + // const { + // openDeleteDialog, + // handleOpenDeleteDialog, + // handleCloseDeleteDialog, + // handleDeleteDialog, + // rowId, + // deleteData, + // } = useContext(DataTableContext); return ( - { - toggleDrawer(true); - // setDrawerContent(); - }} - > - + handleOpenDeleteDialog(row)}> + - handleOpenDeleteDialog(row)} - > - + {/* */} + handleOpenDeleteDialog(row)}> + - {/* - - - + ); } diff --git a/src/components/dashboard/passenger-office/index.jsx b/src/components/dashboard/passenger-office/index.jsx index 2d52dd3..98af2b7 100644 --- a/src/components/dashboard/passenger-office/index.jsx +++ b/src/components/dashboard/passenger-office/index.jsx @@ -1,20 +1,32 @@ import DataTableStructure from "@/core/components/DatatableStructure"; import DashboardLayouts from "@/layouts/dashboardLayouts"; -import { ContentCopy } from "@mui/icons-material"; import { Box, Typography } from "@mui/material"; -import { DateTimePicker, LocalizationProvider } from "@mui/x-date-pickers"; -import { format } from "date-fns-jalali"; import { useMemo } from "react"; -import TableToolbar from "./TableTollbar"; +// import TableToolbar from "./TableTollbar"; +import { GET_PASSENGER_OFFICE } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; import TableRowActions from "./TableRowActions"; function DashboardPassengerOfficeComponent() { + const t = useTranslations(); const columns = useMemo( () => [ + { + accessorFn: (row) => row.name, + id: "name", + header: t("PassengerOffice.name"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, { accessorFn: (row) => row.id, id: "id", - header: "Id", + header: t("PassengerOffice.id"), enableColumnFilter: true, datatype: "numeric", filterFn: "equals", @@ -30,56 +42,98 @@ function DashboardPassengerOfficeComponent() { {renderedCellValue} ), }, - { - accessorFn: (row) => row.username, - id: "username", - header: "Username", - enableColumnFilter: true, - datatype: "text", - filterFn: "contains", - columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.name, - id: "name", - header: "Name", - enableColumnFilter: true, - datatype: "text", - filterFn: "contains", - columnFilterModeOptions: ["contains", "equals", "notEquals"], - muiTableBodyCellCopyButtonProps: { - fullWidth: true, - endIcon: , - sx: { justifyContent: "space-between" }, - }, - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, { accessorFn: (row) => row.phone_number, id: "phone_number", - header: "Phone Number", + header: t("PassengerOffice.phone_number"), enableColumnFilter: true, - datatype: "text", - filterFn: "contains", - columnFilterModeOptions: ["equals", "notEquals", "contains"], - muiTableBodyCellCopyButtonProps: { - fullWidth: true, - endIcon: , - sx: { justifyContent: "space-between" }, - }, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], Cell: ({ renderedCellValue }) => ( {renderedCellValue} ), }, { - accessorFn: (row) => row.status, - id: "status", - header: "Status", + accessorFn: (row) => row.created_at, + id: "created_at", + header: t("PassengerOffice.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("PassengerOffice.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("PassengerOffice.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("PassengerOffice.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("PassengerOffice.state_name"), enableColumnFilter: true, datatype: "numeric", filterFn: "equals", @@ -92,75 +146,6 @@ function DashboardPassengerOfficeComponent() { {renderedCellValue} ), }, - { - accessorFn: (row) => row.gender, - id: "gender", - header: "Gender", - enableColumnFilter: true, - datatype: "text", - filterFn: "equals", - filterSelectOptions: [ - { text: "Male", value: "male" }, - { text: "Female", value: "female" }, - ], - filterVariant: "select", - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.national_id_code, - id: "national_id_code", - header: "National Id Code", - enableColumnFilter: true, - datatype: "text", - filterFn: "contains", - columnFilterModeOptions: ["equals", "notEquals", "contains"], - muiTableBodyCellCopyButtonProps: { - fullWidth: true, - endIcon: , - sx: { justifyContent: "space-between" }, - }, - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => new Date(row.updated_at), - id: "updated_at", - header: "Update Date", - enableColumnFilter: true, - datatype: "date", - filterFn: "lessThan", - columnFilterModeOptions: ["lessThan", "greaterThan"], - Cell: ({ renderedCellValue }) => { - const date = new Date(renderedCellValue); - const formattedDate = format(date, "MM/dd/yyyy HH:mm"); - return {formattedDate}; - }, - Header: ({ column }) => {column.columnDef.header}, - Filter: ({ column }) => { - return ( - - { - const date = new Date(newValue); - const formattedDate = format(date, "yyyy-MM-dd HH:mm"); - column.setFilterValue(formattedDate); - }} - slotProps={{ - textField: { - helperText: `Filter Mode: ${column.columnDef._filterFn}`, - sx: { minWidth: "120px" }, - variant: "standard", - }, - }} - value={column.getFilterValue()} - /> - - ); - }, - }, ], [] ); @@ -168,11 +153,11 @@ function DashboardPassengerOfficeComponent() { } + // CustomToolbar={} enableLastUpdate={true} enablePinning={true} enableDensityToggle={true} diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index 1b299cc..5c73fcf 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -8,6 +8,17 @@ export const GET_USER_TOKEN = BASE_URL + "/dashboard/login"; export const CHANGE_PASSWORD = BASE_URL + "/dashboard/profile/change_password"; //end change password -//user data +//user data export const GET_USER_ROUTE = BASE_URL + "/dashboard/profile/info"; -//user data \ No newline at end of file +//user data + +//passenger office +export const GET_PASSENGER_OFFICE = + BASE_URL + "/dashboard/passenger_office_chief/show"; + +export const CONFIRM_PASSENGER_OFFICE = + BASE_URL + "/dashboard/passenger_office_chief/confirm"; + +export const REJECT_PASSENGER_OFFICE = + BASE_URL + "/dashboard/passenger_office_chief/reject"; +//passenger office diff --git a/src/lib/app/hooks/useDatatable.jsx b/src/lib/app/hooks/useDatatable.jsx index e0626e7..71d0b9d 100644 --- a/src/lib/app/hooks/useDatatable.jsx +++ b/src/lib/app/hooks/useDatatable.jsx @@ -4,7 +4,7 @@ import { useState, useReducer, useCallback, useContext } from "react"; import axios from "axios"; import ImageResizer from "@/core/components/ImageConvertor"; import useUser from "./useUser"; -import { ReloadDataTableContext } from "../contexts/ReloadDatatableContext"; +// import { ReloadDataTableContext } from "../contexts/ReloadDatatableContext"; const initialValues = { url: "", @@ -48,7 +48,7 @@ const reducer = (state, action) => { }; const useDataTable = () => { - const { setReloadDataTable } = useContext(ReloadDataTableContext); + // const { setReloadDataTable } = useContext(ReloadDataTableContext); const [state, dispatch] = useReducer(reducer, initialValues); const [drawerContent, setDrawerContent] = useState(null); const [openDeleteDialog, setOpenDeleteDialog] = useState(false); @@ -95,7 +95,7 @@ const useDataTable = () => { }, }) .then(() => { - setReloadDataTable(true); + // setReloadDataTable(true); }) .catch(() => {}); }, []); diff --git a/src/pages/dashboard/passenger-office/index.jsx b/src/pages/dashboard/passenger-office/index.jsx index 78ec016..36e2a95 100644 --- a/src/pages/dashboard/passenger-office/index.jsx +++ b/src/pages/dashboard/passenger-office/index.jsx @@ -1,6 +1,6 @@ import DashboardPassengerOfficeComponent from "@/components/dashboard/passenger-office"; import TitlePage from "@/core/components/TitlePage"; -import WithAuthMiddleware from "@/middlewares/WithoutAuth"; +import WithAuthMiddleware from "@/middlewares/WithAuth"; import { parse } from "next-useragent"; export default function PassengerOffice() { From f2568ff74e4b45aa26be90f9110a4f1db6cd88f5 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Sat, 15 Jul 2023 16:25:32 +0330 Subject: [PATCH 028/134] interaction with back --- public/locales/fa/app.json | 11 ++ .../machinary-office/Form/ConfirmForm.jsx | 39 ++++ .../machinary-office/Form/RejectForm.jsx | 33 ++++ .../machinary-office/TableRowActions.jsx | 46 +++++ .../machinary-office/TableTolbar.jsx | 13 ++ .../dashboard/machinary-office/index.jsx | 177 ++++++++++++++++++ src/components/login-expert/index.jsx | 2 - .../dashboard/machinary-office/index.jsx | 23 +++ 8 files changed, 342 insertions(+), 2 deletions(-) create mode 100644 src/components/dashboard/machinary-office/Form/ConfirmForm.jsx create mode 100644 src/components/dashboard/machinary-office/Form/RejectForm.jsx create mode 100644 src/components/dashboard/machinary-office/TableRowActions.jsx create mode 100644 src/components/dashboard/machinary-office/TableTolbar.jsx create mode 100644 src/components/dashboard/machinary-office/index.jsx create mode 100644 src/pages/dashboard/machinary-office/index.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 9d1409c..af3efcc 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": "ویرایش پروفایل" }, @@ -99,5 +100,15 @@ "navgan_id": "کد ناوگان", "vehicle_type": "نوع ماشین", "state_name": "وضعیت درخواست" + }, + "MachinaryOffice": { + "name": "نام", + "id": "کد ملی", + "phone_number": "موبایل", + "created_at": "تاریخ درخواست", + "updated_at": "تاریخ بروزرسانی", + "navgan_id": "کد ناوگان", + "vehicle_type": "نوع ماشین", + "state_name": "وضعیت درخواست" } } 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, + }, + }; +} From 83dad6f040a13e446053b403cf9b125a315c0169 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Sat, 15 Jul 2023 16:26:35 +0330 Subject: [PATCH 029/134] debug datatable structure --- public/locales/fa/app.json | 12 ++ .../passenger-office/Form/ConfirmForm.jsx | 8 +- .../passenger-office/Form/RejectForm.jsx | 13 +- .../passenger-office/TableRowActions.jsx | 44 ++--- src/core/components/DatatableStructure.jsx | 2 +- src/lib/app/hooks/useDatatable.jsx | 154 ++++++------------ 6 files changed, 97 insertions(+), 136 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 9d1409c..d263ce5 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -99,5 +99,17 @@ "navgan_id": "کد ناوگان", "vehicle_type": "نوع ماشین", "state_name": "وضعیت درخواست" + }, + "ConfirmDialog": { + "confirm": "تایید", + "context": "آیا از تایید این آیتم اطمینان دارید", + "button-confirm": "تایید", + "button-cancel": "بستن" + }, + "RejectDialog": { + "reject": "عدم تایید", + "context": "آیا از عدم تایید این آیتم اطمینان دارید", + "button-reject": "عدم تایید", + "button-cancel": "بستن" } } diff --git a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx index 5fd3f3b..f5adf2f 100644 --- a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx @@ -21,16 +21,16 @@ const ConfirmForm = ({ }; return ( - {t("delete-dialog.confirm")} + {t("ConfirmDialog.confirm")} - {t("delete-dialog.context")} + {t("ConfirmDialog.context")} diff --git a/src/components/dashboard/passenger-office/Form/RejectForm.jsx b/src/components/dashboard/passenger-office/Form/RejectForm.jsx index cf551a8..75a0e4e 100644 --- a/src/components/dashboard/passenger-office/Form/RejectForm.jsx +++ b/src/components/dashboard/passenger-office/Form/RejectForm.jsx @@ -10,21 +10,22 @@ import { useTranslations } from "next-intl"; const RejectForm = ({ open, handleClose, handleDelete, rowId, deleteData }) => { const t = useTranslations(); - const handleDeleteExpert = () => { + const handleRejectRequest = () => { handleDelete(); }; + console.log(rowId); return ( - {t("delete-dialog.confirm")} + {t("RejectDialog.reject")} - {t("delete-dialog.context")} + {t("RejectDialog.context")} - diff --git a/src/components/dashboard/passenger-office/TableRowActions.jsx b/src/components/dashboard/passenger-office/TableRowActions.jsx index 832e77e..5aefae7 100644 --- a/src/components/dashboard/passenger-office/TableRowActions.jsx +++ b/src/components/dashboard/passenger-office/TableRowActions.jsx @@ -9,36 +9,40 @@ 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, + deleteData, + } = useContext(DataTableContext); return ( - handleOpenDeleteDialog(row)}> + handleOpenConfirmDialog(row)}> - {/* */} - handleOpenDeleteDialog(row)}> + /> + handleOpenRejectDialog(row)}> - {/* */} + /> ); }; diff --git a/src/core/components/DatatableStructure.jsx b/src/core/components/DatatableStructure.jsx index e13ed16..e033a09 100644 --- a/src/core/components/DatatableStructure.jsx +++ b/src/core/components/DatatableStructure.jsx @@ -1,4 +1,4 @@ -import { DataTableProvider } from "@/lib/app/contexts/DatatableContext"; +import { DataTableProvider } from "@/lib/app/contexts/DataTableContext"; import DataTable from "./Datatable"; import { ReloadDataTableProvider } from "@/lib/app/contexts/ReloadDatatableContext"; diff --git a/src/lib/app/hooks/useDatatable.jsx b/src/lib/app/hooks/useDatatable.jsx index 71d0b9d..6b0789a 100644 --- a/src/lib/app/hooks/useDatatable.jsx +++ b/src/lib/app/hooks/useDatatable.jsx @@ -1,46 +1,28 @@ -import { useMediaQuery } from "@mui/material"; -import { useTheme } from "@mui/material/styles"; -import { useState, useReducer, useCallback, useContext } from "react"; import axios from "axios"; -import ImageResizer from "@/core/components/ImageConvertor"; +import { useCallback, useContext, useReducer, useState } from "react"; +import { ReloadDataTableContext } from "../contexts/ReloadDatatableContext"; import useUser from "./useUser"; -// import { ReloadDataTableContext } from "../contexts/ReloadDatatableContext"; const initialValues = { url: "", rowID: "", values: {}, - image: { - key: "", - value: {}, - }, }; const reducer = (state, action) => { switch (action.type) { - case "ADD_DATA": + case "CONFIRM_DATA": return { ...state, url: action.url, - values: action.values, - image: action.image, - rowID: "", - }; - case "EDIT_DATA": - return { - ...state, - url: action.url, - values: action.values, rowID: action.rowID, - image: action.image, }; - case "DELETE_DATA": + case "REJECT_DATA": return { ...state, url: action.url, rowID: action.rowID, values: {}, - image: {}, }; default: return state; @@ -48,120 +30,82 @@ const reducer = (state, action) => { }; const useDataTable = () => { - // const { setReloadDataTable } = useContext(ReloadDataTableContext); + const { setReloadDataTable } = useContext(ReloadDataTableContext); const [state, dispatch] = useReducer(reducer, initialValues); - const [drawerContent, setDrawerContent] = useState(null); - const [openDeleteDialog, setOpenDeleteDialog] = useState(false); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + const [openRejectDialog, setOpenRejectDialog] = useState(false); const [rowId, setRowId] = useState(null); - const theme = useTheme(); + const { token } = useUser(); - const drawerDirection = useMediaQuery(theme.breakpoints.up("sm")) - ? "right" - : "bottom"; - const [sweepableDrawer, setSweepableDrawer] = useState({ - bottom: false, - right: false, - }); - - const addData = useCallback(async (url, values, image) => { - dispatch({ type: "ADD_DATA", url: url, values: values, image: image }); - if (image != null) { - var resizedAvatar = await ImageResizer(image.value); - formData.append(image.key, resizedAvatar); - axios.post(url, formData, { - headers: { - authorization: `Bearer ${token}`, - "Content-Type": "multipart/form-data", - }, - }); - } + const confirmData = useCallback(async (url, rowID) => { + dispatch({ type: "CONFIRM_DATA", url: url, rowID: rowID }); axios - .post(url, values, { - headers: { - authorization: `Bearer ${token}`, - }, - }) - .then(() => {}) - .catch(() => {}); - }, []); - - const deleteData = useCallback(async (url, rowID) => { - dispatch({ type: "DELETE_DATA", url: url, rowID: rowID }); - axios - .delete(`${url}/${rowID}`, { + .post(`${url}/${rowID}`, { headers: { authorization: `Bearer ${token}`, }, }) .then(() => { - // setReloadDataTable(true); + setReloadDataTable(true); }) .catch(() => {}); }, []); - const editData = useCallback(async (url, values, rowID, image) => { - dispatch({ - type: "EDIT_DATA", - url: url, - values: values, - rowID: rowID, - image: image, - }); - if (image != null) { - var resizedAvatar = await ImageResizer(image.value); - formData.append(image.key, resizedAvatar); - axios.post(`${url}/${rowID}`, formData, { - headers: { - authorization: `Bearer ${token}`, - "Content-Type": "multipart/form-data", - }, - }); - } + const rejectData = useCallback(async (url, rowID) => { + dispatch({ type: "REJECT_DATA", url: url, rowID: rowID }); axios - .post(`${url}/${rowID}`, values, { + .post(`${url}/${rowID}`, { headers: { authorization: `Bearer ${token}`, }, }) - .then(() => {}) + .then(() => { + setReloadDataTable(true); + }) .catch(() => {}); }, []); - const toggleDrawer = (open) => { - open == false && - setTimeout(() => { - setDrawerContent(null); - }, theme.transitions.duration.leavingScreen); - setSweepableDrawer({ ...sweepableDrawer, [drawerDirection]: open }); - }; - const handleOpenDeleteDialog = (row) => { + const handleOpenConfirmDialog = (row) => { setRowId(row.getValue("id")); - setOpenDeleteDialog(true); + setOpenConfirmDialog(true); }; - const handleCloseDeleteDialog = () => { - setOpenDeleteDialog(false); + const handleCloseConfirmDialog = () => { + setOpenConfirmDialog(false); }; - const handleDeleteDialog = () => { - setOpenDeleteDialog(false); + const handleConfirmDialog = () => { + setOpenConfirmDialog(false); }; + // Reject Data + const handleOpenRejectDialog = (row) => { + setRowId(row.getValue("id")); + setOpenRejectDialog(true); + }; + + const handleCloseRejectDialog = () => { + setOpenRejectDialog(false); + }; + + const handleRejectDialog = () => { + setOpenRejectDialog(false); + }; + // End Reject Data + const contextValue = { - toggleDrawer, - drawerDirection, - sweepableDrawer, - setSweepableDrawer, - setDrawerContent, - drawerContent, - openDeleteDialog, - handleOpenDeleteDialog, - handleCloseDeleteDialog, - handleDeleteDialog, + handleOpenConfirmDialog, + handleCloseConfirmDialog, + handleConfirmDialog, + handleOpenRejectDialog, + handleCloseRejectDialog, + handleRejectDialog, rowId, - deleteData, - addData, + openConfirmDialog, + openRejectDialog, + rejectData, + confirmData, }; return contextValue; }; From d7f3638b67f2b9d5368eeada449039af844acd19 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Sat, 15 Jul 2023 16:38:26 +0330 Subject: [PATCH 030/134] merg conflict --- public/locales/fa/app.json | 1 + 1 file changed, 1 insertion(+) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index c332aa5..1a505df 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -123,3 +123,4 @@ "button-reject": "عدم تایید", "button-cancel": "بستن" } +} From abcd523663a7b34e9fb86efcbd53481a8bf676eb Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Sat, 15 Jul 2023 17:17:53 +0330 Subject: [PATCH 031/134] confirm data and reject data --- .../dashboard/passenger-office/Form/ConfirmForm.jsx | 8 +++++--- .../dashboard/passenger-office/Form/RejectForm.jsx | 5 +++-- .../dashboard/passenger-office/TableRowActions.jsx | 7 ++++--- src/lib/app/hooks/useDatatable.jsx | 5 ++++- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx index f5adf2f..738428a 100644 --- a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx @@ -1,3 +1,4 @@ +import { CONFIRM_PASSENGER_OFFICE } from "@/core/data/apiRoutes"; import { Dialog, DialogTitle, @@ -13,11 +14,12 @@ const ConfirmForm = ({ handleClose, handleDelete, rowId, - deleteData, + confirmData, }) => { const t = useTranslations(); - const handleDeleteExpert = () => { + const handleConfirm = () => { handleDelete(); + confirmData(CONFIRM_PASSENGER_OFFICE, rowId); }; return ( @@ -26,7 +28,7 @@ const ConfirmForm = ({ {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); From 024da3baf7dd45649f397950459276f5501ac0a4 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Sun, 16 Jul 2023 13:39:46 +0330 Subject: [PATCH 035/134] machinary implement --- public/locales/fa/app.json | 3 ++- .../machinary-office/Form/ConfirmForm.jsx | 16 +++++++++++++++- src/lib/app/hooks/useDatatable.jsx | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 1a505df..35fa040 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -109,7 +109,8 @@ "updated_at": "تاریخ بروزرسانی", "navgan_id": "کد ناوگان", "vehicle_type": "نوع ماشین", - "state_name": "وضعیت درخواست" + "state_name": "وضعیت درخواست", + "proposed_amount": "مقدار پیشنهادی" }, "ConfirmDialog": { "confirm": "تایید", diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx index 702ce9b..3e64087 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx @@ -6,8 +6,10 @@ import { DialogContentText, DialogActions, Button, + TextField, } from "@mui/material"; import { useTranslations } from "next-intl"; +import { useState } from "react"; const ConfirmForm = ({ open, @@ -17,15 +19,27 @@ const ConfirmForm = ({ confirmData, }) => { const t = useTranslations(); + const [proposedAmount, setProposedAmount] = useState(""); const handleConfirm = () => { + const formData = new FormData(); + formData.append("proposed_amount", proposedAmount); handleDelete(); - confirmData(CONFIRM_MACHINARY_OFFICE, rowId); + confirmData(CONFIRM_MACHINARY_OFFICE, rowId, formData); }; return ( {t("ConfirmDialog.confirm")} {t("ConfirmDialog.context")} + setProposedAmount(e.target.value)} + sx={{ mt: 2 }} + fullWidth + /> ); }; + export default RejectForm; diff --git a/src/components/dashboard/passenger-office/TableRowActions.jsx b/src/components/dashboard/passenger-office/TableRowActions.jsx index ec2d790..1c3004c 100644 --- a/src/components/dashboard/passenger-office/TableRowActions.jsx +++ b/src/components/dashboard/passenger-office/TableRowActions.jsx @@ -16,8 +16,6 @@ const TableRowActions = ({ row }) => { handleOpenRejectDialog, handleCloseConfirmDialog, handleCloseRejectDialog, - handleConfirmDialog, - handleRejectDialog, rowId, confirmData, rejectData, @@ -27,23 +25,25 @@ const TableRowActions = ({ row }) => { handleOpenConfirmDialog(row)}> - + {openConfirmDialog && ( + + )} handleOpenRejectDialog(row)}> - + {openRejectDialog && ( + + )} ); }; diff --git a/src/lib/app/hooks/useDatatable.jsx b/src/lib/app/hooks/useDatatable.jsx index ccd772a..5627213 100644 --- a/src/lib/app/hooks/useDatatable.jsx +++ b/src/lib/app/hooks/useDatatable.jsx @@ -57,10 +57,10 @@ const useDataTable = () => { }); }, []); - const rejectData = useCallback(async (url, rowID) => { - dispatch({ type: "REJECT_DATA", url: url, rowID: rowID }); + const rejectData = useCallback(async (url, rowID, values) => { + dispatch({ type: "REJECT_DATA", url: url, rowID: rowID, values: values }); axios - .post(`${url}/${rowID}`, { + .post(`${url}/${rowID}`,values, { headers: { authorization: `Bearer ${token}` }, }) .then(() => { @@ -80,10 +80,6 @@ const useDataTable = () => { const handleCloseConfirmDialog = () => { setOpenConfirmDialog(false); }; - - const handleConfirmDialog = () => { - setOpenConfirmDialog(false); - }; //End Confirm Data // Reject Data @@ -95,19 +91,13 @@ const useDataTable = () => { const handleCloseRejectDialog = () => { setOpenRejectDialog(false); }; - - const handleRejectDialog = () => { - setOpenRejectDialog(false); - }; // End Reject Data const contextValue = { handleOpenConfirmDialog, handleCloseConfirmDialog, - handleConfirmDialog, handleOpenRejectDialog, handleCloseRejectDialog, - handleRejectDialog, rowId, openConfirmDialog, openRejectDialog, From 9caf417101f03227f8b529cb3016f397c9c5648f Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Sun, 16 Jul 2023 14:37:24 +0330 Subject: [PATCH 037/134] transportation assistance design --- public/locales/fa/app.json | 10 + .../Form/ConfirmForm.jsx | 41 ++++ .../Form/RejectForm.jsx | 35 ++++ .../TableRowActions.jsx | 49 +++++ .../TableTollbar.jsx | 13 ++ .../transportation-assistance/index.jsx | 177 ++++++++++++++++++ src/core/data/apiRoutes.js | 11 ++ .../transportation-assistance/index.jsx | 23 +++ 8 files changed, 359 insertions(+) create mode 100644 src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx create mode 100644 src/components/dashboard/transportation-assistance/Form/RejectForm.jsx create mode 100644 src/components/dashboard/transportation-assistance/TableRowActions.jsx create mode 100644 src/components/dashboard/transportation-assistance/TableTollbar.jsx create mode 100644 src/components/dashboard/transportation-assistance/index.jsx create mode 100644 src/pages/dashboard/transportation-assistance/index.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 1a505df..d5d2da8 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -101,6 +101,16 @@ "vehicle_type": "نوع ماشین", "state_name": "وضعیت درخواست" }, + "TransportationAssistance": { + "name": "نام", + "id": "کد ملی", + "phone_number": "موبایل", + "created_at": "تاریخ درخواست", + "updated_at": "تاریخ بروزرسانی", + "navgan_id": "کد ناوگان", + "vehicle_type": "نوع ماشین", + "state_name": "وضعیت درخواست" + }, "MachinaryOffice": { "name": "نام", "id": "کد ملی", diff --git a/src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx b/src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx new file mode 100644 index 0000000..132b850 --- /dev/null +++ b/src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx @@ -0,0 +1,41 @@ +import { CONFIRM_TRANSPORTATION_ASSISTANCE } from "@/core/data/apiRoutes"; +import { + Dialog, + DialogTitle, + DialogContent, + DialogContentText, + DialogActions, + Button, +} from "@mui/material"; +import { useTranslations } from "next-intl"; + +const ConfirmForm = ({ + open, + handleClose, + handleDelete, + rowId, + confirmData, +}) => { + const t = useTranslations(); + const handleConfirm = () => { + handleDelete(); + confirmData(CONFIRM_TRANSPORTATION_ASSISTANCE, rowId); + }; + return ( + + {t("ConfirmDialog.confirm")} + + {t("ConfirmDialog.context")} + + + + + + + ); +}; +export default ConfirmForm; diff --git a/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx b/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx new file mode 100644 index 0000000..5abd534 --- /dev/null +++ b/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx @@ -0,0 +1,35 @@ +import { REJECT_TRANSPORTATION_ASSISTANCE } from "@/core/data/apiRoutes"; +import { + Dialog, + DialogTitle, + DialogContent, + DialogContentText, + DialogActions, + Button, +} from "@mui/material"; +import { useTranslations } from "next-intl"; + +const RejectForm = ({ open, handleClose, handleDelete, rowId, rejectData }) => { + const t = useTranslations(); + const handleRejectRequest = () => { + handleDelete(); + rejectData(REJECT_TRANSPORTATION_ASSISTANCE, rowId); + }; + return ( + + {t("RejectDialog.reject")} + + {t("RejectDialog.context")} + + + + + + + ); +}; +export default RejectForm; diff --git a/src/components/dashboard/transportation-assistance/TableRowActions.jsx b/src/components/dashboard/transportation-assistance/TableRowActions.jsx new file mode 100644 index 0000000..f5ec46b --- /dev/null +++ b/src/components/dashboard/transportation-assistance/TableRowActions.jsx @@ -0,0 +1,49 @@ +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"; + +const TableRowActions = ({ row }) => { + const { + openConfirmDialog, + openRejectDialog, + handleOpenConfirmDialog, + handleOpenRejectDialog, + handleCloseConfirmDialog, + handleCloseRejectDialog, + handleConfirmDialog, + handleRejectDialog, + rowId, + confirmData, + rejectData, + } = useContext(DataTableContext); + return ( + + handleOpenConfirmDialog(row)}> + + + + handleOpenRejectDialog(row)}> + + + + + ); +}; + +export default TableRowActions; diff --git a/src/components/dashboard/transportation-assistance/TableTollbar.jsx b/src/components/dashboard/transportation-assistance/TableTollbar.jsx new file mode 100644 index 0000000..3f06d3b --- /dev/null +++ b/src/components/dashboard/transportation-assistance/TableTollbar.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/transportation-assistance/index.jsx b/src/components/dashboard/transportation-assistance/index.jsx new file mode 100644 index 0000000..6dd3ccf --- /dev/null +++ b/src/components/dashboard/transportation-assistance/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_TRANSPORTATION_ASSISTANCE } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; +import TableRowActions from "./TableRowActions"; + +function DashboardTransportationAssistanceComponent() { + const t = useTranslations(); + const columns = useMemo( + () => [ + { + accessorFn: (row) => row.name, + id: "name", + header: t("TransportationAssistance.name"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.id, + id: "id", + header: t("TransportationAssistance.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("TransportationAssistance.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("TransportationAssistance.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("TransportationAssistance.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("TransportationAssistance.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("TransportationAssistance.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("TransportationAssistance.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 DashboardTransportationAssistanceComponent; diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index 5c73fcf..702c9c9 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -22,3 +22,14 @@ export const CONFIRM_PASSENGER_OFFICE = export const REJECT_PASSENGER_OFFICE = BASE_URL + "/dashboard/passenger_office_chief/reject"; //passenger office + +//transportation assistance +export const GET_TRANSPORTATION_ASSISTANCE = + BASE_URL + "/dashboard/transportation_asisstants/show"; + +export const CONFIRM_TRANSPORTATION_ASSISTANCE = + BASE_URL + "/dashboard/transportation_asisstants/confirm"; + +export const REJECT_TRANSPORTATION_ASSISTANCE = + BASE_URL + "/dashboard/transportation_asisstants/reject"; +//transportation assistance diff --git a/src/pages/dashboard/transportation-assistance/index.jsx b/src/pages/dashboard/transportation-assistance/index.jsx new file mode 100644 index 0000000..9c089ad --- /dev/null +++ b/src/pages/dashboard/transportation-assistance/index.jsx @@ -0,0 +1,23 @@ +import DashboardTransportationAssistanceComponent from "@/components/dashboard/transportation-assistance"; +import TitlePage from "@/core/components/TitlePage"; +import WithAuthMiddleware from "@/middlewares/WithAuth"; +import { parse } from "next-useragent"; + +export default function TransportationAssistance() { + 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, + }, + }; +} From 7d5d69203f31c200307800c8d8be7888021773e9 Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Sun, 16 Jul 2023 14:55:54 +0330 Subject: [PATCH 038/134] fix confirm data --- src/lib/app/hooks/useDatatable.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/app/hooks/useDatatable.jsx b/src/lib/app/hooks/useDatatable.jsx index 5627213..2a9d31f 100644 --- a/src/lib/app/hooks/useDatatable.jsx +++ b/src/lib/app/hooks/useDatatable.jsx @@ -43,10 +43,10 @@ const useDataTable = () => { const { token } = useUser(); - const confirmData = useCallback(async (url, rowID) => { - dispatch({ type: "CONFIRM_DATA", url: url, rowID: rowID }); + const confirmData = useCallback(async (url, rowID, values) => { + dispatch({ type: "CONFIRM_DATA", url: url, rowID: rowID, values: values }); axios - .post(`${url}/${rowID}`, null, { + .post(`${url}/${rowID}`, values, { headers: { authorization: `Bearer ${token}` }, }) .then(() => { @@ -60,7 +60,7 @@ const useDataTable = () => { const rejectData = useCallback(async (url, rowID, values) => { dispatch({ type: "REJECT_DATA", url: url, rowID: rowID, values: values }); axios - .post(`${url}/${rowID}`,values, { + .post(`${url}/${rowID}`, values, { headers: { authorization: `Bearer ${token}` }, }) .then(() => { From 29d031a83e6b34afd11c9d1046bf284ea8a61826 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Sun, 16 Jul 2023 15:16:31 +0330 Subject: [PATCH 039/134] machinary implement --- public/locales/fa/app.json | 3 +- .../machinary-office/Form/ConfirmForm.jsx | 69 +++++++++++++++---- .../machinary-office/Form/RejectForm.jsx | 51 ++++++++++++-- .../machinary-office/TableRowActions.jsx | 39 ++++++----- src/core/data/apiRoutes.js | 2 +- src/lib/app/hooks/useDatatable.jsx | 7 +- 6 files changed, 129 insertions(+), 42 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index c7b9d16..ef91fef 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -116,7 +116,8 @@ "confirm": "تایید", "context": "آیا از تایید این آیتم اطمینان دارید", "button-confirm": "تایید", - "button-cancel": "بستن" + "button-cancel": "بستن", + "amount_error": "وارد کردن مقدار پیشنهادی الزامیست" }, "RejectDialog": { "reject": "عدم تایید", diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx index 3e64087..804036a 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx @@ -10,39 +10,78 @@ import { } from "@mui/material"; import { useTranslations } from "next-intl"; import { useState } from "react"; +import { useFormik } from "formik"; +import * as Yup from "yup"; -const ConfirmForm = ({ - open, - handleClose, - handleDelete, - rowId, - confirmData, -}) => { +const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const t = useTranslations(); const [proposedAmount, setProposedAmount] = useState(""); - const handleConfirm = () => { - const formData = new FormData(); - formData.append("proposed_amount", proposedAmount); - handleDelete(); - confirmData(CONFIRM_MACHINARY_OFFICE, rowId, formData); + const [description, setDescription] = useState(""); + + //formik + const validationSchema = Yup.object().shape({ + proposed_amount: Yup.string().required(t("ConfirmDialog.amount_error")), + }); + const formik = useFormik({ + initialValues: { + proposed_amount: "", + description: "", + }, + validationSchema, + onSubmit: () => { + const formData = new FormData(); + formData.append("proposed_amount", proposedAmount); + formData.append("expert_description", description); + handleClose(); + confirmData(CONFIRM_MACHINARY_OFFICE, rowId, formData); + }, + }); + + const handleDescriptionChange = (event) => { + setDescription(event.target.value); }; + const handleAmountChange = (event) => { + setProposedAmount(event.target.value); + formik.handleChange(event); + }; + return ( {t("ConfirmDialog.confirm")} {t("ConfirmDialog.context")} + setProposedAmount(e.target.value)} - sx={{ mt: 2 }} + onChange={handleAmountChange} + onBlur={formik.handleBlur("proposed_amount")} + error={ + formik.touched.proposed_amount && + Boolean(formik.errors.proposed_amount) + } + helperText={ + formik.touched.proposed_amount && formik.errors.proposed_amount + } + sx={{ mt: 1 }} fullWidth /> - ); }; + export default RejectForm; diff --git a/src/components/dashboard/machinary-office/TableRowActions.jsx b/src/components/dashboard/machinary-office/TableRowActions.jsx index f5ec46b..e9e815e 100644 --- a/src/components/dashboard/machinary-office/TableRowActions.jsx +++ b/src/components/dashboard/machinary-office/TableRowActions.jsx @@ -14,34 +14,39 @@ const TableRowActions = ({ row }) => { handleOpenRejectDialog, handleCloseConfirmDialog, handleCloseRejectDialog, - handleConfirmDialog, - handleRejectDialog, rowId, confirmData, rejectData, } = useContext(DataTableContext); return ( - handleOpenConfirmDialog(row)}> + { + handleOpenConfirmDialog(row); + }} + > - + {openConfirmDialog && ( + + )} handleOpenRejectDialog(row)}> - + {openRejectDialog && ( + + )} ); }; diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index f16d573..79046bc 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -31,5 +31,5 @@ export const CONFIRM_MACHINARY_OFFICE = BASE_URL + "/dashboard/machinery_expert/confirm"; export const REJECT_MACHINARY_OFFICE = - BASE_URL + "dashboard/machinery_expert/reject"; + BASE_URL + "/dashboard/machinery_expert/reject"; //passenger office diff --git a/src/lib/app/hooks/useDatatable.jsx b/src/lib/app/hooks/useDatatable.jsx index e7730bc..9823aca 100644 --- a/src/lib/app/hooks/useDatatable.jsx +++ b/src/lib/app/hooks/useDatatable.jsx @@ -44,9 +44,9 @@ const useDataTable = () => { const { token } = useUser(); const confirmData = useCallback(async (url, rowID, values) => { - dispatch({ type: "CONFIRM_DATA", url: url, rowID: rowID }); + dispatch({ type: "CONFIRM_DATA", url: url, rowID: rowID, values: values }); axios - .post(`${url}/${rowID}`, null, { + .post(`${url}/${rowID}`, values, { headers: { authorization: `Bearer ${token}` }, }) .then(() => { @@ -60,13 +60,14 @@ const useDataTable = () => { const rejectData = useCallback(async (url, rowID, values) => { dispatch({ type: "REJECT_DATA", url: url, rowID: rowID, values: values }); axios - .post(`${url}/${rowID}`,values, { + .post(`${url}/${rowID}`, values, { headers: { authorization: `Bearer ${token}` }, }) .then(() => { setReloadDataTable(true); }) .catch((error) => { + console.log(error); Notifications(directionApp, error.response, t); }); }, []); From c2259031fc73e68b090fd9b88b45d9789e802c1e Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Sun, 16 Jul 2023 15:31:20 +0330 Subject: [PATCH 040/134] confirm data --- src/components/dashboard/machinary-office/Form/ConfirmForm.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx index 804036a..754abce 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx @@ -31,7 +31,7 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { onSubmit: () => { const formData = new FormData(); formData.append("proposed_amount", proposedAmount); - formData.append("expert_description", description); + if (description != "") formData.append("expert_description", description); handleClose(); confirmData(CONFIRM_MACHINARY_OFFICE, rowId, formData); }, From 69a7f3525a3ad5233a761db690d599e607f0a0d7 Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Sun, 16 Jul 2023 15:41:58 +0330 Subject: [PATCH 041/134] add notification to datatable --- src/lib/app/hooks/useDatatable.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/app/hooks/useDatatable.jsx b/src/lib/app/hooks/useDatatable.jsx index 2a9d31f..8b097b1 100644 --- a/src/lib/app/hooks/useDatatable.jsx +++ b/src/lib/app/hooks/useDatatable.jsx @@ -49,8 +49,9 @@ const useDataTable = () => { .post(`${url}/${rowID}`, values, { headers: { authorization: `Bearer ${token}` }, }) - .then(() => { + .then((response) => { setReloadDataTable(true); + Notifications(directionApp, response, t); }) .catch((error) => { Notifications(directionApp, error.response, t); @@ -63,8 +64,9 @@ const useDataTable = () => { .post(`${url}/${rowID}`, values, { headers: { authorization: `Bearer ${token}` }, }) - .then(() => { + .then((response) => { setReloadDataTable(true); + Notifications(directionApp, response, t); }) .catch((error) => { Notifications(directionApp, error.response, t); From 4e9d81ca719aa20b1645637ddace4f372336e151 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Sun, 16 Jul 2023 15:59:31 +0330 Subject: [PATCH 042/134] change id to national id --- public/locales/fa/app.json | 4 ++-- src/components/dashboard/machinary-office/index.jsx | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index ef91fef..f50b62e 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -93,7 +93,7 @@ }, "PassengerOffice": { "name": "نام", - "id": "کد ملی", + "national_id": "کد ملی", "phone_number": "موبایل", "created_at": "تاریخ درخواست", "updated_at": "تاریخ بروزرسانی", @@ -103,7 +103,7 @@ }, "MachinaryOffice": { "name": "نام", - "id": "کد ملی", + "national_id": "کد ملی", "phone_number": "موبایل", "created_at": "تاریخ درخواست", "updated_at": "تاریخ بروزرسانی", diff --git a/src/components/dashboard/machinary-office/index.jsx b/src/components/dashboard/machinary-office/index.jsx index 8a88f5f..bcd3eb4 100644 --- a/src/components/dashboard/machinary-office/index.jsx +++ b/src/components/dashboard/machinary-office/index.jsx @@ -24,9 +24,9 @@ function DashboardMachinaryOfficeComponent() { ), }, { - accessorFn: (row) => row.id, - id: "id", - header: t("MachinaryOffice.id"), + accessorFn: (row) => row.national_id, + id: "national_id", + header: t("MachinaryOffice.national_id"), enableColumnFilter: true, datatype: "numeric", filterFn: "equals", From c505f57cfbb92a989d611dcde4b8d37d4b48b352 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Sun, 16 Jul 2023 16:01:22 +0330 Subject: [PATCH 043/134] change id to national id in passenger office --- src/components/dashboard/passenger-office/index.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/dashboard/passenger-office/index.jsx b/src/components/dashboard/passenger-office/index.jsx index 98af2b7..9313a5b 100644 --- a/src/components/dashboard/passenger-office/index.jsx +++ b/src/components/dashboard/passenger-office/index.jsx @@ -24,9 +24,9 @@ function DashboardPassengerOfficeComponent() { ), }, { - accessorFn: (row) => row.id, - id: "id", - header: t("PassengerOffice.id"), + accessorFn: (row) => row.national_id, + id: "national_id", + header: t("PassengerOffice.national_id"), enableColumnFilter: true, datatype: "numeric", filterFn: "equals", From 05d436058e85a04b2a09e55e63d51cbef08098db Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Sun, 16 Jul 2023 16:38:26 +0330 Subject: [PATCH 044/134] datatable_locale --- public/locales/fa/datatable.js | 176 ++++++++++++++++----------------- 1 file changed, 88 insertions(+), 88 deletions(-) diff --git a/public/locales/fa/datatable.js b/public/locales/fa/datatable.js index e42208f..819a84b 100644 --- a/public/locales/fa/datatable.js +++ b/public/locales/fa/datatable.js @@ -1,92 +1,92 @@ export const FA_DATATABLE_LOCALIZATION = { - actions: "Actions", - and: "and", - cancel: "Cancel", - changeFilterMode: "Change filter mode", - changeSearchMode: "Change search mode", - clearFilter: "Clear filter", - clearSearch: "Clear search", - clearSort: "Clear sort", - clickToCopy: "Click to copy", - collapse: "Collapse", - collapseAll: "Collapse all", - columnActions: "Column Actions", - copiedToClipboard: "Copied to clipboard", - dropToGroupBy: "Drop to group by {column}", - edit: "Edit", - expand: "Expand", - expandAll: "Expand all", - filterArrIncludes: "Includes", - filterArrIncludesAll: "Includes all", - filterArrIncludesSome: "Includes", - filterBetween: "Between", - filterBetweenInclusive: "Between Inclusive", - filterByColumn: "Filter by {column}", - filterContains: "Contains", - filterEmpty: "Empty", - filterEndsWith: "Ends With", - filterEquals: "Equals", - filterEqualsString: "Equals", - filterFuzzy: "Fuzzy", - filterGreaterThan: "Greater Than", - filterGreaterThanOrEqualTo: "Greater Than Or Equal To", - filterInNumberRange: "Between", - filterIncludesString: "Contains", - filterIncludesStringSensitive: "Contains", - filterLessThan: "Less Than", - filterLessThanOrEqualTo: "Less Than Or Equal To", - filterMode: "Filter Mode: {filterType}", - filterNotEmpty: "Not Empty", - filterNotEquals: "Not Equals", - filterStartsWith: "Starts With", - filterWeakEquals: "Equals", - filteringByColumn: "Filtering by {column} - {filterType} {filterValue}", - goToFirstPage: "Go to first page", - goToLastPage: "Go to last page", - goToNextPage: "Go to next page", - goToPreviousPage: "Go to previous page", - grab: "Grab", - groupByColumn: "Group by {column}", - groupedBy: "Grouped by ", - hideAll: "Hide all", - hideColumn: "Hide {column} column", - max: "Max", - min: "Min", - move: "Move", - noRecordsToDisplay: "No records to display", - noResultsFound: "No results found", - of: "of", - or: "or", - pinToLeft: "Pin to left", - pinToRight: "Pin to right", - resetColumnSize: "Reset column size", - resetOrder: "Reset order", - rowActions: "Row Actions", + actions: "عملیات", + and: "و", + cancel: "لغو", + changeFilterMode: "تغییر حالت فیلتر", + changeSearchMode: "تغییر حالت جستجو", + clearFilter: "پاک کردن فیلتر", + clearSearch: "پاک کردن جستجو", + clearSort: "پاک کردن مرتب سازی", + clickToCopy: "کلیک برای کپی", + collapse: "جمع شدن", + collapseAll: "جمع شدن همه", + columnActions: "عملیات ستون", + copiedToClipboard: "کپی شد", + dropToGroupBy: "رها کردن برای گروه بندی بر اساس {column}", + edit: "ویرایش", + expand: "باز شدن", + expandAll: "باز شدن همه", + filterArrIncludes: "شامل", + filterArrIncludesAll: "شامل همه", + filterArrIncludesSome: "شامل", + filterBetween: "میان", + filterBetweenInclusive: "میان با احتساب هر دو", + filterByColumn: "فیلتر بر اساس {column}", + filterContains: "شامل", + filterEmpty: "خالی", + filterEndsWith: "به پایان می‌رسد با", + filterEquals: "برابر", + filterEqualsString: "برابر", + filterFuzzy: "نزدیک", + filterGreaterThan: "بزرگتر از", + filterGreaterThanOrEqualTo: "بزرگتر یا مساوی", + filterInNumberRange: "میان", + filterIncludesString: "شامل", + filterIncludesStringSensitive: "شامل", + filterLessThan: "کوچکتر از", + filterLessThanOrEqualTo: "کوچکتر یا مساوی", + filterMode: "حالت فیلتر: {filterType}", + filterNotEmpty: "غیر خالی", + filterNotEquals: "نا برابر", + filterStartsWith: "شروع می‌شود با", + filterWeakEquals: "برابر", + filteringByColumn: "فیلتر بر اساس {column} - {filterType} {filterValue}", + goToFirstPage: "رفتن به صفحه اول", + goToLastPage: "رفتن به صفحه آخر", + goToNextPage: "رفتن به صفحه بعدی", + goToPreviousPage: "رفتن به صفحه قبلی", + grab: "گرفتن", + groupByColumn: "گروه بندی بر اساس {column}", + groupedBy: "گروه بندی شده بر اساس", + hideAll: "پنهان کردن همه", + hideColumn: "پنهان کردن ستون {column}", + max: "حداکثر", + min: "حداقل", + move: "انتقال", + noRecordsToDisplay: "هیچ رکوردی برای نمایش وجود ندارد", + noResultsFound: "نتیجه‌ای یافت نشد", + of: "از", + or: "یا", + pinToLeft: "چسباندن به سمت چپ", + pinToRight: "چسباندن به سمت راست", + resetColumnSize: "بازنشانی اندازه ستون", + resetOrder: "بازنشانی ترتیب", + rowActions: "عملیات ردیف", rowNumber: "#", - rowNumbers: "Row Numbers", - rowsPerPage: "Rows per page", - save: "Save", - search: "Search", + rowNumbers: "شماره ردیف", + rowsPerPage: "ردیف در هر صفحه", + save: "ذخیره", + search: "جستجو", selectedCountOfRowCountRowsSelected: - "{selectedCount} of {rowCount} row(s) selected", - select: "Select", - showAll: "Show all", - showAllColumns: "Show all columns", - showHideColumns: "Show/Hide columns", - showHideFilters: "Show/Hide filters", - showHideSearch: "Show/Hide search", - sortByColumnAsc: "Sort by {column} ascending", - sortByColumnDesc: "Sort by {column} descending", - sortedByColumnAsc: "Sorted by {column} ascending", - sortedByColumnDesc: "Sorted by {column} descending", - thenBy: ", then by ", - toggleDensity: "Toggle density", - toggleFullScreen: "Toggle full screen", - toggleSelectAll: "Toggle select all", - toggleSelectRow: "Toggle select row", - toggleVisibility: "Toggle visibility", - ungroupByColumn: "Ungroup by {column}", - unpin: "Unpin", - unpinAll: "Unpin all", - unsorted: "Unsorted", + "{selectedCount} از {rowCount} ردیف انتخاب شده", + select: "انتخاب", + showAll: "نمایش همه", + showAllColumns: "نمایش همه ستون‌ها", + showHideColumns: "نمایش/مخفی کردن ستون‌ها", + showHideFilters: "نمایش/مخفی کردن فیلترها", + showHideSearch: "نمایش/مخفی کردن جستجو", + sortByColumnAsc: "مرتب سازی بر اساس {column} صعودی", + sortByColumnDesc: "مرتب سازی بر اساس {column} نزولی", + sortedByColumnAsc: "مرتب شده بر اساس {column} صعودی", + sortedByColumnDesc: "مرتب شده بر اساس {column} نزولی", + thenBy: "، سپس بر اساس ", + toggleDensity: "تغییر تراکم", + toggleFullScreen: "تغییر حالت تمام صفحه", + toggleSelectAll: "انتخاب/عدم انتخاب همه", + toggleSelectRow: "انتخاب/عدم انتخاب ردیف", + toggleVisibility: "تغییر پیدا/پنهان", + ungroupByColumn: "لغو گروه بندی بر اساس {column}", + unpin: "رها کردن", + unpinAll: "رها کردن همه", + unsorted: "بدون مرتب سازی", }; From b9ce99d575e8f5f5eddf63528ce211d6b216d4ac Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Sun, 16 Jul 2023 16:56:41 +0330 Subject: [PATCH 045/134] auth middleware --- src/pages/dashboard/passenger-boss/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/dashboard/passenger-boss/index.jsx b/src/pages/dashboard/passenger-boss/index.jsx index 0920933..961d766 100644 --- a/src/pages/dashboard/passenger-boss/index.jsx +++ b/src/pages/dashboard/passenger-boss/index.jsx @@ -1,6 +1,6 @@ import DashboardPassengerBossComponent from "@/components/dashboard/passenger-boss"; import TitlePage from "@/core/components/TitlePage"; -import WithAuthMiddleware from "@/middlewares/WithoutAuth"; +import WithAuthMiddleware from "@/middlewares/WithAuth"; import { parse } from "next-useragent"; export default function PassengerBoss() { From 1139ba0636af684be3e79092c06bf9daf8346ac9 Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Sun, 16 Jul 2023 17:04:29 +0330 Subject: [PATCH 046/134] debug api routes --- src/core/data/apiRoutes.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index 0f57675..42a6029 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -23,7 +23,6 @@ export const REJECT_PASSENGER_OFFICE = BASE_URL + "/dashboard/passenger_office_chief/reject"; //passenger office -<<<<<<< HEAD //transportation assistance export const GET_TRANSPORTATION_ASSISTANCE = BASE_URL + "/dashboard/transportation_asisstants/show"; @@ -34,7 +33,6 @@ export const CONFIRM_TRANSPORTATION_ASSISTANCE = export const REJECT_TRANSPORTATION_ASSISTANCE = BASE_URL + "/dashboard/transportation_asisstants/reject"; //transportation assistance -======= //machinary office export const GET_MACHINARY_OFFICE = BASE_URL + "/dashboard/machinery_expert/show"; @@ -45,4 +43,3 @@ export const CONFIRM_MACHINARY_OFFICE = export const REJECT_MACHINARY_OFFICE = BASE_URL + "/dashboard/machinery_expert/reject"; //passenger office ->>>>>>> a683c4029fdd3b3cae26a4cc7823835ad7e687b1 From c5b8cd964f37366dfca5f5f190964769dee22b08 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Mon, 17 Jul 2023 11:59:19 +0330 Subject: [PATCH 047/134] debug datatable --- public/locales/fa/app.json | 5 +- .../dashboard/machinary-office/index.jsx | 32 +++++-- .../dashboard/passenger-office/index.jsx | 89 ++++++++++++++----- .../transportation-assistance/index.jsx | 39 +++++--- 4 files changed, 127 insertions(+), 38 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 8170a99..b6bd06f 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -93,6 +93,7 @@ }, "PassengerOffice": { "name": "نام", + "id": "کد یکتا", "national_id": "کد ملی", "phone_number": "موبایل", "created_at": "تاریخ درخواست", @@ -103,7 +104,8 @@ }, "TransportationAssistance": { "name": "نام", - "id": "کد ملی", + "id": "کد یکتا", + "national_id": "کد ملی", "phone_number": "موبایل", "created_at": "تاریخ درخواست", "updated_at": "تاریخ بروزرسانی", @@ -113,6 +115,7 @@ }, "MachinaryOffice": { "name": "نام", + "id": "کد یکتا", "national_id": "کد ملی", "phone_number": "موبایل", "created_at": "تاریخ درخواست", diff --git a/src/components/dashboard/machinary-office/index.jsx b/src/components/dashboard/machinary-office/index.jsx index bcd3eb4..2a8feeb 100644 --- a/src/components/dashboard/machinary-office/index.jsx +++ b/src/components/dashboard/machinary-office/index.jsx @@ -6,11 +6,31 @@ import { useMemo } from "react"; import { GET_MACHINARY_OFFICE } from "@/core/data/apiRoutes"; import { useTranslations } from "next-intl"; import TableRowActions from "./TableRowActions"; +import { format } from "date-fns-jalali"; function DashboardMachinaryOfficeComponent() { const t = useTranslations(); const columns = useMemo( () => [ + { + accessorFn: (row) => row.id, + id: "id", + header: t("PassengerOffice.id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, { accessorFn: (row) => row.name, id: "name", @@ -62,7 +82,7 @@ function DashboardMachinaryOfficeComponent() { ), }, { - accessorFn: (row) => row.created_at, + accessorFn: (row) => format(new Date(row.created_at), "yyyy/mm/dd"), id: "created_at", header: t("MachinaryOffice.created_at"), enableColumnFilter: true, @@ -81,7 +101,7 @@ function DashboardMachinaryOfficeComponent() { ), }, { - accessorFn: (row) => row.updated_at, + accessorFn: (row) => format(new Date(row.updated_at), "yyyy/mm/dd"), id: "updated_at", header: t("MachinaryOffice.updated_at"), enableColumnFilter: true, @@ -137,11 +157,9 @@ function DashboardMachinaryOfficeComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - filterSelectOptions: [ - { text: "Active", value: "0" }, - { text: "Deactive", value: "1" }, - ], - filterVariant: "select", + // filterSelectOptions: [ + // ], + // filterVariant: "select", Cell: ({ renderedCellValue }) => ( {renderedCellValue} ), diff --git a/src/components/dashboard/passenger-office/index.jsx b/src/components/dashboard/passenger-office/index.jsx index 9313a5b..429c16e 100644 --- a/src/components/dashboard/passenger-office/index.jsx +++ b/src/components/dashboard/passenger-office/index.jsx @@ -6,11 +6,34 @@ import { useMemo } from "react"; import { GET_PASSENGER_OFFICE } from "@/core/data/apiRoutes"; import { useTranslations } from "next-intl"; import TableRowActions from "./TableRowActions"; +import { format } from "date-fns-jalali"; +import { DateTimePicker, LocalizationProvider } from "@mui/x-date-pickers"; +import { AdapterDateFnsJalali } from "@mui/x-date-pickers/AdapterDateFnsJalali"; +import moment from "moment"; function DashboardPassengerOfficeComponent() { const t = useTranslations(); const columns = useMemo( () => [ + { + accessorFn: (row) => row.id, + id: "id", + header: t("PassengerOffice.id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, { accessorFn: (row) => row.name, id: "name", @@ -62,26 +85,54 @@ function DashboardPassengerOfficeComponent() { ), }, { - accessorFn: (row) => row.created_at, + accessorFn: (row) => + format(new Date(row.created_at), "yyyy/mm/dd HH:mm"), id: "created_at", header: t("PassengerOffice.created_at"), enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), + datatype: "date", + filterFn: "lessThan", + columnFilterModeOptions: ["lessThan", "greaterThan"], + Cell: ({ renderedCellValue }) => { + return {renderedCellValue}; + }, + Header: ({ column }) => {column.columnDef.header}, + Filter: ({ column }) => { + return ( + + { + console.log({ newValue }); + const date = new Date(newValue); + console.log({ date }); + const formattedDate = moment(date) + .locale("en") + .format("YYYY-MM-DD HH:mm"); + console.log(formattedDate); + // const formattedDate = format(date, "YYYY-MM-DD HH:mm"); + // console.log( + // "moment", + // moment(formattedDate) + // .locale("en") + // .format("YYYY-MM-DD HH:mm") + // ); + column.setFilterValue(formattedDate); + }} + slotProps={{ + textField: { + helperText: `Filter Mode: ${column.columnDef._filterFn}`, + sx: { minWidth: "120px" }, + variant: "standard", + }, + }} + value={column.getFilterValue()} + /> + + ); + }, }, { - accessorFn: (row) => row.updated_at, + accessorFn: (row) => format(new Date(row.updated_at), "yyyy/mm/dd"), id: "updated_at", header: t("PassengerOffice.updated_at"), enableColumnFilter: true, @@ -137,11 +188,9 @@ function DashboardPassengerOfficeComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - filterSelectOptions: [ - { text: "Active", value: "0" }, - { text: "Deactive", value: "1" }, - ], - filterVariant: "select", + // filterSelectOptions: [ + // ], + // filterVariant: "select", Cell: ({ renderedCellValue }) => ( {renderedCellValue} ), diff --git a/src/components/dashboard/transportation-assistance/index.jsx b/src/components/dashboard/transportation-assistance/index.jsx index 6dd3ccf..8a24978 100644 --- a/src/components/dashboard/transportation-assistance/index.jsx +++ b/src/components/dashboard/transportation-assistance/index.jsx @@ -6,11 +6,31 @@ import { useMemo } from "react"; import { GET_TRANSPORTATION_ASSISTANCE } from "@/core/data/apiRoutes"; import { useTranslations } from "next-intl"; import TableRowActions from "./TableRowActions"; +import { format } from "date-fns-jalali"; function DashboardTransportationAssistanceComponent() { const t = useTranslations(); const columns = useMemo( () => [ + { + accessorFn: (row) => row.id, + id: "id", + header: t("TransportationAssistance.id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, { accessorFn: (row) => row.name, id: "name", @@ -23,10 +43,11 @@ function DashboardTransportationAssistanceComponent() { {renderedCellValue} ), }, + { - accessorFn: (row) => row.id, - id: "id", - header: t("TransportationAssistance.id"), + accessorFn: (row) => row.national_id, + id: "national_id", + header: t("TransportationAssistance.national_id"), enableColumnFilter: true, datatype: "numeric", filterFn: "equals", @@ -62,7 +83,7 @@ function DashboardTransportationAssistanceComponent() { ), }, { - accessorFn: (row) => row.created_at, + accessorFn: (row) => format(new Date(row.created_at), "yyyy/mm/dd"), id: "created_at", header: t("TransportationAssistance.created_at"), enableColumnFilter: true, @@ -81,7 +102,7 @@ function DashboardTransportationAssistanceComponent() { ), }, { - accessorFn: (row) => row.updated_at, + accessorFn: (row) => format(new Date(row.updated_at), "yyyy/mm/dd"), id: "updated_at", header: t("TransportationAssistance.updated_at"), enableColumnFilter: true, @@ -137,11 +158,9 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - filterSelectOptions: [ - { text: "Active", value: "0" }, - { text: "Deactive", value: "1" }, - ], - filterVariant: "select", + // filterSelectOptions: [ + // ], + // filterVariant: "select", Cell: ({ renderedCellValue }) => ( {renderedCellValue} ), From fa8e0ba1e755188ffc503ef0db5ac2206d50dbce Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Mon, 17 Jul 2023 14:27:47 +0330 Subject: [PATCH 048/134] prevent proposed amount to get negetive values --- .../dashboard/machinary-office/Form/ConfirmForm.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx index 754abce..4e7ac76 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx @@ -41,7 +41,9 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { setDescription(event.target.value); }; const handleAmountChange = (event) => { - setProposedAmount(event.target.value); + if (/^\d*$/.test(event.target.value)) { + setProposedAmount(event.target.value); + } formik.handleChange(event); }; @@ -65,6 +67,11 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { name="proposed_amount" label={t("MachinaryOffice.proposed_amount")} type="number" + inputProps={{ + min: 0, + inputMode: "numeric", + pattern: "[0-9]*", + }} variant="outlined" value={proposedAmount} onChange={handleAmountChange} From db19c29f896cd4cddde1545773014e0eddbfea6e Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Tue, 18 Jul 2023 09:49:09 +0330 Subject: [PATCH 049/134] description in cinfirm form --- public/locales/fa/app.json | 3 +- .../passenger-office/Form/ConfirmForm.jsx | 37 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index b6bd06f..b553d3b 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -130,7 +130,8 @@ "context": "آیا از تایید این آیتم اطمینان دارید", "button-confirm": "تایید", "button-cancel": "بستن", - "amount_error": "وارد کردن مقدار پیشنهادی الزامیست" + "amount_error": "وارد کردن مقدار پیشنهادی الزامیست", + "description_error": "وارد کردن توضیحات الزامی است!" }, "RejectDialog": { "reject": "عدم تایید", diff --git a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx index 43c6bb3..08bbde6 100644 --- a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx @@ -6,11 +6,36 @@ import { DialogContentText, DialogActions, Button, + TextField, } from "@mui/material"; +import { useFormik } from "formik"; import { useTranslations } from "next-intl"; +import { useState } from "react"; const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const t = useTranslations(); + const [description, setDescription] = useState(""); + + const formik = useFormik({ + initialValues: { + description: "", + fileData: null, + }, + onSubmit: () => { + const formData = new FormData(); + if (description !== "") + formData.append("expert_description", description); + // if (fileData !== null) formData.append("file", fileData); + handleClose(); + confirmData(CONFIRM_PASSENGER_OFFICE, rowId, formData); + }, + }); + + const handleDescriptionChange = (event) => { + setDescription(event.target.value); + formik.handleChange(event); + }; + const handleConfirm = () => { handleClose(); confirmData(CONFIRM_PASSENGER_OFFICE, rowId); @@ -20,6 +45,18 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { {t("ConfirmDialog.confirm")} {t("ConfirmDialog.context")} + + + {/* */} + + + {formik.errors.fileData && formik.errors.fileData} + {formik.values.fileData && + `Selected file: ${formik.values.fileData.name}`} + + - - {/* */} {formik.errors.fileData && formik.errors.fileData} - {formik.values.fileData && - `Selected file: ${formik.values.fileData.name}`} - + + + + ); +}; +export default ConfirmForm; diff --git a/src/components/dashboard/passenger-boss/Form/RejectForm.jsx b/src/components/dashboard/passenger-boss/Form/RejectForm.jsx new file mode 100644 index 0000000..18a48a7 --- /dev/null +++ b/src/components/dashboard/passenger-boss/Form/RejectForm.jsx @@ -0,0 +1,76 @@ +import { REJECT_PASSENGER_BOSS } from "@/core/data/apiRoutes"; +import { + Dialog, + DialogTitle, + DialogContent, + DialogContentText, + DialogActions, + Button, + TextField, +} from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useFormik } from "formik"; +import * as Yup from "yup"; +import { useState } from "react"; + +const RejectForm = ({ open, handleClose, rowId, rejectData }) => { + const t = useTranslations(); + const [description, setDescription] = useState(""); + + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("RejectDialog.description_error")), + }); + + const formik = useFormik({ + initialValues: { + description: "", + }, + validationSchema, + onSubmit: () => { + const formData = new FormData(); + formData.append("expert_description", description); + handleClose(); + rejectData(REJECT_PASSENGER_BOSS, rowId, formData); + }, + }); + + const handleDescriptionChange = (event) => { + setDescription(event.target.value); + formik.handleChange(event); + }; + + return ( + + {t("RejectDialog.reject")} + + {t("RejectDialog.context")} + + + + + + + + ); +}; + +export default RejectForm; diff --git a/src/components/dashboard/passenger-boss/TableRowActions.jsx b/src/components/dashboard/passenger-boss/TableRowActions.jsx index 0290214..e9e815e 100644 --- a/src/components/dashboard/passenger-boss/TableRowActions.jsx +++ b/src/components/dashboard/passenger-boss/TableRowActions.jsx @@ -1,48 +1,52 @@ -import DeleteIcon from "@mui/icons-material/Delete"; -import EditIcon from "@mui/icons-material/Edit"; +import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; +import ThumbDownIcon from "@mui/icons-material/ThumbDown"; import { Box, IconButton } from "@mui/material"; -// import EditForm from "./Form/EditForm"; import { useContext } from "react"; import { DataTableContext } from "@/lib/app/contexts/DataTableContext"; -// import DeleteForm from "./Form/DeleteForm"; +import ConfirmForm from "./Form/ConfirmForm"; +import RejectForm from "./Form/RejectForm"; const TableRowActions = ({ row }) => { const { - toggleDrawer, - setDrawerContent, - openDeleteDialog, - handleOpenDeleteDialog, - handleCloseDeleteDialog, - handleDeleteDialog, + openConfirmDialog, + openRejectDialog, + handleOpenConfirmDialog, + handleOpenRejectDialog, + handleCloseConfirmDialog, + handleCloseRejectDialog, rowId, - deleteData, + confirmData, + rejectData, } = useContext(DataTableContext); return ( { - toggleDrawer(true); - // setDrawerContent(); + handleOpenConfirmDialog(row); }} > - + - handleOpenDeleteDialog(row)} - > - + {openConfirmDialog && ( + + )} + handleOpenRejectDialog(row)}> + - {/* */} + {openRejectDialog && ( + + )} ); }; diff --git a/src/components/dashboard/passenger-boss/TableTollbar.jsx b/src/components/dashboard/passenger-boss/TableTollbar.jsx index 0b29ba8..3f06d3b 100644 --- a/src/components/dashboard/passenger-boss/TableTollbar.jsx +++ b/src/components/dashboard/passenger-boss/TableTollbar.jsx @@ -1,30 +1,11 @@ -import { DataTableContext } from "@/lib/app/contexts/DataTableContext"; -import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; -import { Button, Stack, Tooltip } from "@mui/material"; +import { Stack, Tooltip } from "@mui/material"; import { useTranslations } from "next-intl"; -import { useContext } from "react"; -// import AddForm from "./Form/AddForm"; function TableToolbar() { const t = useTranslations(); - const { toggleDrawer, setDrawerContent } = useContext(DataTableContext); return ( - - - + ); } diff --git a/src/components/dashboard/passenger-boss/index.jsx b/src/components/dashboard/passenger-boss/index.jsx index 46de5ba..c39322d 100644 --- a/src/components/dashboard/passenger-boss/index.jsx +++ b/src/components/dashboard/passenger-boss/index.jsx @@ -1,14 +1,20 @@ import DataTableStructure from "@/core/components/DatatableStructure"; import DashboardLayouts from "@/layouts/dashboardLayouts"; -import { ContentCopy } from "@mui/icons-material"; import { Box, Typography } from "@mui/material"; -import { DateTimePicker, LocalizationProvider } from "@mui/x-date-pickers"; -import { useTranslations } from "next-intl"; import { useMemo } from "react"; -import TableToolbar from "./TableTollbar"; +// import TableToolbar from "./TableTollbar"; +import { GET_PASSENGER_BOSS } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; import TableRowActions from "./TableRowActions"; +import { format } from "date-fns-jalali"; +import { + LocalizationProvider, + MobileDateTimePicker, +} from "@mui/x-date-pickers"; +import { AdapterDateFnsJalali } from "@mui/x-date-pickers/AdapterDateFnsJalali"; +import moment from "moment"; -const DashboardPassengerBossComponent = () => { +function DashboardPassengerOfficeComponent() { const t = useTranslations(); const columns = useMemo( @@ -16,7 +22,7 @@ const DashboardPassengerBossComponent = () => { { accessorFn: (row) => row.id, id: "id", - header: "Id", + header: t("PassengerBoss.id"), enableColumnFilter: true, datatype: "numeric", filterFn: "equals", @@ -33,9 +39,9 @@ const DashboardPassengerBossComponent = () => { ), }, { - accessorFn: (row) => row.username, - id: "username", - header: "Username", + accessorFn: (row) => row.name, + id: "name", + header: t("PassengerBoss.name"), enableColumnFilter: true, datatype: "text", filterFn: "contains", @@ -45,18 +51,20 @@ const DashboardPassengerBossComponent = () => { ), }, { - accessorFn: (row) => row.name, - id: "name", - header: "Name", + accessorFn: (row) => row.national_id, + id: "national_id", + header: t("PassengerBoss.national_id"), enableColumnFilter: true, - datatype: "text", - filterFn: "contains", - columnFilterModeOptions: ["contains", "equals", "notEquals"], - muiTableBodyCellCopyButtonProps: { - fullWidth: true, - endIcon: , - sx: { justifyContent: "space-between" }, - }, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], Cell: ({ renderedCellValue }) => ( {renderedCellValue} ), @@ -64,90 +72,48 @@ const DashboardPassengerBossComponent = () => { { accessorFn: (row) => row.phone_number, id: "phone_number", - header: "Phone Number", - enableColumnFilter: true, - datatype: "text", - filterFn: "contains", - columnFilterModeOptions: ["equals", "notEquals", "contains"], - muiTableBodyCellCopyButtonProps: { - fullWidth: true, - endIcon: , - sx: { justifyContent: "space-between" }, - }, - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.status, - id: "status", - header: "Status", + header: t("PassengerBoss.phone_number"), enableColumnFilter: true, datatype: "numeric", filterFn: "equals", - filterSelectOptions: [ - { text: "Active", value: "0" }, - { text: "Deactive", value: "1" }, + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", ], - filterVariant: "select", Cell: ({ renderedCellValue }) => ( {renderedCellValue} ), }, { - accessorFn: (row) => row.gender, - id: "gender", - header: "Gender", - enableColumnFilter: true, - datatype: "text", - filterFn: "equals", - filterSelectOptions: [ - { text: "Male", value: "male" }, - { text: "Female", value: "female" }, - ], - filterVariant: "select", - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.national_id_code, - id: "national_id_code", - header: "National Id Code", - enableColumnFilter: true, - datatype: "text", - filterFn: "contains", - columnFilterModeOptions: ["equals", "notEquals", "contains"], - muiTableBodyCellCopyButtonProps: { - fullWidth: true, - endIcon: , - sx: { justifyContent: "space-between" }, - }, - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => new Date(row.updated_at), - id: "updated_at", - header: "Update Date", + accessorFn: (row) => + format(new Date(row.created_at), "HH:mm | yyyy/mm/dd"), + id: "created_at", + header: t("PassengerBoss.created_at"), enableColumnFilter: true, datatype: "date", filterFn: "lessThan", columnFilterModeOptions: ["lessThan", "greaterThan"], Cell: ({ renderedCellValue }) => { - const date = new Date(renderedCellValue); - const formattedDate = format(date, "MM/dd/yyyy HH:mm"); - return {formattedDate}; + return ( + + {renderedCellValue} + + ); }, Header: ({ column }) => {column.columnDef.header}, Filter: ({ column }) => { return ( - - + { const date = new Date(newValue); - const formattedDate = format(date, "yyyy-MM-dd HH:mm"); + const formattedDate = moment(date) + .locale("en") + .format("YYYY-MM-DD HH:mm"); column.setFilterValue(formattedDate); }} slotProps={{ @@ -157,25 +123,82 @@ const DashboardPassengerBossComponent = () => { variant: "standard", }, }} - value={column.getFilterValue()} + value={moment(column.getFilterValue()) + .locale("fa") + .format("yyyy/mm/dd HH:mm")} /> ); }, }, + { + accessorFn: (row) => + format(new Date(row.updated_at), "HH:mm | yyyy/mm/dd"), + id: "updated_at", + header: t("PassengerBoss.updated_at"), + enableColumnFilter: false, + datatype: "numeric", + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.navgan_id, + id: "navgan_id", + header: t("PassengerBoss.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("PassengerBoss.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("PassengerBoss.state_name"), + enableColumnFilter: false, + datatype: "numeric", + // filterFn: "equals", + // filterSelectOptions: [ + // ], + // filterVariant: "select", + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, ], [] ); - return ( } + // CustomToolbar={} enableLastUpdate={true} enablePinning={true} enableDensityToggle={true} @@ -190,6 +213,6 @@ const DashboardPassengerBossComponent = () => { ); -}; +} -export default DashboardPassengerBossComponent; +export default DashboardPassengerOfficeComponent; diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index 716ca0f..eb28399 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -23,6 +23,17 @@ export const REJECT_PASSENGER_OFFICE = BASE_URL + "/dashboard/passenger_office_chief/reject"; //passenger office +//passenger boss +export const GET_PASSENGER_BOSS = + BASE_URL + "/dashboard/province_working_group/show"; + +export const CONFIRM_PASSENGER_BOSS = + BASE_URL + "/dashboard/province_working_group/confirm"; + +export const REJECT_PASSENGER_BOSS = + BASE_URL + "/dashboard/province_working_group/reject"; +//passenger boss + //transportation assistance export const GET_TRANSPORTATION_ASSISTANCE = BASE_URL + "/dashboard/transportation_assistant/show"; @@ -33,6 +44,7 @@ export const CONFIRM_TRANSPORTATION_ASSISTANCE = export const REJECT_TRANSPORTATION_ASSISTANCE = BASE_URL + "/dashboard/transportation_assistant/reject"; //transportation assistance + //machinary office export const GET_MACHINARY_OFFICE = BASE_URL + "/dashboard/machinery_expert/show"; From a8516b57dec0dfb1c159436c6ee06091abb29ac4 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Wed, 19 Jul 2023 10:10:23 +0330 Subject: [PATCH 055/134] province manager --- public/locales/fa/app.json | 16 +- .../province-manager/Form/ConfirmForm.jsx | 128 ++++++++++ .../province-manager/Form/RejectForm.jsx | 76 ++++++ .../province-manager/TableRowActions.jsx | 54 +++++ .../province-manager/TableTollbar.jsx | 13 ++ .../dashboard/province-manager/index.jsx | 218 ++++++++++++++++++ src/core/data/apiRoutes.js | 11 + src/core/data/sidebarMenu.jsx | 6 +- src/pages/dashboard/passenger-boss/index.jsx | 2 +- .../dashboard/province-manager/index.jsx | 23 ++ 10 files changed, 541 insertions(+), 6 deletions(-) create mode 100644 src/components/dashboard/province-manager/Form/ConfirmForm.jsx create mode 100644 src/components/dashboard/province-manager/Form/RejectForm.jsx create mode 100644 src/components/dashboard/province-manager/TableRowActions.jsx create mode 100644 src/components/dashboard/province-manager/TableTollbar.jsx create mode 100644 src/components/dashboard/province-manager/index.jsx create mode 100644 src/pages/dashboard/province-manager/index.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 7437875..c644b8c 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -23,7 +23,7 @@ "machinary-office": "ماشین آلات", "passenger-boss": "رئیس مسافر (کارگروه استانی)", "transportation-assistance": "معاونت حمل و نقل", - "manager": "مدیر کل", + "province-manager": "مدیر کل استانی", "change-password": "تغییر رمز عبور", "edit-profile": "ویرایش پروفایل" }, @@ -47,8 +47,9 @@ }, "Dashboard": { "dashboard_page": "داشبورد", - "passenger_boss": "رئیس مسافر", + "passenger_boss_page": "رئیس مسافر", "change_password": "تغییر رمز عبور", + "province_manager_page": "مدیر کل استانی", "passenger_office_page": "اداره مسافر", "machinary_office_page": "ماشین آلات", "edit_profile": "ویرایش پروفایل" @@ -103,6 +104,17 @@ "vehicle_type": "نوع ماشین", "state_name": "وضعیت درخواست" }, + "ProvinceManager": { + "name": "نام", + "id": "کد یکتا", + "national_id": "کد ملی", + "phone_number": "موبایل", + "created_at": "تاریخ درخواست", + "updated_at": "تاریخ بروزرسانی", + "navgan_id": "کد ناوگان", + "vehicle_type": "نوع ماشین", + "state_name": "وضعیت درخواست" + }, "PassengerBoss": { "name": "نام", "id": "کد یکتا", diff --git a/src/components/dashboard/province-manager/Form/ConfirmForm.jsx b/src/components/dashboard/province-manager/Form/ConfirmForm.jsx new file mode 100644 index 0000000..b2ef723 --- /dev/null +++ b/src/components/dashboard/province-manager/Form/ConfirmForm.jsx @@ -0,0 +1,128 @@ +import { CONFIRM_PROVINCE_MANAGER } from "@/core/data/apiRoutes"; +import { + Dialog, + DialogTitle, + DialogContent, + DialogContentText, + DialogActions, + Button, + TextField, + FormHelperText, +} from "@mui/material"; +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useRef, useState } from "react"; +const MAX_FILE_SIZE_IN_BYTES = 2 * 1024 * 1024; + +const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { + const t = useTranslations(); + const [description, setDescription] = useState(""); + const [fileData, setFileData] = useState(null); + const inputRef = useRef(null); + + const formik = useFormik({ + initialValues: { + description: "", + fileData: null, + }, + onSubmit: () => { + const formData = new FormData(); + if (description !== "") + formData.append("expert_description", description); + if (fileData !== null) formData.append("file", fileData); + handleClose(); + confirmData(CONFIRM_PROVINCE_MANAGER, rowId, formData); + }, + }); + + const handleUploadClick = () => { + // 👇 We redirect the click event onto the hidden input element + inputRef.current?.click(); + }; + + const handleDescriptionChange = (event) => { + setDescription(event.target.value); + formik.handleChange(event); + }; + + const handleFileChange = (e) => { + const selectedFile = e.target.files[0]; + if (selectedFile) { + const fileSizeInBytes = selectedFile.size; + if (fileSizeInBytes > MAX_FILE_SIZE_IN_BYTES) { + formik.setFieldError( + "fileData", + `File size exceeds the limit (${MAX_FILE_SIZE_IN_BYTES / 1000000} MB)` + ); + e.target.value = null; + } else { + setFileData(selectedFile); + formik.setFieldValue("fileData", selectedFile); + formik.setFieldError("fileData", ""); + } + } + }; + + return ( + + {t("ConfirmDialog.confirm")} + + {t("ConfirmDialog.context")} + +
+ + +
+ + {formik.errors.fileData && formik.errors.fileData} + +
+ + + + +
+ ); +}; +export default ConfirmForm; diff --git a/src/components/dashboard/province-manager/Form/RejectForm.jsx b/src/components/dashboard/province-manager/Form/RejectForm.jsx new file mode 100644 index 0000000..53f3c62 --- /dev/null +++ b/src/components/dashboard/province-manager/Form/RejectForm.jsx @@ -0,0 +1,76 @@ +import { REJECT_PROVINCE_MANAGER } from "@/core/data/apiRoutes"; +import { + Dialog, + DialogTitle, + DialogContent, + DialogContentText, + DialogActions, + Button, + TextField, +} from "@mui/material"; +import { useTranslations } from "next-intl"; +import { useFormik } from "formik"; +import * as Yup from "yup"; +import { useState } from "react"; + +const RejectForm = ({ open, handleClose, rowId, rejectData }) => { + const t = useTranslations(); + const [description, setDescription] = useState(""); + + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("RejectDialog.description_error")), + }); + + const formik = useFormik({ + initialValues: { + description: "", + }, + validationSchema, + onSubmit: () => { + const formData = new FormData(); + formData.append("expert_description", description); + handleClose(); + rejectData(REJECT_PROVINCE_MANAGER, rowId, formData); + }, + }); + + const handleDescriptionChange = (event) => { + setDescription(event.target.value); + formik.handleChange(event); + }; + + return ( + + {t("RejectDialog.reject")} + + {t("RejectDialog.context")} + + + + + + + + ); +}; + +export default RejectForm; diff --git a/src/components/dashboard/province-manager/TableRowActions.jsx b/src/components/dashboard/province-manager/TableRowActions.jsx new file mode 100644 index 0000000..e9e815e --- /dev/null +++ b/src/components/dashboard/province-manager/TableRowActions.jsx @@ -0,0 +1,54 @@ +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"; + +const TableRowActions = ({ row }) => { + const { + openConfirmDialog, + openRejectDialog, + handleOpenConfirmDialog, + handleOpenRejectDialog, + handleCloseConfirmDialog, + handleCloseRejectDialog, + rowId, + confirmData, + rejectData, + } = useContext(DataTableContext); + return ( + + { + handleOpenConfirmDialog(row); + }} + > + + + {openConfirmDialog && ( + + )} + handleOpenRejectDialog(row)}> + + + {openRejectDialog && ( + + )} + + ); +}; + +export default TableRowActions; diff --git a/src/components/dashboard/province-manager/TableTollbar.jsx b/src/components/dashboard/province-manager/TableTollbar.jsx new file mode 100644 index 0000000..3f06d3b --- /dev/null +++ b/src/components/dashboard/province-manager/TableTollbar.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/province-manager/index.jsx b/src/components/dashboard/province-manager/index.jsx new file mode 100644 index 0000000..fed9e47 --- /dev/null +++ b/src/components/dashboard/province-manager/index.jsx @@ -0,0 +1,218 @@ +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_PROVINCE_MANAGER } from "@/core/data/apiRoutes"; +import { useTranslations } from "next-intl"; +import TableRowActions from "./TableRowActions"; +import { format } from "date-fns-jalali"; +import { + LocalizationProvider, + MobileDateTimePicker, +} from "@mui/x-date-pickers"; +import { AdapterDateFnsJalali } from "@mui/x-date-pickers/AdapterDateFnsJalali"; +import moment from "moment"; + +function DashboardProvinceManagerComponent() { + const t = useTranslations(); + + const columns = useMemo( + () => [ + { + accessorFn: (row) => row.id, + id: "id", + header: t("ProvinceManager.id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.name, + id: "name", + header: t("ProvinceManager.name"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.national_id, + id: "national_id", + header: t("ProvinceManager.national_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("ProvinceManager.phone_number"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => + format(new Date(row.created_at), "HH:mm | yyyy/mm/dd"), + id: "created_at", + header: t("ProvinceManager.created_at"), + enableColumnFilter: true, + datatype: "date", + filterFn: "lessThan", + columnFilterModeOptions: ["lessThan", "greaterThan"], + Cell: ({ renderedCellValue }) => { + return ( + + {renderedCellValue} + + ); + }, + Header: ({ column }) => {column.columnDef.header}, + Filter: ({ column }) => { + return ( + + { + const date = new Date(newValue); + const formattedDate = moment(date) + .locale("en") + .format("YYYY-MM-DD HH:mm"); + column.setFilterValue(formattedDate); + }} + slotProps={{ + textField: { + helperText: `Filter Mode: ${column.columnDef._filterFn}`, + sx: { minWidth: "120px" }, + variant: "standard", + }, + }} + value={moment(column.getFilterValue()) + .locale("fa") + .format("yyyy/mm/dd HH:mm")} + /> + + ); + }, + }, + { + accessorFn: (row) => + format(new Date(row.updated_at), "HH:mm | yyyy/mm/dd"), + id: "updated_at", + header: t("ProvinceManager.updated_at"), + enableColumnFilter: false, + datatype: "numeric", + Cell: ({ renderedCellValue }) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.navgan_id, + id: "navgan_id", + header: t("ProvinceManager.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("ProvinceManager.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("ProvinceManager.state_name"), + enableColumnFilter: false, + datatype: "numeric", + // filterFn: "equals", + // filterSelectOptions: [ + // ], + // 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 DashboardProvinceManagerComponent; diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index eb28399..2c84765 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -55,3 +55,14 @@ export const CONFIRM_MACHINARY_OFFICE = export const REJECT_MACHINARY_OFFICE = BASE_URL + "/dashboard/machinery_expert/reject"; //passenger office + +//province manager +export const GET_PROVINCE_MANAGER = + BASE_URL + "/dashboard/province_manager/show"; + +export const CONFIRM_PROVINCE_MANAGER = + BASE_URL + "/dashboard/province_manager/confirm"; + +export const REJECT_PROVINCE_MANAGER = + BASE_URL + "/dashboard/province_manager/reject"; +//province manager diff --git a/src/core/data/sidebarMenu.jsx b/src/core/data/sidebarMenu.jsx index cf2aacb..f452edf 100644 --- a/src/core/data/sidebarMenu.jsx +++ b/src/core/data/sidebarMenu.jsx @@ -47,12 +47,12 @@ const sidebarMenu = [ role: "transportation-assistance", }, { - key: "sidebar.manager", + key: "sidebar.province-manager", type: "page", - route: "/dashboard/manager", + route: "/dashboard/province-manager", icon: , selected: false, - role: "manager", + role: "province-manager", }, ], ]; diff --git a/src/pages/dashboard/passenger-boss/index.jsx b/src/pages/dashboard/passenger-boss/index.jsx index 961d766..ea0566a 100644 --- a/src/pages/dashboard/passenger-boss/index.jsx +++ b/src/pages/dashboard/passenger-boss/index.jsx @@ -6,7 +6,7 @@ import { parse } from "next-useragent"; export default function PassengerBoss() { return ( - + ); diff --git a/src/pages/dashboard/province-manager/index.jsx b/src/pages/dashboard/province-manager/index.jsx new file mode 100644 index 0000000..7fbc181 --- /dev/null +++ b/src/pages/dashboard/province-manager/index.jsx @@ -0,0 +1,23 @@ +import DashboardProvinceManagerComponent from "@/components/dashboard/province-manager"; +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, + }, + }; +} From 3bf90a3f60a2bb2158317a443775c68d07f7babb Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Wed, 19 Jul 2023 12:59:33 +0330 Subject: [PATCH 056/134] style data base --- src/components/dashboard/machinary-office/index.jsx | 9 ++++----- src/components/dashboard/passenger-boss/index.jsx | 9 ++++----- src/components/dashboard/passenger-office/index.jsx | 9 ++++----- src/components/dashboard/province-manager/index.jsx | 9 ++++----- .../dashboard/transportation-assistance/index.jsx | 7 ++++--- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/components/dashboard/machinary-office/index.jsx b/src/components/dashboard/machinary-office/index.jsx index 44b2a79..12a6316 100644 --- a/src/components/dashboard/machinary-office/index.jsx +++ b/src/components/dashboard/machinary-office/index.jsx @@ -24,6 +24,7 @@ function DashboardMachinaryOfficeComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", + maxSize: 100, columnFilterModeOptions: [ "equals", "notEquals", @@ -94,13 +95,10 @@ function DashboardMachinaryOfficeComponent() { enableColumnFilter: true, datatype: "date", filterFn: "lessThan", + minSize: 200, columnFilterModeOptions: ["lessThan", "greaterThan"], Cell: ({ renderedCellValue }) => { - return ( - - {renderedCellValue} - - ); + return {renderedCellValue}; }, Header: ({ column }) => {column.columnDef.header}, Filter: ({ column }) => { @@ -147,6 +145,7 @@ function DashboardMachinaryOfficeComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", + maxSize: 100, columnFilterModeOptions: [ "equals", "notEquals", diff --git a/src/components/dashboard/passenger-boss/index.jsx b/src/components/dashboard/passenger-boss/index.jsx index c39322d..444e405 100644 --- a/src/components/dashboard/passenger-boss/index.jsx +++ b/src/components/dashboard/passenger-boss/index.jsx @@ -26,6 +26,7 @@ function DashboardPassengerOfficeComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", + maxSize: 100, columnFilterModeOptions: [ "equals", "notEquals", @@ -96,13 +97,10 @@ function DashboardPassengerOfficeComponent() { enableColumnFilter: true, datatype: "date", filterFn: "lessThan", + minSize: 200, columnFilterModeOptions: ["lessThan", "greaterThan"], Cell: ({ renderedCellValue }) => { - return ( - - {renderedCellValue} - - ); + return {renderedCellValue}; }, Header: ({ column }) => {column.columnDef.header}, Filter: ({ column }) => { @@ -149,6 +147,7 @@ function DashboardPassengerOfficeComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", + maxSize: 100, columnFilterModeOptions: [ "equals", "notEquals", diff --git a/src/components/dashboard/passenger-office/index.jsx b/src/components/dashboard/passenger-office/index.jsx index 0452e08..2694501 100644 --- a/src/components/dashboard/passenger-office/index.jsx +++ b/src/components/dashboard/passenger-office/index.jsx @@ -25,6 +25,7 @@ function DashboardPassengerOfficeComponent() { header: t("PassengerOffice.id"), enableColumnFilter: true, datatype: "numeric", + maxSize: 100, filterFn: "equals", columnFilterModeOptions: [ "equals", @@ -96,13 +97,10 @@ function DashboardPassengerOfficeComponent() { enableColumnFilter: true, datatype: "date", filterFn: "lessThan", + minSize: 200, columnFilterModeOptions: ["lessThan", "greaterThan"], Cell: ({ renderedCellValue }) => { - return ( - - {renderedCellValue} - - ); + return {renderedCellValue}; }, Header: ({ column }) => {column.columnDef.header}, Filter: ({ column }) => { @@ -148,6 +146,7 @@ function DashboardPassengerOfficeComponent() { header: t("PassengerOffice.navgan_id"), enableColumnFilter: true, datatype: "numeric", + maxSize: 100, filterFn: "equals", columnFilterModeOptions: [ "equals", diff --git a/src/components/dashboard/province-manager/index.jsx b/src/components/dashboard/province-manager/index.jsx index fed9e47..71d2e96 100644 --- a/src/components/dashboard/province-manager/index.jsx +++ b/src/components/dashboard/province-manager/index.jsx @@ -26,6 +26,7 @@ function DashboardProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", + maxSize: 100, columnFilterModeOptions: [ "equals", "notEquals", @@ -96,13 +97,10 @@ function DashboardProvinceManagerComponent() { enableColumnFilter: true, datatype: "date", filterFn: "lessThan", + minSize: 200, columnFilterModeOptions: ["lessThan", "greaterThan"], Cell: ({ renderedCellValue }) => { - return ( - - {renderedCellValue} - - ); + return {renderedCellValue}; }, Header: ({ column }) => {column.columnDef.header}, Filter: ({ column }) => { @@ -149,6 +147,7 @@ function DashboardProvinceManagerComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", + maxSize: 100, columnFilterModeOptions: [ "equals", "notEquals", diff --git a/src/components/dashboard/transportation-assistance/index.jsx b/src/components/dashboard/transportation-assistance/index.jsx index 3b6b630..0984d8b 100644 --- a/src/components/dashboard/transportation-assistance/index.jsx +++ b/src/components/dashboard/transportation-assistance/index.jsx @@ -24,6 +24,7 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", + maxSize: 100, columnFilterModeOptions: [ "equals", "notEquals", @@ -94,12 +95,11 @@ function DashboardTransportationAssistanceComponent() { header: t("TransportationAssistance.created_at"), enableColumnFilter: true, datatype: "date", + minSize: 200, filterFn: "lessThan", columnFilterModeOptions: ["lessThan", "greaterThan"], Cell: ({ renderedCellValue }) => ( - - {renderedCellValue} - + {renderedCellValue} ), Header: ({ column }) => {column.columnDef.header}, Filter: ({ column }) => { @@ -146,6 +146,7 @@ function DashboardTransportationAssistanceComponent() { enableColumnFilter: true, datatype: "numeric", filterFn: "equals", + maxSize: 100, columnFilterModeOptions: [ "equals", "notEquals", From 34c27ebfd25e883b4448480417b9ed6db0b6d088 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Wed, 19 Jul 2023 13:29:36 +0330 Subject: [PATCH 057/134] delete logs --- src/core/components/Datatable.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/components/Datatable.jsx b/src/core/components/Datatable.jsx index 04be089..2d34ece 100644 --- a/src/core/components/Datatable.jsx +++ b/src/core/components/Datatable.jsx @@ -44,7 +44,6 @@ const DataTable = (props) => { const [sorting, setSorting] = useState([]); const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 }); const [rowCount, setRowCount] = useState(0); - console.log(moment()); const [updateTime, setupdateTime] = useState( moment().format("HH:mm | jYYYY/jM/jD") ); From 8104f94b9e6d5956a5b9f5beb08503517fdc4c5f Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Wed, 19 Jul 2023 14:39:34 +0330 Subject: [PATCH 058/134] sidebar_permission --- public/locales/fa/app.json | 8 +++-- src/core/components/Datatable.jsx | 1 - src/core/data/sidebarMenu.jsx | 13 +++++--- .../dashboardLayouts/sidebar/SidebarList.jsx | 31 ++++++++++--------- .../sidebar/SidebarListItem.jsx | 12 ++++++- 5 files changed, 41 insertions(+), 24 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 7437875..2c923be 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -19,14 +19,18 @@ }, "sidebar": { "dashboard": "داشبورد", - "passenger-office": "اداره مسافر (توزیع درخواست)", + "passenger-office": "اداره مسافر", "machinary-office": "ماشین آلات", - "passenger-boss": "رئیس مسافر (کارگروه استانی)", + "passenger-boss": "رئیس مسافر ", "transportation-assistance": "معاونت حمل و نقل", "manager": "مدیر کل", "change-password": "تغییر رمز عبور", "edit-profile": "ویرایش پروفایل" }, + "secondary": { + "passenger-office": "توزیع درخواست", + "passenger-boss": "کارگروه استانی" + }, "Authorization": { "typography_your_login_is_valid_and_you_do_not_need_to_login_again": "شما دسترسی لازم به این صفحه را دارید نیاز به ورود مجدد نیست.", "typography_your_access_to_this_page_has_expired_Please_login_again": "دسترسی شما منقضی شده است لطفا دوباره ورود نمایید.", diff --git a/src/core/components/Datatable.jsx b/src/core/components/Datatable.jsx index 04be089..2d34ece 100644 --- a/src/core/components/Datatable.jsx +++ b/src/core/components/Datatable.jsx @@ -44,7 +44,6 @@ const DataTable = (props) => { const [sorting, setSorting] = useState([]); const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 }); const [rowCount, setRowCount] = useState(0); - console.log(moment()); const [updateTime, setupdateTime] = useState( moment().format("HH:mm | jYYYY/jM/jD") ); diff --git a/src/core/data/sidebarMenu.jsx b/src/core/data/sidebarMenu.jsx index cf2aacb..26fa92b 100644 --- a/src/core/data/sidebarMenu.jsx +++ b/src/core/data/sidebarMenu.jsx @@ -13,14 +13,16 @@ const sidebarMenu = [ route: "/dashboard", icon: , selected: false, + role: "all", }, { key: "sidebar.passenger-office", + secondary: "secondary.passenger-office", type: "page", route: "/dashboard/passenger-office", icon: , selected: false, - role: "passenger-office", + role: "passenger_office_chief", }, { key: "sidebar.machinary-office", @@ -28,15 +30,16 @@ const sidebarMenu = [ route: "/dashboard/machinary-office", icon: , selected: false, - role: "machinary-office", + role: "machinery_expert", }, { key: "sidebar.passenger-boss", + secondary: "secondary.passenger-boss", type: "page", route: "/dashboard/passenger-boss", icon: , selected: false, - role: "passenger-boss", + role: "passenger_office_chief", }, { key: "sidebar.transportation-assistance", @@ -44,7 +47,7 @@ const sidebarMenu = [ route: "/dashboard/transportation-assistance", icon: , selected: false, - role: "transportation-assistance", + role: "transportation_assistant", }, { key: "sidebar.manager", @@ -52,7 +55,7 @@ const sidebarMenu = [ route: "/dashboard/manager", icon: , selected: false, - role: "manager", + role: "province_manager", }, ], ]; diff --git a/src/layouts/dashboardLayouts/sidebar/SidebarList.jsx b/src/layouts/dashboardLayouts/sidebar/SidebarList.jsx index 79dd93e..c47cf2b 100644 --- a/src/layouts/dashboardLayouts/sidebar/SidebarList.jsx +++ b/src/layouts/dashboardLayouts/sidebar/SidebarList.jsx @@ -1,8 +1,9 @@ import { Divider, List } from "@mui/material"; -import { Fragment, useEffect, useReducer } from "react"; +import { useEffect, useReducer } from "react"; import SidebarListItem from "./SidebarListItem"; import sidebarMenu from "@/core/data/sidebarMenu"; import { useRouter } from "next/router"; +import useUser from "@/lib/app/hooks/useUser"; function reducer(state, action) { switch (action.type) { @@ -29,28 +30,28 @@ function reducer(state, action) { export default function SidebarList({ handleDrawerToggle }) { const [itemMenu, dispatch] = useReducer(reducer, sidebarMenu); - - // activate current page in menu + const { user } = useUser(); const router = useRouter(); + useEffect(() => { dispatch({ type: "SELECTED", route: router.pathname }); }, [router.pathname]); + const filteredItemMenu = itemMenu[0].filter( + (item) => user.role.includes(item.role) || item.role === "all" + ); + return ( - {itemMenu.map((itemArr, index) => ( - - {itemArr.map((item) => ( - - ))} - - + {filteredItemMenu.map((item, index) => ( + ))} + {filteredItemMenu.length > 0 && } ); } diff --git a/src/layouts/dashboardLayouts/sidebar/SidebarListItem.jsx b/src/layouts/dashboardLayouts/sidebar/SidebarListItem.jsx index ba270a5..8d56ad0 100644 --- a/src/layouts/dashboardLayouts/sidebar/SidebarListItem.jsx +++ b/src/layouts/dashboardLayouts/sidebar/SidebarListItem.jsx @@ -6,6 +6,7 @@ import { ListItemButton, ListItemIcon, ListItemText, + Typography, } from "@mui/material"; import { useTranslations } from "next-intl"; import { Fragment } from "react"; @@ -45,7 +46,16 @@ const SidebarListItem = ({ item, dispatch, handleDrawerToggle }) => { > {item.icon} - + + {t(item.secondary)} + + ) : null + } + /> {item.type == "menu" && (item.showSubItem ? : )} From 520581a8e4cf525f8b868914737e22b1644833d7 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Sat, 22 Jul 2023 14:35:19 +0330 Subject: [PATCH 059/134] translate datepicker filter status --- public/locales/fa/app.json | 5 +++++ src/components/dashboard/passenger-office/index.jsx | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index bf81001..0fb31db 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -7,6 +7,11 @@ "login_expert": "ورود کارشناس", "expert": "کارشناس", "last_updated_at": "اخرین بروز رسانی", + "filter_mode": "حالت فیلتر", + "date_picker_label": "فیلتر بر اساس تاریخ", + "lessThan": "کوچکتر از", + "greaterThan": "بزرگتر از", + "between": "میان", "header": { "open_profile": "پروفایل", "edit_profile": "ویرایش پروفایل", diff --git a/src/components/dashboard/passenger-office/index.jsx b/src/components/dashboard/passenger-office/index.jsx index 2694501..a85faaf 100644 --- a/src/components/dashboard/passenger-office/index.jsx +++ b/src/components/dashboard/passenger-office/index.jsx @@ -104,6 +104,7 @@ function DashboardPassengerOfficeComponent() { }, Header: ({ column }) => {column.columnDef.header}, Filter: ({ column }) => { + const filterFnValue = column.columnDef._filterFn; return ( Date: Sat, 22 Jul 2023 14:44:41 +0330 Subject: [PATCH 060/134] add minSize tooltip and delete handleClose --- public/locales/fa/app.json | 1 + .../machinary-office/Form/ConfirmForm.jsx | 8 ++-- .../machinary-office/Form/RejectForm.jsx | 8 ++-- .../machinary-office/TableRowActions.jsx | 30 +++++++------ .../dashboard/machinary-office/index.jsx | 1 + .../passenger-boss/Form/ConfirmForm.jsx | 8 ++-- .../passenger-boss/Form/RejectForm.jsx | 8 ++-- .../passenger-boss/TableRowActions.jsx | 30 +++++++------ .../dashboard/passenger-boss/index.jsx | 1 + .../passenger-office/Form/ConfirmForm.jsx | 8 ++-- .../passenger-office/Form/RejectForm.jsx | 8 ++-- .../passenger-office/TableRowActions.jsx | 30 +++++++------ .../dashboard/passenger-office/index.jsx | 1 + .../province-manager/Form/ConfirmForm.jsx | 8 ++-- .../province-manager/Form/RejectForm.jsx | 8 ++-- .../province-manager/TableRowActions.jsx | 30 +++++++------ .../dashboard/province-manager/index.jsx | 1 + .../Form/ConfirmForm.jsx | 42 +++++++++++++++---- .../Form/RejectForm.jsx | 8 ++-- .../TableRowActions.jsx | 31 ++++++++------ .../transportation-assistance/index.jsx | 1 + src/core/utils/theme.jsx | 9 ++++ .../transportation-assistance/index.jsx | 2 +- 23 files changed, 178 insertions(+), 104 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index bf81001..b0373e7 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -52,6 +52,7 @@ "Dashboard": { "dashboard_page": "داشبورد", "passenger_boss_page": "رئیس مسافر", + "transportation_assistance": "معاونت حمل و نقل", "change_password": "تغییر رمز عبور", "province_manager_page": "مدیر کل استانی", "passenger_office_page": "اداره مسافر", diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx index 55ae682..08e21b6 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx @@ -48,7 +48,7 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { }; return ( - + {t("ConfirmDialog.confirm")} {t("ConfirmDialog.context")} @@ -88,12 +88,12 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { /> - + ); diff --git a/src/components/dashboard/machinary-office/Form/RejectForm.jsx b/src/components/dashboard/machinary-office/Form/RejectForm.jsx index 723f9a6..8b6192f 100644 --- a/src/components/dashboard/machinary-office/Form/RejectForm.jsx +++ b/src/components/dashboard/machinary-office/Form/RejectForm.jsx @@ -40,7 +40,7 @@ const RejectForm = ({ open, handleClose, rowId, rejectData }) => { }; return ( - + {t("RejectDialog.reject")} {t("RejectDialog.context")} @@ -62,12 +62,12 @@ const RejectForm = ({ open, handleClose, rowId, rejectData }) => { /> - + ); diff --git a/src/components/dashboard/machinary-office/TableRowActions.jsx b/src/components/dashboard/machinary-office/TableRowActions.jsx index e9e815e..c7ee618 100644 --- a/src/components/dashboard/machinary-office/TableRowActions.jsx +++ b/src/components/dashboard/machinary-office/TableRowActions.jsx @@ -1,12 +1,14 @@ import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import { Box, IconButton } from "@mui/material"; +import { Box, IconButton, Tooltip } 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 { useTranslations } from "next-intl"; const TableRowActions = ({ row }) => { + const t = useTranslations(); const { openConfirmDialog, openRejectDialog, @@ -20,14 +22,16 @@ const TableRowActions = ({ row }) => { } = useContext(DataTableContext); return ( - { - handleOpenConfirmDialog(row); - }} - > - - + + { + handleOpenConfirmDialog(row); + }} + > + + + {openConfirmDialog && ( { confirmData={confirmData} /> )} - handleOpenRejectDialog(row)}> - - + + handleOpenRejectDialog(row)}> + + + {openRejectDialog && ( { }; return ( - + {t("ConfirmDialog.confirm")} {t("ConfirmDialog.context")} @@ -90,12 +90,12 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { /> - + ); diff --git a/src/components/dashboard/passenger-boss/Form/RejectForm.jsx b/src/components/dashboard/passenger-boss/Form/RejectForm.jsx index 18a48a7..e163b5f 100644 --- a/src/components/dashboard/passenger-boss/Form/RejectForm.jsx +++ b/src/components/dashboard/passenger-boss/Form/RejectForm.jsx @@ -40,7 +40,7 @@ const RejectForm = ({ open, handleClose, rowId, rejectData }) => { }; return ( - + {t("RejectDialog.reject")} {t("RejectDialog.context")} @@ -62,12 +62,12 @@ const RejectForm = ({ open, handleClose, rowId, rejectData }) => { /> - + ); diff --git a/src/components/dashboard/passenger-boss/TableRowActions.jsx b/src/components/dashboard/passenger-boss/TableRowActions.jsx index e9e815e..c7ee618 100644 --- a/src/components/dashboard/passenger-boss/TableRowActions.jsx +++ b/src/components/dashboard/passenger-boss/TableRowActions.jsx @@ -1,12 +1,14 @@ import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import { Box, IconButton } from "@mui/material"; +import { Box, IconButton, Tooltip } 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 { useTranslations } from "next-intl"; const TableRowActions = ({ row }) => { + const t = useTranslations(); const { openConfirmDialog, openRejectDialog, @@ -20,14 +22,16 @@ const TableRowActions = ({ row }) => { } = useContext(DataTableContext); return ( - { - handleOpenConfirmDialog(row); - }} - > - - + + { + handleOpenConfirmDialog(row); + }} + > + + + {openConfirmDialog && ( { confirmData={confirmData} /> )} - handleOpenRejectDialog(row)}> - - + + handleOpenRejectDialog(row)}> + + + {openRejectDialog && ( { }; return ( - + {t("ConfirmDialog.confirm")} {t("ConfirmDialog.context")} @@ -115,12 +115,12 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { - + ); diff --git a/src/components/dashboard/passenger-office/Form/RejectForm.jsx b/src/components/dashboard/passenger-office/Form/RejectForm.jsx index 149c480..6840f7c 100644 --- a/src/components/dashboard/passenger-office/Form/RejectForm.jsx +++ b/src/components/dashboard/passenger-office/Form/RejectForm.jsx @@ -40,7 +40,7 @@ const RejectForm = ({ open, handleClose, rowId, rejectData }) => { }; return ( - + {t("RejectDialog.reject")} {t("RejectDialog.context")} @@ -62,12 +62,12 @@ const RejectForm = ({ open, handleClose, rowId, rejectData }) => { /> - + ); diff --git a/src/components/dashboard/passenger-office/TableRowActions.jsx b/src/components/dashboard/passenger-office/TableRowActions.jsx index e9e815e..c7ee618 100644 --- a/src/components/dashboard/passenger-office/TableRowActions.jsx +++ b/src/components/dashboard/passenger-office/TableRowActions.jsx @@ -1,12 +1,14 @@ import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import { Box, IconButton } from "@mui/material"; +import { Box, IconButton, Tooltip } 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 { useTranslations } from "next-intl"; const TableRowActions = ({ row }) => { + const t = useTranslations(); const { openConfirmDialog, openRejectDialog, @@ -20,14 +22,16 @@ const TableRowActions = ({ row }) => { } = useContext(DataTableContext); return ( - { - handleOpenConfirmDialog(row); - }} - > - - + + { + handleOpenConfirmDialog(row); + }} + > + + + {openConfirmDialog && ( { confirmData={confirmData} /> )} - handleOpenRejectDialog(row)}> - - + + handleOpenRejectDialog(row)}> + + + {openRejectDialog && ( { }; return ( - + {t("ConfirmDialog.confirm")} {t("ConfirmDialog.context")} @@ -115,12 +115,12 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { - + ); diff --git a/src/components/dashboard/province-manager/Form/RejectForm.jsx b/src/components/dashboard/province-manager/Form/RejectForm.jsx index 53f3c62..4cd56a5 100644 --- a/src/components/dashboard/province-manager/Form/RejectForm.jsx +++ b/src/components/dashboard/province-manager/Form/RejectForm.jsx @@ -40,7 +40,7 @@ const RejectForm = ({ open, handleClose, rowId, rejectData }) => { }; return ( - + {t("RejectDialog.reject")} {t("RejectDialog.context")} @@ -62,12 +62,12 @@ const RejectForm = ({ open, handleClose, rowId, rejectData }) => { /> - + ); diff --git a/src/components/dashboard/province-manager/TableRowActions.jsx b/src/components/dashboard/province-manager/TableRowActions.jsx index e9e815e..c7ee618 100644 --- a/src/components/dashboard/province-manager/TableRowActions.jsx +++ b/src/components/dashboard/province-manager/TableRowActions.jsx @@ -1,12 +1,14 @@ import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import { Box, IconButton } from "@mui/material"; +import { Box, IconButton, Tooltip } 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 { useTranslations } from "next-intl"; const TableRowActions = ({ row }) => { + const t = useTranslations(); const { openConfirmDialog, openRejectDialog, @@ -20,14 +22,16 @@ const TableRowActions = ({ row }) => { } = useContext(DataTableContext); return ( - { - handleOpenConfirmDialog(row); - }} - > - - + + { + handleOpenConfirmDialog(row); + }} + > + + + {openConfirmDialog && ( { confirmData={confirmData} /> )} - handleOpenRejectDialog(row)}> - - + + handleOpenRejectDialog(row)}> + + + {openRejectDialog && ( { const t = useTranslations(); - const handleConfirm = () => { - handleClose(); - confirmData(CONFIRM_TRANSPORTATION_ASSISTANCE, rowId); + const [description, setDescription] = useState(""); + + const formik = useFormik({ + initialValues: { + description: "", + }, + onSubmit: () => { + const formData = new FormData(); + if (description != "") formData.append("expert_description", description); + handleClose(); + confirmData(CONFIRM_TRANSPORTATION_ASSISTANCE, rowId, formData); + }, + }); + + const handleDescriptionChange = (event) => { + setDescription(event.target.value); }; + return ( - + {t("ConfirmDialog.confirm")} {t("ConfirmDialog.context")} + - + ); diff --git a/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx b/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx index 262f9db..1bd1464 100644 --- a/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx +++ b/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx @@ -40,7 +40,7 @@ const RejectForm = ({ open, handleClose, rowId, rejectData }) => { }; return ( - + {t("RejectDialog.reject")} {t("RejectDialog.context")} @@ -62,12 +62,12 @@ const RejectForm = ({ open, handleClose, rowId, rejectData }) => { /> - + ); diff --git a/src/components/dashboard/transportation-assistance/TableRowActions.jsx b/src/components/dashboard/transportation-assistance/TableRowActions.jsx index e9e815e..ccd5bde 100644 --- a/src/components/dashboard/transportation-assistance/TableRowActions.jsx +++ b/src/components/dashboard/transportation-assistance/TableRowActions.jsx @@ -1,12 +1,15 @@ import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import { Box, IconButton } from "@mui/material"; +import { Box, IconButton, Tooltip } 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 { useTranslations } from "next-intl"; const TableRowActions = ({ row }) => { + const t = useTranslations(); + const { openConfirmDialog, openRejectDialog, @@ -20,14 +23,16 @@ const TableRowActions = ({ row }) => { } = useContext(DataTableContext); return ( - { - handleOpenConfirmDialog(row); - }} - > - - + + { + handleOpenConfirmDialog(row); + }} + > + + + {openConfirmDialog && ( { confirmData={confirmData} /> )} - handleOpenRejectDialog(row)}> - - + + handleOpenRejectDialog(row)}> + + + {openRejectDialog && ( - + ); From 3f43bf9f4ac4186a1668b57811a0344315467cf1 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Sat, 22 Jul 2023 15:26:57 +0330 Subject: [PATCH 061/134] warning notification --- .../notifications/WarningNotification.jsx | 41 +++++++++++++++++++ src/core/components/notifications/index.jsx | 1 + 2 files changed, 42 insertions(+) create mode 100644 src/core/components/notifications/WarningNotification.jsx diff --git a/src/core/components/notifications/WarningNotification.jsx b/src/core/components/notifications/WarningNotification.jsx new file mode 100644 index 0000000..1451031 --- /dev/null +++ b/src/core/components/notifications/WarningNotification.jsx @@ -0,0 +1,41 @@ +import ReportIcon from "@mui/icons-material/Report"; +import { Box, Divider, Typography } from "@mui/material"; +import { toast } from "react-toastify"; + +const WarningNotification = (directionApp, t, status) => { + toast( + ({ closeToast }) => ( + <> + + + + + + {t("warning")} ({t("code")}: {status}) + + + {t("warning_static_text")} + + + + + + + ), + { + position: directionApp === "ltr" ? "top-left" : "top-right", + autoClose: false, + closeOnClick: false, + draggable: false, + } + ); +}; + +export default WarningNotification; diff --git a/src/core/components/notifications/index.jsx b/src/core/components/notifications/index.jsx index f9eb82c..ddef384 100644 --- a/src/core/components/notifications/index.jsx +++ b/src/core/components/notifications/index.jsx @@ -1,4 +1,5 @@ import ErrorNotification from "./ErrorNotification"; +import WarningNotification from "./WarningNotification"; import SuccessNotification from "./successNotification"; const Notifications = async (directionApp, response, t) => { From cd51ee14ab398e4f520b8d062e2f1b04a3055b4c Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Sat, 22 Jul 2023 15:51:44 +0330 Subject: [PATCH 062/134] upload_file --- public/locales/fa/app.json | 8 + .../machinary-office/Form/ConfirmForm.jsx | 30 ++++ .../machinary-office/Form/RejectForm.jsx | 31 ++++ .../passenger-boss/Form/ConfirmForm.jsx | 30 ++++ .../passenger-boss/Form/RejectForm.jsx | 31 ++++ .../passenger-office/Form/ConfirmForm.jsx | 84 ++++------ .../passenger-office/Form/RejectForm.jsx | 33 +++- .../province-manager/Form/ConfirmForm.jsx | 84 ++++------ .../province-manager/Form/RejectForm.jsx | 30 ++++ .../Form/RejectForm.jsx | 31 +++- src/core/components/UploadSystem.jsx | 154 ++++++++++++++++++ 11 files changed, 434 insertions(+), 112 deletions(-) create mode 100644 src/core/components/UploadSystem.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index bf81001..2a80338 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -172,5 +172,13 @@ "button-cancel": "بستن", "description": "توضیحات", "description_error": "وارد کردن توضیحات الزامی است!" + }, + "UploadSystem": { + "upload_file": "آپلود فایل", + "delete": "پاک کردن", + "button-reject": "عدم تایید", + "button-cancel": "بستن", + "description": "توضیحات", + "description_error": "وارد کردن توضیحات الزامی است!" } } diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx index 55ae682..d5d415b 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx @@ -12,11 +12,16 @@ import { useTranslations } from "next-intl"; import { useState } from "react"; import { useFormik } from "formik"; import * as Yup from "yup"; +import UploadSystem from "@/core/components/UploadSystem"; const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const t = useTranslations(); const [proposedAmount, setProposedAmount] = useState(""); const [description, setDescription] = useState(""); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); //formik const validationSchema = Yup.object().shape({ @@ -47,6 +52,18 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { formik.handleChange(event); }; + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const fileType = event.target?.files?.[0].type; + const fileName = event.target?.files?.[0].name; + setSelectedImage(URL.createObjectURL(uploadedFile)); + setfileType(fileType); + setfileName(fileName); + formik.setFieldValue("confirm_img", uploadedFile); + setShowAddIcon(false); + } + }; return ( {t("ConfirmDialog.confirm")} @@ -86,6 +103,19 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { sx={{ mt: 1 }} fullWidth /> + - - - - - {formik.errors.fileData && formik.errors.fileData} - + - - - - - {formik.errors.fileData && formik.errors.fileData} - + + + + )} + + + ); +}; + +export default UploadSystem; From 1039d61605bd50b9ae609a9dc9055e389c8aef41 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Sat, 22 Jul 2023 16:32:26 +0330 Subject: [PATCH 063/134] show username under avatar --- src/layouts/dashboardLayouts/header/ProfileData.jsx | 4 ++-- src/layouts/dashboardLayouts/header/ProfileMenu.jsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/layouts/dashboardLayouts/header/ProfileData.jsx b/src/layouts/dashboardLayouts/header/ProfileData.jsx index c3fdf58..e07dba6 100644 --- a/src/layouts/dashboardLayouts/header/ProfileData.jsx +++ b/src/layouts/dashboardLayouts/header/ProfileData.jsx @@ -8,10 +8,10 @@ export default function ProfileData() { - {user.user_username} + {user.username} ); diff --git a/src/layouts/dashboardLayouts/header/ProfileMenu.jsx b/src/layouts/dashboardLayouts/header/ProfileMenu.jsx index 50f34db..1c53ef5 100644 --- a/src/layouts/dashboardLayouts/header/ProfileMenu.jsx +++ b/src/layouts/dashboardLayouts/header/ProfileMenu.jsx @@ -29,7 +29,7 @@ function ProfileMenu() { color: "primary.main", }} alt="User Image" - src={user.user_avatar} + src={user.avatar} />
From f4f304115725b9623dd1afc024ce67a110c017af Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Sat, 22 Jul 2023 17:01:54 +0330 Subject: [PATCH 064/134] clear search of date from datatable --- .../dashboard/passenger-office/index.jsx | 54 +++++++++++-------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/src/components/dashboard/passenger-office/index.jsx b/src/components/dashboard/passenger-office/index.jsx index a85faaf..e6643b3 100644 --- a/src/components/dashboard/passenger-office/index.jsx +++ b/src/components/dashboard/passenger-office/index.jsx @@ -1,6 +1,7 @@ import DataTableStructure from "@/core/components/DatatableStructure"; import DashboardLayouts from "@/layouts/dashboardLayouts"; -import { Box, Typography } from "@mui/material"; +import { Box, IconButton, Typography } from "@mui/material"; +import ClearIcon from "@mui/icons-material/Clear"; import { useMemo } from "react"; // import TableToolbar from "./TableTollbar"; import { GET_PASSENGER_OFFICE } from "@/core/data/apiRoutes"; @@ -106,27 +107,38 @@ function DashboardPassengerOfficeComponent() { Filter: ({ column }) => { const filterFnValue = column.columnDef._filterFn; return ( - - { - const date = new Date(newValue); - const formattedDate = moment(date) - .locale("en") - .format("YYYY-MM-DD HH:mm"); - column.setFilterValue(formattedDate); + + + { + const date = new Date(newValue); + const formattedDate = moment(date) + .locale("en") + .format("YYYY-MM-DD HH:mm"); + column.setFilterValue(formattedDate); + }} + slotProps={{ + textField: { + helperText: `${t("filter_mode")}: ${t(filterFnValue)}`, + sx: { minWidth: "120px" }, + variant: "standard", + }, + }} + value={moment(column.getFilterValue()) + .locale("fa") + .format("yyyy/mm/dd HH:mm")} + /> + + { + column.setFilterValue(null); }} - slotProps={{ - textField: { - helperText: `${t("filter_mode")}: ${t(filterFnValue)}`, - sx: { minWidth: "120px" }, - variant: "standard", - }, - }} - value={moment(column.getFilterValue()) - .locale("fa") - .format("yyyy/mm/dd HH:mm")} - /> - + color="rgba(0, 0, 0, 0.54)" + > + +
+
); }, }, From 8866cbc52fbb69141a4c86daab91c69689060e0f Mon Sep 17 00:00:00 2001 From: Yasiu1376 Date: Sat, 22 Jul 2023 17:26:19 +0330 Subject: [PATCH 065/134] upload file --- public/locales/fa/app.json | 5 +-- .../machinary-office/Form/ConfirmForm.jsx | 8 ++++ .../machinary-office/Form/RejectForm.jsx | 8 ++++ .../passenger-boss/Form/ConfirmForm.jsx | 8 ++++ .../passenger-boss/Form/RejectForm.jsx | 10 ++++- .../passenger-office/Form/ConfirmForm.jsx | 15 ++++---- .../passenger-office/Form/RejectForm.jsx | 10 ++++- .../province-manager/Form/ConfirmForm.jsx | 13 ++++--- .../province-manager/Form/RejectForm.jsx | 8 ++++ .../Form/ConfirmForm.jsx | 38 +++++++++++++++++++ .../Form/RejectForm.jsx | 8 ++++ src/core/components/UploadSystem.jsx | 7 +++- .../notifications/UploadFileNotification.jsx | 37 ++++++++++++++++++ 13 files changed, 155 insertions(+), 20 deletions(-) create mode 100644 src/core/components/notifications/UploadFileNotification.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index a4791a5..a7b7a9a 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -177,9 +177,6 @@ "UploadSystem": { "upload_file": "آپلود فایل", "delete": "پاک کردن", - "button-reject": "عدم تایید", - "button-cancel": "بستن", - "description": "توضیحات", - "description_error": "وارد کردن توضیحات الزامی است!" + "uploadfile_error": "حجم فایل بیشتر از 2 مگابایت می باشد" } } diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx index f868aa0..6166ff4 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx @@ -13,9 +13,12 @@ import { useState } from "react"; import { useFormik } from "formik"; import * as Yup from "yup"; import UploadSystem from "@/core/components/UploadSystem"; +import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; +import useDirection from "@/lib/app/hooks/useDirection"; const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const t = useTranslations(); + const { directionApp } = useDirection(); const [proposedAmount, setProposedAmount] = useState(""); const [description, setDescription] = useState(""); const [selectedImage, setSelectedImage] = useState(""); @@ -55,6 +58,11 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const handleUploadChange = (event) => { const uploadedFile = event.target?.files?.[0]; if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(directionApp, t); + return; + } const fileType = event.target?.files?.[0].type; const fileName = event.target?.files?.[0].name; setSelectedImage(URL.createObjectURL(uploadedFile)); diff --git a/src/components/dashboard/machinary-office/Form/RejectForm.jsx b/src/components/dashboard/machinary-office/Form/RejectForm.jsx index 69f7e61..70c606c 100644 --- a/src/components/dashboard/machinary-office/Form/RejectForm.jsx +++ b/src/components/dashboard/machinary-office/Form/RejectForm.jsx @@ -13,9 +13,12 @@ import { useFormik } from "formik"; import * as Yup from "yup"; import { useState } from "react"; import UploadSystem from "@/core/components/UploadSystem"; +import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; +import useDirection from "@/lib/app/hooks/useDirection"; const RejectForm = ({ open, handleClose, rowId, rejectData }) => { const t = useTranslations(); + const { directionApp } = useDirection(); const [description, setDescription] = useState(""); const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); @@ -47,6 +50,11 @@ const RejectForm = ({ open, handleClose, rowId, rejectData }) => { const handleUploadChange = (event) => { const uploadedFile = event.target?.files?.[0]; if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(directionApp, t); + return; + } const fileType = event.target?.files?.[0].type; const fileName = event.target?.files?.[0].name; setSelectedImage(URL.createObjectURL(uploadedFile)); diff --git a/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx b/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx index d8f3b00..788305c 100644 --- a/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx +++ b/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx @@ -13,9 +13,12 @@ import { useState } from "react"; import { useFormik } from "formik"; import * as Yup from "yup"; import UploadSystem from "@/core/components/UploadSystem"; +import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; +import useDirection from "@/lib/app/hooks/useDirection"; const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const t = useTranslations(); + const { directionApp } = useDirection(); const [proposedAmount, setProposedAmount] = useState(""); const [description, setDescription] = useState(""); const [selectedImage, setSelectedImage] = useState(""); @@ -56,6 +59,11 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const handleUploadChange = (event) => { const uploadedFile = event.target?.files?.[0]; if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(directionApp, t); + return; + } const fileType = event.target?.files?.[0].type; const fileName = event.target?.files?.[0].name; setSelectedImage(URL.createObjectURL(uploadedFile)); diff --git a/src/components/dashboard/passenger-boss/Form/RejectForm.jsx b/src/components/dashboard/passenger-boss/Form/RejectForm.jsx index d430af5..eeb23c1 100644 --- a/src/components/dashboard/passenger-boss/Form/RejectForm.jsx +++ b/src/components/dashboard/passenger-boss/Form/RejectForm.jsx @@ -13,9 +13,12 @@ import { useFormik } from "formik"; import * as Yup from "yup"; import { useState } from "react"; import UploadSystem from "@/core/components/UploadSystem"; +import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; +import useDirection from "@/lib/app/hooks/useDirection"; const RejectForm = ({ open, handleClose, rowId, rejectData }) => { const t = useTranslations(); + const { directionApp } = useDirection(); const [description, setDescription] = useState(""); const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); @@ -43,10 +46,15 @@ const RejectForm = ({ open, handleClose, rowId, rejectData }) => { setDescription(event.target.value); formik.handleChange(event); }; - + const handleUploadChange = (event) => { const uploadedFile = event.target?.files?.[0]; if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(directionApp, t); + return; + } const fileType = event.target?.files?.[0].type; const fileName = event.target?.files?.[0].name; setSelectedImage(URL.createObjectURL(uploadedFile)); diff --git a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx index 86eced4..645c2f6 100644 --- a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx @@ -1,5 +1,7 @@ import UploadSystem from "@/core/components/UploadSystem"; +import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; import { CONFIRM_PASSENGER_OFFICE } from "@/core/data/apiRoutes"; +import useDirection from "@/lib/app/hooks/useDirection"; import { Dialog, DialogTitle, @@ -8,39 +10,33 @@ import { DialogActions, Button, TextField, - FormHelperText, } from "@mui/material"; import { useFormik } from "formik"; import { useTranslations } from "next-intl"; import { useRef, useState } from "react"; -const MAX_FILE_SIZE_IN_BYTES = 2 * 1024 * 1024; const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const t = useTranslations(); + const { directionApp } = useDirection(); const [description, setDescription] = useState(""); const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); const [fileName, setfileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); - const formik = useFormik({ initialValues: { description: "", - fileData: null, }, onSubmit: () => { const formData = new FormData(); if (description !== "") formData.append("expert_description", description); - if (fileData !== null) formData.append("file", fileData); handleClose(); confirmData(CONFIRM_PASSENGER_OFFICE, rowId, formData); }, }); - - const handleDescriptionChange = (event) => { setDescription(event.target.value); formik.handleChange(event); @@ -49,6 +45,11 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const handleUploadChange = (event) => { const uploadedFile = event.target?.files?.[0]; if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(directionApp, t); + return; + } const fileType = event.target?.files?.[0].type; const fileName = event.target?.files?.[0].name; setSelectedImage(URL.createObjectURL(uploadedFile)); diff --git a/src/components/dashboard/passenger-office/Form/RejectForm.jsx b/src/components/dashboard/passenger-office/Form/RejectForm.jsx index 5ee55f1..d4ab6d6 100644 --- a/src/components/dashboard/passenger-office/Form/RejectForm.jsx +++ b/src/components/dashboard/passenger-office/Form/RejectForm.jsx @@ -13,15 +13,18 @@ import { useFormik } from "formik"; import * as Yup from "yup"; import { useState } from "react"; import UploadSystem from "@/core/components/UploadSystem"; +import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; +import useDirection from "@/lib/app/hooks/useDirection"; const RejectForm = ({ open, handleClose, rowId, rejectData }) => { const t = useTranslations(); + const { directionApp } = useDirection(); const [description, setDescription] = useState(""); const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); const [fileName, setfileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); - + const validationSchema = Yup.object().shape({ description: Yup.string().required(t("RejectDialog.description_error")), }); @@ -46,6 +49,11 @@ const RejectForm = ({ open, handleClose, rowId, rejectData }) => { const handleUploadChange = (event) => { const uploadedFile = event.target?.files?.[0]; if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(directionApp, t); + return; + } const fileType = event.target?.files?.[0].type; const fileName = event.target?.files?.[0].name; setSelectedImage(URL.createObjectURL(uploadedFile)); diff --git a/src/components/dashboard/province-manager/Form/ConfirmForm.jsx b/src/components/dashboard/province-manager/Form/ConfirmForm.jsx index 0a8078f..e5c04ec 100644 --- a/src/components/dashboard/province-manager/Form/ConfirmForm.jsx +++ b/src/components/dashboard/province-manager/Form/ConfirmForm.jsx @@ -1,5 +1,7 @@ import UploadSystem from "@/core/components/UploadSystem"; +import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; import { CONFIRM_PROVINCE_MANAGER } from "@/core/data/apiRoutes"; +import useDirection from "@/lib/app/hooks/useDirection"; import { Dialog, DialogTitle, @@ -8,15 +10,14 @@ import { DialogActions, Button, TextField, - FormHelperText, } from "@mui/material"; import { useFormik } from "formik"; import { useTranslations } from "next-intl"; import { useRef, useState } from "react"; -const MAX_FILE_SIZE_IN_BYTES = 2 * 1024 * 1024; const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const t = useTranslations(); + const { directionApp } = useDirection(); const [description, setDescription] = useState(""); const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); @@ -26,13 +27,11 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const formik = useFormik({ initialValues: { description: "", - fileData: null, }, onSubmit: () => { const formData = new FormData(); if (description !== "") formData.append("expert_description", description); - if (fileData !== null) formData.append("file", fileData); handleClose(); confirmData(CONFIRM_PROVINCE_MANAGER, rowId, formData); }, @@ -46,6 +45,11 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const handleUploadChange = (event) => { const uploadedFile = event.target?.files?.[0]; if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(directionApp, t); + return; + } const fileType = event.target?.files?.[0].type; const fileName = event.target?.files?.[0].name; setSelectedImage(URL.createObjectURL(uploadedFile)); @@ -86,7 +90,6 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { setShowAddIcon={setShowAddIcon} showAddIcon={showAddIcon} /> - + + } + /> + ); + } + + return <>{children}; +}; + +export default RolePermission; diff --git a/src/pages/dashboard/machinary-office/index.jsx b/src/pages/dashboard/machinary-expert/index.jsx similarity index 66% rename from src/pages/dashboard/machinary-office/index.jsx rename to src/pages/dashboard/machinary-expert/index.jsx index 0bb3553..ed7b514 100644 --- a/src/pages/dashboard/machinary-office/index.jsx +++ b/src/pages/dashboard/machinary-expert/index.jsx @@ -1,13 +1,16 @@ import DashboardMachinaryOfficeComponent from "@/components/dashboard/machinary-office"; import TitlePage from "@/core/components/TitlePage"; +import RolePermission from "@/middlewares/RolePermission"; import WithAuthMiddleware from "@/middlewares/WithAuth"; import { parse } from "next-useragent"; - +const requiredPermissions = ["machinery_expert"]; export default function PassengerOffice() { return ( - - + + + + ); } diff --git a/src/pages/dashboard/passenger-boss/index.jsx b/src/pages/dashboard/passenger-boss/index.jsx index ea0566a..8a261f3 100644 --- a/src/pages/dashboard/passenger-boss/index.jsx +++ b/src/pages/dashboard/passenger-boss/index.jsx @@ -1,13 +1,16 @@ import DashboardPassengerBossComponent from "@/components/dashboard/passenger-boss"; import TitlePage from "@/core/components/TitlePage"; +import RolePermission from "@/middlewares/RolePermission"; import WithAuthMiddleware from "@/middlewares/WithAuth"; import { parse } from "next-useragent"; - +const requiredPermissions = ["passenger_office_chief"]; export default function PassengerBoss() { return ( - - + + + + ); } diff --git a/src/pages/dashboard/passenger-office/index.jsx b/src/pages/dashboard/passenger-office-chief/index.jsx similarity index 65% rename from src/pages/dashboard/passenger-office/index.jsx rename to src/pages/dashboard/passenger-office-chief/index.jsx index 36e2a95..2402f75 100644 --- a/src/pages/dashboard/passenger-office/index.jsx +++ b/src/pages/dashboard/passenger-office-chief/index.jsx @@ -1,13 +1,16 @@ import DashboardPassengerOfficeComponent from "@/components/dashboard/passenger-office"; import TitlePage from "@/core/components/TitlePage"; +import RolePermission from "@/middlewares/RolePermission"; import WithAuthMiddleware from "@/middlewares/WithAuth"; import { parse } from "next-useragent"; - +const requiredPermissions = ["passenger_office_chief"]; export default function PassengerOffice() { return ( - - + + + + ); } diff --git a/src/pages/dashboard/province-manager/index.jsx b/src/pages/dashboard/province-manager/index.jsx index 7fbc181..808a5d4 100644 --- a/src/pages/dashboard/province-manager/index.jsx +++ b/src/pages/dashboard/province-manager/index.jsx @@ -1,13 +1,16 @@ import DashboardProvinceManagerComponent from "@/components/dashboard/province-manager"; import TitlePage from "@/core/components/TitlePage"; +import RolePermission from "@/middlewares/RolePermission"; import WithAuthMiddleware from "@/middlewares/WithAuth"; import { parse } from "next-useragent"; - +const requiredPermissions = ["province_manager"]; export default function PassengerOffice() { return ( - - + + + + ); } diff --git a/src/pages/dashboard/transportation-assistance/index.jsx b/src/pages/dashboard/transportation-assistant/index.jsx similarity index 65% rename from src/pages/dashboard/transportation-assistance/index.jsx rename to src/pages/dashboard/transportation-assistant/index.jsx index ef9a661..47297f6 100644 --- a/src/pages/dashboard/transportation-assistance/index.jsx +++ b/src/pages/dashboard/transportation-assistant/index.jsx @@ -1,13 +1,16 @@ import DashboardTransportationAssistanceComponent from "@/components/dashboard/transportation-assistance"; import TitlePage from "@/core/components/TitlePage"; +import RolePermission from "@/middlewares/RolePermission"; import WithAuthMiddleware from "@/middlewares/WithAuth"; import { parse } from "next-useragent"; - +const requiredPermissions = ["transportation_assistant"]; export default function TransportationAssistance() { return ( - - + + + + ); } From f2b3d532ae90c12829fc7ea88f1d580e231f5056 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Mon, 24 Jul 2023 16:06:23 +0330 Subject: [PATCH 082/134] confirm form handle change --- src/components/dashboard/machinary-office/Form/ConfirmForm.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx index 6166ff4..f2988ef 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx @@ -61,6 +61,7 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const maxFileSize = 2 * 1024 * 1024; if (uploadedFile.size > maxFileSize) { UploadFileNotification(directionApp, t); + event.target.value = ""; return; } const fileType = event.target?.files?.[0].type; From 53e03e0e45ba7462a3d0e08a7ffab8ba72476375 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Mon, 24 Jul 2023 16:18:05 +0330 Subject: [PATCH 083/134] change cartables --- src/components/dashboard/machinary-office/Form/RejectForm.jsx | 1 + src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx | 1 + src/components/dashboard/passenger-boss/Form/RejectForm.jsx | 1 + src/components/dashboard/passenger-office/Form/ConfirmForm.jsx | 1 + src/components/dashboard/passenger-office/Form/RejectForm.jsx | 1 + src/components/dashboard/province-manager/Form/ConfirmForm.jsx | 1 + src/components/dashboard/province-manager/Form/RejectForm.jsx | 1 + .../dashboard/transportation-assistance/Form/ConfirmForm.jsx | 1 + .../dashboard/transportation-assistance/Form/RejectForm.jsx | 3 ++- 9 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/dashboard/machinary-office/Form/RejectForm.jsx b/src/components/dashboard/machinary-office/Form/RejectForm.jsx index 70c606c..b7a37e9 100644 --- a/src/components/dashboard/machinary-office/Form/RejectForm.jsx +++ b/src/components/dashboard/machinary-office/Form/RejectForm.jsx @@ -53,6 +53,7 @@ const RejectForm = ({ open, handleClose, rowId, rejectData }) => { const maxFileSize = 2 * 1024 * 1024; if (uploadedFile.size > maxFileSize) { UploadFileNotification(directionApp, t); + event.target.value = ""; return; } const fileType = event.target?.files?.[0].type; diff --git a/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx b/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx index 788305c..ec01590 100644 --- a/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx +++ b/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx @@ -62,6 +62,7 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const maxFileSize = 2 * 1024 * 1024; if (uploadedFile.size > maxFileSize) { UploadFileNotification(directionApp, t); + event.target.value = ""; return; } const fileType = event.target?.files?.[0].type; diff --git a/src/components/dashboard/passenger-boss/Form/RejectForm.jsx b/src/components/dashboard/passenger-boss/Form/RejectForm.jsx index eeb23c1..955a487 100644 --- a/src/components/dashboard/passenger-boss/Form/RejectForm.jsx +++ b/src/components/dashboard/passenger-boss/Form/RejectForm.jsx @@ -53,6 +53,7 @@ const RejectForm = ({ open, handleClose, rowId, rejectData }) => { const maxFileSize = 2 * 1024 * 1024; if (uploadedFile.size > maxFileSize) { UploadFileNotification(directionApp, t); + event.target.value = ""; return; } const fileType = event.target?.files?.[0].type; diff --git a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx index 645c2f6..1e02f33 100644 --- a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx @@ -48,6 +48,7 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const maxFileSize = 2 * 1024 * 1024; if (uploadedFile.size > maxFileSize) { UploadFileNotification(directionApp, t); + event.target.value = ""; return; } const fileType = event.target?.files?.[0].type; diff --git a/src/components/dashboard/passenger-office/Form/RejectForm.jsx b/src/components/dashboard/passenger-office/Form/RejectForm.jsx index d4ab6d6..6b66c7a 100644 --- a/src/components/dashboard/passenger-office/Form/RejectForm.jsx +++ b/src/components/dashboard/passenger-office/Form/RejectForm.jsx @@ -52,6 +52,7 @@ const RejectForm = ({ open, handleClose, rowId, rejectData }) => { const maxFileSize = 2 * 1024 * 1024; if (uploadedFile.size > maxFileSize) { UploadFileNotification(directionApp, t); + event.target.value = ""; return; } const fileType = event.target?.files?.[0].type; diff --git a/src/components/dashboard/province-manager/Form/ConfirmForm.jsx b/src/components/dashboard/province-manager/Form/ConfirmForm.jsx index e5c04ec..69e3a62 100644 --- a/src/components/dashboard/province-manager/Form/ConfirmForm.jsx +++ b/src/components/dashboard/province-manager/Form/ConfirmForm.jsx @@ -48,6 +48,7 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const maxFileSize = 2 * 1024 * 1024; if (uploadedFile.size > maxFileSize) { UploadFileNotification(directionApp, t); + event.target.value = ""; return; } const fileType = event.target?.files?.[0].type; diff --git a/src/components/dashboard/province-manager/Form/RejectForm.jsx b/src/components/dashboard/province-manager/Form/RejectForm.jsx index 430c5b2..f1e266d 100644 --- a/src/components/dashboard/province-manager/Form/RejectForm.jsx +++ b/src/components/dashboard/province-manager/Form/RejectForm.jsx @@ -52,6 +52,7 @@ const RejectForm = ({ open, handleClose, rowId, rejectData }) => { const maxFileSize = 2 * 1024 * 1024; if (uploadedFile.size > maxFileSize) { UploadFileNotification(directionApp, t); + event.target.value = ""; return; } const fileType = event.target?.files?.[0].type; diff --git a/src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx b/src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx index 93a76e8..8067eee 100644 --- a/src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx +++ b/src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx @@ -45,6 +45,7 @@ const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { const maxFileSize = 2 * 1024 * 1024; if (uploadedFile.size > maxFileSize) { UploadFileNotification(directionApp, t); + event.target.value = ""; return; } diff --git a/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx b/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx index a022a33..fb3a290 100644 --- a/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx +++ b/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx @@ -23,7 +23,7 @@ const RejectForm = ({ open, handleClose, rowId, rejectData }) => { const [fileName, setfileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); const t = useTranslations(); - const { directionApp } = useDirection(); + const { directionApp } = useDirection(); const validationSchema = Yup.object().shape({ description: Yup.string().required(t("RejectDialog.description_error")), @@ -52,6 +52,7 @@ const RejectForm = ({ open, handleClose, rowId, rejectData }) => { const maxFileSize = 2 * 1024 * 1024; if (uploadedFile.size > maxFileSize) { UploadFileNotification(directionApp, t); + event.target.value = ""; return; } const fileType = event.target?.files?.[0].type; From c4a268b524c5c0a4b7b815b70716b5508eb1589d Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Mon, 24 Jul 2023 17:21:52 +0330 Subject: [PATCH 084/134] debug --- src/components/dashboard/machinary-office/TableRowActions.jsx | 2 +- src/components/dashboard/passenger-boss/TableRowActions.jsx | 2 +- src/components/dashboard/passenger-office/TableRowActions.jsx | 2 +- src/components/dashboard/province-manager/TableRowActions.jsx | 2 +- .../dashboard/transportation-assistance/TableRowActions.jsx | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/dashboard/machinary-office/TableRowActions.jsx b/src/components/dashboard/machinary-office/TableRowActions.jsx index c7ee618..8a85502 100644 --- a/src/components/dashboard/machinary-office/TableRowActions.jsx +++ b/src/components/dashboard/machinary-office/TableRowActions.jsx @@ -2,10 +2,10 @@ import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; import { Box, IconButton, Tooltip } 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 { useTranslations } from "next-intl"; +import { DataTableContext } from "@/lib/app/contexts/datatableContext"; const TableRowActions = ({ row }) => { const t = useTranslations(); diff --git a/src/components/dashboard/passenger-boss/TableRowActions.jsx b/src/components/dashboard/passenger-boss/TableRowActions.jsx index c7ee618..8a85502 100644 --- a/src/components/dashboard/passenger-boss/TableRowActions.jsx +++ b/src/components/dashboard/passenger-boss/TableRowActions.jsx @@ -2,10 +2,10 @@ import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; import { Box, IconButton, Tooltip } 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 { useTranslations } from "next-intl"; +import { DataTableContext } from "@/lib/app/contexts/datatableContext"; const TableRowActions = ({ row }) => { const t = useTranslations(); diff --git a/src/components/dashboard/passenger-office/TableRowActions.jsx b/src/components/dashboard/passenger-office/TableRowActions.jsx index c7ee618..8a85502 100644 --- a/src/components/dashboard/passenger-office/TableRowActions.jsx +++ b/src/components/dashboard/passenger-office/TableRowActions.jsx @@ -2,10 +2,10 @@ import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; import { Box, IconButton, Tooltip } 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 { useTranslations } from "next-intl"; +import { DataTableContext } from "@/lib/app/contexts/datatableContext"; const TableRowActions = ({ row }) => { const t = useTranslations(); diff --git a/src/components/dashboard/province-manager/TableRowActions.jsx b/src/components/dashboard/province-manager/TableRowActions.jsx index c7ee618..8a85502 100644 --- a/src/components/dashboard/province-manager/TableRowActions.jsx +++ b/src/components/dashboard/province-manager/TableRowActions.jsx @@ -2,10 +2,10 @@ import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; import { Box, IconButton, Tooltip } 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 { useTranslations } from "next-intl"; +import { DataTableContext } from "@/lib/app/contexts/datatableContext"; const TableRowActions = ({ row }) => { const t = useTranslations(); diff --git a/src/components/dashboard/transportation-assistance/TableRowActions.jsx b/src/components/dashboard/transportation-assistance/TableRowActions.jsx index ccd5bde..db9640b 100644 --- a/src/components/dashboard/transportation-assistance/TableRowActions.jsx +++ b/src/components/dashboard/transportation-assistance/TableRowActions.jsx @@ -2,10 +2,10 @@ import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; import { Box, IconButton, Tooltip } 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 { useTranslations } from "next-intl"; +import { DataTableContext } from "@/lib/app/contexts/datatableContext"; const TableRowActions = ({ row }) => { const t = useTranslations(); From 644deb4e4841ab0ea378030f0bb1f36887ba63ce Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Mon, 24 Jul 2023 17:25:17 +0330 Subject: [PATCH 085/134] debug --- src/components/dashboard/machinary-office/TableRowActions.jsx | 2 +- src/components/dashboard/passenger-boss/TableRowActions.jsx | 2 +- src/components/dashboard/passenger-office/TableRowActions.jsx | 2 +- src/components/dashboard/province-manager/TableRowActions.jsx | 2 +- .../dashboard/transportation-assistance/TableRowActions.jsx | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/dashboard/machinary-office/TableRowActions.jsx b/src/components/dashboard/machinary-office/TableRowActions.jsx index 8a85502..30367b9 100644 --- a/src/components/dashboard/machinary-office/TableRowActions.jsx +++ b/src/components/dashboard/machinary-office/TableRowActions.jsx @@ -5,7 +5,7 @@ import { useContext } from "react"; import ConfirmForm from "./Form/ConfirmForm"; import RejectForm from "./Form/RejectForm"; import { useTranslations } from "next-intl"; -import { DataTableContext } from "@/lib/app/contexts/datatableContext"; +import { DataTableContext } from "@/lib/app/contexts/DatatableContext"; const TableRowActions = ({ row }) => { const t = useTranslations(); diff --git a/src/components/dashboard/passenger-boss/TableRowActions.jsx b/src/components/dashboard/passenger-boss/TableRowActions.jsx index 8a85502..30367b9 100644 --- a/src/components/dashboard/passenger-boss/TableRowActions.jsx +++ b/src/components/dashboard/passenger-boss/TableRowActions.jsx @@ -5,7 +5,7 @@ import { useContext } from "react"; import ConfirmForm from "./Form/ConfirmForm"; import RejectForm from "./Form/RejectForm"; import { useTranslations } from "next-intl"; -import { DataTableContext } from "@/lib/app/contexts/datatableContext"; +import { DataTableContext } from "@/lib/app/contexts/DatatableContext"; const TableRowActions = ({ row }) => { const t = useTranslations(); diff --git a/src/components/dashboard/passenger-office/TableRowActions.jsx b/src/components/dashboard/passenger-office/TableRowActions.jsx index 8a85502..30367b9 100644 --- a/src/components/dashboard/passenger-office/TableRowActions.jsx +++ b/src/components/dashboard/passenger-office/TableRowActions.jsx @@ -5,7 +5,7 @@ import { useContext } from "react"; import ConfirmForm from "./Form/ConfirmForm"; import RejectForm from "./Form/RejectForm"; import { useTranslations } from "next-intl"; -import { DataTableContext } from "@/lib/app/contexts/datatableContext"; +import { DataTableContext } from "@/lib/app/contexts/DatatableContext"; const TableRowActions = ({ row }) => { const t = useTranslations(); diff --git a/src/components/dashboard/province-manager/TableRowActions.jsx b/src/components/dashboard/province-manager/TableRowActions.jsx index 8a85502..30367b9 100644 --- a/src/components/dashboard/province-manager/TableRowActions.jsx +++ b/src/components/dashboard/province-manager/TableRowActions.jsx @@ -5,7 +5,7 @@ import { useContext } from "react"; import ConfirmForm from "./Form/ConfirmForm"; import RejectForm from "./Form/RejectForm"; import { useTranslations } from "next-intl"; -import { DataTableContext } from "@/lib/app/contexts/datatableContext"; +import { DataTableContext } from "@/lib/app/contexts/DatatableContext"; const TableRowActions = ({ row }) => { const t = useTranslations(); diff --git a/src/components/dashboard/transportation-assistance/TableRowActions.jsx b/src/components/dashboard/transportation-assistance/TableRowActions.jsx index db9640b..e4b8334 100644 --- a/src/components/dashboard/transportation-assistance/TableRowActions.jsx +++ b/src/components/dashboard/transportation-assistance/TableRowActions.jsx @@ -5,7 +5,7 @@ import { useContext } from "react"; import ConfirmForm from "./Form/ConfirmForm"; import RejectForm from "./Form/RejectForm"; import { useTranslations } from "next-intl"; -import { DataTableContext } from "@/lib/app/contexts/datatableContext"; +import { DataTableContext } from "@/lib/app/contexts/DatatableContext"; const TableRowActions = ({ row }) => { const t = useTranslations(); From 70451c354551ff65d85290b1ce28beee16153990 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Mon, 24 Jul 2023 17:26:04 +0330 Subject: [PATCH 086/134] debug --- src/core/components/DatatableStructure.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/components/DatatableStructure.jsx b/src/core/components/DatatableStructure.jsx index e033a09..e13ed16 100644 --- a/src/core/components/DatatableStructure.jsx +++ b/src/core/components/DatatableStructure.jsx @@ -1,4 +1,4 @@ -import { DataTableProvider } from "@/lib/app/contexts/DataTableContext"; +import { DataTableProvider } from "@/lib/app/contexts/DatatableContext"; import DataTable from "./Datatable"; import { ReloadDataTableProvider } from "@/lib/app/contexts/ReloadDatatableContext"; From 298ca1d96f17670b8d6f381123f0d3d309c2f9df Mon Sep 17 00:00:00 2001 From: Amirhossein Mahmoodi Date: Mon, 24 Jul 2023 17:33:35 +0330 Subject: [PATCH 087/134] fixed bug --- src/core/components/notifications/index.jsx | 2 +- src/lib/app/contexts/DatatableContext.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/components/notifications/index.jsx b/src/core/components/notifications/index.jsx index ddef384..ef63918 100644 --- a/src/core/components/notifications/index.jsx +++ b/src/core/components/notifications/index.jsx @@ -1,6 +1,6 @@ import ErrorNotification from "./ErrorNotification"; import WarningNotification from "./WarningNotification"; -import SuccessNotification from "./successNotification"; +import SuccessNotification from "./SuccessNotification"; const Notifications = async (directionApp, response, t) => { const { status, data } = response; diff --git a/src/lib/app/contexts/DatatableContext.jsx b/src/lib/app/contexts/DatatableContext.jsx index d751640..94bc016 100644 --- a/src/lib/app/contexts/DatatableContext.jsx +++ b/src/lib/app/contexts/DatatableContext.jsx @@ -1,5 +1,5 @@ import { createContext } from "react"; -import useDataTable from "../hooks/useDataTable"; +import useDataTable from "../hooks/useDatatable"; export const DataTableContext = createContext(); From 3a14df43a538ab6953a904e8ae146ee3527513de Mon Sep 17 00:00:00 2001 From: Amirhossein Mahmoodi Date: Tue, 25 Jul 2023 14:39:48 +0330 Subject: [PATCH 088/134] add .idea to .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e9618a3..4e572ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules .next -.env.local \ No newline at end of file +.env.local +.idea \ No newline at end of file From 51b21957b99d1bcae0b4135645fcd270452d04ef Mon Sep 17 00:00:00 2001 From: Amirhossein Mahmoodi Date: Mon, 31 Jul 2023 09:34:59 +0330 Subject: [PATCH 089/134] recode and add editor config file --- jsconfig.json | 8 +- next.config.js | 12 +- public/fontiran.scss | 228 ++++---- public/images/change-password.svg | 65 ++- public/images/dashboard.svg | 105 +++- public/images/loading_logo.svg | 122 +++- public/images/login.svg | 61 +- public/images/logo.svg | 23 +- public/locales/fa/datatable.js | 180 +++--- .../dashboard/change-password/index.jsx | 325 ++++++----- .../dashboard/edit-profile/index.jsx | 523 +++++++++--------- src/components/dashboard/first/index.jsx | 2 +- .../machinary-office/Form/ConfirmForm.jsx | 252 ++++----- .../machinary-office/Form/RejectForm.jsx | 198 ++++--- .../machinary-office/TableRowActions.jsx | 104 ++-- .../machinary-office/TableTolbar.jsx | 16 +- .../dashboard/machinary-office/index.jsx | 457 ++++++++------- .../passenger-boss/Form/ConfirmForm.jsx | 256 +++++---- .../passenger-boss/Form/RejectForm.jsx | 198 ++++--- .../passenger-boss/TableRowActions.jsx | 104 ++-- .../dashboard/passenger-boss/TableTollbar.jsx | 16 +- .../dashboard/passenger-boss/index.jsx | 457 ++++++++------- .../passenger-office/Form/ConfirmForm.jsx | 184 +++--- .../passenger-office/Form/RejectForm.jsx | 198 ++++--- .../passenger-office/TableRowActions.jsx | 104 ++-- .../passenger-office/TableTollbar.jsx | 16 +- .../dashboard/passenger-office/index.jsx | 460 ++++++++------- .../province-manager/Form/ConfirmForm.jsx | 184 +++--- .../province-manager/Form/RejectForm.jsx | 198 ++++--- .../province-manager/TableRowActions.jsx | 104 ++-- .../province-manager/TableTollbar.jsx | 16 +- .../dashboard/province-manager/index.jsx | 457 ++++++++------- .../Form/ConfirmForm.jsx | 178 +++--- .../Form/RejectForm.jsx | 198 ++++--- .../TableRowActions.jsx | 104 ++-- .../TableTollbar.jsx | 16 +- .../transportation-assistance/index.jsx | 457 ++++++++------- src/components/first/index.jsx | 84 +-- src/components/login-expert/index.jsx | 269 +++++---- src/core/components/AvatarUpload.jsx | 220 ++++---- src/core/components/Datatable.jsx | 308 +++++------ src/core/components/DatatableStructure.jsx | 18 +- src/core/components/FormErrorMassage.jsx | 13 +- src/core/components/ImageConvertor.jsx | 26 +- src/core/components/LinkRouting.jsx | 176 +++--- src/core/components/LoadingHardPage.jsx | 70 +-- src/core/components/Messages.jsx | 30 +- src/core/components/MuiDatePicker.jsx | 58 +- src/core/components/PasswordField.jsx | 52 +- src/core/components/StyledForm.jsx | 4 +- src/core/components/StyledImage.jsx | 2 +- src/core/components/TitlePage.jsx | 20 +- src/core/components/UploadSystem.jsx | 327 ++++++----- src/core/components/isBotHandler.jsx | 8 +- .../notifications/ErrorNotification.jsx | 68 +-- .../notifications/SuccessNotification.jsx | 74 +-- .../notifications/UploadFileNotification.jsx | 62 +-- .../notifications/WarningNotification.jsx | 70 +-- src/core/components/notifications/index.jsx | 60 +- src/core/data/apiRoutes.js | 30 +- src/core/data/headerProfileItems.jsx | 24 +- src/core/data/sidebarMenu.jsx | 104 ++-- src/core/utils/createEmotionCache.jsx | 48 +- src/core/utils/theme-rtl.jsx | 12 +- src/core/utils/theme.jsx | 46 +- src/layouts/AppLayout.jsx | 174 +++--- src/layouts/CenterLayout.jsx | 26 +- src/layouts/FullPageLayout.jsx | 32 +- src/layouts/MuiLayout.jsx | 118 ++-- src/layouts/ScrollableLayout.jsx | 38 +- .../breadcrumbs/BreadcrumbItem.jsx | 28 +- .../dashboardLayouts/breadcrumbs/index.jsx | 78 +-- .../dashboardLayouts/header/ProfileData.jsx | 28 +- .../dashboardLayouts/header/ProfileMenu.jsx | 105 ++-- .../header/ProfileOptionLogOut.jsx | 90 +-- .../header/ProfileOptions.jsx | 88 +-- src/layouts/dashboardLayouts/header/index.jsx | 136 +++-- src/layouts/dashboardLayouts/index.jsx | 70 +-- .../sidebar/SidebarDrawer.jsx | 45 +- .../dashboardLayouts/sidebar/SidebarList.jsx | 92 +-- .../sidebar/SidebarListItem.jsx | 143 +++-- .../sidebar/SidebarListSubItem.jsx | 90 ++- .../dashboardLayouts/sidebar/index.jsx | 80 +-- src/lib/app/contexts/DatatableContext.jsx | 14 +- .../app/contexts/ReloadDatatableContext.jsx | 20 +- src/lib/app/contexts/language.jsx | 178 +++--- src/lib/app/contexts/loading.jsx | 18 +- src/lib/app/contexts/user.jsx | 204 ++++--- src/lib/app/hooks/useDatatable.jsx | 180 +++--- src/lib/app/hooks/useDirection.jsx | 8 +- src/lib/app/hooks/useLanguage.jsx | 38 +- src/lib/app/hooks/useLoading.jsx | 8 +- src/lib/app/hooks/useUser.jsx | 56 +- src/middlewares/RolePermission.jsx | 68 +-- src/middlewares/WithAuth.jsx | 70 +-- src/middlewares/WithoutAuth.jsx | 92 +-- src/pages/_app.jsx | 44 +- src/pages/_document.jsx | 104 ++-- src/pages/dashboard/change-password/index.jsx | 30 +- src/pages/dashboard/edit-profile/index.jsx | 30 +- src/pages/dashboard/index.jsx | 30 +- .../dashboard/machinary-expert/index.jsx | 35 +- src/pages/dashboard/passenger-boss/index.jsx | 35 +- .../passenger-office-chief/index.jsx | 35 +- .../dashboard/province-manager/index.jsx | 35 +- .../transportation-assistant/index.jsx | 35 +- src/pages/index.jsx | 30 +- src/pages/login-expert.jsx | 36 +- 108 files changed, 5993 insertions(+), 5770 deletions(-) diff --git a/jsconfig.json b/jsconfig.json index f6a30b1..fcd02aa 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -1,8 +1,12 @@ { "compilerOptions": { "paths": { - "@/*": ["./src/*"], - "&/*": ["./public/*"], + "@/*": [ + "./src/*" + ], + "&/*": [ + "./public/*" + ] } } } diff --git a/next.config.js b/next.config.js index 03fb527..409876a 100644 --- a/next.config.js +++ b/next.config.js @@ -1,12 +1,12 @@ /** @type {import('next').NextConfig} */ const nextConfig = { - reactStrictMode: true, - i18n: { - defaultLocale: 'fa', - locales: ['fa'], - localeDetection: false, - }, + reactStrictMode: true, + i18n: { + defaultLocale: 'fa', + locales: ['fa'], + localeDetection: false, + }, } module.exports = nextConfig diff --git a/public/fontiran.scss b/public/fontiran.scss index 33b59b4..86d585d 100644 --- a/public/fontiran.scss +++ b/public/fontiran.scss @@ -17,145 +17,153 @@ This set of fonts are used in this project under the license: (.....) * **/ @font-face { - font-family: IRANSansFaNum; - font-style: normal; - font-weight: 900; - src: url('./fonts/eot/IRANSansWeb(FaNum)_Black.eot'); - src: url('./fonts/eot/IRANSansWeb(FaNum)_Black.eot?#iefix') format('embedded-opentype'),/* IE6-8 */ - url('./fonts/woff2/IRANSansWeb(FaNum)_Black.woff2') format('woff2'),/* FF39+,Chrome36+, Opera24+*/ - url('./fonts/woff/IRANSansWeb(FaNum)_Black.woff') format('woff'),/* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/IRANSansWeb(FaNum)_Black.ttf') format('truetype'); + font-family: IRANSansFaNum; + font-style: normal; + font-weight: 900; + src: url('./fonts/eot/IRANSansWeb(FaNum)_Black.eot'); + src: url('./fonts/eot/IRANSansWeb(FaNum)_Black.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff2/IRANSansWeb(FaNum)_Black.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ + url('./fonts/woff/IRANSansWeb(FaNum)_Black.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/IRANSansWeb(FaNum)_Black.ttf') format('truetype'); } @font-face { - font-family: IRANSansFaNum; - font-style: normal; - font-weight: bold; - src: url('./fonts/eot/IRANSansWeb(FaNum)_Bold.eot'); - src: url('./fonts/eot/IRANSansWeb(FaNum)_Bold.eot?#iefix') format('embedded-opentype'),/* IE6-8 */ - url('./fonts/woff2/IRANSansWeb(FaNum)_Bold.woff2') format('woff2'),/* FF39+,Chrome36+, Opera24+*/ - url('./fonts/woff/IRANSansWeb(FaNum)_Bold.woff') format('woff'),/* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/IRANSansWeb(FaNum)_Bold.ttf') format('truetype'); + font-family: IRANSansFaNum; + font-style: normal; + font-weight: bold; + src: url('./fonts/eot/IRANSansWeb(FaNum)_Bold.eot'); + src: url('./fonts/eot/IRANSansWeb(FaNum)_Bold.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff2/IRANSansWeb(FaNum)_Bold.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ + url('./fonts/woff/IRANSansWeb(FaNum)_Bold.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/IRANSansWeb(FaNum)_Bold.ttf') format('truetype'); } @font-face { - font-family: IRANSansFaNum; - font-style: normal; - font-weight: 500; - src: url('./fonts/eot/IRANSansWeb(FaNum)_Medium.eot'); - src: url('./fonts/eot/IRANSansWeb(FaNum)_Medium.eot?#iefix') format('embedded-opentype'),/* IE6-8 */ - url('./fonts/woff2/IRANSansWeb(FaNum)_Medium.woff2') format('woff2'),/* FF39+,Chrome36+, Opera24+*/ - url('./fonts/woff/IRANSansWeb(FaNum)_Medium.woff') format('woff'),/* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/IRANSansWeb(FaNum)_Medium.ttf') format('truetype'); + font-family: IRANSansFaNum; + font-style: normal; + font-weight: 500; + src: url('./fonts/eot/IRANSansWeb(FaNum)_Medium.eot'); + src: url('./fonts/eot/IRANSansWeb(FaNum)_Medium.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff2/IRANSansWeb(FaNum)_Medium.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ + url('./fonts/woff/IRANSansWeb(FaNum)_Medium.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/IRANSansWeb(FaNum)_Medium.ttf') format('truetype'); } @font-face { - font-family: IRANSansFaNum; - font-style: normal; - font-weight: 300; - src: url('./fonts/eot/IRANSansWeb(FaNum)_Light.eot'); - src: url('./fonts/eot/IRANSansWeb(FaNum)_Light.eot?#iefix') format('embedded-opentype'),/* IE6-8 */ - url('./fonts/woff2/IRANSansWeb(FaNum)_Light.woff2') format('woff2'),/* FF39+,Chrome36+, Opera24+*/ - url('./fonts/woff/IRANSansWeb(FaNum)_Light.woff') format('woff'),/* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/IRANSansWeb(FaNum)_Light.ttf') format('truetype'); + font-family: IRANSansFaNum; + font-style: normal; + font-weight: 300; + src: url('./fonts/eot/IRANSansWeb(FaNum)_Light.eot'); + src: url('./fonts/eot/IRANSansWeb(FaNum)_Light.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff2/IRANSansWeb(FaNum)_Light.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ + url('./fonts/woff/IRANSansWeb(FaNum)_Light.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/IRANSansWeb(FaNum)_Light.ttf') format('truetype'); } @font-face { - font-family: IRANSansFaNum; - font-style: normal; - font-weight: 200; - src: url('./fonts/eot/IRANSansWeb(FaNum)_UltraLight.eot'); - src: url('./fonts/eot/IRANSansWeb(FaNum)_UltraLight.eot?#iefix') format('embedded-opentype'),/* IE6-8 */ - url('./fonts/woff2/IRANSansWeb(FaNum)_UltraLight.woff2') format('woff2'),/* FF39+,Chrome36+, Opera24+*/ - url('./fonts/woff/IRANSansWeb(FaNum)_UltraLight.woff') format('woff'),/* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/IRANSansWeb(FaNum)_UltraLight.ttf') format('truetype'); + font-family: IRANSansFaNum; + font-style: normal; + font-weight: 200; + src: url('./fonts/eot/IRANSansWeb(FaNum)_UltraLight.eot'); + src: url('./fonts/eot/IRANSansWeb(FaNum)_UltraLight.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff2/IRANSansWeb(FaNum)_UltraLight.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ + url('./fonts/woff/IRANSansWeb(FaNum)_UltraLight.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/IRANSansWeb(FaNum)_UltraLight.ttf') format('truetype'); } @font-face { - font-family: IRANSansFaNum; - font-style: normal; - font-weight: normal; - src: url('./fonts/eot/IRANSansWeb(FaNum).eot'); - src: url('./fonts/eot/IRANSansWeb(FaNum).eot?#iefix') format('embedded-opentype'),/* IE6-8 */ - url('./fonts/woff2/IRANSansWeb(FaNum).woff2') format('woff2'),/* FF39+,Chrome36+, Opera24+*/ - url('./fonts/woff/IRANSansWeb(FaNum).woff') format('woff'),/* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/IRANSansWeb(FaNum).ttf') format('truetype'); + font-family: IRANSansFaNum; + font-style: normal; + font-weight: normal; + src: url('./fonts/eot/IRANSansWeb(FaNum).eot'); + src: url('./fonts/eot/IRANSansWeb(FaNum).eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff2/IRANSansWeb(FaNum).woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ + url('./fonts/woff/IRANSansWeb(FaNum).woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/IRANSansWeb(FaNum).ttf') format('truetype'); } + @font-face { - font-family: IRANSans; - font-style: normal; - font-weight: 900; - src: url('./fonts/eot/IRANSansWeb_Black.eot'); - src: url('./fonts/eot/IRANSansWeb_Black.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ - url('./fonts/woff2/IRANSansWeb_Black.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ - url('./fonts/woff/IRANSansWeb_Black.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/IRANSansWeb_Black.ttf') format('truetype'); + font-family: IRANSans; + font-style: normal; + font-weight: 900; + src: url('./fonts/eot/IRANSansWeb_Black.eot'); + src: url('./fonts/eot/IRANSansWeb_Black.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff2/IRANSansWeb_Black.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ + url('./fonts/woff/IRANSansWeb_Black.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/IRANSansWeb_Black.ttf') format('truetype'); } + @font-face { - font-family: IRANSans; - font-style: normal; - font-weight: bold; - src: url('./fonts/eot/IRANSansWeb_Bold.eot'); - src: url('./fonts/eot/IRANSansWeb_Bold.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ - url('./fonts/woff2/IRANSansWeb_Bold.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ - url('./fonts/woff/IRANSansWeb_Bold.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/IRANSansWeb_Bold.ttf') format('truetype'); + font-family: IRANSans; + font-style: normal; + font-weight: bold; + src: url('./fonts/eot/IRANSansWeb_Bold.eot'); + src: url('./fonts/eot/IRANSansWeb_Bold.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff2/IRANSansWeb_Bold.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ + url('./fonts/woff/IRANSansWeb_Bold.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/IRANSansWeb_Bold.ttf') format('truetype'); } + @font-face { - font-family: IRANSans; - font-style: normal; - font-weight: 500; - src: url('./fonts/eot/IRANSansWeb_Medium.eot'); - src: url('./fonts/eot/IRANSansWeb_Medium.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ - url('./fonts/woff2/IRANSansWeb_Medium.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ - url('./fonts/woff/IRANSansWeb_Medium.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/IRANSansWeb_Medium.ttf') format('truetype'); + font-family: IRANSans; + font-style: normal; + font-weight: 500; + src: url('./fonts/eot/IRANSansWeb_Medium.eot'); + src: url('./fonts/eot/IRANSansWeb_Medium.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff2/IRANSansWeb_Medium.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ + url('./fonts/woff/IRANSansWeb_Medium.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/IRANSansWeb_Medium.ttf') format('truetype'); } + @font-face { - font-family: IRANSans; - font-style: normal; - font-weight: 300; - src: url('./fonts/eot/IRANSansWeb_Light.eot'); - src: url('./fonts/eot/IRANSansWeb_Light.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ - url('./fonts/woff2/IRANSansWeb_Light.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ - url('./fonts/woff/IRANSansWeb_Light.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/IRANSansWeb_Light.ttf') format('truetype'); + font-family: IRANSans; + font-style: normal; + font-weight: 300; + src: url('./fonts/eot/IRANSansWeb_Light.eot'); + src: url('./fonts/eot/IRANSansWeb_Light.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff2/IRANSansWeb_Light.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ + url('./fonts/woff/IRANSansWeb_Light.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/IRANSansWeb_Light.ttf') format('truetype'); } + @font-face { - font-family: IRANSans; - font-style: normal; - font-weight: 200; - src: url('./fonts/eot/IRANSansWeb_UltraLight.eot'); - src: url('./fonts/eot/IRANSansWeb_UltraLight.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ - url('./fonts/woff2/IRANSansWeb_UltraLight.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ - url('./fonts/woff/IRANSansWeb_UltraLight.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/IRANSansWeb_UltraLight.ttf') format('truetype'); + font-family: IRANSans; + font-style: normal; + font-weight: 200; + src: url('./fonts/eot/IRANSansWeb_UltraLight.eot'); + src: url('./fonts/eot/IRANSansWeb_UltraLight.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff2/IRANSansWeb_UltraLight.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ + url('./fonts/woff/IRANSansWeb_UltraLight.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/IRANSansWeb_UltraLight.ttf') format('truetype'); } + @font-face { - font-family: IRANSans; - font-style: normal; - font-weight: normal; - src: url('./fonts/eot/IRANSansWeb.eot'); - src: url('./fonts/eot/IRANSansWeb.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ - url('./fonts/woff2/IRANSansWeb.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ - url('./fonts/woff/IRANSansWeb.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/IRANSansWeb.ttf') format('truetype'); + font-family: IRANSans; + font-style: normal; + font-weight: normal; + src: url('./fonts/eot/IRANSansWeb.eot'); + src: url('./fonts/eot/IRANSansWeb.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff2/IRANSansWeb.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ + url('./fonts/woff/IRANSansWeb.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/IRANSansWeb.ttf') format('truetype'); } + @font-face { - font-family: Parastoo; - font-style: normal; - font-weight: normal; - src: url('./fonts/eot/Parastoo.eot'); - src: url('./fonts/eot/Parastoo.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ - url('./fonts/woff/Parastoo.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/Parastoo.ttf') format('truetype'); + font-family: Parastoo; + font-style: normal; + font-weight: normal; + src: url('./fonts/eot/Parastoo.eot'); + src: url('./fonts/eot/Parastoo.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff/Parastoo.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/Parastoo.ttf') format('truetype'); } + @font-face { - font-family: Parastoo; - font-style: normal; - font-weight: bold; - src: url('./fonts/eot/Parastoo-Bold.eot'); - src: url('./fonts/eot/Parastoo-Bold.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ - url('./fonts/woff/Parastoo-Bold.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ - url('./fonts/ttf/Parastoo-Bold.ttf') format('truetype'); + font-family: Parastoo; + font-style: normal; + font-weight: bold; + src: url('./fonts/eot/Parastoo-Bold.eot'); + src: url('./fonts/eot/Parastoo-Bold.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ + url('./fonts/woff/Parastoo-Bold.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ + url('./fonts/ttf/Parastoo-Bold.ttf') format('truetype'); } diff --git a/public/images/change-password.svg b/public/images/change-password.svg index f3b65aa..d940442 100644 --- a/public/images/change-password.svg +++ b/public/images/change-password.svg @@ -1 +1,64 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/images/dashboard.svg b/public/images/dashboard.svg index ea3f11b..f7c0340 100644 --- a/public/images/dashboard.svg +++ b/public/images/dashboard.svg @@ -1 +1,104 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/images/loading_logo.svg b/public/images/loading_logo.svg index 48fde43..ba14232 100644 --- a/public/images/loading_logo.svg +++ b/public/images/loading_logo.svg @@ -1 +1,121 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/images/login.svg b/public/images/login.svg index e2854d2..cd7e24e 100644 --- a/public/images/login.svg +++ b/public/images/login.svg @@ -1 +1,60 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/images/logo.svg b/public/images/logo.svg index 5931dd4..eebb9fa 100644 --- a/public/images/logo.svg +++ b/public/images/logo.svg @@ -1,10 +1,19 @@ - - - - - + + + + + + + + MARHABA + - MARHABA - diff --git a/public/locales/fa/datatable.js b/public/locales/fa/datatable.js index 819a84b..fd43663 100644 --- a/public/locales/fa/datatable.js +++ b/public/locales/fa/datatable.js @@ -1,92 +1,92 @@ export const FA_DATATABLE_LOCALIZATION = { - actions: "عملیات", - and: "و", - cancel: "لغو", - changeFilterMode: "تغییر حالت فیلتر", - changeSearchMode: "تغییر حالت جستجو", - clearFilter: "پاک کردن فیلتر", - clearSearch: "پاک کردن جستجو", - clearSort: "پاک کردن مرتب سازی", - clickToCopy: "کلیک برای کپی", - collapse: "جمع شدن", - collapseAll: "جمع شدن همه", - columnActions: "عملیات ستون", - copiedToClipboard: "کپی شد", - dropToGroupBy: "رها کردن برای گروه بندی بر اساس {column}", - edit: "ویرایش", - expand: "باز شدن", - expandAll: "باز شدن همه", - filterArrIncludes: "شامل", - filterArrIncludesAll: "شامل همه", - filterArrIncludesSome: "شامل", - filterBetween: "میان", - filterBetweenInclusive: "میان با احتساب هر دو", - filterByColumn: "فیلتر بر اساس {column}", - filterContains: "شامل", - filterEmpty: "خالی", - filterEndsWith: "به پایان می‌رسد با", - filterEquals: "برابر", - filterEqualsString: "برابر", - filterFuzzy: "نزدیک", - filterGreaterThan: "بزرگتر از", - filterGreaterThanOrEqualTo: "بزرگتر یا مساوی", - filterInNumberRange: "میان", - filterIncludesString: "شامل", - filterIncludesStringSensitive: "شامل", - filterLessThan: "کوچکتر از", - filterLessThanOrEqualTo: "کوچکتر یا مساوی", - filterMode: "حالت فیلتر: {filterType}", - filterNotEmpty: "غیر خالی", - filterNotEquals: "نا برابر", - filterStartsWith: "شروع می‌شود با", - filterWeakEquals: "برابر", - filteringByColumn: "فیلتر بر اساس {column} - {filterType} {filterValue}", - goToFirstPage: "رفتن به صفحه اول", - goToLastPage: "رفتن به صفحه آخر", - goToNextPage: "رفتن به صفحه بعدی", - goToPreviousPage: "رفتن به صفحه قبلی", - grab: "گرفتن", - groupByColumn: "گروه بندی بر اساس {column}", - groupedBy: "گروه بندی شده بر اساس", - hideAll: "پنهان کردن همه", - hideColumn: "پنهان کردن ستون {column}", - max: "حداکثر", - min: "حداقل", - move: "انتقال", - noRecordsToDisplay: "هیچ رکوردی برای نمایش وجود ندارد", - noResultsFound: "نتیجه‌ای یافت نشد", - of: "از", - or: "یا", - pinToLeft: "چسباندن به سمت چپ", - pinToRight: "چسباندن به سمت راست", - resetColumnSize: "بازنشانی اندازه ستون", - resetOrder: "بازنشانی ترتیب", - rowActions: "عملیات ردیف", - rowNumber: "#", - rowNumbers: "شماره ردیف", - rowsPerPage: "ردیف در هر صفحه", - save: "ذخیره", - search: "جستجو", - selectedCountOfRowCountRowsSelected: - "{selectedCount} از {rowCount} ردیف انتخاب شده", - select: "انتخاب", - showAll: "نمایش همه", - showAllColumns: "نمایش همه ستون‌ها", - showHideColumns: "نمایش/مخفی کردن ستون‌ها", - showHideFilters: "نمایش/مخفی کردن فیلترها", - showHideSearch: "نمایش/مخفی کردن جستجو", - sortByColumnAsc: "مرتب سازی بر اساس {column} صعودی", - sortByColumnDesc: "مرتب سازی بر اساس {column} نزولی", - sortedByColumnAsc: "مرتب شده بر اساس {column} صعودی", - sortedByColumnDesc: "مرتب شده بر اساس {column} نزولی", - thenBy: "، سپس بر اساس ", - toggleDensity: "تغییر تراکم", - toggleFullScreen: "تغییر حالت تمام صفحه", - toggleSelectAll: "انتخاب/عدم انتخاب همه", - toggleSelectRow: "انتخاب/عدم انتخاب ردیف", - toggleVisibility: "تغییر پیدا/پنهان", - ungroupByColumn: "لغو گروه بندی بر اساس {column}", - unpin: "رها کردن", - unpinAll: "رها کردن همه", - unsorted: "بدون مرتب سازی", + actions: "عملیات", + and: "و", + cancel: "لغو", + changeFilterMode: "تغییر حالت فیلتر", + changeSearchMode: "تغییر حالت جستجو", + clearFilter: "پاک کردن فیلتر", + clearSearch: "پاک کردن جستجو", + clearSort: "پاک کردن مرتب سازی", + clickToCopy: "کلیک برای کپی", + collapse: "جمع شدن", + collapseAll: "جمع شدن همه", + columnActions: "عملیات ستون", + copiedToClipboard: "کپی شد", + dropToGroupBy: "رها کردن برای گروه بندی بر اساس {column}", + edit: "ویرایش", + expand: "باز شدن", + expandAll: "باز شدن همه", + filterArrIncludes: "شامل", + filterArrIncludesAll: "شامل همه", + filterArrIncludesSome: "شامل", + filterBetween: "میان", + filterBetweenInclusive: "میان با احتساب هر دو", + filterByColumn: "فیلتر بر اساس {column}", + filterContains: "شامل", + filterEmpty: "خالی", + filterEndsWith: "به پایان می‌رسد با", + filterEquals: "برابر", + filterEqualsString: "برابر", + filterFuzzy: "نزدیک", + filterGreaterThan: "بزرگتر از", + filterGreaterThanOrEqualTo: "بزرگتر یا مساوی", + filterInNumberRange: "میان", + filterIncludesString: "شامل", + filterIncludesStringSensitive: "شامل", + filterLessThan: "کوچکتر از", + filterLessThanOrEqualTo: "کوچکتر یا مساوی", + filterMode: "حالت فیلتر: {filterType}", + filterNotEmpty: "غیر خالی", + filterNotEquals: "نا برابر", + filterStartsWith: "شروع می‌شود با", + filterWeakEquals: "برابر", + filteringByColumn: "فیلتر بر اساس {column} - {filterType} {filterValue}", + goToFirstPage: "رفتن به صفحه اول", + goToLastPage: "رفتن به صفحه آخر", + goToNextPage: "رفتن به صفحه بعدی", + goToPreviousPage: "رفتن به صفحه قبلی", + grab: "گرفتن", + groupByColumn: "گروه بندی بر اساس {column}", + groupedBy: "گروه بندی شده بر اساس", + hideAll: "پنهان کردن همه", + hideColumn: "پنهان کردن ستون {column}", + max: "حداکثر", + min: "حداقل", + move: "انتقال", + noRecordsToDisplay: "هیچ رکوردی برای نمایش وجود ندارد", + noResultsFound: "نتیجه‌ای یافت نشد", + of: "از", + or: "یا", + pinToLeft: "چسباندن به سمت چپ", + pinToRight: "چسباندن به سمت راست", + resetColumnSize: "بازنشانی اندازه ستون", + resetOrder: "بازنشانی ترتیب", + rowActions: "عملیات ردیف", + rowNumber: "#", + rowNumbers: "شماره ردیف", + rowsPerPage: "ردیف در هر صفحه", + save: "ذخیره", + search: "جستجو", + selectedCountOfRowCountRowsSelected: + "{selectedCount} از {rowCount} ردیف انتخاب شده", + select: "انتخاب", + showAll: "نمایش همه", + showAllColumns: "نمایش همه ستون‌ها", + showHideColumns: "نمایش/مخفی کردن ستون‌ها", + showHideFilters: "نمایش/مخفی کردن فیلترها", + showHideSearch: "نمایش/مخفی کردن جستجو", + sortByColumnAsc: "مرتب سازی بر اساس {column} صعودی", + sortByColumnDesc: "مرتب سازی بر اساس {column} نزولی", + sortedByColumnAsc: "مرتب شده بر اساس {column} صعودی", + sortedByColumnDesc: "مرتب شده بر اساس {column} نزولی", + thenBy: "، سپس بر اساس ", + toggleDensity: "تغییر تراکم", + toggleFullScreen: "تغییر حالت تمام صفحه", + toggleSelectAll: "انتخاب/عدم انتخاب همه", + toggleSelectRow: "انتخاب/عدم انتخاب ردیف", + toggleVisibility: "تغییر پیدا/پنهان", + ungroupByColumn: "لغو گروه بندی بر اساس {column}", + unpin: "رها کردن", + unpinAll: "رها کردن همه", + unsorted: "بدون مرتب سازی", }; diff --git a/src/components/dashboard/change-password/index.jsx b/src/components/dashboard/change-password/index.jsx index c2b5fd4..4583549 100644 --- a/src/components/dashboard/change-password/index.jsx +++ b/src/components/dashboard/change-password/index.jsx @@ -1,184 +1,177 @@ import CenterLayout from "@/layouts/CenterLayout"; import DashboardLayouts from "@/layouts/dashboardLayouts"; -import { - Button, - Typography, - Stack, - Paper, - Container, - Box, -} from "@mui/material"; +import {Box, Button, Container, Paper, Stack, Typography,} from "@mui/material"; import Image from "next/image"; -import { Formik } from "formik"; +import {Formik} from "formik"; import * as Yup from "yup"; -import { useTranslations } from "next-intl"; +import {useTranslations} from "next-intl"; import PasswordField from "@/core/components/PasswordField"; import StyledForm from "@/core/components/StyledForm"; -import { CHANGE_PASSWORD } from "@/core/data/apiRoutes"; +import {CHANGE_PASSWORD} from "@/core/data/apiRoutes"; import useUser from "@/lib/app/hooks/useUser"; import axios from "axios"; import Notifications from "@/core/components/notifications"; import useDirection from "@/lib/app/hooks/useDirection"; -import { toast } from "react-toastify"; +import {toast} from "react-toastify"; const DashboardChangePasswordComponent = () => { - const t = useTranslations(); - const { token } = useUser(); - const { directionApp } = useDirection(); + const t = useTranslations(); + const {token} = useUser(); + const {directionApp} = useDirection(); - const handleSubmit = (values, { setSubmitting, resetForm }) => { - toast.dismiss(); - const pendingToast = toast(t("notifications.pending"), { - position: directionApp === "ltr" ? "top-left" : "top-right", - autoClose: false, - closeOnClick: false, - draggable: false, + const handleSubmit = (values, {setSubmitting, resetForm}) => { + toast.dismiss(); + const pendingToast = toast(t("notifications.pending"), { + position: directionApp === "ltr" ? "top-left" : "top-right", + autoClose: false, + closeOnClick: false, + draggable: false, + }); + axios + .post( + CHANGE_PASSWORD, + { + current_password: values.current_password, + new_password: values.new_password, + new_password_confirmation: values.new_password_confirmation, + }, + { + headers: {authorization: `Bearer ${token}`}, + } + ) + .then((response) => { + toast.dismiss(pendingToast); // Dismiss the pending toast notification + Notifications(directionApp, response, t); + resetForm(); + }) + .catch((error) => { + toast.dismiss(pendingToast); // Dismiss the pending toast notification + Notifications(directionApp, error.response, t); + }) + .finally(() => { + setSubmitting(false); // Set `setSubmitting` to false after the API request completes + }); + }; + const initialValues = { + current_password: "", + new_password: "", + new_password_confirmation: "", + }; + const validationSchema = Yup.object().shape({ + current_password: Yup.string().required( + t("ChangePassword.error_message_required") + ), + new_password: Yup.string() + .min(8, t("ChangePassword.error_message_password_length")) + .required(t("ChangePassword.error_message_required")), + new_password_confirmation: Yup.string() + .required(t("ChangePassword.error_message_required")) + .test( + t("ChangePassword.error_message_password_match"), + t("ChangePassword.error_message_password_not_match"), + function (value) { + return this.parent.new_password === value; + } + ), }); - axios - .post( - CHANGE_PASSWORD, - { - current_password: values.current_password, - new_password: values.new_password, - new_password_confirmation: values.new_password_confirmation, - }, - { - headers: { authorization: `Bearer ${token}` }, - } - ) - .then((response) => { - toast.dismiss(pendingToast); // Dismiss the pending toast notification - Notifications(directionApp, response, t); - resetForm(); - }) - .catch((error) => { - toast.dismiss(pendingToast); // Dismiss the pending toast notification - Notifications(directionApp, error.response, t); - }) - .finally(() => { - setSubmitting(false); // Set `setSubmitting` to false after the API request completes - }); - }; - const initialValues = { - current_password: "", - new_password: "", - new_password_confirmation: "", - }; - const validationSchema = Yup.object().shape({ - current_password: Yup.string().required( - t("ChangePassword.error_message_required") - ), - new_password: Yup.string() - .min(8, t("ChangePassword.error_message_password_length")) - .required(t("ChangePassword.error_message_required")), - new_password_confirmation: Yup.string() - .required(t("ChangePassword.error_message_required")) - .test( - t("ChangePassword.error_message_password_match"), - t("ChangePassword.error_message_password_not_match"), - function (value) { - return this.parent.new_password === value; - } - ), - }); - return ( - - - - - {(props) => ( - { - e.preventDefault(); - props.handleSubmit(); - }} - > - - - + + + - - - - {t("ChangePassword.typography_change_password")} - - - - - - - - - - - - - - - )} - - - - - ); + {(props) => ( + { + e.preventDefault(); + props.handleSubmit(); + }} + > + + + + + + + {t("ChangePassword.typography_change_password")} + + + + + + + + + + + + + + + )} + + +
+ + ); }; export default DashboardChangePasswordComponent; diff --git a/src/components/dashboard/edit-profile/index.jsx b/src/components/dashboard/edit-profile/index.jsx index fa3e2e1..9391754 100644 --- a/src/components/dashboard/edit-profile/index.jsx +++ b/src/components/dashboard/edit-profile/index.jsx @@ -2,277 +2,268 @@ import StyledForm from "@/core/components/StyledForm"; import CenterLayout from "@/layouts/CenterLayout"; import DashboardLayouts from "@/layouts/dashboardLayouts"; import useUser from "@/lib/app/hooks/useUser"; -import { - Box, - Button, - Container, - Grid, - Paper, - Stack, - TextField, - Typography, -} from "@mui/material"; +import {Box, Container, Grid, Paper, Stack, TextField, Typography,} from "@mui/material"; import * as Yup from "yup"; -import { Field, Formik } from "formik"; -import { useTranslations } from "next-intl"; +import {Field, Formik} from "formik"; +import {useTranslations} from "next-intl"; import AvatarUpload from "@/core/components/AvatarUpload"; import axios from "axios"; -import { UPDATE_PROFILE, UPDATE_AVATAR } from "@/core/data/apiRoutes"; +import {UPDATE_AVATAR} from "@/core/data/apiRoutes"; import useDirection from "@/lib/app/hooks/useDirection"; import Notifications from "@/core/components/notifications"; import ImageResizer from "@/core/components/ImageConvertor"; const DashboardEditProfile = () => { - const t = useTranslations(); - const { user, token, getUser, changeUser } = useUser(); - console.log(user); - const { directionApp } = useDirection(); + const t = useTranslations(); + const {user, token, getUser, changeUser} = useUser(); + console.log(user); + const {directionApp} = useDirection(); - const editAvatar = async (avatar) => { - try { - const formData = new FormData(); + const editAvatar = async (avatar) => { + try { + const formData = new FormData(); - if (avatar != null) { - var resizedAvatar; - resizedAvatar = await ImageResizer(avatar); - formData.append("avatar", resizedAvatar); - } + if (avatar != null) { + var resizedAvatar; + resizedAvatar = await ImageResizer(avatar); + formData.append("avatar", resizedAvatar); + } - await axios.post(UPDATE_AVATAR, formData, { - headers: { - authorization: `Bearer ${token}`, - "Content-Type": "multipart/form-data", - }, - }); - } catch (error) { - Notifications(directionApp, error.response, t); - throw error; - } - }; - const handleSubmit = (values, { setSubmitting }) => { - // const formData = new FormData(); - // formData.append("email", values.expert_email); - // if (values.change_avatar !== false) { - // editAvatar(values.expert_avatar) - // .then(() => { - // return axios.post(UPDATE_PROFILE, formData, { - // headers: { - // authorization: `Bearer ${token}`, - // "Content-Type": "multipart/form-data", - // }, - // }); - // }) - // .then((response) => { - // Notifications(directionApp, response, t); - // getUser((data) => { - // changeUser(data); - // }); - // }) - // .catch((error) => { - // Notifications(directionApp, error.response, t); - // }) - // .finally(() => { - // setSubmitting(false); - // }); - // } else { - // axios - // .post(UPDATE_PROFILE, formData, { - // headers: { - // authorization: `Bearer ${token}`, - // "Content-Type": "multipart/form-data", - // }, - // }) - // .then((response) => { - // Notifications(directionApp, response, t); - // getUser((data) => { - // changeUser(data); - // }); - // }) - // .catch((error) => { - // Notifications(directionApp, error.response, t); - // }) - // .finally(() => { - // setSubmitting(false); - // }); - // } - }; - const initialValues = { - expert_avatar: null, - username: user.username, - name: user.name, - email: user.email, - province_name: user.province_name, - position: user.position, - }; - const validationSchema = Yup.object().shape({ - // username: Yup.string().required(t("UpdateProfile.error_message_required")), - // name: Yup.string().required(t("UpdateProfile.error_message_required")), - // email: Yup.string() - // .email(t("UpdateProfile.error_invalid_email")) - // .required(t("UpdateProfile.error_message_required")), - // province_name: Yup.string().required( - // t("UpdateProfile.error_message_required") - // ), - // position: Yup.string().required(t("UpdateProfile.error_message_required")), - }); + await axios.post(UPDATE_AVATAR, formData, { + headers: { + authorization: `Bearer ${token}`, + "Content-Type": "multipart/form-data", + }, + }); + } catch (error) { + Notifications(directionApp, error.response, t); + throw error; + } + }; + const handleSubmit = (values, {setSubmitting}) => { + // const formData = new FormData(); + // formData.append("email", values.expert_email); + // if (values.change_avatar !== false) { + // editAvatar(values.expert_avatar) + // .then(() => { + // return axios.post(UPDATE_PROFILE, formData, { + // headers: { + // authorization: `Bearer ${token}`, + // "Content-Type": "multipart/form-data", + // }, + // }); + // }) + // .then((response) => { + // Notifications(directionApp, response, t); + // getUser((data) => { + // changeUser(data); + // }); + // }) + // .catch((error) => { + // Notifications(directionApp, error.response, t); + // }) + // .finally(() => { + // setSubmitting(false); + // }); + // } else { + // axios + // .post(UPDATE_PROFILE, formData, { + // headers: { + // authorization: `Bearer ${token}`, + // "Content-Type": "multipart/form-data", + // }, + // }) + // .then((response) => { + // Notifications(directionApp, response, t); + // getUser((data) => { + // changeUser(data); + // }); + // }) + // .catch((error) => { + // Notifications(directionApp, error.response, t); + // }) + // .finally(() => { + // setSubmitting(false); + // }); + // } + }; + const initialValues = { + expert_avatar: null, + username: user.username, + name: user.name, + email: user.email, + province_name: user.province_name, + position: user.position, + }; + const validationSchema = Yup.object().shape({ + // username: Yup.string().required(t("UpdateProfile.error_message_required")), + // name: Yup.string().required(t("UpdateProfile.error_message_required")), + // email: Yup.string() + // .email(t("UpdateProfile.error_invalid_email")) + // .required(t("UpdateProfile.error_message_required")), + // province_name: Yup.string().required( + // t("UpdateProfile.error_message_required") + // ), + // position: Yup.string().required(t("UpdateProfile.error_message_required")), + }); - return ( - - - - - {(props) => ( - { - e.preventDefault(); - props.handleSubmit(); - }} - > - - - - {t("UpdateProfile.typography_edit_profile")} - - + + + - - - - - - - - - - - - + {(props) => ( + { + e.preventDefault(); + props.handleSubmit(); + }} + > + + + + {t("UpdateProfile.typography_edit_profile")} + + + + + + + + + + + + + + - - - - - - - - {/* */} - - - - )} - - - - - ); + + + + )} + + + + + ); }; export default DashboardEditProfile; diff --git a/src/components/dashboard/first/index.jsx b/src/components/dashboard/first/index.jsx index c693380..ee4f80a 100644 --- a/src/components/dashboard/first/index.jsx +++ b/src/components/dashboard/first/index.jsx @@ -1,7 +1,7 @@ import DashboardLayouts from "@/layouts/dashboardLayouts"; const DashboardFirstComponent = () => { - return ; + return ; }; export default DashboardFirstComponent; diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx index f2988ef..a0d8017 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx @@ -1,140 +1,132 @@ -import { CONFIRM_MACHINARY_OFFICE } from "@/core/data/apiRoutes"; -import { - Dialog, - DialogTitle, - DialogContent, - DialogContentText, - DialogActions, - Button, - TextField, -} from "@mui/material"; -import { useTranslations } from "next-intl"; -import { useState } from "react"; -import { useFormik } from "formik"; +import {CONFIRM_MACHINARY_OFFICE} from "@/core/data/apiRoutes"; +import {Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, TextField,} from "@mui/material"; +import {useTranslations} from "next-intl"; +import {useState} from "react"; +import {useFormik} from "formik"; import * as Yup from "yup"; import UploadSystem from "@/core/components/UploadSystem"; import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; import useDirection from "@/lib/app/hooks/useDirection"; -const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { - const t = useTranslations(); - const { directionApp } = useDirection(); - const [proposedAmount, setProposedAmount] = useState(""); - const [description, setDescription] = useState(""); - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); +const ConfirmForm = ({open, handleClose, rowId, confirmData}) => { + const t = useTranslations(); + const {directionApp} = useDirection(); + const [proposedAmount, setProposedAmount] = useState(""); + const [description, setDescription] = useState(""); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); - //formik - const validationSchema = Yup.object().shape({ - proposed_amount: Yup.string().required(t("ConfirmDialog.amount_error")), - }); - const formik = useFormik({ - initialValues: { - proposed_amount: "", - description: "", - }, - validationSchema, - onSubmit: () => { - const formData = new FormData(); - formData.append("proposed_amount", proposedAmount); - if (description != "") formData.append("expert_description", description); - handleClose(); - confirmData(CONFIRM_MACHINARY_OFFICE, rowId, formData); - }, - }); + //formik + const validationSchema = Yup.object().shape({ + proposed_amount: Yup.string().required(t("ConfirmDialog.amount_error")), + }); + const formik = useFormik({ + initialValues: { + proposed_amount: "", + description: "", + }, + validationSchema, + onSubmit: () => { + const formData = new FormData(); + formData.append("proposed_amount", proposedAmount); + if (description != "") formData.append("expert_description", description); + handleClose(); + confirmData(CONFIRM_MACHINARY_OFFICE, rowId, formData); + }, + }); - const handleDescriptionChange = (event) => { - setDescription(event.target.value); - }; - const handleAmountChange = (event) => { - if (/^\d*$/.test(event.target.value)) { - setProposedAmount(event.target.value); - } - formik.handleChange(event); - }; + const handleDescriptionChange = (event) => { + setDescription(event.target.value); + }; + const handleAmountChange = (event) => { + if (/^\d*$/.test(event.target.value)) { + setProposedAmount(event.target.value); + } + formik.handleChange(event); + }; - const handleUploadChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(directionApp, t); - event.target.value = ""; - return; - } - const fileType = event.target?.files?.[0].type; - const fileName = event.target?.files?.[0].name; - setSelectedImage(URL.createObjectURL(uploadedFile)); - setfileType(fileType); - setfileName(fileName); - formik.setFieldValue("confirm_img", uploadedFile); - setShowAddIcon(false); - } - }; - return ( - - {t("ConfirmDialog.confirm")} - - {t("ConfirmDialog.context")} - - - - - - - - - - ); + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(directionApp, t); + event.target.value = ""; + return; + } + const fileType = event.target?.files?.[0].type; + const fileName = event.target?.files?.[0].name; + setSelectedImage(URL.createObjectURL(uploadedFile)); + setfileType(fileType); + setfileName(fileName); + formik.setFieldValue("confirm_img", uploadedFile); + setShowAddIcon(false); + } + }; + return ( + + {t("ConfirmDialog.confirm")} + + {t("ConfirmDialog.context")} + + + + + + + + + + ); }; export default ConfirmForm; diff --git a/src/components/dashboard/machinary-office/Form/RejectForm.jsx b/src/components/dashboard/machinary-office/Form/RejectForm.jsx index b7a37e9..06f7292 100644 --- a/src/components/dashboard/machinary-office/Form/RejectForm.jsx +++ b/src/components/dashboard/machinary-office/Form/RejectForm.jsx @@ -1,116 +1,108 @@ -import { REJECT_MACHINARY_OFFICE } from "@/core/data/apiRoutes"; -import { - Dialog, - DialogTitle, - DialogContent, - DialogContentText, - DialogActions, - Button, - TextField, -} from "@mui/material"; -import { useTranslations } from "next-intl"; -import { useFormik } from "formik"; +import {REJECT_MACHINARY_OFFICE} from "@/core/data/apiRoutes"; +import {Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, TextField,} from "@mui/material"; +import {useTranslations} from "next-intl"; +import {useFormik} from "formik"; import * as Yup from "yup"; -import { useState } from "react"; +import {useState} from "react"; import UploadSystem from "@/core/components/UploadSystem"; import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; import useDirection from "@/lib/app/hooks/useDirection"; -const RejectForm = ({ open, handleClose, rowId, rejectData }) => { - const t = useTranslations(); - const { directionApp } = useDirection(); - const [description, setDescription] = useState(""); - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); +const RejectForm = ({open, handleClose, rowId, rejectData}) => { + const t = useTranslations(); + const {directionApp} = useDirection(); + const [description, setDescription] = useState(""); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); - const validationSchema = Yup.object().shape({ - description: Yup.string().required(t("RejectDialog.description_error")), - }); + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("RejectDialog.description_error")), + }); - const formik = useFormik({ - initialValues: { - description: "", - }, - validationSchema, - onSubmit: () => { - const formData = new FormData(); - formData.append("expert_description", description); - handleClose(); - rejectData(REJECT_MACHINARY_OFFICE, rowId, formData); - }, - }); + const formik = useFormik({ + initialValues: { + description: "", + }, + validationSchema, + onSubmit: () => { + const formData = new FormData(); + formData.append("expert_description", description); + handleClose(); + rejectData(REJECT_MACHINARY_OFFICE, rowId, formData); + }, + }); - const handleDescriptionChange = (event) => { - setDescription(event.target.value); - formik.handleChange(event); - }; + const handleDescriptionChange = (event) => { + setDescription(event.target.value); + formik.handleChange(event); + }; - const handleUploadChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(directionApp, t); - event.target.value = ""; - return; - } - const fileType = event.target?.files?.[0].type; - const fileName = event.target?.files?.[0].name; - setSelectedImage(URL.createObjectURL(uploadedFile)); - setfileType(fileType); - setfileName(fileName); - formik.setFieldValue("reject_img", uploadedFile); - setShowAddIcon(false); - } - }; + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(directionApp, t); + event.target.value = ""; + return; + } + const fileType = event.target?.files?.[0].type; + const fileName = event.target?.files?.[0].name; + setSelectedImage(URL.createObjectURL(uploadedFile)); + setfileType(fileType); + setfileName(fileName); + formik.setFieldValue("reject_img", uploadedFile); + setShowAddIcon(false); + } + }; - return ( - - {t("RejectDialog.reject")} - - {t("RejectDialog.context")} - - - - - - - - - ); + return ( + + {t("RejectDialog.reject")} + + {t("RejectDialog.context")} + + + + + + + + + ); }; export default RejectForm; diff --git a/src/components/dashboard/machinary-office/TableRowActions.jsx b/src/components/dashboard/machinary-office/TableRowActions.jsx index 30367b9..13c6e7b 100644 --- a/src/components/dashboard/machinary-office/TableRowActions.jsx +++ b/src/components/dashboard/machinary-office/TableRowActions.jsx @@ -1,60 +1,60 @@ import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import { Box, IconButton, Tooltip } from "@mui/material"; -import { useContext } from "react"; +import {Box, IconButton, Tooltip} from "@mui/material"; +import {useContext} from "react"; import ConfirmForm from "./Form/ConfirmForm"; import RejectForm from "./Form/RejectForm"; -import { useTranslations } from "next-intl"; -import { DataTableContext } from "@/lib/app/contexts/DatatableContext"; +import {useTranslations} from "next-intl"; +import {DataTableContext} from "@/lib/app/contexts/DatatableContext"; -const TableRowActions = ({ row }) => { - const t = useTranslations(); - const { - openConfirmDialog, - openRejectDialog, - handleOpenConfirmDialog, - handleOpenRejectDialog, - handleCloseConfirmDialog, - handleCloseRejectDialog, - rowId, - confirmData, - rejectData, - } = useContext(DataTableContext); - return ( - - - { - handleOpenConfirmDialog(row); - }} - > - - - - {openConfirmDialog && ( - - )} - - handleOpenRejectDialog(row)}> - - - - {openRejectDialog && ( - - )} - - ); +const TableRowActions = ({row}) => { + const t = useTranslations(); + const { + openConfirmDialog, + openRejectDialog, + handleOpenConfirmDialog, + handleOpenRejectDialog, + handleCloseConfirmDialog, + handleCloseRejectDialog, + rowId, + confirmData, + rejectData, + } = useContext(DataTableContext); + return ( + + + { + handleOpenConfirmDialog(row); + }} + > + + + + {openConfirmDialog && ( + + )} + + handleOpenRejectDialog(row)}> + + + + {openRejectDialog && ( + + )} + + ); }; export default TableRowActions; diff --git a/src/components/dashboard/machinary-office/TableTolbar.jsx b/src/components/dashboard/machinary-office/TableTolbar.jsx index 3f06d3b..e267691 100644 --- a/src/components/dashboard/machinary-office/TableTolbar.jsx +++ b/src/components/dashboard/machinary-office/TableTolbar.jsx @@ -1,13 +1,13 @@ -import { Stack, Tooltip } from "@mui/material"; -import { useTranslations } from "next-intl"; +import {Stack, Tooltip} from "@mui/material"; +import {useTranslations} from "next-intl"; function TableToolbar() { - const t = useTranslations(); - return ( - - - - ); + 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 index 30415e4..63061ce 100644 --- a/src/components/dashboard/machinary-office/index.jsx +++ b/src/components/dashboard/machinary-office/index.jsx @@ -1,244 +1,241 @@ import DataTableStructure from "@/core/components/DatatableStructure"; import DashboardLayouts from "@/layouts/dashboardLayouts"; -import { Box, IconButton, Typography } from "@mui/material"; +import {Box, IconButton, Typography} from "@mui/material"; import ClearIcon from "@mui/icons-material/Clear"; -import { useMemo } from "react"; +import {useMemo} from "react"; // import TableToolbar from "./TableTollbar"; -import { GET_MACHINARY_OFFICE } from "@/core/data/apiRoutes"; -import { useTranslations } from "next-intl"; +import {GET_MACHINARY_OFFICE} from "@/core/data/apiRoutes"; +import {useTranslations} from "next-intl"; import TableRowActions from "./TableRowActions"; -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 {faIR} from "@mui/x-date-pickers/locales"; function DashboardMachinaryOfficeComponent() { - const t = useTranslations(); - const columns = useMemo( - () => [ - { - accessorFn: (row) => row.id, - id: "id", - header: t("PassengerOffice.id"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - maxSize: 100, - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", + const t = useTranslations(); + const columns = useMemo( + () => [ + { + accessorFn: (row) => row.id, + id: "id", + header: t("PassengerOffice.id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + maxSize: 100, + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + 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.national_id, + id: "national_id", + header: t("MachinaryOffice.national_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) => + moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + id: "created_at", + header: t("MachinaryOffice.created_at"), + enableColumnFilter: true, + datatype: "date", + filterFn: "lessThan", + minSize: 200, + columnFilterModeOptions: ["lessThan", "greaterThan"], + Cell: ({renderedCellValue}) => { + return {renderedCellValue}; + }, + Header: ({column}) => {column.columnDef.header}, + Filter: ({column}) => { + const filterFnValue = column.columnDef._filterFn; + return ( + + + { + const date = new Date(newValue); + const formattedDate = moment(date) + .locale("en") + .format("YYYY-MM-DD HH:mm"); + column.setFilterValue(formattedDate); + }} + slotProps={{ + textField: { + placeholder: "تاریخ خود را وارد کنید", + helperText: `${t("filter_mode")}: ${t(filterFnValue)}`, + sx: {minWidth: "120px"}, + variant: "standard", + }, + }} + value={ + column.getFilterValue() + ? new Date(column.getFilterValue()) + : null + } + /> + + { + column.setFilterValue(null); + }} + sx={{ + color: column.getFilterValue() + ? "rgba(0, 0, 0, 0.54)" + : "#bfbfbf", + }} + > + + + + ); + }, + }, + { + accessorFn: (row) => + moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + id: "updated_at", + header: t("MachinaryOffice.updated_at"), + enableColumnFilter: false, + datatype: "numeric", + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.navgan_id, + id: "navgan_id", + header: t("MachinaryOffice.navgan_id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + maxSize: 100, + 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: false, + datatype: "numeric", + minSize: 300, + // filterFn: "equals", + // filterSelectOptions: [ + // ], + // filterVariant: "select", + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, ], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - 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.national_id, - id: "national_id", - header: t("MachinaryOffice.national_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) => - moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), - id: "created_at", - header: t("MachinaryOffice.created_at"), - enableColumnFilter: true, - datatype: "date", - filterFn: "lessThan", - minSize: 200, - columnFilterModeOptions: ["lessThan", "greaterThan"], - Cell: ({ renderedCellValue }) => { - return {renderedCellValue}; - }, - Header: ({ column }) => {column.columnDef.header}, - Filter: ({ column }) => { - const filterFnValue = column.columnDef._filterFn; - return ( - - - { - const date = new Date(newValue); - const formattedDate = moment(date) - .locale("en") - .format("YYYY-MM-DD HH:mm"); - column.setFilterValue(formattedDate); - }} - slotProps={{ - textField: { - placeholder: "تاریخ خود را وارد کنید", - helperText: `${t("filter_mode")}: ${t(filterFnValue)}`, - sx: { minWidth: "120px" }, - variant: "standard", - }, - }} - value={ - column.getFilterValue() - ? new Date(column.getFilterValue()) - : null - } + [] + ); + 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}) => } /> - - { - column.setFilterValue(null); - }} - sx={{ - color: column.getFilterValue() - ? "rgba(0, 0, 0, 0.54)" - : "#bfbfbf", - }} - > - - - ); - }, - }, - { - accessorFn: (row) => - moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), - id: "updated_at", - header: t("MachinaryOffice.updated_at"), - enableColumnFilter: false, - datatype: "numeric", - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.navgan_id, - id: "navgan_id", - header: t("MachinaryOffice.navgan_id"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - maxSize: 100, - 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: false, - datatype: "numeric", - minSize: 300, - // filterFn: "equals", - // filterSelectOptions: [ - // ], - // 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/dashboard/passenger-boss/Form/ConfirmForm.jsx b/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx index ec01590..f12c0bc 100644 --- a/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx +++ b/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx @@ -1,142 +1,134 @@ -import { CONFIRM_PASSENGER_BOSS } from "@/core/data/apiRoutes"; -import { - Dialog, - DialogTitle, - DialogContent, - DialogContentText, - DialogActions, - Button, - TextField, -} from "@mui/material"; -import { useTranslations } from "next-intl"; -import { useState } from "react"; -import { useFormik } from "formik"; +import {CONFIRM_PASSENGER_BOSS} from "@/core/data/apiRoutes"; +import {Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, TextField,} from "@mui/material"; +import {useTranslations} from "next-intl"; +import {useState} from "react"; +import {useFormik} from "formik"; import * as Yup from "yup"; import UploadSystem from "@/core/components/UploadSystem"; import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; import useDirection from "@/lib/app/hooks/useDirection"; -const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { - const t = useTranslations(); - const { directionApp } = useDirection(); - const [proposedAmount, setProposedAmount] = useState(""); - const [description, setDescription] = useState(""); - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); +const ConfirmForm = ({open, handleClose, rowId, confirmData}) => { + const t = useTranslations(); + const {directionApp} = useDirection(); + const [proposedAmount, setProposedAmount] = useState(""); + const [description, setDescription] = useState(""); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); - //formik - const validationSchema = Yup.object().shape({ - proposed_amount: Yup.string().required( - t("ConfirmDialog.approved_amount_error") - ), - }); - const formik = useFormik({ - initialValues: { - proposed_amount: "", - description: "", - }, - validationSchema, - onSubmit: () => { - const formData = new FormData(); - formData.append("approved_amount", proposedAmount); - if (description != "") formData.append("expert_description", description); - handleClose(); - confirmData(CONFIRM_PASSENGER_BOSS, rowId, formData); - }, - }); + //formik + const validationSchema = Yup.object().shape({ + proposed_amount: Yup.string().required( + t("ConfirmDialog.approved_amount_error") + ), + }); + const formik = useFormik({ + initialValues: { + proposed_amount: "", + description: "", + }, + validationSchema, + onSubmit: () => { + const formData = new FormData(); + formData.append("approved_amount", proposedAmount); + if (description != "") formData.append("expert_description", description); + handleClose(); + confirmData(CONFIRM_PASSENGER_BOSS, rowId, formData); + }, + }); - const handleDescriptionChange = (event) => { - setDescription(event.target.value); - }; - const handleAmountChange = (event) => { - if (/^\d*$/.test(event.target.value)) { - setProposedAmount(event.target.value); - } - formik.handleChange(event); - }; - const handleUploadChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(directionApp, t); - event.target.value = ""; - return; - } - const fileType = event.target?.files?.[0].type; - const fileName = event.target?.files?.[0].name; - setSelectedImage(URL.createObjectURL(uploadedFile)); - setfileType(fileType); - setfileName(fileName); - formik.setFieldValue("confirm_img", uploadedFile); - setShowAddIcon(false); - } - }; + const handleDescriptionChange = (event) => { + setDescription(event.target.value); + }; + const handleAmountChange = (event) => { + if (/^\d*$/.test(event.target.value)) { + setProposedAmount(event.target.value); + } + formik.handleChange(event); + }; + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(directionApp, t); + event.target.value = ""; + return; + } + const fileType = event.target?.files?.[0].type; + const fileName = event.target?.files?.[0].name; + setSelectedImage(URL.createObjectURL(uploadedFile)); + setfileType(fileType); + setfileName(fileName); + formik.setFieldValue("confirm_img", uploadedFile); + setShowAddIcon(false); + } + }; - return ( - - {t("ConfirmDialog.confirm")} - - {t("ConfirmDialog.context")} - - - - - - - - - - ); + return ( + + {t("ConfirmDialog.confirm")} + + {t("ConfirmDialog.context")} + + + + + + + + + + ); }; export default ConfirmForm; diff --git a/src/components/dashboard/passenger-boss/Form/RejectForm.jsx b/src/components/dashboard/passenger-boss/Form/RejectForm.jsx index 955a487..e8dd93e 100644 --- a/src/components/dashboard/passenger-boss/Form/RejectForm.jsx +++ b/src/components/dashboard/passenger-boss/Form/RejectForm.jsx @@ -1,116 +1,108 @@ -import { REJECT_PASSENGER_BOSS } from "@/core/data/apiRoutes"; -import { - Dialog, - DialogTitle, - DialogContent, - DialogContentText, - DialogActions, - Button, - TextField, -} from "@mui/material"; -import { useTranslations } from "next-intl"; -import { useFormik } from "formik"; +import {REJECT_PASSENGER_BOSS} from "@/core/data/apiRoutes"; +import {Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, TextField,} from "@mui/material"; +import {useTranslations} from "next-intl"; +import {useFormik} from "formik"; import * as Yup from "yup"; -import { useState } from "react"; +import {useState} from "react"; import UploadSystem from "@/core/components/UploadSystem"; import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; import useDirection from "@/lib/app/hooks/useDirection"; -const RejectForm = ({ open, handleClose, rowId, rejectData }) => { - const t = useTranslations(); - const { directionApp } = useDirection(); - const [description, setDescription] = useState(""); - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); +const RejectForm = ({open, handleClose, rowId, rejectData}) => { + const t = useTranslations(); + const {directionApp} = useDirection(); + const [description, setDescription] = useState(""); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); - const validationSchema = Yup.object().shape({ - description: Yup.string().required(t("RejectDialog.description_error")), - }); + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("RejectDialog.description_error")), + }); - const formik = useFormik({ - initialValues: { - description: "", - }, - validationSchema, - onSubmit: () => { - const formData = new FormData(); - formData.append("expert_description", description); - handleClose(); - rejectData(REJECT_PASSENGER_BOSS, rowId, formData); - }, - }); + const formik = useFormik({ + initialValues: { + description: "", + }, + validationSchema, + onSubmit: () => { + const formData = new FormData(); + formData.append("expert_description", description); + handleClose(); + rejectData(REJECT_PASSENGER_BOSS, rowId, formData); + }, + }); - const handleDescriptionChange = (event) => { - setDescription(event.target.value); - formik.handleChange(event); - }; + const handleDescriptionChange = (event) => { + setDescription(event.target.value); + formik.handleChange(event); + }; - const handleUploadChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(directionApp, t); - event.target.value = ""; - return; - } - const fileType = event.target?.files?.[0].type; - const fileName = event.target?.files?.[0].name; - setSelectedImage(URL.createObjectURL(uploadedFile)); - setfileType(fileType); - setfileName(fileName); - formik.setFieldValue("reject_img", uploadedFile); - setShowAddIcon(false); - } - }; + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(directionApp, t); + event.target.value = ""; + return; + } + const fileType = event.target?.files?.[0].type; + const fileName = event.target?.files?.[0].name; + setSelectedImage(URL.createObjectURL(uploadedFile)); + setfileType(fileType); + setfileName(fileName); + formik.setFieldValue("reject_img", uploadedFile); + setShowAddIcon(false); + } + }; - return ( - - {t("RejectDialog.reject")} - - {t("RejectDialog.context")} - - - - - - - - - ); + return ( + + {t("RejectDialog.reject")} + + {t("RejectDialog.context")} + + + + + + + + + ); }; export default RejectForm; diff --git a/src/components/dashboard/passenger-boss/TableRowActions.jsx b/src/components/dashboard/passenger-boss/TableRowActions.jsx index 30367b9..13c6e7b 100644 --- a/src/components/dashboard/passenger-boss/TableRowActions.jsx +++ b/src/components/dashboard/passenger-boss/TableRowActions.jsx @@ -1,60 +1,60 @@ import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import { Box, IconButton, Tooltip } from "@mui/material"; -import { useContext } from "react"; +import {Box, IconButton, Tooltip} from "@mui/material"; +import {useContext} from "react"; import ConfirmForm from "./Form/ConfirmForm"; import RejectForm from "./Form/RejectForm"; -import { useTranslations } from "next-intl"; -import { DataTableContext } from "@/lib/app/contexts/DatatableContext"; +import {useTranslations} from "next-intl"; +import {DataTableContext} from "@/lib/app/contexts/DatatableContext"; -const TableRowActions = ({ row }) => { - const t = useTranslations(); - const { - openConfirmDialog, - openRejectDialog, - handleOpenConfirmDialog, - handleOpenRejectDialog, - handleCloseConfirmDialog, - handleCloseRejectDialog, - rowId, - confirmData, - rejectData, - } = useContext(DataTableContext); - return ( - - - { - handleOpenConfirmDialog(row); - }} - > - - - - {openConfirmDialog && ( - - )} - - handleOpenRejectDialog(row)}> - - - - {openRejectDialog && ( - - )} - - ); +const TableRowActions = ({row}) => { + const t = useTranslations(); + const { + openConfirmDialog, + openRejectDialog, + handleOpenConfirmDialog, + handleOpenRejectDialog, + handleCloseConfirmDialog, + handleCloseRejectDialog, + rowId, + confirmData, + rejectData, + } = useContext(DataTableContext); + return ( + + + { + handleOpenConfirmDialog(row); + }} + > + + + + {openConfirmDialog && ( + + )} + + handleOpenRejectDialog(row)}> + + + + {openRejectDialog && ( + + )} + + ); }; export default TableRowActions; diff --git a/src/components/dashboard/passenger-boss/TableTollbar.jsx b/src/components/dashboard/passenger-boss/TableTollbar.jsx index 3f06d3b..e267691 100644 --- a/src/components/dashboard/passenger-boss/TableTollbar.jsx +++ b/src/components/dashboard/passenger-boss/TableTollbar.jsx @@ -1,13 +1,13 @@ -import { Stack, Tooltip } from "@mui/material"; -import { useTranslations } from "next-intl"; +import {Stack, Tooltip} from "@mui/material"; +import {useTranslations} from "next-intl"; function TableToolbar() { - const t = useTranslations(); - return ( - - - - ); + const t = useTranslations(); + return ( + + + + ); } export default TableToolbar; diff --git a/src/components/dashboard/passenger-boss/index.jsx b/src/components/dashboard/passenger-boss/index.jsx index a741312..72f567e 100644 --- a/src/components/dashboard/passenger-boss/index.jsx +++ b/src/components/dashboard/passenger-boss/index.jsx @@ -1,245 +1,242 @@ import DataTableStructure from "@/core/components/DatatableStructure"; import DashboardLayouts from "@/layouts/dashboardLayouts"; -import { Box, IconButton, Typography } from "@mui/material"; +import {Box, IconButton, Typography} from "@mui/material"; import ClearIcon from "@mui/icons-material/Clear"; -import { useMemo } from "react"; +import {useMemo} from "react"; // import TableToolbar from "./TableTollbar"; -import { GET_PASSENGER_BOSS } from "@/core/data/apiRoutes"; -import { useTranslations } from "next-intl"; +import {GET_PASSENGER_BOSS} from "@/core/data/apiRoutes"; +import {useTranslations} from "next-intl"; import TableRowActions from "./TableRowActions"; -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 {faIR} from "@mui/x-date-pickers/locales"; function DashboardPassengerOfficeComponent() { - const t = useTranslations(); + const t = useTranslations(); - const columns = useMemo( - () => [ - { - accessorFn: (row) => row.id, - id: "id", - header: t("PassengerBoss.id"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - maxSize: 100, - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", + const columns = useMemo( + () => [ + { + accessorFn: (row) => row.id, + id: "id", + header: t("PassengerBoss.id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + maxSize: 100, + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.name, + id: "name", + header: t("PassengerBoss.name"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.national_id, + id: "national_id", + header: t("PassengerBoss.national_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("PassengerBoss.phone_number"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => + moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + id: "created_at", + header: t("PassengerBoss.created_at"), + enableColumnFilter: true, + datatype: "date", + filterFn: "lessThan", + minSize: 200, + columnFilterModeOptions: ["lessThan", "greaterThan"], + Cell: ({renderedCellValue}) => { + return {renderedCellValue}; + }, + Header: ({column}) => {column.columnDef.header}, + Filter: ({column}) => { + const filterFnValue = column.columnDef._filterFn; + return ( + + + { + const date = new Date(newValue); + const formattedDate = moment(date) + .locale("en") + .format("YYYY-MM-DD HH:mm"); + column.setFilterValue(formattedDate); + }} + slotProps={{ + textField: { + placeholder: "تاریخ خود را وارد کنید", + helperText: `${t("filter_mode")}: ${t(filterFnValue)}`, + sx: {minWidth: "120px"}, + variant: "standard", + }, + }} + value={ + column.getFilterValue() + ? new Date(column.getFilterValue()) + : null + } + /> + + { + column.setFilterValue(null); + }} + sx={{ + color: column.getFilterValue() + ? "rgba(0, 0, 0, 0.54)" + : "#bfbfbf", + }} + > + + + + ); + }, + }, + { + accessorFn: (row) => + moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + id: "updated_at", + header: t("PassengerBoss.updated_at"), + enableColumnFilter: false, + datatype: "numeric", + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.navgan_id, + id: "navgan_id", + header: t("PassengerBoss.navgan_id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + maxSize: 100, + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.vehicle_type, + id: "vehicle_type", + header: t("PassengerBoss.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("PassengerBoss.state_name"), + enableColumnFilter: false, + datatype: "numeric", + minSize: 300, + // filterFn: "equals", + // filterSelectOptions: [ + // ], + // filterVariant: "select", + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, ], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.name, - id: "name", - header: t("PassengerBoss.name"), - enableColumnFilter: true, - datatype: "text", - filterFn: "contains", - columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.national_id, - id: "national_id", - header: t("PassengerBoss.national_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("PassengerBoss.phone_number"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => - moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), - id: "created_at", - header: t("PassengerBoss.created_at"), - enableColumnFilter: true, - datatype: "date", - filterFn: "lessThan", - minSize: 200, - columnFilterModeOptions: ["lessThan", "greaterThan"], - Cell: ({ renderedCellValue }) => { - return {renderedCellValue}; - }, - Header: ({ column }) => {column.columnDef.header}, - Filter: ({ column }) => { - const filterFnValue = column.columnDef._filterFn; - return ( - - - { - const date = new Date(newValue); - const formattedDate = moment(date) - .locale("en") - .format("YYYY-MM-DD HH:mm"); - column.setFilterValue(formattedDate); - }} - slotProps={{ - textField: { - placeholder: "تاریخ خود را وارد کنید", - helperText: `${t("filter_mode")}: ${t(filterFnValue)}`, - sx: { minWidth: "120px" }, - variant: "standard", - }, - }} - value={ - column.getFilterValue() - ? new Date(column.getFilterValue()) - : null - } + [] + ); + 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}) => } /> - - { - column.setFilterValue(null); - }} - sx={{ - color: column.getFilterValue() - ? "rgba(0, 0, 0, 0.54)" - : "#bfbfbf", - }} - > - - - ); - }, - }, - { - accessorFn: (row) => - moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), - id: "updated_at", - header: t("PassengerBoss.updated_at"), - enableColumnFilter: false, - datatype: "numeric", - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.navgan_id, - id: "navgan_id", - header: t("PassengerBoss.navgan_id"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - maxSize: 100, - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.vehicle_type, - id: "vehicle_type", - header: t("PassengerBoss.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("PassengerBoss.state_name"), - enableColumnFilter: false, - datatype: "numeric", - minSize: 300, - // filterFn: "equals", - // filterSelectOptions: [ - // ], - // 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 DashboardPassengerOfficeComponent; diff --git a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx index 1e02f33..c5abc13 100644 --- a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx @@ -1,106 +1,98 @@ import UploadSystem from "@/core/components/UploadSystem"; import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; -import { CONFIRM_PASSENGER_OFFICE } from "@/core/data/apiRoutes"; +import {CONFIRM_PASSENGER_OFFICE} from "@/core/data/apiRoutes"; import useDirection from "@/lib/app/hooks/useDirection"; -import { - Dialog, - DialogTitle, - DialogContent, - DialogContentText, - DialogActions, - Button, - TextField, -} from "@mui/material"; -import { useFormik } from "formik"; -import { useTranslations } from "next-intl"; -import { useRef, useState } from "react"; +import {Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, TextField,} from "@mui/material"; +import {useFormik} from "formik"; +import {useTranslations} from "next-intl"; +import {useState} from "react"; -const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { - const t = useTranslations(); - const { directionApp } = useDirection(); - const [description, setDescription] = useState(""); - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); +const ConfirmForm = ({open, handleClose, rowId, confirmData}) => { + const t = useTranslations(); + const {directionApp} = useDirection(); + const [description, setDescription] = useState(""); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); - const formik = useFormik({ - initialValues: { - description: "", - }, - onSubmit: () => { - const formData = new FormData(); - if (description !== "") - formData.append("expert_description", description); - handleClose(); - confirmData(CONFIRM_PASSENGER_OFFICE, rowId, formData); - }, - }); + const formik = useFormik({ + initialValues: { + description: "", + }, + onSubmit: () => { + const formData = new FormData(); + if (description !== "") + formData.append("expert_description", description); + handleClose(); + confirmData(CONFIRM_PASSENGER_OFFICE, rowId, formData); + }, + }); - const handleDescriptionChange = (event) => { - setDescription(event.target.value); - formik.handleChange(event); - }; + const handleDescriptionChange = (event) => { + setDescription(event.target.value); + formik.handleChange(event); + }; - const handleUploadChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(directionApp, t); - event.target.value = ""; - return; - } - const fileType = event.target?.files?.[0].type; - const fileName = event.target?.files?.[0].name; - setSelectedImage(URL.createObjectURL(uploadedFile)); - setfileType(fileType); - setfileName(fileName); - formik.setFieldValue("confirm_img", uploadedFile); - setShowAddIcon(false); - } - }; + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(directionApp, t); + event.target.value = ""; + return; + } + const fileType = event.target?.files?.[0].type; + const fileName = event.target?.files?.[0].name; + setSelectedImage(URL.createObjectURL(uploadedFile)); + setfileType(fileType); + setfileName(fileName); + formik.setFieldValue("confirm_img", uploadedFile); + setShowAddIcon(false); + } + }; - return ( - - {t("ConfirmDialog.confirm")} - - {t("ConfirmDialog.context")} - - - - - - - - - ); + return ( + + {t("ConfirmDialog.confirm")} + + {t("ConfirmDialog.context")} + + + + + + + + + ); }; export default ConfirmForm; diff --git a/src/components/dashboard/passenger-office/Form/RejectForm.jsx b/src/components/dashboard/passenger-office/Form/RejectForm.jsx index 6b66c7a..ec3b07a 100644 --- a/src/components/dashboard/passenger-office/Form/RejectForm.jsx +++ b/src/components/dashboard/passenger-office/Form/RejectForm.jsx @@ -1,114 +1,106 @@ -import { REJECT_PASSENGER_OFFICE } from "@/core/data/apiRoutes"; -import { - Dialog, - DialogTitle, - DialogContent, - DialogContentText, - DialogActions, - Button, - TextField, -} from "@mui/material"; -import { useTranslations } from "next-intl"; -import { useFormik } from "formik"; +import {REJECT_PASSENGER_OFFICE} from "@/core/data/apiRoutes"; +import {Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, TextField,} from "@mui/material"; +import {useTranslations} from "next-intl"; +import {useFormik} from "formik"; import * as Yup from "yup"; -import { useState } from "react"; +import {useState} from "react"; import UploadSystem from "@/core/components/UploadSystem"; import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; import useDirection from "@/lib/app/hooks/useDirection"; -const RejectForm = ({ open, handleClose, rowId, rejectData }) => { - const t = useTranslations(); - const { directionApp } = useDirection(); - const [description, setDescription] = useState(""); - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); +const RejectForm = ({open, handleClose, rowId, rejectData}) => { + const t = useTranslations(); + const {directionApp} = useDirection(); + const [description, setDescription] = useState(""); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); - const validationSchema = Yup.object().shape({ - description: Yup.string().required(t("RejectDialog.description_error")), - }); + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("RejectDialog.description_error")), + }); - const formik = useFormik({ - initialValues: { - description: "", - }, - validationSchema, - onSubmit: () => { - const formData = new FormData(); - formData.append("expert_description", description); - handleClose(); - rejectData(REJECT_PASSENGER_OFFICE, rowId, formData); - }, - }); + const formik = useFormik({ + initialValues: { + description: "", + }, + validationSchema, + onSubmit: () => { + const formData = new FormData(); + formData.append("expert_description", description); + handleClose(); + rejectData(REJECT_PASSENGER_OFFICE, rowId, formData); + }, + }); - const handleDescriptionChange = (event) => { - setDescription(event.target.value); - formik.handleChange(event); - }; - const handleUploadChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(directionApp, t); - event.target.value = ""; - return; - } - const fileType = event.target?.files?.[0].type; - const fileName = event.target?.files?.[0].name; - setSelectedImage(URL.createObjectURL(uploadedFile)); - setfileType(fileType); - setfileName(fileName); - formik.setFieldValue("reject_img", uploadedFile); - setShowAddIcon(false); - } - }; - return ( - - {t("RejectDialog.reject")} - - {t("RejectDialog.context")} - - - - - - - - - ); + const handleDescriptionChange = (event) => { + setDescription(event.target.value); + formik.handleChange(event); + }; + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(directionApp, t); + event.target.value = ""; + return; + } + const fileType = event.target?.files?.[0].type; + const fileName = event.target?.files?.[0].name; + setSelectedImage(URL.createObjectURL(uploadedFile)); + setfileType(fileType); + setfileName(fileName); + formik.setFieldValue("reject_img", uploadedFile); + setShowAddIcon(false); + } + }; + return ( + + {t("RejectDialog.reject")} + + {t("RejectDialog.context")} + + + + + + + + + ); }; export default RejectForm; diff --git a/src/components/dashboard/passenger-office/TableRowActions.jsx b/src/components/dashboard/passenger-office/TableRowActions.jsx index 30367b9..13c6e7b 100644 --- a/src/components/dashboard/passenger-office/TableRowActions.jsx +++ b/src/components/dashboard/passenger-office/TableRowActions.jsx @@ -1,60 +1,60 @@ import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import { Box, IconButton, Tooltip } from "@mui/material"; -import { useContext } from "react"; +import {Box, IconButton, Tooltip} from "@mui/material"; +import {useContext} from "react"; import ConfirmForm from "./Form/ConfirmForm"; import RejectForm from "./Form/RejectForm"; -import { useTranslations } from "next-intl"; -import { DataTableContext } from "@/lib/app/contexts/DatatableContext"; +import {useTranslations} from "next-intl"; +import {DataTableContext} from "@/lib/app/contexts/DatatableContext"; -const TableRowActions = ({ row }) => { - const t = useTranslations(); - const { - openConfirmDialog, - openRejectDialog, - handleOpenConfirmDialog, - handleOpenRejectDialog, - handleCloseConfirmDialog, - handleCloseRejectDialog, - rowId, - confirmData, - rejectData, - } = useContext(DataTableContext); - return ( - - - { - handleOpenConfirmDialog(row); - }} - > - - - - {openConfirmDialog && ( - - )} - - handleOpenRejectDialog(row)}> - - - - {openRejectDialog && ( - - )} - - ); +const TableRowActions = ({row}) => { + const t = useTranslations(); + const { + openConfirmDialog, + openRejectDialog, + handleOpenConfirmDialog, + handleOpenRejectDialog, + handleCloseConfirmDialog, + handleCloseRejectDialog, + rowId, + confirmData, + rejectData, + } = useContext(DataTableContext); + return ( + + + { + handleOpenConfirmDialog(row); + }} + > + + + + {openConfirmDialog && ( + + )} + + handleOpenRejectDialog(row)}> + + + + {openRejectDialog && ( + + )} + + ); }; export default TableRowActions; diff --git a/src/components/dashboard/passenger-office/TableTollbar.jsx b/src/components/dashboard/passenger-office/TableTollbar.jsx index 3f06d3b..e267691 100644 --- a/src/components/dashboard/passenger-office/TableTollbar.jsx +++ b/src/components/dashboard/passenger-office/TableTollbar.jsx @@ -1,13 +1,13 @@ -import { Stack, Tooltip } from "@mui/material"; -import { useTranslations } from "next-intl"; +import {Stack, Tooltip} from "@mui/material"; +import {useTranslations} from "next-intl"; function TableToolbar() { - const t = useTranslations(); - return ( - - - - ); + const t = useTranslations(); + return ( + + + + ); } export default TableToolbar; diff --git a/src/components/dashboard/passenger-office/index.jsx b/src/components/dashboard/passenger-office/index.jsx index 5401adc..5f8ddc5 100644 --- a/src/components/dashboard/passenger-office/index.jsx +++ b/src/components/dashboard/passenger-office/index.jsx @@ -1,247 +1,243 @@ import DataTableStructure from "@/core/components/DatatableStructure"; import DashboardLayouts from "@/layouts/dashboardLayouts"; -import { Box, IconButton, Typography } from "@mui/material"; +import {Box, IconButton, Typography} from "@mui/material"; import ClearIcon from "@mui/icons-material/Clear"; -import { useMemo } from "react"; -import { faIR } from "@mui/x-date-pickers/locales"; +import {useMemo} from "react"; +import {faIR} from "@mui/x-date-pickers/locales"; // import TableToolbar from "./TableTollbar"; -import { GET_PASSENGER_OFFICE } from "@/core/data/apiRoutes"; -import { useTranslations } from "next-intl"; +import {GET_PASSENGER_OFFICE} from "@/core/data/apiRoutes"; +import {useTranslations} from "next-intl"; import TableRowActions from "./TableRowActions"; -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 dayjs from "dayjs"; function DashboardPassengerOfficeComponent() { - const t = useTranslations(); + const t = useTranslations(); - const columns = useMemo( - () => [ - { - accessorFn: (row) => row.id, - id: "id", - header: t("PassengerOffice.id"), - enableColumnFilter: true, - datatype: "numeric", - maxSize: 100, - filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", + const columns = useMemo( + () => [ + { + accessorFn: (row) => row.id, + id: "id", + header: t("PassengerOffice.id"), + enableColumnFilter: true, + datatype: "numeric", + maxSize: 100, + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.name, + id: "name", + header: t("PassengerOffice.name"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.national_id, + id: "national_id", + header: t("PassengerOffice.national_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("PassengerOffice.phone_number"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => + moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + id: "created_at", + header: t("PassengerOffice.created_at"), + enableColumnFilter: true, + datatype: "date", + filterFn: "lessThan", + minSize: 200, + columnFilterModeOptions: ["lessThan", "greaterThan"], + Cell: ({renderedCellValue}) => { + return {renderedCellValue}; + }, + Header: ({column}) => {column.columnDef.header}, + Filter: ({column}) => { + const filterFnValue = column.columnDef._filterFn; + return ( + + + { + const date = new Date(newValue); + const formattedDate = moment(date) + .locale("en") + .format("YYYY-MM-DD HH:mm"); + column.setFilterValue(formattedDate); + }} + slotProps={{ + textField: { + placeholder: "تاریخ خود را وارد کنید", + helperText: `${t("filter_mode")}: ${t(filterFnValue)}`, + sx: {minWidth: "120px"}, + variant: "standard", + actionBar: {actions: ["accept", "today"]}, + }, + }} + value={ + column.getFilterValue() + ? new Date(column.getFilterValue()) + : null + } + /> + + { + column.setFilterValue(null); + }} + sx={{ + color: column.getFilterValue() + ? "rgba(0, 0, 0, 0.54)" + : "#bfbfbf", + }} + > + + + + ); + }, + }, + { + accessorFn: (row) => + moment(row.updated_at).locale("fa").format("HH:mm | YYYY/MM/DD"), + id: "updated_at", + header: t("PassengerOffice.updated_at"), + enableColumnFilter: false, + datatype: "numeric", + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.navgan_id, + id: "navgan_id", + header: t("PassengerOffice.navgan_id"), + enableColumnFilter: true, + datatype: "numeric", + maxSize: 100, + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.vehicle_type, + id: "vehicle_type", + header: t("PassengerOffice.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("PassengerOffice.state_name"), + enableColumnFilter: false, + datatype: "numeric", + minSize: 300, + // filterFn: "equals", + // filterSelectOptions: [ + // ], + // filterVariant: "select", + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, ], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.name, - id: "name", - header: t("PassengerOffice.name"), - enableColumnFilter: true, - datatype: "text", - filterFn: "contains", - columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.national_id, - id: "national_id", - header: t("PassengerOffice.national_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("PassengerOffice.phone_number"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => - moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), - id: "created_at", - header: t("PassengerOffice.created_at"), - enableColumnFilter: true, - datatype: "date", - filterFn: "lessThan", - minSize: 200, - columnFilterModeOptions: ["lessThan", "greaterThan"], - Cell: ({ renderedCellValue }) => { - return {renderedCellValue}; - }, - Header: ({ column }) => {column.columnDef.header}, - Filter: ({ column }) => { - const filterFnValue = column.columnDef._filterFn; - return ( - - - { - const date = new Date(newValue); - const formattedDate = moment(date) - .locale("en") - .format("YYYY-MM-DD HH:mm"); - column.setFilterValue(formattedDate); - }} - slotProps={{ - textField: { - placeholder: "تاریخ خود را وارد کنید", - helperText: `${t("filter_mode")}: ${t(filterFnValue)}`, - sx: { minWidth: "120px" }, - variant: "standard", - actionBar: { actions: ["accept", "today"] }, - }, - }} - value={ - column.getFilterValue() - ? new Date(column.getFilterValue()) - : null - } + [] + ); + 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}) => } /> - - { - column.setFilterValue(null); - }} - sx={{ - color: column.getFilterValue() - ? "rgba(0, 0, 0, 0.54)" - : "#bfbfbf", - }} - > - - - ); - }, - }, - { - accessorFn: (row) => - moment(row.updated_at).locale("fa").format("HH:mm | YYYY/MM/DD"), - id: "updated_at", - header: t("PassengerOffice.updated_at"), - enableColumnFilter: false, - datatype: "numeric", - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.navgan_id, - id: "navgan_id", - header: t("PassengerOffice.navgan_id"), - enableColumnFilter: true, - datatype: "numeric", - maxSize: 100, - filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.vehicle_type, - id: "vehicle_type", - header: t("PassengerOffice.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("PassengerOffice.state_name"), - enableColumnFilter: false, - datatype: "numeric", - minSize: 300, - // filterFn: "equals", - // filterSelectOptions: [ - // ], - // 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 DashboardPassengerOfficeComponent; diff --git a/src/components/dashboard/province-manager/Form/ConfirmForm.jsx b/src/components/dashboard/province-manager/Form/ConfirmForm.jsx index 69e3a62..e456631 100644 --- a/src/components/dashboard/province-manager/Form/ConfirmForm.jsx +++ b/src/components/dashboard/province-manager/Form/ConfirmForm.jsx @@ -1,106 +1,98 @@ import UploadSystem from "@/core/components/UploadSystem"; import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; -import { CONFIRM_PROVINCE_MANAGER } from "@/core/data/apiRoutes"; +import {CONFIRM_PROVINCE_MANAGER} from "@/core/data/apiRoutes"; import useDirection from "@/lib/app/hooks/useDirection"; -import { - Dialog, - DialogTitle, - DialogContent, - DialogContentText, - DialogActions, - Button, - TextField, -} from "@mui/material"; -import { useFormik } from "formik"; -import { useTranslations } from "next-intl"; -import { useRef, useState } from "react"; +import {Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, TextField,} from "@mui/material"; +import {useFormik} from "formik"; +import {useTranslations} from "next-intl"; +import {useState} from "react"; -const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { - const t = useTranslations(); - const { directionApp } = useDirection(); - const [description, setDescription] = useState(""); - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); +const ConfirmForm = ({open, handleClose, rowId, confirmData}) => { + const t = useTranslations(); + const {directionApp} = useDirection(); + const [description, setDescription] = useState(""); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); - const formik = useFormik({ - initialValues: { - description: "", - }, - onSubmit: () => { - const formData = new FormData(); - if (description !== "") - formData.append("expert_description", description); - handleClose(); - confirmData(CONFIRM_PROVINCE_MANAGER, rowId, formData); - }, - }); + const formik = useFormik({ + initialValues: { + description: "", + }, + onSubmit: () => { + const formData = new FormData(); + if (description !== "") + formData.append("expert_description", description); + handleClose(); + confirmData(CONFIRM_PROVINCE_MANAGER, rowId, formData); + }, + }); - const handleDescriptionChange = (event) => { - setDescription(event.target.value); - formik.handleChange(event); - }; + const handleDescriptionChange = (event) => { + setDescription(event.target.value); + formik.handleChange(event); + }; - const handleUploadChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(directionApp, t); - event.target.value = ""; - return; - } - const fileType = event.target?.files?.[0].type; - const fileName = event.target?.files?.[0].name; - setSelectedImage(URL.createObjectURL(uploadedFile)); - setfileType(fileType); - setfileName(fileName); - formik.setFieldValue("confirm_img", uploadedFile); - setShowAddIcon(false); - } - }; + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(directionApp, t); + event.target.value = ""; + return; + } + const fileType = event.target?.files?.[0].type; + const fileName = event.target?.files?.[0].name; + setSelectedImage(URL.createObjectURL(uploadedFile)); + setfileType(fileType); + setfileName(fileName); + formik.setFieldValue("confirm_img", uploadedFile); + setShowAddIcon(false); + } + }; - return ( - - {t("ConfirmDialog.confirm")} - - {t("ConfirmDialog.context")} - - - - - - - - - ); + return ( + + {t("ConfirmDialog.confirm")} + + {t("ConfirmDialog.context")} + + + + + + + + + ); }; export default ConfirmForm; diff --git a/src/components/dashboard/province-manager/Form/RejectForm.jsx b/src/components/dashboard/province-manager/Form/RejectForm.jsx index f1e266d..a50bcf0 100644 --- a/src/components/dashboard/province-manager/Form/RejectForm.jsx +++ b/src/components/dashboard/province-manager/Form/RejectForm.jsx @@ -1,115 +1,107 @@ -import { REJECT_PROVINCE_MANAGER } from "@/core/data/apiRoutes"; -import { - Dialog, - DialogTitle, - DialogContent, - DialogContentText, - DialogActions, - Button, - TextField, -} from "@mui/material"; -import { useTranslations } from "next-intl"; -import { useFormik } from "formik"; +import {REJECT_PROVINCE_MANAGER} from "@/core/data/apiRoutes"; +import {Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, TextField,} from "@mui/material"; +import {useTranslations} from "next-intl"; +import {useFormik} from "formik"; import * as Yup from "yup"; -import { useState } from "react"; +import {useState} from "react"; import UploadSystem from "@/core/components/UploadSystem"; import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; import useDirection from "@/lib/app/hooks/useDirection"; -const RejectForm = ({ open, handleClose, rowId, rejectData }) => { - const t = useTranslations(); - const { directionApp } = useDirection(); - const [description, setDescription] = useState(""); - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); +const RejectForm = ({open, handleClose, rowId, rejectData}) => { + const t = useTranslations(); + const {directionApp} = useDirection(); + const [description, setDescription] = useState(""); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); - const validationSchema = Yup.object().shape({ - description: Yup.string().required(t("RejectDialog.description_error")), - }); + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("RejectDialog.description_error")), + }); - const formik = useFormik({ - initialValues: { - description: "", - }, - validationSchema, - onSubmit: () => { - const formData = new FormData(); - formData.append("expert_description", description); - handleClose(); - rejectData(REJECT_PROVINCE_MANAGER, rowId, formData); - }, - }); + const formik = useFormik({ + initialValues: { + description: "", + }, + validationSchema, + onSubmit: () => { + const formData = new FormData(); + formData.append("expert_description", description); + handleClose(); + rejectData(REJECT_PROVINCE_MANAGER, rowId, formData); + }, + }); - const handleDescriptionChange = (event) => { - setDescription(event.target.value); - formik.handleChange(event); - }; - const handleUploadChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(directionApp, t); - event.target.value = ""; - return; - } - const fileType = event.target?.files?.[0].type; - const fileName = event.target?.files?.[0].name; - setSelectedImage(URL.createObjectURL(uploadedFile)); - setfileType(fileType); - setfileName(fileName); - formik.setFieldValue("reject_img", uploadedFile); - setShowAddIcon(false); - } - }; + const handleDescriptionChange = (event) => { + setDescription(event.target.value); + formik.handleChange(event); + }; + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(directionApp, t); + event.target.value = ""; + return; + } + const fileType = event.target?.files?.[0].type; + const fileName = event.target?.files?.[0].name; + setSelectedImage(URL.createObjectURL(uploadedFile)); + setfileType(fileType); + setfileName(fileName); + formik.setFieldValue("reject_img", uploadedFile); + setShowAddIcon(false); + } + }; - return ( - - {t("RejectDialog.reject")} - - {t("RejectDialog.context")} - - - - - - - - - ); + return ( + + {t("RejectDialog.reject")} + + {t("RejectDialog.context")} + + + + + + + + + ); }; export default RejectForm; diff --git a/src/components/dashboard/province-manager/TableRowActions.jsx b/src/components/dashboard/province-manager/TableRowActions.jsx index 30367b9..13c6e7b 100644 --- a/src/components/dashboard/province-manager/TableRowActions.jsx +++ b/src/components/dashboard/province-manager/TableRowActions.jsx @@ -1,60 +1,60 @@ import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import { Box, IconButton, Tooltip } from "@mui/material"; -import { useContext } from "react"; +import {Box, IconButton, Tooltip} from "@mui/material"; +import {useContext} from "react"; import ConfirmForm from "./Form/ConfirmForm"; import RejectForm from "./Form/RejectForm"; -import { useTranslations } from "next-intl"; -import { DataTableContext } from "@/lib/app/contexts/DatatableContext"; +import {useTranslations} from "next-intl"; +import {DataTableContext} from "@/lib/app/contexts/DatatableContext"; -const TableRowActions = ({ row }) => { - const t = useTranslations(); - const { - openConfirmDialog, - openRejectDialog, - handleOpenConfirmDialog, - handleOpenRejectDialog, - handleCloseConfirmDialog, - handleCloseRejectDialog, - rowId, - confirmData, - rejectData, - } = useContext(DataTableContext); - return ( - - - { - handleOpenConfirmDialog(row); - }} - > - - - - {openConfirmDialog && ( - - )} - - handleOpenRejectDialog(row)}> - - - - {openRejectDialog && ( - - )} - - ); +const TableRowActions = ({row}) => { + const t = useTranslations(); + const { + openConfirmDialog, + openRejectDialog, + handleOpenConfirmDialog, + handleOpenRejectDialog, + handleCloseConfirmDialog, + handleCloseRejectDialog, + rowId, + confirmData, + rejectData, + } = useContext(DataTableContext); + return ( + + + { + handleOpenConfirmDialog(row); + }} + > + + + + {openConfirmDialog && ( + + )} + + handleOpenRejectDialog(row)}> + + + + {openRejectDialog && ( + + )} + + ); }; export default TableRowActions; diff --git a/src/components/dashboard/province-manager/TableTollbar.jsx b/src/components/dashboard/province-manager/TableTollbar.jsx index 3f06d3b..e267691 100644 --- a/src/components/dashboard/province-manager/TableTollbar.jsx +++ b/src/components/dashboard/province-manager/TableTollbar.jsx @@ -1,13 +1,13 @@ -import { Stack, Tooltip } from "@mui/material"; -import { useTranslations } from "next-intl"; +import {Stack, Tooltip} from "@mui/material"; +import {useTranslations} from "next-intl"; function TableToolbar() { - const t = useTranslations(); - return ( - - - - ); + const t = useTranslations(); + return ( + + + + ); } export default TableToolbar; diff --git a/src/components/dashboard/province-manager/index.jsx b/src/components/dashboard/province-manager/index.jsx index 062e866..5054e02 100644 --- a/src/components/dashboard/province-manager/index.jsx +++ b/src/components/dashboard/province-manager/index.jsx @@ -1,245 +1,242 @@ import DataTableStructure from "@/core/components/DatatableStructure"; import DashboardLayouts from "@/layouts/dashboardLayouts"; -import { Box, IconButton, Typography } from "@mui/material"; +import {Box, IconButton, Typography} from "@mui/material"; import ClearIcon from "@mui/icons-material/Clear"; -import { useMemo } from "react"; +import {useMemo} from "react"; // import TableToolbar from "./TableTollbar"; -import { GET_PROVINCE_MANAGER } from "@/core/data/apiRoutes"; -import { useTranslations } from "next-intl"; +import {GET_PROVINCE_MANAGER} from "@/core/data/apiRoutes"; +import {useTranslations} from "next-intl"; import TableRowActions from "./TableRowActions"; -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 {faIR} from "@mui/x-date-pickers/locales"; function DashboardProvinceManagerComponent() { - const t = useTranslations(); + const t = useTranslations(); - const columns = useMemo( - () => [ - { - accessorFn: (row) => row.id, - id: "id", - header: t("ProvinceManager.id"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - maxSize: 100, - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", + const columns = useMemo( + () => [ + { + accessorFn: (row) => row.id, + id: "id", + header: t("ProvinceManager.id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + maxSize: 100, + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.name, + id: "name", + header: t("ProvinceManager.name"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.national_id, + id: "national_id", + header: t("ProvinceManager.national_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("ProvinceManager.phone_number"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => + moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + id: "created_at", + header: t("ProvinceManager.created_at"), + enableColumnFilter: true, + datatype: "date", + filterFn: "lessThan", + minSize: 200, + columnFilterModeOptions: ["lessThan", "greaterThan"], + Cell: ({renderedCellValue}) => { + return {renderedCellValue}; + }, + Header: ({column}) => {column.columnDef.header}, + Filter: ({column}) => { + const filterFnValue = column.columnDef._filterFn; + return ( + + + { + const date = new Date(newValue); + const formattedDate = moment(date) + .locale("en") + .format("YYYY-MM-DD HH:mm"); + column.setFilterValue(formattedDate); + }} + slotProps={{ + textField: { + placeholder: "تاریخ خود را وارد کنید", + helperText: `${t("filter_mode")}: ${t(filterFnValue)}`, + sx: {minWidth: "120px"}, + variant: "standard", + }, + }} + value={ + column.getFilterValue() + ? new Date(column.getFilterValue()) + : null + } + /> + + { + column.setFilterValue(null); + }} + sx={{ + color: column.getFilterValue() + ? "rgba(0, 0, 0, 0.54)" + : "#bfbfbf", + }} + > + + + + ); + }, + }, + { + accessorFn: (row) => + moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + id: "updated_at", + header: t("ProvinceManager.updated_at"), + enableColumnFilter: false, + datatype: "numeric", + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.navgan_id, + id: "navgan_id", + header: t("ProvinceManager.navgan_id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + maxSize: 100, + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.vehicle_type, + id: "vehicle_type", + header: t("ProvinceManager.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("ProvinceManager.state_name"), + enableColumnFilter: false, + datatype: "numeric", + minSize: 300, + // filterFn: "equals", + // filterSelectOptions: [ + // ], + // filterVariant: "select", + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, ], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.name, - id: "name", - header: t("ProvinceManager.name"), - enableColumnFilter: true, - datatype: "text", - filterFn: "contains", - columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.national_id, - id: "national_id", - header: t("ProvinceManager.national_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("ProvinceManager.phone_number"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => - moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), - id: "created_at", - header: t("ProvinceManager.created_at"), - enableColumnFilter: true, - datatype: "date", - filterFn: "lessThan", - minSize: 200, - columnFilterModeOptions: ["lessThan", "greaterThan"], - Cell: ({ renderedCellValue }) => { - return {renderedCellValue}; - }, - Header: ({ column }) => {column.columnDef.header}, - Filter: ({ column }) => { - const filterFnValue = column.columnDef._filterFn; - return ( - - - { - const date = new Date(newValue); - const formattedDate = moment(date) - .locale("en") - .format("YYYY-MM-DD HH:mm"); - column.setFilterValue(formattedDate); - }} - slotProps={{ - textField: { - placeholder: "تاریخ خود را وارد کنید", - helperText: `${t("filter_mode")}: ${t(filterFnValue)}`, - sx: { minWidth: "120px" }, - variant: "standard", - }, - }} - value={ - column.getFilterValue() - ? new Date(column.getFilterValue()) - : null - } + [] + ); + 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}) => } /> - - { - column.setFilterValue(null); - }} - sx={{ - color: column.getFilterValue() - ? "rgba(0, 0, 0, 0.54)" - : "#bfbfbf", - }} - > - - - ); - }, - }, - { - accessorFn: (row) => - moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), - id: "updated_at", - header: t("ProvinceManager.updated_at"), - enableColumnFilter: false, - datatype: "numeric", - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.navgan_id, - id: "navgan_id", - header: t("ProvinceManager.navgan_id"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - maxSize: 100, - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.vehicle_type, - id: "vehicle_type", - header: t("ProvinceManager.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("ProvinceManager.state_name"), - enableColumnFilter: false, - datatype: "numeric", - minSize: 300, - // filterFn: "equals", - // filterSelectOptions: [ - // ], - // 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 DashboardProvinceManagerComponent; diff --git a/src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx b/src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx index 8067eee..f7f7b88 100644 --- a/src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx +++ b/src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx @@ -1,102 +1,94 @@ import UploadSystem from "@/core/components/UploadSystem"; -import { CONFIRM_TRANSPORTATION_ASSISTANCE } from "@/core/data/apiRoutes"; +import {CONFIRM_TRANSPORTATION_ASSISTANCE} from "@/core/data/apiRoutes"; import useDirection from "@/lib/app/hooks/useDirection"; -import { - Dialog, - DialogTitle, - DialogContent, - DialogContentText, - DialogActions, - Button, - TextField, -} from "@mui/material"; -import { useFormik } from "formik"; -import { useTranslations } from "next-intl"; -import { useState } from "react"; +import {Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, TextField,} from "@mui/material"; +import {useFormik} from "formik"; +import {useTranslations} from "next-intl"; +import {useState} from "react"; import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; -const ConfirmForm = ({ open, handleClose, rowId, confirmData }) => { - const t = useTranslations(); - const { directionApp } = useDirection(); - const [description, setDescription] = useState(""); - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); +const ConfirmForm = ({open, handleClose, rowId, confirmData}) => { + const t = useTranslations(); + const {directionApp} = useDirection(); + const [description, setDescription] = useState(""); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); - const formik = useFormik({ - initialValues: { - description: "", - }, - onSubmit: () => { - const formData = new FormData(); - if (description != "") formData.append("expert_description", description); - handleClose(); - confirmData(CONFIRM_TRANSPORTATION_ASSISTANCE, rowId, formData); - }, - }); + const formik = useFormik({ + initialValues: { + description: "", + }, + onSubmit: () => { + const formData = new FormData(); + if (description != "") formData.append("expert_description", description); + handleClose(); + confirmData(CONFIRM_TRANSPORTATION_ASSISTANCE, rowId, formData); + }, + }); - const handleDescriptionChange = (event) => { - setDescription(event.target.value); - }; - const handleUploadChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(directionApp, t); - event.target.value = ""; - return; - } + const handleDescriptionChange = (event) => { + setDescription(event.target.value); + }; + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(directionApp, t); + event.target.value = ""; + return; + } - const fileType = event.target?.files?.[0].type; - const fileName = event.target?.files?.[0].name; - setSelectedImage(URL.createObjectURL(uploadedFile)); - setfileType(fileType); - setfileName(fileName); - formik.setFieldValue("confirm_img", uploadedFile); - setShowAddIcon(false); - } - }; - return ( - - {t("ConfirmDialog.confirm")} - - {t("ConfirmDialog.context")} - - - - - - - - - ); + const fileType = event.target?.files?.[0].type; + const fileName = event.target?.files?.[0].name; + setSelectedImage(URL.createObjectURL(uploadedFile)); + setfileType(fileType); + setfileName(fileName); + formik.setFieldValue("confirm_img", uploadedFile); + setShowAddIcon(false); + } + }; + return ( + + {t("ConfirmDialog.confirm")} + + {t("ConfirmDialog.context")} + + + + + + + + + ); }; export default ConfirmForm; diff --git a/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx b/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx index fb3a290..f7643ab 100644 --- a/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx +++ b/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx @@ -1,113 +1,105 @@ -import { REJECT_TRANSPORTATION_ASSISTANCE } from "@/core/data/apiRoutes"; -import { - Dialog, - DialogTitle, - DialogContent, - DialogContentText, - DialogActions, - Button, - TextField, -} from "@mui/material"; -import { useTranslations } from "next-intl"; -import { useFormik } from "formik"; +import {REJECT_TRANSPORTATION_ASSISTANCE} from "@/core/data/apiRoutes"; +import {Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, TextField,} from "@mui/material"; +import {useTranslations} from "next-intl"; +import {useFormik} from "formik"; import * as Yup from "yup"; -import { useState } from "react"; +import {useState} from "react"; import UploadSystem from "@/core/components/UploadSystem"; import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; import useDirection from "@/lib/app/hooks/useDirection"; -const RejectForm = ({ open, handleClose, rowId, rejectData }) => { - const [description, setDescription] = useState(""); - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); - const t = useTranslations(); - const { directionApp } = useDirection(); +const RejectForm = ({open, handleClose, rowId, rejectData}) => { + const [description, setDescription] = useState(""); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const t = useTranslations(); + const {directionApp} = useDirection(); - const validationSchema = Yup.object().shape({ - description: Yup.string().required(t("RejectDialog.description_error")), - }); + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("RejectDialog.description_error")), + }); - const formik = useFormik({ - initialValues: { - description: "", - }, - validationSchema, - onSubmit: () => { - const formData = new FormData(); - formData.append("expert_description", description); - handleClose(); - rejectData(REJECT_TRANSPORTATION_ASSISTANCE, rowId, formData); - }, - }); + const formik = useFormik({ + initialValues: { + description: "", + }, + validationSchema, + onSubmit: () => { + const formData = new FormData(); + formData.append("expert_description", description); + handleClose(); + rejectData(REJECT_TRANSPORTATION_ASSISTANCE, rowId, formData); + }, + }); - const handleDescriptionChange = (event) => { - setDescription(event.target.value); - formik.handleChange(event); - }; - const handleUploadChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(directionApp, t); - event.target.value = ""; - return; - } - const fileType = event.target?.files?.[0].type; - const fileName = event.target?.files?.[0].name; - setSelectedImage(URL.createObjectURL(uploadedFile)); - setfileType(fileType); - setfileName(fileName); - formik.setFieldValue("reject_img", uploadedFile); - setShowAddIcon(false); - } - }; - return ( - - {t("RejectDialog.reject")} - - {t("RejectDialog.context")} - - - - - - - - - ); + const handleDescriptionChange = (event) => { + setDescription(event.target.value); + formik.handleChange(event); + }; + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(directionApp, t); + event.target.value = ""; + return; + } + const fileType = event.target?.files?.[0].type; + const fileName = event.target?.files?.[0].name; + setSelectedImage(URL.createObjectURL(uploadedFile)); + setfileType(fileType); + setfileName(fileName); + formik.setFieldValue("reject_img", uploadedFile); + setShowAddIcon(false); + } + }; + return ( + + {t("RejectDialog.reject")} + + {t("RejectDialog.context")} + + + + + + + + + ); }; export default RejectForm; diff --git a/src/components/dashboard/transportation-assistance/TableRowActions.jsx b/src/components/dashboard/transportation-assistance/TableRowActions.jsx index e4b8334..1306d2c 100644 --- a/src/components/dashboard/transportation-assistance/TableRowActions.jsx +++ b/src/components/dashboard/transportation-assistance/TableRowActions.jsx @@ -1,61 +1,61 @@ import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import { Box, IconButton, Tooltip } from "@mui/material"; -import { useContext } from "react"; +import {Box, IconButton, Tooltip} from "@mui/material"; +import {useContext} from "react"; import ConfirmForm from "./Form/ConfirmForm"; import RejectForm from "./Form/RejectForm"; -import { useTranslations } from "next-intl"; -import { DataTableContext } from "@/lib/app/contexts/DatatableContext"; +import {useTranslations} from "next-intl"; +import {DataTableContext} from "@/lib/app/contexts/DatatableContext"; -const TableRowActions = ({ row }) => { - const t = useTranslations(); +const TableRowActions = ({row}) => { + const t = useTranslations(); - const { - openConfirmDialog, - openRejectDialog, - handleOpenConfirmDialog, - handleOpenRejectDialog, - handleCloseConfirmDialog, - handleCloseRejectDialog, - rowId, - confirmData, - rejectData, - } = useContext(DataTableContext); - return ( - - - { - handleOpenConfirmDialog(row); - }} - > - - - - {openConfirmDialog && ( - - )} - - handleOpenRejectDialog(row)}> - - - - {openRejectDialog && ( - - )} - - ); + const { + openConfirmDialog, + openRejectDialog, + handleOpenConfirmDialog, + handleOpenRejectDialog, + handleCloseConfirmDialog, + handleCloseRejectDialog, + rowId, + confirmData, + rejectData, + } = useContext(DataTableContext); + return ( + + + { + handleOpenConfirmDialog(row); + }} + > + + + + {openConfirmDialog && ( + + )} + + handleOpenRejectDialog(row)}> + + + + {openRejectDialog && ( + + )} + + ); }; export default TableRowActions; diff --git a/src/components/dashboard/transportation-assistance/TableTollbar.jsx b/src/components/dashboard/transportation-assistance/TableTollbar.jsx index 3f06d3b..e267691 100644 --- a/src/components/dashboard/transportation-assistance/TableTollbar.jsx +++ b/src/components/dashboard/transportation-assistance/TableTollbar.jsx @@ -1,13 +1,13 @@ -import { Stack, Tooltip } from "@mui/material"; -import { useTranslations } from "next-intl"; +import {Stack, Tooltip} from "@mui/material"; +import {useTranslations} from "next-intl"; function TableToolbar() { - const t = useTranslations(); - return ( - - - - ); + const t = useTranslations(); + return ( + + + + ); } export default TableToolbar; diff --git a/src/components/dashboard/transportation-assistance/index.jsx b/src/components/dashboard/transportation-assistance/index.jsx index fa6dbd9..51b780d 100644 --- a/src/components/dashboard/transportation-assistance/index.jsx +++ b/src/components/dashboard/transportation-assistance/index.jsx @@ -1,245 +1,242 @@ import DataTableStructure from "@/core/components/DatatableStructure"; import DashboardLayouts from "@/layouts/dashboardLayouts"; -import { Box, IconButton, Typography } from "@mui/material"; +import {Box, IconButton, Typography} from "@mui/material"; import ClearIcon from "@mui/icons-material/Clear"; -import { useMemo } from "react"; +import {useMemo} from "react"; // import TableToolbar from "./TableTollbar"; -import { GET_TRANSPORTATION_ASSISTANCE } from "@/core/data/apiRoutes"; -import { useTranslations } from "next-intl"; +import {GET_TRANSPORTATION_ASSISTANCE} from "@/core/data/apiRoutes"; +import {useTranslations} from "next-intl"; import TableRowActions from "./TableRowActions"; -import { - LocalizationProvider, - MobileDateTimePicker, -} from "@mui/x-date-pickers"; -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 {AdapterDateFnsJalali} from "@mui/x-date-pickers/AdapterDateFnsJalali"; +import {faIR} from "@mui/x-date-pickers/locales"; import moment from "jalali-moment"; function DashboardTransportationAssistanceComponent() { - const t = useTranslations(); - const columns = useMemo( - () => [ - { - accessorFn: (row) => row.id, - id: "id", - header: t("TransportationAssistance.id"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - maxSize: 100, - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.name, - id: "name", - header: t("TransportationAssistance.name"), - enableColumnFilter: true, - datatype: "text", - filterFn: "contains", - columnFilterModeOptions: ["contains", "equals", "notEquals"], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, + const t = useTranslations(); + const columns = useMemo( + () => [ + { + accessorFn: (row) => row.id, + id: "id", + header: t("TransportationAssistance.id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + maxSize: 100, + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.name, + id: "name", + header: t("TransportationAssistance.name"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, - { - accessorFn: (row) => row.national_id, - id: "national_id", - header: t("TransportationAssistance.national_id"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", + { + accessorFn: (row) => row.national_id, + id: "national_id", + header: t("TransportationAssistance.national_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("TransportationAssistance.phone_number"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => + moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + id: "created_at", + header: t("TransportationAssistance.created_at"), + enableColumnFilter: true, + datatype: "date", + minSize: 200, + filterFn: "lessThan", + columnFilterModeOptions: ["lessThan", "greaterThan"], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + Header: ({column}) => {column.columnDef.header}, + Filter: ({column}) => { + const filterFnValue = column.columnDef._filterFn; + return ( + + + { + const date = new Date(newValue); + const formattedDate = moment(date) + .locale("en") + .format("YYYY-MM-DD HH:mm"); + column.setFilterValue(formattedDate); + }} + slotProps={{ + textField: { + placeholder: "تاریخ خود را وارد کنید", + helperText: `${t("filter_mode")}: ${t(filterFnValue)}`, + sx: {minWidth: "120px"}, + variant: "standard", + }, + }} + value={ + column.getFilterValue() + ? new Date(column.getFilterValue()) + : null + } + /> + + { + column.setFilterValue(null); + }} + sx={{ + color: column.getFilterValue() + ? "rgba(0, 0, 0, 0.54)" + : "#bfbfbf", + }} + > + + + + ); + }, + }, + { + accessorFn: (row) => + moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + id: "updated_at", + header: t("TransportationAssistance.updated_at"), + enableColumnFilter: false, + datatype: "numeric", + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.navgan_id, + id: "navgan_id", + header: t("TransportationAssistance.navgan_id"), + enableColumnFilter: true, + datatype: "numeric", + filterFn: "equals", + maxSize: 100, + columnFilterModeOptions: [ + "equals", + "notEquals", + "contains", + "lessThan", + "greaterThan", + "between", + ], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.vehicle_type, + id: "vehicle_type", + header: t("TransportationAssistance.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("TransportationAssistance.state_name"), + enableColumnFilter: false, + datatype: "numeric", + minSize: 300, + // filterFn: "equals", + // filterSelectOptions: [ + // ], + // filterVariant: "select", + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, ], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.phone_number, - id: "phone_number", - header: t("TransportationAssistance.phone_number"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => - moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"), - id: "created_at", - header: t("TransportationAssistance.created_at"), - enableColumnFilter: true, - datatype: "date", - minSize: 200, - filterFn: "lessThan", - columnFilterModeOptions: ["lessThan", "greaterThan"], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - Header: ({ column }) => {column.columnDef.header}, - Filter: ({ column }) => { - const filterFnValue = column.columnDef._filterFn; - return ( - - - { - const date = new Date(newValue); - const formattedDate = moment(date) - .locale("en") - .format("YYYY-MM-DD HH:mm"); - column.setFilterValue(formattedDate); - }} - slotProps={{ - textField: { - placeholder: "تاریخ خود را وارد کنید", - helperText: `${t("filter_mode")}: ${t(filterFnValue)}`, - sx: { minWidth: "120px" }, - variant: "standard", - }, - }} - value={ - column.getFilterValue() - ? new Date(column.getFilterValue()) - : null - } + [] + ); + 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}) => } /> - - { - column.setFilterValue(null); - }} - sx={{ - color: column.getFilterValue() - ? "rgba(0, 0, 0, 0.54)" - : "#bfbfbf", - }} - > - - - ); - }, - }, - { - accessorFn: (row) => - moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), - id: "updated_at", - header: t("TransportationAssistance.updated_at"), - enableColumnFilter: false, - datatype: "numeric", - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.navgan_id, - id: "navgan_id", - header: t("TransportationAssistance.navgan_id"), - enableColumnFilter: true, - datatype: "numeric", - filterFn: "equals", - maxSize: 100, - columnFilterModeOptions: [ - "equals", - "notEquals", - "contains", - "lessThan", - "greaterThan", - "between", - ], - Cell: ({ renderedCellValue }) => ( - {renderedCellValue} - ), - }, - { - accessorFn: (row) => row.vehicle_type, - id: "vehicle_type", - header: t("TransportationAssistance.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("TransportationAssistance.state_name"), - enableColumnFilter: false, - datatype: "numeric", - minSize: 300, - // filterFn: "equals", - // filterSelectOptions: [ - // ], - // 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 DashboardTransportationAssistanceComponent; diff --git a/src/components/first/index.jsx b/src/components/first/index.jsx index adf4393..9304403 100644 --- a/src/components/first/index.jsx +++ b/src/components/first/index.jsx @@ -1,53 +1,53 @@ import dahsboardImage from "&/images/dashboard.svg"; -import { NextLinkComposed } from "@/core/components/LinkRouting"; +import {NextLinkComposed} from "@/core/components/LinkRouting"; import StyledImage from "@/core/components/StyledImage"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import useUser from "@/lib/app/hooks/useUser"; -import { Button, Typography } from "@mui/material"; -import { useTranslations } from "next-intl"; +import {Button, Typography} from "@mui/material"; +import {useTranslations} from "next-intl"; const FirstComponent = () => { - const t = useTranslations(); - const { isAuth } = useUser(); + const t = useTranslations(); + const {isAuth} = useUser(); - return ( - - - - - {t("app_name")} - - {isAuth ? ( - - ) : ( - - )} - - - ); + return ( + + + + + {t("app_name")} + + {isAuth ? ( + + ) : ( + + )} + + + ); }; export default FirstComponent; diff --git a/src/components/login-expert/index.jsx b/src/components/login-expert/index.jsx index 4d6af4a..10ac3b6 100644 --- a/src/components/login-expert/index.jsx +++ b/src/components/login-expert/index.jsx @@ -2,158 +2,149 @@ import LinkRouting from "@/core/components/LinkRouting"; // import Notifications from "@/core/components/notifications"; import PasswordField from "@/core/components/PasswordField"; import StyledForm from "@/core/components/StyledForm"; -import { GET_USER_TOKEN } from "@/core/data/apiRoutes"; +import {GET_USER_TOKEN} from "@/core/data/apiRoutes"; import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; -import useDirection from "@/lib/app/hooks/useDirection"; import useUser from "@/lib/app/hooks/useUser"; import LoginIcon from "@mui/icons-material/Login"; -import { - Box, - Button, - Container, - Paper, - Stack, - TextField, - Typography, -} from "@mui/material"; +import {Box, Button, Container, Paper, Stack, TextField, Typography,} from "@mui/material"; import axios from "axios"; -import { Field, Formik } from "formik"; -import { useTranslations } from "next-intl"; +import {Field, Formik} from "formik"; +import {useTranslations} from "next-intl"; import Image from "next/image"; -import { useSearchParams } from "next/navigation"; +import {useSearchParams} from "next/navigation"; import * as Yup from "yup"; const LoginComponent = () => { - const t = useTranslations(); - // const { directionApp } = useDirection(); // should delete because we dont have direction anymore - const { setToken } = useUser(); // pass token to set token + const t = useTranslations(); + // const { directionApp } = useDirection(); // should delete because we dont have direction anymore + const {setToken} = useUser(); // pass token to set token - // gettin url query - const searchParams = useSearchParams(); - const backUrlDecodedPath = searchParams.get("back_url"); + // gettin url query + const searchParams = useSearchParams(); + const backUrlDecodedPath = searchParams.get("back_url"); - //formik properties - const handleSubmit = async (values, props) => { - await axios - .post(GET_USER_TOKEN, { - username: values.username, - password: values.password, - }) - .then(function (response) { - setToken(response.data.token); - }) - .catch(function (error) { - // Notifications(directionApp, error.response, t); - props.setSubmitting(false); - }); - }; - const initialValues = { - username: "", - password: "", - }; - const validationSchema = Yup.object().shape({ - username: Yup.string().required(t("LoginPage.error_message_required")), - password: Yup.string().required(t("LoginPage.error_message_required")), - }); + //formik properties + const handleSubmit = async (values, props) => { + await axios + .post(GET_USER_TOKEN, { + username: values.username, + password: values.password, + }) + .then(function (response) { + setToken(response.data.token); + }) + .catch(function (error) { + // Notifications(directionApp, error.response, t); + props.setSubmitting(false); + }); + }; + const initialValues = { + username: "", + password: "", + }; + const validationSchema = Yup.object().shape({ + username: Yup.string().required(t("LoginPage.error_message_required")), + password: Yup.string().required(t("LoginPage.error_message_required")), + }); - return ( - - - - - - {(props) => ( - - - {t("app_name")} - - - {t("login_expert")} - - - - - - - - - - - - )} - - - - - - - {t("LoginPage.link_routing_back_to")}{" "} - {backUrlDecodedPath - ? t("LoginPage.link_routing_previuos_page") - : t("LoginPage.link_routing_main_page")} - - - - ); + {(props) => ( + + + {t("app_name")}/ + + + {t("login_expert")} + + + + + + + + + + + + )} + + + + + + + {t("LoginPage.link_routing_back_to")}{" "} + {backUrlDecodedPath + ? t("LoginPage.link_routing_previuos_page") + : t("LoginPage.link_routing_main_page")} + + +
+ ); }; export default LoginComponent; diff --git a/src/core/components/AvatarUpload.jsx b/src/core/components/AvatarUpload.jsx index e1ade5c..03a9cba 100644 --- a/src/core/components/AvatarUpload.jsx +++ b/src/core/components/AvatarUpload.jsx @@ -1,128 +1,128 @@ -import { Avatar, Box, TextField } from "@mui/material"; -import { useState } from "react"; +import {Avatar, Box, TextField} from "@mui/material"; +import {useState} from "react"; import DeleteIcon from "@mui/icons-material/Delete"; import AddIcon from "@mui/icons-material/Add"; -const AvatarUpload = ({ user, setFieldValue, valueAvatar, changeFlag }) => { - const [selectedImage, setSelectedImage] = useState(user.expert_avatar); - const [isHovered, setIsHovered] = useState(false); +const AvatarUpload = ({user, setFieldValue, valueAvatar, changeFlag}) => { + const [selectedImage, setSelectedImage] = useState(user.expert_avatar); + const [isHovered, setIsHovered] = useState(false); - const handleImageChange = (event) => { - const newImage = event.target?.files?.[0]; - if (newImage) { - setSelectedImage(URL.createObjectURL(newImage)); - setFieldValue(valueAvatar, newImage); - setFieldValue(changeFlag, true); - } else { - setSelectedImage(""); - setFieldValue(valueAvatar, null); - } - }; + const handleImageChange = (event) => { + const newImage = event.target?.files?.[0]; + if (newImage) { + setSelectedImage(URL.createObjectURL(newImage)); + setFieldValue(valueAvatar, newImage); + setFieldValue(changeFlag, true); + } else { + setSelectedImage(""); + setFieldValue(valueAvatar, null); + } + }; - const handleDeleteImage = () => { - setSelectedImage(""); - setFieldValue(valueAvatar, null); - setFieldValue(changeFlag, true); - }; + const handleDeleteImage = () => { + setSelectedImage(""); + setFieldValue(valueAvatar, null); + setFieldValue(changeFlag, true); + }; - const handleMouseEnter = () => { - setIsHovered(true); - }; + const handleMouseEnter = () => { + setIsHovered(true); + }; - const handleMouseLeave = () => { - setIsHovered(false); - }; + const handleMouseLeave = () => { + setIsHovered(false); + }; - return ( - - + return ( - - {isHovered && ( + > - {selectedImage ? ( - - ) : ( - - )} + + + {isHovered && ( + + {selectedImage ? ( + + ) : ( + + )} + + )} + - )} + - - - - ); + ); }; export default AvatarUpload; diff --git a/src/core/components/Datatable.jsx b/src/core/components/Datatable.jsx index 2d34ece..060e089 100644 --- a/src/core/components/Datatable.jsx +++ b/src/core/components/Datatable.jsx @@ -1,174 +1,174 @@ -import { ReloadDataTableContext } from "@/lib/app/contexts/ReloadDatatableContext"; +import {ReloadDataTableContext} from "@/lib/app/contexts/ReloadDatatableContext"; import useLanguage from "@/lib/app/hooks/useLanguage"; -import { Typography } from "@mui/material"; +import {Typography} from "@mui/material"; import axios from "axios"; import MaterialReactTable from "material-react-table"; import moment from "moment-jalaali"; -import { useTranslations } from "next-intl"; -import { useContext, useEffect, useMemo, useState } from "react"; +import {useTranslations} from "next-intl"; +import {useContext, useEffect, useMemo, useState} from "react"; import useSWR from "swr"; const DataTable = (props) => { - const { reloadDataTable, setReloadDataTable } = useContext( - ReloadDataTableContext - ); - - const fetcher = (...args) => { - return axios - .get(args, { - headers: { - Authorization: `Bearer ${props.token}`, - }, - }) - .then((res) => { - setRowCount(res.data.meta.totalRowCount); - return res.data.data; - }); - }; - const t = useTranslations(); - const { languageApp, languageList } = useLanguage(); - const [columnFilters, setColumnFilters] = useState([]); - const [columnFilterFns, setColumnFilterFns] = useState(() => { - let output = {}; - const list = props.columns.map((item) => - item.enableColumnFilter ? { [item.id]: item.filterFn } : { [item.id]: "" } + const {reloadDataTable, setReloadDataTable} = useContext( + ReloadDataTableContext ); - for (var key in list) { - var nestedObj = list[key]; - for (var nestedKey in nestedObj) { - output[nestedKey] = nestedObj[nestedKey]; - } - } - return output; - }); - const [sorting, setSorting] = useState([]); - const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 }); - const [rowCount, setRowCount] = useState(0); - const [updateTime, setupdateTime] = useState( - moment().format("HH:mm | jYYYY/jM/jD") - ); - const tableLocalization = useMemo( - () => - languageList.find((item) => item.key == languageApp).tableLocalization, - [languageApp, languageList] - ); - - const fetchUrl = useMemo(() => { - const url = new URL(props.tableUrl /* send your api */); - url.searchParams.set( - "start", - `${pagination.pageIndex * pagination.pageSize}` - ); - const filters = columnFilters.map((filter) => { - let datatype; - for (const i in props.columns) { - if (props.columns[i].id == filter.id) { - datatype = props.columns[i].datatype; + const fetcher = (...args) => { + return axios + .get(args, { + headers: { + Authorization: `Bearer ${props.token}`, + }, + }) + .then((res) => { + setRowCount(res.data.meta.totalRowCount); + return res.data.data; + }); + }; + const t = useTranslations(); + const {languageApp, languageList} = useLanguage(); + const [columnFilters, setColumnFilters] = useState([]); + const [columnFilterFns, setColumnFilterFns] = useState(() => { + let output = {}; + const list = props.columns.map((item) => + item.enableColumnFilter ? {[item.id]: item.filterFn} : {[item.id]: ""} + ); + for (var key in list) { + var nestedObj = list[key]; + for (var nestedKey in nestedObj) { + output[nestedKey] = nestedObj[nestedKey]; + } } - } - return { - ...filter, - fn: columnFilterFns[filter.id], - datatype: datatype, - }; + return output; }); - url.searchParams.set("size", pagination.pageSize); - url.searchParams.set("filters", JSON.stringify(filters ?? [])); - url.searchParams.set("sorting", JSON.stringify(sorting ?? [])); - return url; - }, [ - props.tableUrl, - columnFilters, - columnFilterFns, - pagination, - sorting, - props.columns, - ]); - const { data, isLoading, isValidating, mutate } = useSWR(fetchUrl, fetcher, { - revalidateOnFocus: false, - }); + const [sorting, setSorting] = useState([]); + const [pagination, setPagination] = useState({pageIndex: 0, pageSize: 10}); + const [rowCount, setRowCount] = useState(0); + const [updateTime, setupdateTime] = useState( + moment().format("HH:mm | jYYYY/jM/jD") + ); - useEffect(() => { - if (reloadDataTable) { - mutate(fetchUrl).then(() => { - setReloadDataTable(false); // Set reloadDataTable to false after mutation is complete - }); - } - }, [reloadDataTable, setReloadDataTable]); + const tableLocalization = useMemo( + () => + languageList.find((item) => item.key == languageApp).tableLocalization, + [languageApp, languageList] + ); - useEffect(() => { - setupdateTime(moment().format("HH:mm | jYYYY/jM/jD")); - }, [isValidating, languageApp]); - - return ( - ( - <> - {props.enableCustomToolbar /* send condition */ - ? props.CustomToolbar /* send component */ - : ""} - - )} - renderBottomToolbarCustomActions={({ table }) => ( - <> - {props.enableLastUpdate /* send condition */ ? ( - - {t("last_updated_at")}: {updateTime} - - ) : ( - "" - )} - - )} - state={{ - isLoading, + const fetchUrl = useMemo(() => { + const url = new URL(props.tableUrl /* send your api */); + url.searchParams.set( + "start", + `${pagination.pageIndex * pagination.pageSize}` + ); + const filters = columnFilters.map((filter) => { + let datatype; + for (const i in props.columns) { + if (props.columns[i].id == filter.id) { + datatype = props.columns[i].datatype; + } + } + return { + ...filter, + fn: columnFilterFns[filter.id], + datatype: datatype, + }; + }); + url.searchParams.set("size", pagination.pageSize); + url.searchParams.set("filters", JSON.stringify(filters ?? [])); + url.searchParams.set("sorting", JSON.stringify(sorting ?? [])); + return url; + }, [ + props.tableUrl, columnFilters, columnFilterFns, pagination, sorting, - }} - positionActionsColumn={"last"} - enableRowActions={props.enableRowActions} - {...props} - /> - ); + props.columns, + ]); + const {data, isLoading, isValidating, mutate} = useSWR(fetchUrl, fetcher, { + revalidateOnFocus: false, + }); + + useEffect(() => { + if (reloadDataTable) { + mutate(fetchUrl).then(() => { + setReloadDataTable(false); // Set reloadDataTable to false after mutation is complete + }); + } + }, [reloadDataTable, setReloadDataTable]); + + useEffect(() => { + setupdateTime(moment().format("HH:mm | jYYYY/jM/jD")); + }, [isValidating, languageApp]); + + return ( + ( + <> + {props.enableCustomToolbar /* send condition */ + ? props.CustomToolbar /* send component */ + : ""} + + )} + renderBottomToolbarCustomActions={({table}) => ( + <> + {props.enableLastUpdate /* send condition */ ? ( + + {t("last_updated_at")}: {updateTime} + + ) : ( + "" + )} + + )} + state={{ + isLoading, + columnFilters, + columnFilterFns, + pagination, + sorting, + }} + positionActionsColumn={"last"} + enableRowActions={props.enableRowActions} + {...props} + /> + ); }; export default DataTable; diff --git a/src/core/components/DatatableStructure.jsx b/src/core/components/DatatableStructure.jsx index e13ed16..ae97461 100644 --- a/src/core/components/DatatableStructure.jsx +++ b/src/core/components/DatatableStructure.jsx @@ -1,15 +1,15 @@ -import { DataTableProvider } from "@/lib/app/contexts/DatatableContext"; +import {DataTableProvider} from "@/lib/app/contexts/DatatableContext"; import DataTable from "./Datatable"; -import { ReloadDataTableProvider } from "@/lib/app/contexts/ReloadDatatableContext"; +import {ReloadDataTableProvider} from "@/lib/app/contexts/ReloadDatatableContext"; function DataTableStructure(props) { - return ( - - - - - - ); + return ( + + + + + + ); } export default DataTableStructure; diff --git a/src/core/components/FormErrorMassage.jsx b/src/core/components/FormErrorMassage.jsx index 4bf74e3..e1d155b 100644 --- a/src/core/components/FormErrorMassage.jsx +++ b/src/core/components/FormErrorMassage.jsx @@ -1,10 +1,11 @@ -import { Typography } from "@mui/material"; +import {Typography} from "@mui/material"; + const FormErrorMessage = (props) => { - return ( - - {props.children} - - ); + return ( + + {props.children} + + ); }; export default FormErrorMessage; diff --git a/src/core/components/ImageConvertor.jsx b/src/core/components/ImageConvertor.jsx index 667182e..9f99bc1 100644 --- a/src/core/components/ImageConvertor.jsx +++ b/src/core/components/ImageConvertor.jsx @@ -1,22 +1,22 @@ import ImageResize from "image-resize"; const ImageResizer = async (image) => { - const imageResize = new ImageResize({ - quality: 1, - format: "jpg", - outputType: "base64", - width: 400, - }); + const imageResize = new ImageResize({ + quality: 1, + format: "jpg", + outputType: "base64", + width: 400, + }); - const get = await imageResize.get(image); - const resize = await imageResize.resize(get).then(); - const output = await imageResize.output(resize).then(); + const get = await imageResize.get(image); + const resize = await imageResize.resize(get).then(); + const output = await imageResize.output(resize).then(); - const avatar = await (await import("image-to-file-converter")) - .base64ToFile(output) - .then(); + const avatar = await (await import("image-to-file-converter")) + .base64ToFile(output) + .then(); - return avatar; + return avatar; }; export default ImageResizer; diff --git a/src/core/components/LinkRouting.jsx b/src/core/components/LinkRouting.jsx index ff33c86..f8fac0a 100644 --- a/src/core/components/LinkRouting.jsx +++ b/src/core/components/LinkRouting.jsx @@ -1,116 +1,116 @@ import MuiLink from "@mui/material/Link"; -import { styled } from "@mui/material/styles"; +import {styled} from "@mui/material/styles"; import clsx from "clsx"; import NextLink from "next/link"; -import { useRouter } from "next/router"; +import {useRouter} from "next/router"; import * as React from "react"; // Add support for the sx prop for consistency with the other branches. const Anchor = styled("a")({}); export const NextLinkComposed = React.forwardRef(function NextLinkComposed( - props, - ref + props, + ref ) { - const { - to, - linkAs, - replace, - scroll, - shallow, - prefetch, - legacyBehavior = true, - locale, - ...other - } = props; + const { + to, + linkAs, + replace, + scroll, + shallow, + prefetch, + legacyBehavior = true, + locale, + ...other + } = props; - return ( - - - - ); + return ( + + + + ); }); // A styled version of the Next.js Link component: // https://nextjs.org/docs/api-reference/next/link const LinkRouting = React.forwardRef(function Link(props, ref) { - const { - activeClassName = "active", - as, - className: classNameProps, - href, - legacyBehavior, - linkAs: linkAsProp, - locale, - noLinkStyle, - prefetch, - replace, - role, // Link don't have roles. - scroll, - shallow, - ...other - } = props; + const { + activeClassName = "active", + as, + className: classNameProps, + href, + legacyBehavior, + linkAs: linkAsProp, + locale, + noLinkStyle, + prefetch, + replace, + role, // Link don't have roles. + scroll, + shallow, + ...other + } = props; - const router = useRouter(); - const pathname = typeof href === "string" ? href : href.pathname; - const className = clsx(classNameProps, { - [activeClassName]: router.pathname === pathname && activeClassName, - }); + const router = useRouter(); + const pathname = typeof href === "string" ? href : href.pathname; + const className = clsx(classNameProps, { + [activeClassName]: router.pathname === pathname && activeClassName, + }); - const isExternal = - typeof href === "string" && - (href.indexOf("http") === 0 || href.indexOf("mailto:") === 0); + const isExternal = + typeof href === "string" && + (href.indexOf("http") === 0 || href.indexOf("mailto:") === 0); - if (isExternal) { - if (noLinkStyle) { - return ; + if (isExternal) { + if (noLinkStyle) { + return ; + } + + return ; } - return ; - } + const linkAs = linkAsProp || as; + const nextjsProps = { + to: href, + linkAs, + replace, + scroll, + shallow, + prefetch, + legacyBehavior, + locale, + }; - const linkAs = linkAsProp || as; - const nextjsProps = { - to: href, - linkAs, - replace, - scroll, - shallow, - prefetch, - legacyBehavior, - locale, - }; + if (noLinkStyle) { + return ( + + ); + } - if (noLinkStyle) { return ( - + ); - } - - return ( - - ); }); export default LinkRouting; diff --git a/src/core/components/LoadingHardPage.jsx b/src/core/components/LoadingHardPage.jsx index 5a86af8..d0f1c3f 100644 --- a/src/core/components/LoadingHardPage.jsx +++ b/src/core/components/LoadingHardPage.jsx @@ -1,44 +1,44 @@ -import { Backdrop, Fade, styled } from "@mui/material"; +import {Backdrop, Fade, styled} from "@mui/material"; import StyledImage from "./StyledImage"; const LoadingImage = styled(StyledImage)({ - "@keyframes load": { - "0%": { - // opacity: 0, - transform: "scale(1)", + "@keyframes load": { + "0%": { + // opacity: 0, + transform: "scale(1)", + }, + "50%": { + // opacity: 1, + transform: "scale(2)", + }, + "100%": { + // opacity: 0, + transform: "scale(1)", + }, }, - "50%": { - // opacity: 1, - transform: "scale(2)", - }, - "100%": { - // opacity: 0, - transform: "scale(1)", - }, - }, - animation: "load 2s infinite", + animation: "load 2s infinite", }); -const LoadingHardPage = ({ children, loading }) => { - return ( - <> - theme.zIndex.drawer + 1 }} - open={loading} - > - - - - - {children} - - ); +const LoadingHardPage = ({children, loading}) => { + return ( + <> + theme.zIndex.drawer + 1}} + open={loading} + > + + + + + {children} + + ); }; export default LoadingHardPage; diff --git a/src/core/components/Messages.jsx b/src/core/components/Messages.jsx index e80c572..bc53b6e 100644 --- a/src/core/components/Messages.jsx +++ b/src/core/components/Messages.jsx @@ -2,21 +2,21 @@ import CenterLayout from "@/layouts/CenterLayout"; import FullPageLayout from "@/layouts/FullPageLayout"; import StyledImage from "./StyledImage"; -const Message = ({ text, actions }) => { - return ( - - - - {text} - {actions} - - - ); +const Message = ({text, actions}) => { + return ( + + + + {text} + {actions} + + + ); }; export default Message; diff --git a/src/core/components/MuiDatePicker.jsx b/src/core/components/MuiDatePicker.jsx index d906666..de6c5d5 100644 --- a/src/core/components/MuiDatePicker.jsx +++ b/src/core/components/MuiDatePicker.jsx @@ -1,35 +1,35 @@ -import { LocalizationProvider, DatePicker } from "@mui/x-date-pickers"; -import { AdapterDateFnsJalali } from "@mui/x-date-pickers/AdapterDateFnsJalali"; +import {DatePicker, LocalizationProvider} from "@mui/x-date-pickers"; +import {AdapterDateFnsJalali} from "@mui/x-date-pickers/AdapterDateFnsJalali"; import moment from "jalali-moment"; -import { useTranslations } from "next-intl"; +import {useTranslations} from "next-intl"; export default function MuiDatePicker({ - setFieldValue, - selectType, - error, - helperText, -}) { - const t = useTranslations(); + setFieldValue, + selectType, + error, + helperText, + }) { + const t = useTranslations(); - const handleDateChange = (date) => { - const selectedDate = moment(date).locale("fa"); // should add .format() at the end to format the data - setFieldValue(selectType, selectedDate); - }; + const handleDateChange = (date) => { + const selectedDate = moment(date).locale("fa"); // should add .format() at the end to format the data + setFieldValue(selectType, selectedDate); + }; - return ( - - - - ); + return ( + + + + ); } diff --git a/src/core/components/PasswordField.jsx b/src/core/components/PasswordField.jsx index 5747bdb..d109b73 100644 --- a/src/core/components/PasswordField.jsx +++ b/src/core/components/PasswordField.jsx @@ -1,33 +1,33 @@ -import { useState } from "react"; -import { IconButton, InputAdornment, TextField } from "@mui/material"; -import { Visibility, VisibilityOff } from "@mui/icons-material"; -import { Field } from "formik"; +import {useState} from "react"; +import {IconButton, InputAdornment, TextField} from "@mui/material"; +import {Visibility, VisibilityOff} from "@mui/icons-material"; +import {Field} from "formik"; const PasswordField = (props) => { - const [showPassword, setShowPassword] = useState(false); + const [showPassword, setShowPassword] = useState(false); - const handleClickShowPassword = () => { - setShowPassword(!showPassword); - }; + const handleClickShowPassword = () => { + setShowPassword(!showPassword); + }; - return ( - - - {showPassword ? : } - - - ), - }} - /> - ); + return ( + + + {showPassword ? : } + + + ), + }} + /> + ); }; export default PasswordField; diff --git a/src/core/components/StyledForm.jsx b/src/core/components/StyledForm.jsx index 1f299bb..41eeabc 100644 --- a/src/core/components/StyledForm.jsx +++ b/src/core/components/StyledForm.jsx @@ -1,5 +1,5 @@ -import { styled } from "@mui/material"; -import { Form } from "formik"; +import {styled} from "@mui/material"; +import {Form} from "formik"; const StyledForm = styled(Form)``; diff --git a/src/core/components/StyledImage.jsx b/src/core/components/StyledImage.jsx index 64391ad..58dd65f 100644 --- a/src/core/components/StyledImage.jsx +++ b/src/core/components/StyledImage.jsx @@ -1,4 +1,4 @@ -import { styled } from "@mui/material"; +import {styled} from "@mui/material"; import Image from "next/image"; const StyledImage = styled(Image)``; diff --git a/src/core/components/TitlePage.jsx b/src/core/components/TitlePage.jsx index 7bdcfc2..77c72ee 100644 --- a/src/core/components/TitlePage.jsx +++ b/src/core/components/TitlePage.jsx @@ -1,15 +1,15 @@ -import { useTranslations } from "next-intl"; +import {useTranslations} from "next-intl"; import Head from "next/head"; -const TitlePage = ({ text }) => { - const t = useTranslations(); - return ( - - - {text ? `${t("app_short_name")} | ${t(text)}` : t("app_short_name")} - - - ); +const TitlePage = ({text}) => { + const t = useTranslations(); + return ( + + + {text ? `${t("app_short_name")} | ${t(text)}` : t("app_short_name")} + + + ); }; export default TitlePage; diff --git a/src/core/components/UploadSystem.jsx b/src/core/components/UploadSystem.jsx index fe04b73..b40fb46 100644 --- a/src/core/components/UploadSystem.jsx +++ b/src/core/components/UploadSystem.jsx @@ -1,176 +1,175 @@ -import { Box, Button, Paper, Typography } from "@mui/material"; -import { useTranslations } from "next-intl"; -import Image from "next/image"; +import {Box, Button, Paper, Typography} from "@mui/material"; +import {useTranslations} from "next-intl"; import AddIcon from "@mui/icons-material/Add"; import DeleteForeverIcon from "@mui/icons-material/DeleteForever"; -import { useRef } from "react"; +import {useRef} from "react"; const UploadSystem = ({ - selectedImage, - setselectedImage, - handleUploadChange, - fieldname, - setFieldValue, - imageAlt, - imageSize, - fileType, - fileName, - setShowAddIcon, - showAddIcon, -}) => { - const t = useTranslations(); - const fileInputRef = useRef(null); + selectedImage, + setselectedImage, + handleUploadChange, + fieldname, + setFieldValue, + imageAlt, + imageSize, + fileType, + fileName, + setShowAddIcon, + showAddIcon, + }) => { + const t = useTranslations(); + const fileInputRef = useRef(null); - const handleClick = () => { - fileInputRef.current.click(); - }; + const handleClick = () => { + fileInputRef.current.click(); + }; - const handleDeleteImage = () => { - setselectedImage(null); - setFieldValue(fieldname, null); - setShowAddIcon(true); - if (fileInputRef.current) { - fileInputRef.current.value = ""; - } - }; + const handleDeleteImage = () => { + setselectedImage(null); + setFieldValue(fieldname, null); + setShowAddIcon(true); + if (fileInputRef.current) { + fileInputRef.current.value = ""; + } + }; - const isDocumentFormat = (fileType) => { - const documentFormats = [ - "application/pdf", - "application/msword", - "application/vnd.openxmlformats-officedocument.wordprocessingml.document", - "application/vnd.ms-excel", - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", - ]; - return documentFormats.includes(fileType); - }; + const isDocumentFormat = (fileType) => { + const documentFormats = [ + "application/pdf", + "application/msword", + "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + "application/vnd.ms-excel", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + ]; + return documentFormats.includes(fileType); + }; - return ( - - {showAddIcon ? ( - // Show the add icon and "Upload File" text when no image is selected - <> - + {showAddIcon ? ( + // Show the add icon and "Upload File" text when no image is selected + <> + - - - {t("UploadSystem.upload_file")} - - - - ) : ( - // Show the uploaded content along with the delete button when an image or document is selected - <> - {fileType && fileType.startsWith("image/") ? ( - - - - ) : ( - fileType && - isDocumentFormat(fileType) && ( - - - {fileName} - - - ) - )} - - - )} - - - ); + height: imageSize[1], + }} + onClick={handleClick} + > + + + {t("UploadSystem.upload_file")} + + + + ) : ( + // Show the uploaded content along with the delete button when an image or document is selected + <> + {fileType && fileType.startsWith("image/") ? ( + + + + ) : ( + fileType && + isDocumentFormat(fileType) && ( + + + {fileName} + + + ) + )} + + + )} + + + ); }; export default UploadSystem; diff --git a/src/core/components/isBotHandler.jsx b/src/core/components/isBotHandler.jsx index 0fde3e3..5a4c4e1 100644 --- a/src/core/components/isBotHandler.jsx +++ b/src/core/components/isBotHandler.jsx @@ -1,8 +1,8 @@ -import { NoSsr } from "@mui/material"; +import {NoSsr} from "@mui/material"; -const NoSsrHandler = ({ isBot, children }) => { - if (isBot) return children; - return {children}; +const NoSsrHandler = ({isBot, children}) => { + if (isBot) return children; + return {children}; }; export default NoSsrHandler; diff --git a/src/core/components/notifications/ErrorNotification.jsx b/src/core/components/notifications/ErrorNotification.jsx index f0c887d..e6ac204 100644 --- a/src/core/components/notifications/ErrorNotification.jsx +++ b/src/core/components/notifications/ErrorNotification.jsx @@ -1,40 +1,40 @@ import DangerousIcon from "@mui/icons-material/Dangerous"; -import { Box, Typography } from "@mui/material"; -import { toast } from "react-toastify"; +import {Box, Typography} from "@mui/material"; +import {toast} from "react-toastify"; const ErrorNotification = (directionApp, status, t, message) => { - toast( - () => ( - <> - - - - - - {t("notifications.error")} ({t("notifications.code")}: {status}) - - - {message || t("notifications.error_static_text")} - - - - - - ), - { - position: directionApp === "ltr" ? "top-left" : "top-right", - autoClose: false, - closeOnClick: false, - draggable: false, - } - ); + toast( + () => ( + <> + + + + + + {t("notifications.error")} ({t("notifications.code")}: {status}) + + + {message || t("notifications.error_static_text")} + + + + + + ), + { + position: directionApp === "ltr" ? "top-left" : "top-right", + autoClose: false, + closeOnClick: false, + draggable: false, + } + ); }; export default ErrorNotification; diff --git a/src/core/components/notifications/SuccessNotification.jsx b/src/core/components/notifications/SuccessNotification.jsx index ea484d6..085b154 100644 --- a/src/core/components/notifications/SuccessNotification.jsx +++ b/src/core/components/notifications/SuccessNotification.jsx @@ -1,43 +1,43 @@ import BeenhereIcon from "@mui/icons-material/Beenhere"; -import { Box, Typography } from "@mui/material"; -import { toast } from "react-toastify"; +import {Box, Typography} from "@mui/material"; +import {toast} from "react-toastify"; const SuccessNotification = (directionApp, status, t) => { - toast( - () => ( - <> - - - - - - {t("notifications.success")} ({t("notifications.code")}:{" "} - {status}) - - - {t("notifications.success_static_text")} - - - - - - ), - { - position: directionApp === "ltr" ? "top-left" : "top-right", - autoClose: 3000, - hideProgressBar: true, - pauseOnHover: true, - closeOnClick: false, - draggable: true, - } - ); + toast( + () => ( + <> + + + + + + {t("notifications.success")} ({t("notifications.code")}:{" "} + {status}) + + + {t("notifications.success_static_text")} + + + + + + ), + { + position: directionApp === "ltr" ? "top-left" : "top-right", + autoClose: 3000, + hideProgressBar: true, + pauseOnHover: true, + closeOnClick: false, + draggable: true, + } + ); }; export default SuccessNotification; diff --git a/src/core/components/notifications/UploadFileNotification.jsx b/src/core/components/notifications/UploadFileNotification.jsx index d06783b..51e2761 100644 --- a/src/core/components/notifications/UploadFileNotification.jsx +++ b/src/core/components/notifications/UploadFileNotification.jsx @@ -1,37 +1,37 @@ import DangerousIcon from "@mui/icons-material/Dangerous"; -import { Box, Typography } from "@mui/material"; -import { toast } from "react-toastify"; +import {Box, Typography} from "@mui/material"; +import {toast} from "react-toastify"; const UploadFileNotification = (directionApp, t) => { - toast( - ({ closeToast }) => ( - <> - - - - - - {t("UploadSystem.uploadfile_error")} - - - - - - ), - { - position: directionApp === "ltr" ? "top-left" : "top-right", - autoClose: false, - closeOnClick: false, - draggable: false, - } - ); + toast( + ({closeToast}) => ( + <> + + + + + + {t("UploadSystem.uploadfile_error")} + + + + + + ), + { + position: directionApp === "ltr" ? "top-left" : "top-right", + autoClose: false, + closeOnClick: false, + draggable: false, + } + ); }; export default UploadFileNotification; diff --git a/src/core/components/notifications/WarningNotification.jsx b/src/core/components/notifications/WarningNotification.jsx index 8a2bfa3..8e3280e 100644 --- a/src/core/components/notifications/WarningNotification.jsx +++ b/src/core/components/notifications/WarningNotification.jsx @@ -1,41 +1,41 @@ import ReportIcon from "@mui/icons-material/Report"; -import { Box, Typography } from "@mui/material"; -import { toast } from "react-toastify"; +import {Box, Typography} from "@mui/material"; +import {toast} from "react-toastify"; const WarningNotification = (directionApp, status, t) => { - toast( - () => ( - <> - - - - - - {t("notifications.warning")} ({t("notifications.code")}:{" "} - {status}) - - - {t("notifications.warning_static_text")} - - - - - - ), - { - position: directionApp === "ltr" ? "top-left" : "top-right", - autoClose: false, - closeOnClick: false, - draggable: false, - } - ); + toast( + () => ( + <> + + + + + + {t("notifications.warning")} ({t("notifications.code")}:{" "} + {status}) + + + {t("notifications.warning_static_text")} + + + + + + ), + { + position: directionApp === "ltr" ? "top-left" : "top-right", + autoClose: false, + closeOnClick: false, + draggable: false, + } + ); }; export default WarningNotification; diff --git a/src/core/components/notifications/index.jsx b/src/core/components/notifications/index.jsx index ef63918..41a1896 100644 --- a/src/core/components/notifications/index.jsx +++ b/src/core/components/notifications/index.jsx @@ -3,37 +3,37 @@ import WarningNotification from "./WarningNotification"; import SuccessNotification from "./SuccessNotification"; const Notifications = async (directionApp, response, t) => { - const { status, data } = response; + const {status, data} = response; - switch (status) { - case 200: - SuccessNotification(directionApp, status, t); - break; - case 400: - ErrorNotification(directionApp, status, t); - break; - case 401: - ErrorNotification(directionApp, status, t); - break; - case 403: - ErrorNotification(directionApp, status, t); - break; - case 422: - ErrorNotification(directionApp, status, t, data.message); - break; - case 500: - WarningNotification(directionApp, status, t); - break; - case 503: - WarningNotification(directionApp, status, t); - break; - case 504: - WarningNotification(directionApp, status, t); - break; - default: - // Handle other cases if needed - break; - } + switch (status) { + case 200: + SuccessNotification(directionApp, status, t); + break; + case 400: + ErrorNotification(directionApp, status, t); + break; + case 401: + ErrorNotification(directionApp, status, t); + break; + case 403: + ErrorNotification(directionApp, status, t); + break; + case 422: + ErrorNotification(directionApp, status, t, data.message); + break; + case 500: + WarningNotification(directionApp, status, t); + break; + case 503: + WarningNotification(directionApp, status, t); + break; + case 504: + WarningNotification(directionApp, status, t); + break; + default: + // Handle other cases if needed + break; + } }; export default Notifications; diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index 2c84765..cf01622 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -14,55 +14,55 @@ export const GET_USER_ROUTE = BASE_URL + "/dashboard/profile/info"; //passenger office export const GET_PASSENGER_OFFICE = - BASE_URL + "/dashboard/passenger_office_chief/show"; + BASE_URL + "/dashboard/passenger_office_chief/show"; export const CONFIRM_PASSENGER_OFFICE = - BASE_URL + "/dashboard/passenger_office_chief/confirm"; + BASE_URL + "/dashboard/passenger_office_chief/confirm"; export const REJECT_PASSENGER_OFFICE = - BASE_URL + "/dashboard/passenger_office_chief/reject"; + BASE_URL + "/dashboard/passenger_office_chief/reject"; //passenger office //passenger boss export const GET_PASSENGER_BOSS = - BASE_URL + "/dashboard/province_working_group/show"; + BASE_URL + "/dashboard/province_working_group/show"; export const CONFIRM_PASSENGER_BOSS = - BASE_URL + "/dashboard/province_working_group/confirm"; + BASE_URL + "/dashboard/province_working_group/confirm"; export const REJECT_PASSENGER_BOSS = - BASE_URL + "/dashboard/province_working_group/reject"; + BASE_URL + "/dashboard/province_working_group/reject"; //passenger boss //transportation assistance export const GET_TRANSPORTATION_ASSISTANCE = - BASE_URL + "/dashboard/transportation_assistant/show"; + BASE_URL + "/dashboard/transportation_assistant/show"; export const CONFIRM_TRANSPORTATION_ASSISTANCE = - BASE_URL + "/dashboard/transportation_assistant/confirm"; + BASE_URL + "/dashboard/transportation_assistant/confirm"; export const REJECT_TRANSPORTATION_ASSISTANCE = - BASE_URL + "/dashboard/transportation_assistant/reject"; + BASE_URL + "/dashboard/transportation_assistant/reject"; //transportation assistance //machinary office export const GET_MACHINARY_OFFICE = - BASE_URL + "/dashboard/machinery_expert/show"; + BASE_URL + "/dashboard/machinery_expert/show"; export const CONFIRM_MACHINARY_OFFICE = - BASE_URL + "/dashboard/machinery_expert/confirm"; + BASE_URL + "/dashboard/machinery_expert/confirm"; export const REJECT_MACHINARY_OFFICE = - BASE_URL + "/dashboard/machinery_expert/reject"; + BASE_URL + "/dashboard/machinery_expert/reject"; //passenger office //province manager export const GET_PROVINCE_MANAGER = - BASE_URL + "/dashboard/province_manager/show"; + BASE_URL + "/dashboard/province_manager/show"; export const CONFIRM_PROVINCE_MANAGER = - BASE_URL + "/dashboard/province_manager/confirm"; + BASE_URL + "/dashboard/province_manager/confirm"; export const REJECT_PROVINCE_MANAGER = - BASE_URL + "/dashboard/province_manager/reject"; + BASE_URL + "/dashboard/province_manager/reject"; //province manager diff --git a/src/core/data/headerProfileItems.jsx b/src/core/data/headerProfileItems.jsx index 63e661a..577fba3 100644 --- a/src/core/data/headerProfileItems.jsx +++ b/src/core/data/headerProfileItems.jsx @@ -2,18 +2,18 @@ import BorderColorIcon from "@mui/icons-material/BorderColor"; import PasswordIcon from "@mui/icons-material/Password"; const headerProfileItems = [ - { - key: 0, - name: "header.edit_profile", - route: "/dashboard/edit-profile", - icon: , - }, - { - key: 1, - name: "header.change_password", - route: "/dashboard/change-password", - icon: , - }, + { + key: 0, + name: "header.edit_profile", + route: "/dashboard/edit-profile", + icon: , + }, + { + key: 1, + name: "header.change_password", + route: "/dashboard/change-password", + icon: , + }, ]; export default headerProfileItems; diff --git a/src/core/data/sidebarMenu.jsx b/src/core/data/sidebarMenu.jsx index 667c688..352b424 100644 --- a/src/core/data/sidebarMenu.jsx +++ b/src/core/data/sidebarMenu.jsx @@ -6,58 +6,58 @@ import AssignmentIndIcon from "@mui/icons-material/AssignmentInd"; import DesktopWindowsIcon from "@mui/icons-material/DesktopWindows"; const sidebarMenu = [ - [ - { - key: "sidebar.dashboard", - type: "page", - route: "/dashboard", - icon: , - selected: false, - role: "all", - }, - { - key: "sidebar.passenger-office-chief", - secondary: "secondary.passenger-office", - type: "page", - route: "/dashboard/passenger-office-chief", - icon: , - selected: false, - role: "passenger_office_chief", - }, - { - key: "sidebar.machinary-expert", - type: "page", - route: "/dashboard/machinary-expert", - icon: , - selected: false, - role: "machinery_expert", - }, - { - key: "sidebar.passenger-boss", - secondary: "secondary.passenger-boss", - type: "page", - route: "/dashboard/passenger-boss", - icon: , - selected: false, - role: "passenger_office_chief", - }, - { - key: "sidebar.transportation-assistant", - type: "page", - route: "/dashboard/transportation-assistant", - icon: , - selected: false, - role: "transportation_assistant", - }, - { - key: "sidebar.province-manager", - type: "page", - route: "/dashboard/province-manager", - icon: , - selected: false, - role: "province_manager", - }, - ], + [ + { + key: "sidebar.dashboard", + type: "page", + route: "/dashboard", + icon: , + selected: false, + role: "all", + }, + { + key: "sidebar.passenger-office-chief", + secondary: "secondary.passenger-office", + type: "page", + route: "/dashboard/passenger-office-chief", + icon: , + selected: false, + role: "passenger_office_chief", + }, + { + key: "sidebar.machinary-expert", + type: "page", + route: "/dashboard/machinary-expert", + icon: , + selected: false, + role: "machinery_expert", + }, + { + key: "sidebar.passenger-boss", + secondary: "secondary.passenger-boss", + type: "page", + route: "/dashboard/passenger-boss", + icon: , + selected: false, + role: "passenger_office_chief", + }, + { + key: "sidebar.transportation-assistant", + type: "page", + route: "/dashboard/transportation-assistant", + icon: , + selected: false, + role: "transportation_assistant", + }, + { + key: "sidebar.province-manager", + type: "page", + route: "/dashboard/province-manager", + icon: , + selected: false, + role: "province_manager", + }, + ], ]; export default sidebarMenu; diff --git a/src/core/utils/createEmotionCache.jsx b/src/core/utils/createEmotionCache.jsx index 06add02..413fafe 100644 --- a/src/core/utils/createEmotionCache.jsx +++ b/src/core/utils/createEmotionCache.jsx @@ -1,38 +1,38 @@ import createCache from "@emotion/cache"; -import { prefixer } from "stylis"; +import {prefixer} from "stylis"; import stylisRTLPlugin from "stylis-plugin-rtl"; const isBrowser = typeof document !== "undefined"; export const createEmotionCacheLtr = () => { - let insertionPoint; + let insertionPoint; - if (isBrowser) { - const emotionInsertionPoint = document.querySelector( - 'meta[name="emotion-insertion-point"]' - ); - insertionPoint = emotionInsertionPoint ?? undefined; - } + if (isBrowser) { + const emotionInsertionPoint = document.querySelector( + 'meta[name="emotion-insertion-point"]' + ); + insertionPoint = emotionInsertionPoint ?? undefined; + } - return createCache({ - key: "mui-style", - insertionPoint, - }); + return createCache({ + key: "mui-style", + insertionPoint, + }); }; export const createEmotionCacheRtl = () => { - let insertionPoint; + let insertionPoint; - if (isBrowser) { - const emotionInsertionPoint = document.querySelector( - 'meta[name="emotion-insertion-point"]' - ); - insertionPoint = emotionInsertionPoint ?? undefined; - } + if (isBrowser) { + const emotionInsertionPoint = document.querySelector( + 'meta[name="emotion-insertion-point"]' + ); + insertionPoint = emotionInsertionPoint ?? undefined; + } - return createCache({ - key: "muirtl", - stylisPlugins: [prefixer, stylisRTLPlugin], - insertionPoint, - }); + return createCache({ + key: "muirtl", + stylisPlugins: [prefixer, stylisRTLPlugin], + insertionPoint, + }); }; diff --git a/src/core/utils/theme-rtl.jsx b/src/core/utils/theme-rtl.jsx index 2d0fdab..fb0bbaa 100644 --- a/src/core/utils/theme-rtl.jsx +++ b/src/core/utils/theme-rtl.jsx @@ -1,12 +1,12 @@ -import { createTheme } from "@mui/material/styles"; +import {createTheme} from "@mui/material/styles"; import theme from "./theme"; const themeRtl = createTheme({ - direction: "rtl", - typography: { - fontFamily: `IRANSansFaNum, sans-serif`, - }, - ...theme, + direction: "rtl", + typography: { + fontFamily: `IRANSansFaNum, sans-serif`, + }, + ...theme, }); export default themeRtl; diff --git a/src/core/utils/theme.jsx b/src/core/utils/theme.jsx index e921777..1679552 100644 --- a/src/core/utils/theme.jsx +++ b/src/core/utils/theme.jsx @@ -1,30 +1,30 @@ -import { faIR } from "@mui/x-date-pickers/locales"; +import {faIR} from "@mui/x-date-pickers/locales"; const theme = { - palette: { - primary: { - main: "#084070", - contrastText: "#fff", - light: "#2c6291", - dark: "#11293e", - }, - secondary: { - main: "#FF4E00", - contrastText: "#fff", - light: "#ed743e", - dark: "#ad3a07", - }, - }, - faIR, - components: { - MuiBackdrop: { - styleOverrides: { - root: { - backgroundColor: "#02020226", // Replace with your desired backdrop color and opacity + palette: { + primary: { + main: "#084070", + contrastText: "#fff", + light: "#2c6291", + dark: "#11293e", + }, + secondary: { + main: "#FF4E00", + contrastText: "#fff", + light: "#ed743e", + dark: "#ad3a07", + }, + }, + faIR, + components: { + MuiBackdrop: { + styleOverrides: { + root: { + backgroundColor: "#02020226", // Replace with your desired backdrop color and opacity + }, + }, }, - }, }, - }, }; export default theme; diff --git a/src/layouts/AppLayout.jsx b/src/layouts/AppLayout.jsx index 4845f6d..d2c5da5 100644 --- a/src/layouts/AppLayout.jsx +++ b/src/layouts/AppLayout.jsx @@ -4,96 +4,96 @@ import useLoading from "@/lib/app/hooks/useLoading"; import useUser from "@/lib/app/hooks/useUser"; import Head from "next/head"; import NextNProgress from "nextjs-progressbar"; -import { useEffect } from "react"; +import {useEffect} from "react"; -function AppLayout({ children, isBot }) { - const { languageIsReady } = useLanguage(); - const { setLoadingPage } = useLoading(); - const { userChangedLanguage, token, isAuth } = useUser(); - useEffect(() => { - if (languageIsReady) { - if (token) { - if (isAuth) { - if (userChangedLanguage) { - setLoadingPage(true); - return; - } - setLoadingPage(false); - return; - } - setLoadingPage(true); - return; - } - setLoadingPage(false); - return; - } - setLoadingPage(true); - }, [languageIsReady, token, isAuth, userChangedLanguage]); +function AppLayout({children, isBot}) { + const {languageIsReady} = useLanguage(); + const {setLoadingPage} = useLoading(); + const {userChangedLanguage, token, isAuth} = useUser(); + useEffect(() => { + if (languageIsReady) { + if (token) { + if (isAuth) { + if (userChangedLanguage) { + setLoadingPage(true); + return; + } + setLoadingPage(false); + return; + } + setLoadingPage(true); + return; + } + setLoadingPage(false); + return; + } + setLoadingPage(true); + }, [languageIsReady, token, isAuth, userChangedLanguage]); - if (!isBot) { - if (userChangedLanguage) return; - if (!languageIsReady) return; - } + if (!isBot) { + if (userChangedLanguage) return; + if (!languageIsReady) return; + } - return ( - <> - - - - - - - - - - - - - - - - - - - - - - {children} - - ); + return ( + <> + + + + + + + + + + + + + + + + + + + + + + {children} + + ); } export default AppLayout; diff --git a/src/layouts/CenterLayout.jsx b/src/layouts/CenterLayout.jsx index 4c8767f..1e1b8bf 100644 --- a/src/layouts/CenterLayout.jsx +++ b/src/layouts/CenterLayout.jsx @@ -1,18 +1,18 @@ -import { Fade, Stack } from "@mui/material"; +import {Fade, Stack} from "@mui/material"; const CenterLayout = (props) => { - return ( - - - {props.children} - - - ); + return ( + + + {props.children} + + + ); }; export default CenterLayout; diff --git a/src/layouts/FullPageLayout.jsx b/src/layouts/FullPageLayout.jsx index cbf2102..d6ed61e 100644 --- a/src/layouts/FullPageLayout.jsx +++ b/src/layouts/FullPageLayout.jsx @@ -1,21 +1,21 @@ -import { Stack } from "@mui/material"; +import {Stack} from "@mui/material"; const FullPageLayout = (props) => { - return ( - - {props.children} - - ); + return ( + + {props.children} + + ); }; export default FullPageLayout; diff --git a/src/layouts/MuiLayout.jsx b/src/layouts/MuiLayout.jsx index ba891d0..2614ac2 100644 --- a/src/layouts/MuiLayout.jsx +++ b/src/layouts/MuiLayout.jsx @@ -1,76 +1,74 @@ import NoSsrHandler from "@/core/components/isBotHandler"; -import { - createEmotionCacheRtl -} from "@/core/utils/createEmotionCache"; +import {createEmotionCacheRtl} from "@/core/utils/createEmotionCache"; import themeRtl from "@/core/utils/theme-rtl"; -import { CacheProvider } from "@emotion/react"; -import { GlobalStyles } from "@mui/material"; +import {CacheProvider} from "@emotion/react"; +import {GlobalStyles} from "@mui/material"; import CssBaseline from "@mui/material/CssBaseline"; -import { ThemeProvider } from "@mui/material/styles"; +import {ThemeProvider} from "@mui/material/styles"; import Head from "next/head"; const clientSideEmotionCacheRtl = createEmotionCacheRtl(); -const MuiLayout = ({ children, isBot }) => { +const MuiLayout = ({children, isBot}) => { - const emotionCache = clientSideEmotionCacheRtl; + const emotionCache = clientSideEmotionCacheRtl; - const theme = themeRtl; - return ( - - - - - - - + + + + + + + body: { + width: "100vw", + height: "100vh", + }, + "#__next": { + width: "100%", + height: "100%", + }, + }} + /> - - {children} - - - - ); + + {children} + + + + ); }; export default MuiLayout; diff --git a/src/layouts/ScrollableLayout.jsx b/src/layouts/ScrollableLayout.jsx index 5ab58ca..583edd7 100644 --- a/src/layouts/ScrollableLayout.jsx +++ b/src/layouts/ScrollableLayout.jsx @@ -1,25 +1,25 @@ -import { Box, Fade } from "@mui/material"; +import {Box, Fade} from "@mui/material"; const ScrollableLayout = (props) => { - const overflowY = props?.y || "hidden"; - const overflowX = props?.x || "hidden"; + const overflowY = props?.y || "hidden"; + const overflowX = props?.x || "hidden"; - return ( - - - {props.children} - - - ); + return ( + + + {props.children} + + + ); }; export default ScrollableLayout; diff --git a/src/layouts/dashboardLayouts/breadcrumbs/BreadcrumbItem.jsx b/src/layouts/dashboardLayouts/breadcrumbs/BreadcrumbItem.jsx index ccff4c9..c233be3 100644 --- a/src/layouts/dashboardLayouts/breadcrumbs/BreadcrumbItem.jsx +++ b/src/layouts/dashboardLayouts/breadcrumbs/BreadcrumbItem.jsx @@ -1,19 +1,19 @@ import LinkRouting from "@/core/components/LinkRouting"; -import { Typography } from "@mui/material"; -import { useTranslations } from "next-intl"; +import {Typography} from "@mui/material"; +import {useTranslations} from "next-intl"; export default function BreadcrumbItem(props) { - const t = useTranslations(); - const isLast = props.index === props.RouterArray.length - 1; - const url = `/${props.RouterArray.slice(0, props.index + 1).join("/")}`; + const t = useTranslations(); + const isLast = props.index === props.RouterArray.length - 1; + const url = `/${props.RouterArray.slice(0, props.index + 1).join("/")}`; - return isLast ? ( - - {t("sidebar." + props.label)} - - ) : ( - - {t("sidebar." + props.label)} - - ); + return isLast ? ( + + {t("sidebar." + props.label)} + + ) : ( + + {t("sidebar." + props.label)} + + ); } diff --git a/src/layouts/dashboardLayouts/breadcrumbs/index.jsx b/src/layouts/dashboardLayouts/breadcrumbs/index.jsx index 3123a12..9ab234e 100644 --- a/src/layouts/dashboardLayouts/breadcrumbs/index.jsx +++ b/src/layouts/dashboardLayouts/breadcrumbs/index.jsx @@ -1,49 +1,49 @@ -import { useRouter } from "next/router"; -import { Box, Breadcrumbs } from "@mui/material"; -import { useTheme } from "@mui/material/styles"; -import { NavigateBefore, NavigateNext } from "@mui/icons-material"; +import {useRouter} from "next/router"; +import {Box, Breadcrumbs} from "@mui/material"; +import {useTheme} from "@mui/material/styles"; +import {NavigateBefore, NavigateNext} from "@mui/icons-material"; import BreadcrumbItem from "./BreadcrumbItem"; const BreadCrumbs = (props) => { - const { isVisible } = props; - const theme = useTheme(); - const router = useRouter(); + const {isVisible} = props; + const theme = useTheme(); + const router = useRouter(); - if (!isVisible) { - return null; - } + if (!isVisible) { + return null; + } - const { pathname } = router; - const RouterArray = pathname.split("/").filter((segment) => segment !== ""); + const {pathname} = router; + const RouterArray = pathname.split("/").filter((segment) => segment !== ""); - if (RouterArray.length === 1) { - return null; - } + if (RouterArray.length === 1) { + return null; + } - return ( - - - ) : ( - - ) - } - aria-label="breadcrumb" - > - {RouterArray.map((segment, index) => ( - - ))} - - - ); + return ( + + + ) : ( + + ) + } + aria-label="breadcrumb" + > + {RouterArray.map((segment, index) => ( + + ))} + + + ); }; export default BreadCrumbs; diff --git a/src/layouts/dashboardLayouts/header/ProfileData.jsx b/src/layouts/dashboardLayouts/header/ProfileData.jsx index e07dba6..548378b 100644 --- a/src/layouts/dashboardLayouts/header/ProfileData.jsx +++ b/src/layouts/dashboardLayouts/header/ProfileData.jsx @@ -1,18 +1,18 @@ -import { Avatar, Stack, Typography } from "@mui/material"; +import {Avatar, Stack, Typography} from "@mui/material"; import useUser from "@/lib/app/hooks/useUser"; export default function ProfileData() { - const { user } = useUser(); - return ( - - - - {user.username} - - - ); + const {user} = useUser(); + return ( + + + + {user.username} + + + ); } diff --git a/src/layouts/dashboardLayouts/header/ProfileMenu.jsx b/src/layouts/dashboardLayouts/header/ProfileMenu.jsx index 1c53ef5..415d501 100644 --- a/src/layouts/dashboardLayouts/header/ProfileMenu.jsx +++ b/src/layouts/dashboardLayouts/header/ProfileMenu.jsx @@ -1,61 +1,62 @@ -import { Avatar, Menu, IconButton, Tooltip } from "@mui/material"; -import { useState } from "react"; +import {Avatar, IconButton, Menu, Tooltip} from "@mui/material"; +import {useState} from "react"; import ProfileData from "./ProfileData"; import ProfileOptions from "./ProfileOptions"; -import { useTranslations } from "next-intl"; +import {useTranslations} from "next-intl"; import useUser from "@/lib/app/hooks/useUser"; function ProfileMenu() { - const t = useTranslations(); - const [anchorElUser, setAnchorElUser] = useState(null); - const { user } = useUser(); + const t = useTranslations(); + const [anchorElUser, setAnchorElUser] = useState(null); + const {user} = useUser(); - const handleOpenUserMenu = (event) => { - setAnchorElUser(event.currentTarget); - }; - const handleCloseUserMenu = () => { - setAnchorElUser(null); - }; + const handleOpenUserMenu = (event) => { + setAnchorElUser(event.currentTarget); + }; + const handleCloseUserMenu = () => { + setAnchorElUser(null); + }; - return ( - <> - - - - - - - - - - - ); + return ( + <> + + + + + + + + + + + ); } + export default ProfileMenu; diff --git a/src/layouts/dashboardLayouts/header/ProfileOptionLogOut.jsx b/src/layouts/dashboardLayouts/header/ProfileOptionLogOut.jsx index f56db6c..2a6cf85 100644 --- a/src/layouts/dashboardLayouts/header/ProfileOptionLogOut.jsx +++ b/src/layouts/dashboardLayouts/header/ProfileOptionLogOut.jsx @@ -1,49 +1,49 @@ -import { Box, Button, MenuItem, Typography } from "@mui/material"; +import {Box, Button, MenuItem, Typography} from "@mui/material"; import MeetingRoomIcon from "@mui/icons-material/MeetingRoom"; import useUser from "@/lib/app/hooks/useUser"; -import { useTranslations } from "next-intl"; +import {useTranslations} from "next-intl"; -export default function ProfileOptionLogOut({ handleCloseUserMenu }) { - const t = useTranslations(); - const { clearToken } = useUser(); - const handleClickLogOut = () => { - handleCloseUserMenu(); - clearToken(); - }; - return ( - <> - - - - - - - {t("header.logout")} - - - - - ); +export default function ProfileOptionLogOut({handleCloseUserMenu}) { + const t = useTranslations(); + const {clearToken} = useUser(); + const handleClickLogOut = () => { + handleCloseUserMenu(); + clearToken(); + }; + return ( + <> + + + + + + + {t("header.logout")} + + + + + ); } diff --git a/src/layouts/dashboardLayouts/header/ProfileOptions.jsx b/src/layouts/dashboardLayouts/header/ProfileOptions.jsx index bf63212..6e7bdba 100644 --- a/src/layouts/dashboardLayouts/header/ProfileOptions.jsx +++ b/src/layouts/dashboardLayouts/header/ProfileOptions.jsx @@ -1,49 +1,49 @@ -import { Box, MenuItem, Typography } from "@mui/material"; -import { NextLinkComposed } from "@/core/components/LinkRouting"; -import { useTranslations } from "next-intl"; +import {Box, MenuItem, Typography} from "@mui/material"; +import {NextLinkComposed} from "@/core/components/LinkRouting"; +import {useTranslations} from "next-intl"; import headerProfileItems from "@/core/data/headerProfileItems"; import ProfileOptionLogOut from "./ProfileOptionLogOut"; -export default function ProfileOptions({ handleCloseUserMenu }) { - const t = useTranslations(); +export default function ProfileOptions({handleCloseUserMenu}) { + const t = useTranslations(); - return ( - <> - {headerProfileItems.map((profile_item) => ( - - - - {profile_item.icon} - - - {t(profile_item.name)} - - - - ))} - - - ); + return ( + <> + {headerProfileItems.map((profile_item) => ( + + + + {profile_item.icon} + + + {t(profile_item.name)} + + + + ))} + + + ); } diff --git a/src/layouts/dashboardLayouts/header/index.jsx b/src/layouts/dashboardLayouts/header/index.jsx index cd1e4a0..8760960 100644 --- a/src/layouts/dashboardLayouts/header/index.jsx +++ b/src/layouts/dashboardLayouts/header/index.jsx @@ -1,80 +1,72 @@ import MenuIcon from "@mui/icons-material/Menu"; -import { - AppBar, - Box, - Container, - CssBaseline, - IconButton, - Stack, - Toolbar, - useTheme -} from "@mui/material"; +import {AppBar, Box, Container, CssBaseline, IconButton, Stack, Toolbar, useTheme} from "@mui/material"; import ProfileMenu from "./ProfileMenu"; -function Header({ drawerWidth, handleDrawerToggle }) { - const theme = useTheme(); +function Header({drawerWidth, handleDrawerToggle}) { + const theme = useTheme(); - return ( - <> - - - - - - - - - - - + + - - - - - - - - - - ); + > + + + + + + + + + + + + + + + + + + + ); } + export default Header; diff --git a/src/layouts/dashboardLayouts/index.jsx b/src/layouts/dashboardLayouts/index.jsx index f1478bf..ed0ee31 100644 --- a/src/layouts/dashboardLayouts/index.jsx +++ b/src/layouts/dashboardLayouts/index.jsx @@ -1,50 +1,50 @@ -import { useState } from "react"; +import {useState} from "react"; import FullPageLayout from "../FullPageLayout"; import Header from "./header"; import Sidebar from "./sidebar"; -import { Toolbar } from "@mui/material"; +import {Toolbar} from "@mui/material"; import BreadCrumbs from "./breadcrumbs"; -import { ToastContainer } from "react-toastify"; +import {ToastContainer} from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; import useDirection from "@/lib/app/hooks/useDirection"; const drawerWidth = 240; const DashboardLayouts = (props) => { - const { directionApp } = useDirection(); - const { window } = props; - const [mobileOpen, setMobileOpen] = useState(false); - const container = - window !== undefined ? () => window().document.body : undefined; + const {directionApp} = useDirection(); + const {window} = props; + const [mobileOpen, setMobileOpen] = useState(false); + const container = + window !== undefined ? () => window().document.body : undefined; - const handleDrawerToggle = () => { - setMobileOpen(!mobileOpen); - }; - return ( - -
- - - - - - {props.children} + const handleDrawerToggle = () => { + setMobileOpen(!mobileOpen); + }; + return ( + +
+ + + + + + {props.children} + + + {directionApp === "rtl" ? : } - - {directionApp === "rtl" ? : } - - ); + ); }; export default DashboardLayouts; diff --git a/src/layouts/dashboardLayouts/sidebar/SidebarDrawer.jsx b/src/layouts/dashboardLayouts/sidebar/SidebarDrawer.jsx index 6eb5e60..fecc252 100644 --- a/src/layouts/dashboardLayouts/sidebar/SidebarDrawer.jsx +++ b/src/layouts/dashboardLayouts/sidebar/SidebarDrawer.jsx @@ -1,29 +1,28 @@ -import { Divider, Stack, Toolbar, Typography } from "@mui/material"; -import { useTranslations } from "next-intl"; +import {Divider, Stack, Toolbar, Typography} from "@mui/material"; +import {useTranslations} from "next-intl"; import SidebarList from "./SidebarList"; -import StyledImage from "@/core/components/StyledImage"; -const SidebarDrawer = ({ handleDrawerToggle }) => { - const t = useTranslations(); - return ( - <> - - - - {t("app_short_name")} - - - { - t("expert") /* make if on thease t("user_welfare_services") +const SidebarDrawer = ({handleDrawerToggle}) => { + const t = useTranslations(); + return ( + <> + + + + {t("app_short_name")} + + + { + t("expert") /* make if on thease t("user_welfare_services") t("user_navy") */ - } - - - - - - - ); + } + + + + + + + ); }; export default SidebarDrawer; diff --git a/src/layouts/dashboardLayouts/sidebar/SidebarList.jsx b/src/layouts/dashboardLayouts/sidebar/SidebarList.jsx index c47cf2b..dffd844 100644 --- a/src/layouts/dashboardLayouts/sidebar/SidebarList.jsx +++ b/src/layouts/dashboardLayouts/sidebar/SidebarList.jsx @@ -1,57 +1,57 @@ -import { Divider, List } from "@mui/material"; -import { useEffect, useReducer } from "react"; +import {Divider, List} from "@mui/material"; +import {useEffect, useReducer} from "react"; import SidebarListItem from "./SidebarListItem"; import sidebarMenu from "@/core/data/sidebarMenu"; -import { useRouter } from "next/router"; +import {useRouter} from "next/router"; import useUser from "@/lib/app/hooks/useUser"; function reducer(state, action) { - switch (action.type) { - case "COLLAPSE_MENU": - return state.map((itemsArr) => - itemsArr.map((item) => - action.key == item.key - ? { ...item, showSubItem: !item.showSubItem } - : item - ) - ); - case "SELECTED": - return state.map((itemsArr) => - itemsArr.map((item) => - action.route == item.route - ? { ...item, selected: true } - : { ...item, selected: false } - ) - ); - default: - throw new Error(); - } + switch (action.type) { + case "COLLAPSE_MENU": + return state.map((itemsArr) => + itemsArr.map((item) => + action.key == item.key + ? {...item, showSubItem: !item.showSubItem} + : item + ) + ); + case "SELECTED": + return state.map((itemsArr) => + itemsArr.map((item) => + action.route == item.route + ? {...item, selected: true} + : {...item, selected: false} + ) + ); + default: + throw new Error(); + } } -export default function SidebarList({ handleDrawerToggle }) { - const [itemMenu, dispatch] = useReducer(reducer, sidebarMenu); - const { user } = useUser(); - const router = useRouter(); +export default function SidebarList({handleDrawerToggle}) { + const [itemMenu, dispatch] = useReducer(reducer, sidebarMenu); + const {user} = useUser(); + const router = useRouter(); - useEffect(() => { - dispatch({ type: "SELECTED", route: router.pathname }); - }, [router.pathname]); + useEffect(() => { + dispatch({type: "SELECTED", route: router.pathname}); + }, [router.pathname]); - const filteredItemMenu = itemMenu[0].filter( - (item) => user.role.includes(item.role) || item.role === "all" - ); + const filteredItemMenu = itemMenu[0].filter( + (item) => user.role.includes(item.role) || item.role === "all" + ); - return ( - - {filteredItemMenu.map((item, index) => ( - - ))} - {filteredItemMenu.length > 0 && } - - ); + return ( + + {filteredItemMenu.map((item, index) => ( + + ))} + {filteredItemMenu.length > 0 && } + + ); } diff --git a/src/layouts/dashboardLayouts/sidebar/SidebarListItem.jsx b/src/layouts/dashboardLayouts/sidebar/SidebarListItem.jsx index 949b171..f14ae1d 100644 --- a/src/layouts/dashboardLayouts/sidebar/SidebarListItem.jsx +++ b/src/layouts/dashboardLayouts/sidebar/SidebarListItem.jsx @@ -1,84 +1,77 @@ -import { NextLinkComposed } from "@/core/components/LinkRouting"; +import {NextLinkComposed} from "@/core/components/LinkRouting"; import ExpandLess from "@mui/icons-material/ExpandLess"; import ExpandMore from "@mui/icons-material/ExpandMore"; -import { - Badge, - ListItem, - ListItemButton, - ListItemIcon, - ListItemText, - Typography, -} from "@mui/material"; -import { useTranslations } from "next-intl"; -import { Fragment } from "react"; +import {Badge, ListItem, ListItemButton, ListItemIcon, ListItemText, Typography,} from "@mui/material"; +import {useTranslations} from "next-intl"; +import {Fragment} from "react"; import SidebarListSubItem from "./SidebarListSubItem"; -const SidebarListItem = ({ item, dispatch, handleDrawerToggle }) => { - const t = useTranslations(); +const SidebarListItem = ({item, dispatch, handleDrawerToggle}) => { + const t = useTranslations(); - return ( - - - { - if (item.type == "menu") { - dispatch({ type: "COLLAPSE_MENU", key: item.key }); - } - handleDrawerToggle(); - }} - sx={{ - minHeight: 48, - }} - > - - {item.icon} - - - {t(item.secondary)} - - ) : null - } - /> + return ( + + + { + if (item.type == "menu") { + dispatch({type: "COLLAPSE_MENU", key: item.key}); + } + handleDrawerToggle(); + }} + sx={{ + minHeight: 48, + }} + > + + {item.icon} + + + {t(item.secondary)} + + ) : null + } + /> - {item.type == "menu" && - (item.showSubItem ? : )} - - - - {item.subItem && ( - - )} - - ); + {item.type == "menu" && + (item.showSubItem ? : )} + + + + {item.subItem && ( + + )} + + ); }; export default SidebarListItem; diff --git a/src/layouts/dashboardLayouts/sidebar/SidebarListSubItem.jsx b/src/layouts/dashboardLayouts/sidebar/SidebarListSubItem.jsx index f960efb..3407081 100644 --- a/src/layouts/dashboardLayouts/sidebar/SidebarListSubItem.jsx +++ b/src/layouts/dashboardLayouts/sidebar/SidebarListSubItem.jsx @@ -1,54 +1,48 @@ -import { NextLinkComposed } from "@/core/components/LinkRouting"; +import {NextLinkComposed} from "@/core/components/LinkRouting"; import InboxIcon from "@mui/icons-material/MoveToInbox"; -import { - Collapse, - List, - ListItemButton, - ListItemIcon, - ListItemText, -} from "@mui/material"; -import { useTranslations } from "next-intl"; -import { Fragment } from "react"; +import {Collapse, List, ListItemButton, ListItemIcon, ListItemText,} from "@mui/material"; +import {useTranslations} from "next-intl"; +import {Fragment} from "react"; -const SidebarListSubItem = ({ item, handleDrawerToggle }) => { - const t = useTranslations(); +const SidebarListSubItem = ({item, handleDrawerToggle}) => { + const t = useTranslations(); - return ( - - - {item.subItem.map((subitem, index) => ( - - { - if (item.type == "menu") { - dispatch({ type: "COLLAPSE_MENU", key: item.key }); - } - handleDrawerToggle(); - }} - > - - - - - - - ))} - - - ); + return ( + + + {item.subItem.map((subitem, index) => ( + + { + if (item.type == "menu") { + dispatch({type: "COLLAPSE_MENU", key: item.key}); + } + handleDrawerToggle(); + }} + > + + + + + + + ))} + + + ); }; export default SidebarListSubItem; diff --git a/src/layouts/dashboardLayouts/sidebar/index.jsx b/src/layouts/dashboardLayouts/sidebar/index.jsx index dcf7fe2..2498dfd 100644 --- a/src/layouts/dashboardLayouts/sidebar/index.jsx +++ b/src/layouts/dashboardLayouts/sidebar/index.jsx @@ -1,46 +1,46 @@ -import { Box, Drawer } from "@mui/material"; +import {Box, Drawer} from "@mui/material"; import SidebarDrawer from "./SidebarDrawer"; const Sidebar = (props) => { - return ( - - - - - - - - - ); + return ( + + + + + + + + + ); }; export default Sidebar; diff --git a/src/lib/app/contexts/DatatableContext.jsx b/src/lib/app/contexts/DatatableContext.jsx index 94bc016..27fa6ac 100644 --- a/src/lib/app/contexts/DatatableContext.jsx +++ b/src/lib/app/contexts/DatatableContext.jsx @@ -1,14 +1,14 @@ -import { createContext } from "react"; +import {createContext} from "react"; import useDataTable from "../hooks/useDatatable"; export const DataTableContext = createContext(); export const DataTableProvider = (props) => { - const contextValue = useDataTable(); + const contextValue = useDataTable(); - return ( - - {props.children} - - ); + return ( + + {props.children} + + ); }; diff --git a/src/lib/app/contexts/ReloadDatatableContext.jsx b/src/lib/app/contexts/ReloadDatatableContext.jsx index 05c788b..de359c5 100644 --- a/src/lib/app/contexts/ReloadDatatableContext.jsx +++ b/src/lib/app/contexts/ReloadDatatableContext.jsx @@ -1,15 +1,15 @@ -import { createContext, useState } from "react"; +import {createContext, useState} from "react"; export const ReloadDataTableContext = createContext(); -export const ReloadDataTableProvider = ({ children }) => { - const [reloadDataTable, setReloadDataTable] = useState(false); +export const ReloadDataTableProvider = ({children}) => { + const [reloadDataTable, setReloadDataTable] = useState(false); - return ( - - {children} - - ); + return ( + + {children} + + ); }; diff --git a/src/lib/app/contexts/language.jsx b/src/lib/app/contexts/language.jsx index c8ac313..e3f41f4 100644 --- a/src/lib/app/contexts/language.jsx +++ b/src/lib/app/contexts/language.jsx @@ -1,99 +1,99 @@ -import { FA_DATATABLE_LOCALIZATION } from "&/locales/fa/datatable"; -import { useRouter } from "next/router"; -import { createContext, useEffect, useState } from "react"; +import {FA_DATATABLE_LOCALIZATION} from "&/locales/fa/datatable"; +import {useRouter} from "next/router"; +import {createContext, useEffect, useState} from "react"; import useUser from "../hooks/useUser"; export const LanguageContext = createContext(); -export const LanguageProvider = ({ children }) => { - const router = useRouter(); - const languageList = [ - { - key: "fa", - dir: "rtl", - name: "فارسی", - fontFamily: `IRANSans, sans-serif`, - tableLocalization: FA_DATATABLE_LOCALIZATION, - } - ]; - const { user, userChangedLanguage, changeLanguageState } = useUser(); - const [languageIsReady, setLanguageIsReady] = useState(false); - const [languageApp, setLanguageApp] = useState(); - const [directionApp, setDirectionApp] = useState( - process.env.NEXT_PUBLIC_DEFAULT_DIRECTION - ); - - useEffect(() => { - const lang = localStorage.getItem("_language"); - - if (!lang && !languageApp) { - setLanguageApp(process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE); - } else if (lang) { - setLanguageApp(lang); - } - }, []); - - useEffect(() => { - if (!languageApp) return; - - const lang = localStorage.getItem("_language"); - - if (!lang) { - localStorage.setItem("_language", languageApp); - } else { - if (languageApp != lang) { - localStorage.setItem("_language", languageApp); - } - } - }, [languageApp]); - - useEffect(() => { - if (!router.isReady) return; - if (user.user_language) { - if (user.user_language != languageApp) { - setLanguageApp(user.user_language); - return; - } - } - - if (languageApp != router.locale) { - router.replace( - { pathname: router.pathname, query: router.query }, - router.asPath, +export const LanguageProvider = ({children}) => { + const router = useRouter(); + const languageList = [ { - locale: languageApp, + key: "fa", + dir: "rtl", + name: "فارسی", + fontFamily: `IRANSans, sans-serif`, + tableLocalization: FA_DATATABLE_LOCALIZATION, } - ); - return; - } - for (const lang of languageList) { - if (languageApp != lang.key) continue; - setDirectionApp(lang.dir); - document.dir = lang.dir; - } + ]; + const {user, userChangedLanguage, changeLanguageState} = useUser(); + const [languageIsReady, setLanguageIsReady] = useState(false); + const [languageApp, setLanguageApp] = useState(); + const [directionApp, setDirectionApp] = useState( + process.env.NEXT_PUBLIC_DEFAULT_DIRECTION + ); - const timer = setTimeout(() => { - changeLanguageState(false); - setLanguageIsReady(true); - }, 1000); + useEffect(() => { + const lang = localStorage.getItem("_language"); - return () => { - clearTimeout(timer); - }; - }, [router.locale, router.isReady, userChangedLanguage, languageApp]); + if (!lang && !languageApp) { + setLanguageApp(process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE); + } else if (lang) { + setLanguageApp(lang); + } + }, []); - return ( - - {children} - - ); + useEffect(() => { + if (!languageApp) return; + + const lang = localStorage.getItem("_language"); + + if (!lang) { + localStorage.setItem("_language", languageApp); + } else { + if (languageApp != lang) { + localStorage.setItem("_language", languageApp); + } + } + }, [languageApp]); + + useEffect(() => { + if (!router.isReady) return; + if (user.user_language) { + if (user.user_language != languageApp) { + setLanguageApp(user.user_language); + return; + } + } + + if (languageApp != router.locale) { + router.replace( + {pathname: router.pathname, query: router.query}, + router.asPath, + { + locale: languageApp, + } + ); + return; + } + for (const lang of languageList) { + if (languageApp != lang.key) continue; + setDirectionApp(lang.dir); + document.dir = lang.dir; + } + + const timer = setTimeout(() => { + changeLanguageState(false); + setLanguageIsReady(true); + }, 1000); + + return () => { + clearTimeout(timer); + }; + }, [router.locale, router.isReady, userChangedLanguage, languageApp]); + + return ( + + {children} + + ); }; diff --git a/src/lib/app/contexts/loading.jsx b/src/lib/app/contexts/loading.jsx index 6e95a8c..f5b8a47 100644 --- a/src/lib/app/contexts/loading.jsx +++ b/src/lib/app/contexts/loading.jsx @@ -1,14 +1,14 @@ import LoadingHardPage from "@/core/components/LoadingHardPage"; -import { createContext, useState } from "react"; +import {createContext, useState} from "react"; export const LoadingContext = createContext(); -export const LoadingProvider = ({ children }) => { - const [loadingPage, setLoadingPage] = useState(false); - return ( - - - {children} - - ); +export const LoadingProvider = ({children}) => { + const [loadingPage, setLoadingPage] = useState(false); + return ( + + + {children} + + ); }; diff --git a/src/lib/app/contexts/user.jsx b/src/lib/app/contexts/user.jsx index 30875d9..1dcdb1f 100644 --- a/src/lib/app/contexts/user.jsx +++ b/src/lib/app/contexts/user.jsx @@ -1,124 +1,122 @@ -import { - GET_USER_ROUTE, - SET_LANGUAGE -} from "@/core/data/apiRoutes"; +import {GET_USER_ROUTE} from "@/core/data/apiRoutes"; import axios from "axios"; -import { createContext, useCallback, useEffect, useReducer } from "react"; +import {createContext, useCallback, useEffect, useReducer} from "react"; const initialUser = { - isAuth: false, - userChangedLanguage: false, - token: null, - user: {}, + isAuth: false, + userChangedLanguage: false, + token: null, + user: {}, }; const reducer = (state, action) => { - switch (action.type) { - case "CLEAR_USER": - return { ...state, user: {} }; - case "CHANGE_USER": - return { ...state, user: action.user }; - case "CHANGE_USER_LANGUAGE": - return { - ...state, - user: { ...state.user, user_language: action.language }, - }; - case "CHANGE_AUTH_STATE": - return { ...state, isAuth: action.isAuth }; - case "CHANGE_LANGUAGE_STATE": - return { ...state, userChangedLanguage: action.userChangedLanguage }; - case "CLEAR_TOKEN": - localStorage.removeItem("_token"); - return { ...state, token: null }; - case "SET_TOKEN": - localStorage.setItem("_token", action.token); - return { ...state, token: action.token }; - default: - return state; - } + switch (action.type) { + case "CLEAR_USER": + return {...state, user: {}}; + case "CHANGE_USER": + return {...state, user: action.user}; + case "CHANGE_USER_LANGUAGE": + return { + ...state, + user: {...state.user, user_language: action.language}, + }; + case "CHANGE_AUTH_STATE": + return {...state, isAuth: action.isAuth}; + case "CHANGE_LANGUAGE_STATE": + return {...state, userChangedLanguage: action.userChangedLanguage}; + case "CLEAR_TOKEN": + localStorage.removeItem("_token"); + return {...state, token: null}; + case "SET_TOKEN": + localStorage.setItem("_token", action.token); + return {...state, token: action.token}; + default: + return state; + } }; export const UserContext = createContext(); -export const UserProvider = ({ children }) => { - const [state, dispatch] = useReducer(reducer, initialUser); +export const UserProvider = ({children}) => { + const [state, dispatch] = useReducer(reducer, initialUser); - const clearUser = useCallback(() => { - dispatch({ type: "CLEAR_USER" }); - }, []); + const clearUser = useCallback(() => { + dispatch({type: "CLEAR_USER"}); + }, []); - const changeUser = useCallback((user) => { - dispatch({ type: "CHANGE_USER", user }); - }, []); + const changeUser = useCallback((user) => { + dispatch({type: "CHANGE_USER", user}); + }, []); - const changeUserLanguage = useCallback(/* use in multi language app */); + const changeUserLanguage = useCallback(/* use in multi language app */); - const changeAuthState = useCallback((isAuth) => { - dispatch({ type: "CHANGE_AUTH_STATE", isAuth }); - }, []); + const changeAuthState = useCallback((isAuth) => { + dispatch({type: "CHANGE_AUTH_STATE", isAuth}); + }, []); - const changeLanguageState = useCallback((userChangedLanguage) => { - dispatch({ type: "CHANGE_LANGUAGE_STATE", userChangedLanguage }); - }, []); + const changeLanguageState = useCallback((userChangedLanguage) => { + dispatch({type: "CHANGE_LANGUAGE_STATE", userChangedLanguage}); + }, []); - const clearToken = useCallback(() => { - dispatch({ type: "CLEAR_TOKEN" }); - }, []); + const clearToken = useCallback(() => { + dispatch({type: "CLEAR_TOKEN"}); + }, []); - const setToken = useCallback((token) => { - dispatch({ type: "SET_TOKEN", token }); - }, []); + const setToken = useCallback((token) => { + dispatch({type: "SET_TOKEN", token}); + }, []); - const getUser = useCallback( - (callback = () => {}) => { - axios - .get(GET_USER_ROUTE, { - headers: { authorization: `Bearer ${state.token}` }, - }) - .then(({ data }) => { - if (typeof callback === "function") callback(data); + const getUser = useCallback( + (callback = () => { + }) => { + axios + .get(GET_USER_ROUTE, { + headers: {authorization: `Bearer ${state.token}`}, + }) + .then(({data}) => { + if (typeof callback === "function") callback(data); + }); + }, + [state.token] + ); + + useEffect(() => { + const localToken = localStorage.getItem("_token"); + if (localToken) dispatch({type: "SET_TOKEN", token: localToken}); + }, []); + + useEffect(() => { + if (!state.token) { + clearUser(); + changeAuthState(false); + changeLanguageState(false); + return; + } + getUser((data) => { + changeUser(data); + changeAuthState(true); + changeLanguageState(true); }); - }, - [state.token] - ); + }, [state.token]); - useEffect(() => { - const localToken = localStorage.getItem("_token"); - if (localToken) dispatch({ type: "SET_TOKEN", token: localToken }); - }, []); - - useEffect(() => { - if (!state.token) { - clearUser(); - changeAuthState(false); - changeLanguageState(false); - return; - } - getUser((data) => { - changeUser(data); - changeAuthState(true); - changeLanguageState(true); - }); - }, [state.token]); - - return ( - - {children} - - ); + return ( + + {children} + + ); }; diff --git a/src/lib/app/hooks/useDatatable.jsx b/src/lib/app/hooks/useDatatable.jsx index ddde95f..ff44b61 100644 --- a/src/lib/app/hooks/useDatatable.jsx +++ b/src/lib/app/hooks/useDatatable.jsx @@ -1,113 +1,113 @@ import axios from "axios"; -import { useCallback, useContext, useReducer, useState } from "react"; -import { ReloadDataTableContext } from "../contexts/ReloadDatatableContext"; +import {useCallback, useContext, useReducer, useState} from "react"; +import {ReloadDataTableContext} from "../contexts/ReloadDatatableContext"; import useUser from "./useUser"; import Notifications from "@/core/components/notifications"; import useDirection from "./useDirection"; -import { useTranslations } from "next-intl"; +import {useTranslations} from "next-intl"; const initialValues = { - url: "", - rowID: "", - values: {}, + url: "", + rowID: "", + values: {}, }; const reducer = (state, action) => { - switch (action.type) { - case "CONFIRM_DATA": - return { - ...state, - url: action.url, - rowID: action.rowID, - }; - case "REJECT_DATA": - return { - ...state, - url: action.url, - rowID: action.rowID, - values: {}, - }; - default: - return state; - } + switch (action.type) { + case "CONFIRM_DATA": + return { + ...state, + url: action.url, + rowID: action.rowID, + }; + case "REJECT_DATA": + return { + ...state, + url: action.url, + rowID: action.rowID, + values: {}, + }; + default: + return state; + } }; const useDataTable = () => { - const { setReloadDataTable } = useContext(ReloadDataTableContext); - const [state, dispatch] = useReducer(reducer, initialValues); - const [openConfirmDialog, setOpenConfirmDialog] = useState(false); - const [openRejectDialog, setOpenRejectDialog] = useState(false); - const [rowId, setRowId] = useState(null); - const { directionApp } = useDirection(); - const t = useTranslations(); + const {setReloadDataTable} = useContext(ReloadDataTableContext); + const [state, dispatch] = useReducer(reducer, initialValues); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + const [openRejectDialog, setOpenRejectDialog] = useState(false); + const [rowId, setRowId] = useState(null); + const {directionApp} = useDirection(); + const t = useTranslations(); - const { token } = useUser(); + const {token} = useUser(); - const confirmData = useCallback(async (url, rowID, values) => { - dispatch({ type: "CONFIRM_DATA", url: url, rowID: rowID, values: values }); - axios - .post(`${url}/${rowID}`, values, { - headers: { authorization: `Bearer ${token}` }, - }) - .then((response) => { - setReloadDataTable(true); - Notifications(directionApp, response, t); - }) - .catch((error) => { - Notifications(directionApp, error.response, t); - }); - }, []); + const confirmData = useCallback(async (url, rowID, values) => { + dispatch({type: "CONFIRM_DATA", url: url, rowID: rowID, values: values}); + axios + .post(`${url}/${rowID}`, values, { + headers: {authorization: `Bearer ${token}`}, + }) + .then((response) => { + setReloadDataTable(true); + Notifications(directionApp, response, t); + }) + .catch((error) => { + Notifications(directionApp, error.response, t); + }); + }, []); - const rejectData = useCallback(async (url, rowID, values) => { - dispatch({ type: "REJECT_DATA", url: url, rowID: rowID, values: values }); - axios - .post(`${url}/${rowID}`, values, { - headers: { authorization: `Bearer ${token}` }, - }) - .then((response) => { - setReloadDataTable(true); - Notifications(directionApp, response, t); - }) - .catch((error) => { - console.log(error); - Notifications(directionApp, error.response, t); - }); - }, []); + const rejectData = useCallback(async (url, rowID, values) => { + dispatch({type: "REJECT_DATA", url: url, rowID: rowID, values: values}); + axios + .post(`${url}/${rowID}`, values, { + headers: {authorization: `Bearer ${token}`}, + }) + .then((response) => { + setReloadDataTable(true); + Notifications(directionApp, response, t); + }) + .catch((error) => { + console.log(error); + Notifications(directionApp, error.response, t); + }); + }, []); - //Confirm Data - const handleOpenConfirmDialog = (row) => { - setRowId(row.getValue("id")); - setOpenConfirmDialog(true); - }; + //Confirm Data + const handleOpenConfirmDialog = (row) => { + setRowId(row.getValue("id")); + setOpenConfirmDialog(true); + }; - const handleCloseConfirmDialog = () => { - setOpenConfirmDialog(false); - }; - //End Confirm Data + const handleCloseConfirmDialog = () => { + setOpenConfirmDialog(false); + }; + //End Confirm Data - // Reject Data - const handleOpenRejectDialog = (row) => { - setRowId(row.getValue("id")); - setOpenRejectDialog(true); - }; + // Reject Data + const handleOpenRejectDialog = (row) => { + setRowId(row.getValue("id")); + setOpenRejectDialog(true); + }; - const handleCloseRejectDialog = () => { - setOpenRejectDialog(false); - }; - // End Reject Data + const handleCloseRejectDialog = () => { + setOpenRejectDialog(false); + }; + // End Reject Data - const contextValue = { - handleOpenConfirmDialog, - handleCloseConfirmDialog, - handleOpenRejectDialog, - handleCloseRejectDialog, - rowId, - openConfirmDialog, - openRejectDialog, - rejectData, - confirmData, - }; - return contextValue; + const contextValue = { + handleOpenConfirmDialog, + handleCloseConfirmDialog, + handleOpenRejectDialog, + handleCloseRejectDialog, + rowId, + openConfirmDialog, + openRejectDialog, + rejectData, + confirmData, + }; + return contextValue; }; export default useDataTable; diff --git a/src/lib/app/hooks/useDirection.jsx b/src/lib/app/hooks/useDirection.jsx index e45cb24..b2e01fe 100644 --- a/src/lib/app/hooks/useDirection.jsx +++ b/src/lib/app/hooks/useDirection.jsx @@ -1,10 +1,10 @@ -import { useContext } from "react"; -import { LanguageContext } from "../contexts/language"; +import {useContext} from "react"; +import {LanguageContext} from "../contexts/language"; const useDirection = () => { - const { directionApp } = useContext(LanguageContext); + const {directionApp} = useContext(LanguageContext); - return { directionApp }; + return {directionApp}; }; export default useDirection; diff --git a/src/lib/app/hooks/useLanguage.jsx b/src/lib/app/hooks/useLanguage.jsx index 66e2ee0..d663835 100644 --- a/src/lib/app/hooks/useLanguage.jsx +++ b/src/lib/app/hooks/useLanguage.jsx @@ -1,28 +1,28 @@ -import { useContext } from "react"; -import { LanguageContext } from "../contexts/language"; +import {useContext} from "react"; +import {LanguageContext} from "../contexts/language"; import useUser from "./useUser"; const useLanguage = () => { - const { isAuth, changeUserLanguage } = useUser(); - const { - languageApp, - setLanguageApp, - languageIsReady, - setLanguageIsReady, - languageList, - } = useContext(LanguageContext); + const {isAuth, changeUserLanguage} = useUser(); + const { + languageApp, + setLanguageApp, + languageIsReady, + setLanguageIsReady, + languageList, + } = useContext(LanguageContext); - const changeLanguage = (lang) => { - if (lang == languageApp) return; + const changeLanguage = (lang) => { + if (lang == languageApp) return; - setLanguageIsReady(false); - setLanguageApp(lang); - if (isAuth) { - changeUserLanguage(lang); - } - }; + setLanguageIsReady(false); + setLanguageApp(lang); + if (isAuth) { + changeUserLanguage(lang); + } + }; - return { languageApp, changeLanguage, languageIsReady, languageList }; + return {languageApp, changeLanguage, languageIsReady, languageList}; }; export default useLanguage; diff --git a/src/lib/app/hooks/useLoading.jsx b/src/lib/app/hooks/useLoading.jsx index d74a87e..a691bd7 100644 --- a/src/lib/app/hooks/useLoading.jsx +++ b/src/lib/app/hooks/useLoading.jsx @@ -1,10 +1,10 @@ -import { useContext } from "react"; -import { LoadingContext } from "../contexts/loading"; +import {useContext} from "react"; +import {LoadingContext} from "../contexts/loading"; const useLoading = () => { - const { setLoadingPage } = useContext(LoadingContext); + const {setLoadingPage} = useContext(LoadingContext); - return { setLoadingPage }; + return {setLoadingPage}; }; export default useLoading; diff --git a/src/lib/app/hooks/useUser.jsx b/src/lib/app/hooks/useUser.jsx index 56bdf7c..b0bbc1a 100644 --- a/src/lib/app/hooks/useUser.jsx +++ b/src/lib/app/hooks/useUser.jsx @@ -1,34 +1,34 @@ -import { useContext } from "react"; -import { UserContext } from "../contexts/user"; +import {useContext} from "react"; +import {UserContext} from "../contexts/user"; const useUser = () => { - const { - isAuth, - userChangedLanguage, - token, - user, - getUser, - clearUser, - changeUser, - changeAuthState, - changeLanguageState, - clearToken, - setToken, - } = useContext(UserContext); + const { + isAuth, + userChangedLanguage, + token, + user, + getUser, + clearUser, + changeUser, + changeAuthState, + changeLanguageState, + clearToken, + setToken, + } = useContext(UserContext); - return { - isAuth, - userChangedLanguage, - token, - user, - getUser, - clearUser, - changeUser, - changeAuthState, - changeLanguageState, - clearToken, - setToken, - }; + return { + isAuth, + userChangedLanguage, + token, + user, + getUser, + clearUser, + changeUser, + changeAuthState, + changeLanguageState, + clearToken, + setToken, + }; }; export default useUser; diff --git a/src/middlewares/RolePermission.jsx b/src/middlewares/RolePermission.jsx index 2cf2baa..9fece10 100644 --- a/src/middlewares/RolePermission.jsx +++ b/src/middlewares/RolePermission.jsx @@ -1,43 +1,43 @@ -import { NextLinkComposed } from "@/core/components/LinkRouting"; +import {NextLinkComposed} from "@/core/components/LinkRouting"; import Message from "@/core/components/Messages"; import useUser from "@/lib/app/hooks/useUser"; -import { Button, Typography } from "@mui/material"; -import { useTranslations } from "next-intl"; +import {Button, Typography} from "@mui/material"; +import {useTranslations} from "next-intl"; -const RolePermission = ({ children, requiredPermissions }) => { - const { user } = useUser(); - const t = useTranslations(); +const RolePermission = ({children, requiredPermissions}) => { + const {user} = useUser(); + const t = useTranslations(); - const hasPermission = requiredPermissions.some((permission) => - user?.role?.includes(permission) - ); - - if (!hasPermission) { - return ( - - {t("Permission.typography_you_dont_have_access")} - - } - actions={ - <> - - - } - /> + const hasPermission = requiredPermissions.some((permission) => + user?.role?.includes(permission) ); - } - return <>{children}; + if (!hasPermission) { + return ( + + {t("Permission.typography_you_dont_have_access")} + + } + actions={ + <> + + + } + /> + ); + } + + return <>{children}; }; export default RolePermission; diff --git a/src/middlewares/WithAuth.jsx b/src/middlewares/WithAuth.jsx index 3fa5f43..b20d8b3 100644 --- a/src/middlewares/WithAuth.jsx +++ b/src/middlewares/WithAuth.jsx @@ -1,42 +1,42 @@ -import { NextLinkComposed } from "@/core/components/LinkRouting"; +import {NextLinkComposed} from "@/core/components/LinkRouting"; import Message from "@/core/components/Messages"; import useUser from "@/lib/app/hooks/useUser"; -import { Button, Typography } from "@mui/material"; -import { useTranslations } from "next-intl"; -import { useRouter } from "next/router"; +import {Button, Typography} from "@mui/material"; +import {useTranslations} from "next-intl"; +import {useRouter} from "next/router"; -const WithAuthMiddleware = ({ children }) => { - const { isAuth } = useUser(); - const t = useTranslations(); - const router = useRouter(); +const WithAuthMiddleware = ({children}) => { + const {isAuth} = useUser(); + const t = useTranslations(); + const router = useRouter(); - if (!isAuth) - return ( - - {t( - "Authorization.typography_your_access_to_this_page_has_expired_Please_login_again" - )} - - } - actions={ - <> - - - } - /> - ); - return <>{children}; + if (!isAuth) + return ( + + {t( + "Authorization.typography_your_access_to_this_page_has_expired_Please_login_again" + )} + + } + actions={ + <> + + + } + /> + ); + return <>{children}; }; export default WithAuthMiddleware; diff --git a/src/middlewares/WithoutAuth.jsx b/src/middlewares/WithoutAuth.jsx index cb8e571..594ffc5 100644 --- a/src/middlewares/WithoutAuth.jsx +++ b/src/middlewares/WithoutAuth.jsx @@ -1,56 +1,56 @@ import Message from "@/core/components/Messages"; import useUser from "@/lib/app/hooks/useUser"; -import { Stack, Typography } from "@mui/material"; -import { useTranslations } from "next-intl"; -import { useSearchParams } from "next/navigation"; -import { useRouter } from "next/router"; -import { useEffect } from "react"; +import {Stack, Typography} from "@mui/material"; +import {useTranslations} from "next-intl"; +import {useSearchParams} from "next/navigation"; +import {useRouter} from "next/router"; +import {useEffect} from "react"; -const WithoutAuthMiddleware = ({ children }) => { - const { isAuth } = useUser(); - const t = useTranslations(); - const router = useRouter(); +const WithoutAuthMiddleware = ({children}) => { + const {isAuth} = useUser(); + const t = useTranslations(); + const router = useRouter(); - // gettin url query - const searchParams = useSearchParams(); - const backUrlDecodedPath = searchParams.get("back_url"); + // gettin url query + const searchParams = useSearchParams(); + const backUrlDecodedPath = searchParams.get("back_url"); - useEffect(() => { - if (!isAuth) return; - const timer = setTimeout(() => { - router.replace( - backUrlDecodedPath - ? decodeURIComponent(backUrlDecodedPath) - : "/dashboard" - ); - }, 2000); + useEffect(() => { + if (!isAuth) return; + const timer = setTimeout(() => { + router.replace( + backUrlDecodedPath + ? decodeURIComponent(backUrlDecodedPath) + : "/dashboard" + ); + }, 2000); - return () => { - clearTimeout(timer); - }; - }, [isAuth]); + return () => { + clearTimeout(timer); + }; + }, [isAuth]); - if (isAuth) - return ( - - - {t( - "Authorization.typography_your_login_is_valid_and_you_do_not_need_to_login_again" - )} - - - {t("Authorization.typography_redirect_to")}{" "} - {backUrlDecodedPath - ? t("Authorization.typography_routing_previuos_page") - : t("Authorization.typography_routing_dashbaord_page")} - - - } - /> - ); - return <>{children}; + if (isAuth) + return ( + + + {t( + "Authorization.typography_your_login_is_valid_and_you_do_not_need_to_login_again" + )} + + + {t("Authorization.typography_redirect_to")}{" "} + {backUrlDecodedPath + ? t("Authorization.typography_routing_previuos_page") + : t("Authorization.typography_routing_dashbaord_page")} + + + } + /> + ); + return <>{children}; }; export default WithoutAuthMiddleware; diff --git a/src/pages/_app.jsx b/src/pages/_app.jsx index be5d828..573bef2 100644 --- a/src/pages/_app.jsx +++ b/src/pages/_app.jsx @@ -1,30 +1,30 @@ import "&/fontiran.scss"; import AppLayout from "@/layouts/AppLayout"; import MuiLayout from "@/layouts/MuiLayout"; -import { LanguageProvider } from "@/lib/app/contexts/language"; -import { LoadingProvider } from "@/lib/app/contexts/loading"; -import { UserProvider } from "@/lib/app/contexts/user"; +import {LanguageProvider} from "@/lib/app/contexts/language"; +import {LoadingProvider} from "@/lib/app/contexts/loading"; +import {UserProvider} from "@/lib/app/contexts/user"; import "moment/locale/fa"; -import { NextIntlProvider } from "next-intl"; +import {NextIntlProvider} from "next-intl"; -const App = ({ Component, pageProps }) => { - return ( - <> - - - - - - - - - - - - - - - ); +const App = ({Component, pageProps}) => { + return ( + <> + + + + + + + + + + + + + + + ); }; export default App; diff --git a/src/pages/_document.jsx b/src/pages/_document.jsx index e763884..f71303f 100644 --- a/src/pages/_document.jsx +++ b/src/pages/_document.jsx @@ -1,67 +1,65 @@ -import { - createEmotionCacheLtr -} from "@/core/utils/createEmotionCache"; +import {createEmotionCacheLtr} from "@/core/utils/createEmotionCache"; import theme from "@/core/utils/theme"; import createEmotionServer from "@emotion/server/create-instance"; -import Document, { Head, Html, Main, NextScript } from "next/document"; +import Document, {Head, Html, Main, NextScript} from "next/document"; export default function MyDocument(props) { - const { emotionStyleTags } = props; + const {emotionStyleTags} = props; - return ( - - - - - - - - {emotionStyleTags} - - -
- - - - ); + return ( + + + + + + + + {emotionStyleTags} + + +
+ + + + ); } MyDocument.getInitialProps = async (ctx) => { - const originalRenderPage = ctx.renderPage; - let cache; - switch (ctx.locale) { - case "fa": - cache = createEmotionCacheLtr(); - break; - } + const originalRenderPage = ctx.renderPage; + let cache; + switch (ctx.locale) { + case "fa": + cache = createEmotionCacheLtr(); + break; + } - const { extractCriticalToChunks } = createEmotionServer(cache); + const {extractCriticalToChunks} = createEmotionServer(cache); - ctx.renderPage = () => - originalRenderPage({ - enhanceApp: (App) => - function EnhanceApp(props) { - return ; - }, - }); + ctx.renderPage = () => + originalRenderPage({ + enhanceApp: (App) => + function EnhanceApp(props) { + return ; + }, + }); - const initialProps = await Document.getInitialProps(ctx); + const initialProps = await Document.getInitialProps(ctx); - const emotionStyles = extractCriticalToChunks(initialProps.html); - const emotionStyleTags = emotionStyles.styles.map((style) => ( -