From 6d5db8dd3bed9c1acf50ff2be0631994a0d79894 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Tue, 5 Sep 2023 15:15:11 +0330 Subject: [PATCH] enable custom tollbar --- public/locales/fa/app.json | 33 +++ .../dashboard/commercial-chief/index.jsx | 2 +- .../dashboard/development-assistant/index.jsx | 2 +- .../dashboard/inspector-expert/index.jsx | 2 +- .../dashboard/machinary-office/index.jsx | 2 +- .../navgan-loan-management/index.jsx | 3 +- .../navgan-province-manager/index.jsx | 2 +- .../passenger-boss/Form/ConfirmForm.jsx | 2 +- .../dashboard/passenger-boss/index.jsx | 3 +- .../dashboard/passenger-office/index.jsx | 3 +- .../dashboard/province-head-expert/index.jsx | 2 +- .../refahi-loan-management/index.jsx | 3 +- .../refahi-province-manager/index.jsx | 3 +- .../transportation-assistance/index.jsx | 2 +- .../user-management/Form/AddForm.jsx | 190 ++++++++++++++++++ .../user-management/Form/DeleteForm.jsx | 60 ++++++ .../user-management/Form/UpdateForm.jsx | 151 ++++++++++++++ .../user-management/TableRowActions.jsx | 23 +++ .../user-management/TableToolbar.jsx | 32 +++ .../dashboard/user-management/index.jsx | 155 ++++++++++++++ src/core/components/DataTable.jsx | 2 +- src/core/data/apiRoutes.js | 11 + src/core/data/sidebarMenu.jsx | 9 + src/pages/dashboard/user-management/index.jsx | 26 +++ 24 files changed, 704 insertions(+), 19 deletions(-) create mode 100644 src/components/dashboard/user-management/Form/AddForm.jsx create mode 100644 src/components/dashboard/user-management/Form/DeleteForm.jsx create mode 100644 src/components/dashboard/user-management/Form/UpdateForm.jsx create mode 100644 src/components/dashboard/user-management/TableRowActions.jsx create mode 100644 src/components/dashboard/user-management/TableToolbar.jsx create mode 100644 src/components/dashboard/user-management/index.jsx create mode 100644 src/pages/dashboard/user-management/index.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 065e317..719ba4a 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -42,6 +42,7 @@ "province-head-expert": "کارشناس ستادی", "change-password": "تغییر رمز عبور", "development-assistant": "معاون توسعه", + "user-management": "مدیریت کاربر", "edit-profile": "ویرایش پروفایل" }, "secondary": { @@ -95,6 +96,7 @@ "development_assistant_page": "معاون توسعه", "inspector_expert_page": "بازدید کارشناس", "commercial_chief_page": "رئیس اداره بازرگانی", + "user_management_page": "مدیریت کاربر", "edit_profile": "ویرایش پروفایل" }, "MuiDatePicker": { @@ -268,6 +270,17 @@ "vehicle_type": "نوع ماشین", "state_name": "وضعیت درخواست" }, + "UserManagement": { + "name": "نام", + "id": "کد یکتا", + "national_id": "کد ملی", + "phone_number": "موبایل", + "created_at": "تاریخ درخواست", + "updated_at": "تاریخ بروزرسانی", + "navgan_id": "کد ناوگان", + "vehicle_type": "نوع ماشین", + "state_name": "وضعیت درخواست" + }, "ConfirmDialog": { "confirm": "تایید", "context": "آیا از تایید این آیتم اطمینان دارید؟", @@ -321,5 +334,25 @@ "upload_file_format": "فرمت قابل قبول : png,jpg,pdf", "delete": "پاک کردن", "uploadfile_error": "حجم فایل بیشتر از 2 مگابایت می باشد" + }, + "DeleteDialog": { + "delete": "حذف", + "button-cancel": "انصراف", + "button-delete": "حذف کردن" + }, + "AddDialog": { + "add": "اضافه کردن", + "phone_number": "شماره تلفن", + "phone_number_positive": "شماره تلفن باید مثبت باشد", + "phone_number_error": "وارد کردن شماره تلفن الزامیست", + "type_id_error": "وارد کردن نوع کاربر الزامیست", + "navgan_id_error": "وارد کردن کد ناوگان الزامیست", + "national_id_error": "وارد کردن کد ملی الزامیست", + "phone_number_number": "شماره تلفن باید شامل اعداد باشد", + "national_id": "کد ملی", + "type_id": "نوع کاربر", + "navgan_id": "کد ناوگان", + "button-cancel": "انصراف", + "button-add": "اضافه کردن" } } diff --git a/src/components/dashboard/commercial-chief/index.jsx b/src/components/dashboard/commercial-chief/index.jsx index 9f84193..ab514a5 100644 --- a/src/components/dashboard/commercial-chief/index.jsx +++ b/src/components/dashboard/commercial-chief/index.jsx @@ -131,7 +131,7 @@ function DashboardCommercialChiefComponent() { tableUrl={GET_COMMERCIAL_CHIEF} columns={columns} selectableRow={false} - enableCustomToolbar={true} + enableCustomToolbar={false} enableLastUpdate={true} enablePinning={true} enableDensityToggle={false} diff --git a/src/components/dashboard/development-assistant/index.jsx b/src/components/dashboard/development-assistant/index.jsx index ed46fb0..ab35636 100644 --- a/src/components/dashboard/development-assistant/index.jsx +++ b/src/components/dashboard/development-assistant/index.jsx @@ -132,7 +132,7 @@ function DashboardDevelopmentAssistantComponent() { tableUrl={GET_DEVELOPMENT_ASSISTANT} columns={columns} selectableRow={false} - enableCustomToolbar={true} + enableCustomToolbar={false} enableLastUpdate={true} enablePinning={true} enableDensityToggle={false} diff --git a/src/components/dashboard/inspector-expert/index.jsx b/src/components/dashboard/inspector-expert/index.jsx index 1be98ed..53a2661 100644 --- a/src/components/dashboard/inspector-expert/index.jsx +++ b/src/components/dashboard/inspector-expert/index.jsx @@ -131,7 +131,7 @@ function DashboardInspectorExpertComponent() { tableUrl={GET_INSPECTOR_EXPERT} columns={columns} selectableRow={false} - enableCustomToolbar={true} + enableCustomToolbar={false} enableLastUpdate={true} enablePinning={true} enableDensityToggle={false} diff --git a/src/components/dashboard/machinary-office/index.jsx b/src/components/dashboard/machinary-office/index.jsx index 73c373c..b341529 100644 --- a/src/components/dashboard/machinary-office/index.jsx +++ b/src/components/dashboard/machinary-office/index.jsx @@ -162,7 +162,7 @@ function DashboardMachinaryOfficeComponent() { tableUrl={GET_MACHINARY_OFFICE} columns={columns} selectableRow={false} - enableCustomToolbar={true} + enableCustomToolbar={false} enableLastUpdate={true} enablePinning={true} enableDensityToggle={false} diff --git a/src/components/dashboard/navgan-loan-management/index.jsx b/src/components/dashboard/navgan-loan-management/index.jsx index eddf02b..57d3227 100644 --- a/src/components/dashboard/navgan-loan-management/index.jsx +++ b/src/components/dashboard/navgan-loan-management/index.jsx @@ -132,8 +132,7 @@ function DashboardNavganLoanManagementComponent() { tableUrl={GET_LOAN_MANAGEMENT_NAVGAN} columns={columns} selectableRow={false} - enableCustomToolbar={true} - // CustomToolbar={} + enableCustomToolbar={false} enableLastUpdate={true} enablePinning={true} enableDensityToggle={false} diff --git a/src/components/dashboard/navgan-province-manager/index.jsx b/src/components/dashboard/navgan-province-manager/index.jsx index 8823e37..a529336 100644 --- a/src/components/dashboard/navgan-province-manager/index.jsx +++ b/src/components/dashboard/navgan-province-manager/index.jsx @@ -163,7 +163,7 @@ function DashboardNavganProvinceManagerComponent() { tableUrl={GET_NAVGAN_PROVINCE_MANAGER} columns={columns} selectableRow={false} - enableCustomToolbar={true} + enableCustomToolbar={false} enableLastUpdate={true} enablePinning={true} enableDensityToggle={false} diff --git a/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx b/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx index 4b188f2..7349e22 100644 --- a/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx +++ b/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx @@ -40,7 +40,7 @@ const Confirm = ({rowId, fetchUrl, mutate}) => { "is-number", `${t("ConfirmDialog.approved_amount_number")}`, (value) => !isNaN(value) - ).test("positive", `${t("ConfirmDialog.proposed_amount_positive")}`, (value) => value >= 0) + ).test("positive", `${t("ConfirmDialog.approved_amount_positive")}`, (value) => value >= 0) .required(t("ConfirmDialog.approved_amount_error")) }); const formik = useFormik({ diff --git a/src/components/dashboard/passenger-boss/index.jsx b/src/components/dashboard/passenger-boss/index.jsx index ad6848f..4f5f553 100644 --- a/src/components/dashboard/passenger-boss/index.jsx +++ b/src/components/dashboard/passenger-boss/index.jsx @@ -163,8 +163,7 @@ function DashboardPassengerOfficeComponent() { tableUrl={GET_PASSENGER_BOSS} columns={columns} selectableRow={false} - enableCustomToolbar={true} - // CustomToolbar={} + enableCustomToolbar={false} enableLastUpdate={true} enablePinning={true} enableDensityToggle={false} diff --git a/src/components/dashboard/passenger-office/index.jsx b/src/components/dashboard/passenger-office/index.jsx index 3f50345..92335ad 100644 --- a/src/components/dashboard/passenger-office/index.jsx +++ b/src/components/dashboard/passenger-office/index.jsx @@ -163,8 +163,7 @@ function DashboardPassengerOfficeComponent() { tableUrl={GET_PASSENGER_OFFICE} columns={columns} selectableRow={false} - enableCustomToolbar={true} - // CustomToolbar={} + enableCustomToolbar={false} enableLastUpdate={true} enablePinning={true} enableDensityToggle={false} diff --git a/src/components/dashboard/province-head-expert/index.jsx b/src/components/dashboard/province-head-expert/index.jsx index c76c96d..6a20fa4 100644 --- a/src/components/dashboard/province-head-expert/index.jsx +++ b/src/components/dashboard/province-head-expert/index.jsx @@ -132,7 +132,7 @@ function DashboardProvinceHeadExpertComponent() { tableUrl={GET_PROVINCE_HEAD_EXPERT} columns={columns} selectableRow={false} - enableCustomToolbar={true} + enableCustomToolbar={false} enableLastUpdate={true} enablePinning={true} enableDensityToggle={false} diff --git a/src/components/dashboard/refahi-loan-management/index.jsx b/src/components/dashboard/refahi-loan-management/index.jsx index 4f0b3e1..762c026 100644 --- a/src/components/dashboard/refahi-loan-management/index.jsx +++ b/src/components/dashboard/refahi-loan-management/index.jsx @@ -132,8 +132,7 @@ function DashboardRefahiLoanManagementComponent() { tableUrl={GET_LOAN_MANAGEMENT_REFAHI} columns={columns} selectableRow={false} - enableCustomToolbar={true} - // CustomToolbar={} + enableCustomToolbar={false} enableLastUpdate={true} enablePinning={true} enableDensityToggle={false} diff --git a/src/components/dashboard/refahi-province-manager/index.jsx b/src/components/dashboard/refahi-province-manager/index.jsx index 740f6e7..25f7527 100644 --- a/src/components/dashboard/refahi-province-manager/index.jsx +++ b/src/components/dashboard/refahi-province-manager/index.jsx @@ -132,8 +132,7 @@ function DashboardRefahiProvinceManagerComponent() { tableUrl={GET_REFAHI_PROVINCE_MANAGER} columns={columns} selectableRow={false} - enableCustomToolbar={true} - // CustomToolbar={} + enableCustomToolbar={false} enableLastUpdate={true} enablePinning={true} enableDensityToggle={false} diff --git a/src/components/dashboard/transportation-assistance/index.jsx b/src/components/dashboard/transportation-assistance/index.jsx index 01314d1..351107c 100644 --- a/src/components/dashboard/transportation-assistance/index.jsx +++ b/src/components/dashboard/transportation-assistance/index.jsx @@ -163,7 +163,7 @@ function DashboardTransportationAssistanceComponent() { tableUrl={GET_TRANSPORTATION_ASSISTANCE} columns={columns} selectableRow={false} - enableCustomToolbar={true} + enableCustomToolbar={false} enableLastUpdate={true} enablePinning={true} enableDensityToggle={false} diff --git a/src/components/dashboard/user-management/Form/AddForm.jsx b/src/components/dashboard/user-management/Form/AddForm.jsx new file mode 100644 index 0000000..a13ec48 --- /dev/null +++ b/src/components/dashboard/user-management/Form/AddForm.jsx @@ -0,0 +1,190 @@ +import {useTranslations} from "next-intl"; +import * as Yup from "yup"; +import {ADD_USER_MANAGEMENT} from "@/core/data/apiRoutes"; +import {useFormik} from "formik"; +import {Button, Dialog, DialogActions, DialogContent, DialogTitle, Stack, TextField} from "@mui/material"; +import useRequest from "@/lib/app/hooks/useRequest"; + +const AddForm = ({openConfirmDialog, setOpenConfirmDialog, mutate, fetchUrl}) => { + const t = useTranslations(); + const requestServer = useRequest({auth: true}) + const validationSchema = Yup.object().shape({ + phone_number: Yup.mixed().test( + "is-number", + `${t("AddDialog.phone_number_number")}`, + (value) => !isNaN(value) + ).test("positive", `${t("AddDialog.phone_number_positive")}`, (value) => value >= 0) + .required(t("AddDialog.phone_number_error")), + type_id: Yup.number().required(t("AddDialog.type_id_error")), + navgan_id: Yup.number().required(t("AddDialog.navgan_id_error")), + national_id: Yup.number().required(t("AddDialog.national_id_error")), + }); + + // const handleSubmit = async (values, {setSubmitting, resetForm}) => { + // const formData = new FormData(); + // formData.append("phone_number", values.phone_number); + // formData.append("national_id", values.national_id); + // formData.append("type_id", values.type_id); + // formData.append("navgan_id", values.navgan_id); + // requestServer(ADD_USER_MANAGEMENT, 'post', { + // data: formData, + // }).then((response) => { + // mutate(fetchUrl) + // update_notification() + // }).catch(() => { + // }).finally(() => { + // setSubmitting(false); + // }); + // }; + // initialValues: { + // phone_number: "", + // national_id: "", + // type_id: "", + // navgan_id: "" + // } + const formik = useFormik({ + initialValues: { + phone_number: "", + national_id: "", + type_id: "", + navgan_id: "", + }, validationSchema, + onSubmit: (values, {setSubmitting}) => { + console.log("hello") + const formData = new FormData(); + formData.append("phone_number", values.phone_number); + formData.append("national_id", values.national_id); + formData.append("type_id", values.type_id); + formData.append("navgan_id", values.navgan_id); + + requestServer(ADD_USER_MANAGEMENT, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + const handlePhoneNumberChange = (event) => { + formik.setFieldValue("phone_number", event.target.value) + }; + const handleNationalIDChange = (event) => { + formik.setFieldValue("national_id", event.target.value) + }; + const handleTypeIDChange = (event) => { + formik.setFieldValue("type_id", event.target.value) + }; + const handleNavganIDChange = (event) => { + formik.setFieldValue("navgan_id", event.target.value) + }; + return ( + + {t("AddDialog.add")} + + + + + + + + + + + + + + + + + + + + + + ); +}; +export default AddForm; \ No newline at end of file diff --git a/src/components/dashboard/user-management/Form/DeleteForm.jsx b/src/components/dashboard/user-management/Form/DeleteForm.jsx new file mode 100644 index 0000000..122354b --- /dev/null +++ b/src/components/dashboard/user-management/Form/DeleteForm.jsx @@ -0,0 +1,60 @@ +import {useTranslations} from "next-intl"; +import {useState} from "react"; +import {Button, Dialog, DialogActions, DialogTitle, IconButton, Tooltip} from "@mui/material"; +import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; +import {useFormik} from "formik"; +import {DELETE_USER_MANAGEMENT} from "@/core/data/apiRoutes"; +import useRequest from "@/lib/app/hooks/useRequest"; +import useNotification from "@/lib/app/hooks/useNotification"; + + +const DeleteForm = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const formik = useFormik({ + onSubmit: (values, {setSubmitting}) => { + + + requestServer(`${DELETE_USER_MANAGEMENT}/${rowId}`, 'post').then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + return ( + <> + + { + setOpenConfirmDialog(true) + }} + > + + + + + {t("DeleteDialog.delete")} + + + + + + + ); +}; +export default DeleteForm; \ No newline at end of file diff --git a/src/components/dashboard/user-management/Form/UpdateForm.jsx b/src/components/dashboard/user-management/Form/UpdateForm.jsx new file mode 100644 index 0000000..ea16667 --- /dev/null +++ b/src/components/dashboard/user-management/Form/UpdateForm.jsx @@ -0,0 +1,151 @@ +import {useTranslations} from "next-intl"; +import {useState} from "react"; +import { + Button, + Dialog, + DialogActions, + DialogContent, + DialogTitle, + IconButton, + Stack, + TextField, + Tooltip +} from "@mui/material"; +import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; +import {useFormik} from "formik"; +import {UPDATE_USER_MANAGEMENT} from "@/core/data/apiRoutes"; +import useRequest from "@/lib/app/hooks/useRequest"; +import useNotification from "@/lib/app/hooks/useNotification"; + + +const UpdateForm = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const formik = useFormik({ + initialValues: { + phone_number: "", + national_id: "", + type_id: "", + navgan_id: "", + }, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + formData.append("phone_number", values.phone_number); + formData.append("national_id", values.national_id); + formData.append("type_id", values.type_id); + formData.append("navgan_id", values.navgan_id); + + requestServer(`${UPDATE_USER_MANAGEMENT}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handlePhoneNumberChange = (event) => { + formik.setFieldValue("phone_number", event.target.value) + }; + const handleNationalIDChange = (event) => { + formik.setFieldValue("national_id", event.target.value) + }; + const handleTypeIDChange = (event) => { + formik.setFieldValue("type_id", event.target.value) + }; + const handleNavganIDChange = (event) => { + formik.setFieldValue("navgan_id", event.target.value) + }; + + return ( + <> + + { + setOpenConfirmDialog(true) + }} + > + + + + + {t("ConfirmDialog.confirm")} + + + + + + + + + + + + + + + + + + + + + + + ); +}; +export default UpdateForm; \ No newline at end of file diff --git a/src/components/dashboard/user-management/TableRowActions.jsx b/src/components/dashboard/user-management/TableRowActions.jsx new file mode 100644 index 0000000..c67acb3 --- /dev/null +++ b/src/components/dashboard/user-management/TableRowActions.jsx @@ -0,0 +1,23 @@ +import {Box} from "@mui/material"; +import DeleteForm from "./Form/DeleteForm" +import UpdateForm from "./Form/UpdateForm" + +const TableRowActions = ({row, mutate, fetchUrl}) => { + + return ( + + + + + ); +}; + +export default TableRowActions; diff --git a/src/components/dashboard/user-management/TableToolbar.jsx b/src/components/dashboard/user-management/TableToolbar.jsx new file mode 100644 index 0000000..7371fbc --- /dev/null +++ b/src/components/dashboard/user-management/TableToolbar.jsx @@ -0,0 +1,32 @@ +import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; +import {Button, Stack, Tooltip} from "@mui/material"; +import {useTranslations} from "next-intl"; +import {useState} from "react"; +import AddForm from "./Form/AddForm"; + +function TableToolbar({mutate, fetchUrl}) { + const t = useTranslations(); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + return ( + + + + + + + ); +} + +export default TableToolbar; diff --git a/src/components/dashboard/user-management/index.jsx b/src/components/dashboard/user-management/index.jsx new file mode 100644 index 0000000..596c7e6 --- /dev/null +++ b/src/components/dashboard/user-management/index.jsx @@ -0,0 +1,155 @@ +import DashboardLayouts from "@/layouts/dashboardLayouts"; +import {Box, Typography} from "@mui/material"; +import {useMemo} from "react"; +import {GET_USER_MANAGEMENT} from "@/core/data/apiRoutes"; +import {useTranslations} from "next-intl"; +import DataTable from "@/core/components/DataTable"; +import moment from "jalali-moment"; +import MuiDatePicker from "@/core/components/MuiDatePicker"; +import TableToolbar from "@/components/dashboard/user-management/TableToolbar"; +import TableRowActions from "./TableRowActions" + +function DashboardUserManagementComponent() { + const t = useTranslations(); + + const columns = useMemo( + () => [ + { + accessorFn: (row) => row.id, + id: "id", + header: t("UserManagement.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("UserManagement.name"), + enableColumnFilter: true, + datatype: "text", + filterFn: "contains", + columnFilterModeOptions: ["contains", "equals", "notEquals"], + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.national_id, + id: "national_id", + header: t("UserManagement.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("UserManagement.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("UserManagement.created_at"), + enableColumnFilter: true, + datatype: "date", + filterFn: "lessThan", + columnFilterModeOptions: ["lessThan", "greaterThan"], + Cell: ({renderedCellValue}) => { + return {renderedCellValue}; + }, + Header: ({column}) => <>{column.columnDef.header}, + Filter: ({column}) => { + return ( + + ); + }, + }, + { + accessorFn: (row) => + moment(row.updated_at).locale("fa").format("HH:mm | yyyy/MM/DD"), + id: "updated_at", + header: t("UserManagement.updated_at"), + enableColumnFilter: false, + datatype: "numeric", + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + { + accessorFn: (row) => row.state_name, + id: "state_id", + header: t("UserManagement.state_name"), + enableColumnFilter: false, + datatype: "numeric", + Cell: ({renderedCellValue}) => ( + {renderedCellValue} + ), + }, + ], + [] + ); + return ( + + + + + + ); +} + +export default DashboardUserManagementComponent; diff --git a/src/core/components/DataTable.jsx b/src/core/components/DataTable.jsx index b3b0f26..8d06a02 100644 --- a/src/core/components/DataTable.jsx +++ b/src/core/components/DataTable.jsx @@ -134,7 +134,7 @@ function DataTable(props) { renderTopToolbarCustomActions={({table}) => ( <> {props.enableCustomToolbar /* send condition */ - ? props.CustomToolbar /* send component */ + ? /* send component */ : ""} )} diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index aba46f1..19b89a2 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -150,3 +150,14 @@ export const UPDATE_LOAN_MANAGEMENT_NAVGAN = export const GET_LOAN_STATE_NAVGAN = BASE_URL + "/dashboard/loan_states/navgan" //loan management navgan + +//user management +export const GET_USER_MANAGEMENT = + BASE_URL + "/dashboard/user_management/show" +export const ADD_USER_MANAGEMENT = + BASE_URL + "/dashboard/user_management/store" +export const UPDATE_USER_MANAGEMENT = + BASE_URL + "/dashboard/user_management/update" +export const DELETE_USER_MANAGEMENT = + BASE_URL + "/dashboard/user_management/delete" +//user management diff --git a/src/core/data/sidebarMenu.jsx b/src/core/data/sidebarMenu.jsx index 21a0952..29eab1d 100644 --- a/src/core/data/sidebarMenu.jsx +++ b/src/core/data/sidebarMenu.jsx @@ -136,6 +136,15 @@ const sidebarMenu = [ selected: false, permission: "manage_navgan_loan", }, + { + key: "sidebar.user-management", + name: "user_management", + type: "page", + route: "/dashboard/user-management", + icon: , + selected: false, + permission: "user_management", + }, ], ]; diff --git a/src/pages/dashboard/user-management/index.jsx b/src/pages/dashboard/user-management/index.jsx new file mode 100644 index 0000000..ce9cc1e --- /dev/null +++ b/src/pages/dashboard/user-management/index.jsx @@ -0,0 +1,26 @@ +import RolePermissionMiddleware from "@/middlewares/RolePermission"; +import WithAuthMiddleware from "@/middlewares/WithAuth"; +import {parse} from "next-useragent"; +import DashboardUserManagementComponent from "@/components/dashboard/user-management"; + +const requiredPermissions = ["manage_refahi_loan"]; +export default function UserManagement() { + return ( + + + + + + ); +} + +export async function getServerSideProps({req, locale}) { + const {isBot} = parse(req.headers["user-agent"]); + return { + props: { + messages: (await import(`&/locales/${locale}/app.json`)).default, + title: "Dashboard.user_management_page", + isBot, + }, + }; +}