From ae8e2a3378cfeb3d3f70cf365045eda557fc881f Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Sun, 10 Sep 2023 15:08:41 +0330 Subject: [PATCH] TF-4 user management edit form --- public/locales/fa/app.json | 8 +- .../user-management/Form/AddForm.jsx | 6 +- .../user-management/Form/DeleteForm.jsx | 15 +- .../user-management/Form/UpdateForm.jsx | 260 ++++++++---------- .../user-management/TableRowActions.jsx | 2 +- .../dashboard/user-management/index.jsx | 12 +- 6 files changed, 143 insertions(+), 160 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 7f2f162..e2e5105 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -278,6 +278,7 @@ "created_at": "تاریخ درخواست", "updated_at": "تاریخ بروزرسانی", "navgan_id": "کد ناوگان", + "type_name": "نوع کاربر", "vehicle_type": "نوع ماشین", "state_name": "وضعیت درخواست" }, @@ -318,8 +319,8 @@ "description_error": "وارد کردن توضیحات الزامی است!" }, "UpdateDialog": { - "update": "تغییر وضعیت درخواست", - "update-tooltip": "بروزرسانی", + "update": "ویرایش", + "update-tooltip": "ویرایش", "button-cancel": "بستن", "refahi": "رفاهی", "navgan": "ناوگان", @@ -327,7 +328,7 @@ "national_id": "کد ملی", "type_id": "نوع کاربر", "navgan_id": "کد ناوگان", - "button-update": "بروزرسانی" + "button-update": "ویرایش" }, "UploadSystem": { "upload_file": "فایل خود را بارگذاری کنید", @@ -344,6 +345,7 @@ "DeleteDialog": { "delete": "حذف", "button-cancel": "انصراف", + "typography": "آیا از حدف این مورد اطمینان دارید ؟", "button-delete": "حذف کردن" }, "AddDialog": { diff --git a/src/components/dashboard/user-management/Form/AddForm.jsx b/src/components/dashboard/user-management/Form/AddForm.jsx index d807d68..c0021e8 100644 --- a/src/components/dashboard/user-management/Form/AddForm.jsx +++ b/src/components/dashboard/user-management/Form/AddForm.jsx @@ -147,11 +147,11 @@ const AddForm = ({mutate, fetchUrl}) => { formik.touched.type_id && Boolean(formik.errors.type_id) } - onBlur={formik.handleBlur("type_id")} > {t("AddDialog.type_id")} diff --git a/src/components/dashboard/user-management/Form/DeleteForm.jsx b/src/components/dashboard/user-management/Form/DeleteForm.jsx index f336036..b653428 100644 --- a/src/components/dashboard/user-management/Form/DeleteForm.jsx +++ b/src/components/dashboard/user-management/Form/DeleteForm.jsx @@ -1,6 +1,15 @@ import {useTranslations} from "next-intl"; import {useState} from "react"; -import {Button, Dialog, DialogActions, DialogTitle, IconButton, Tooltip} from "@mui/material"; +import { + Button, + Dialog, + DialogActions, + DialogContent, + DialogTitle, + IconButton, + Tooltip, + Typography +} from "@mui/material"; import DeleteIcon from '@mui/icons-material/Delete'; import {DELETE_USER_MANAGEMENT} from "@/core/data/apiRoutes"; import useRequest from "@/lib/app/hooks/useRequest"; @@ -12,7 +21,6 @@ const DeleteForm = ({rowId, fetchUrl, mutate}) => { const [isSubmitting, setIsSubmitting] = useState(false) const requestServer = useRequest({auth: true}) const {update_notification} = useNotification() - const handleSubmit = () => { setIsSubmitting(true) requestServer(`${DELETE_USER_MANAGEMENT}/${rowId}`, 'delete').then((response) => { @@ -39,6 +47,9 @@ const DeleteForm = ({rowId, fetchUrl, mutate}) => { {t("DeleteDialog.delete")} + + {t("DeleteDialog.typography")} + - - - - - ); + + { + if (event.target.value.length <= 10) return formik.handleChange(event) + }} + fullWidth + variant="outlined" + onBlur={formik.handleBlur("national_id")} + error={formik.touched.national_id && Boolean(formik.errors.national_id)} + helperText={formik.touched.national_id && formik.errors.national_id} + sx={{mt: 1}} + /> + + + + {t("UpdateDialog.type_id")} + + + {formik.touched.type_id && formik.errors.type_id} + + + + + + + + + + + + + + ); }; 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 index c67acb3..5b0f031 100644 --- a/src/components/dashboard/user-management/TableRowActions.jsx +++ b/src/components/dashboard/user-management/TableRowActions.jsx @@ -7,7 +7,7 @@ const TableRowActions = ({row, mutate, fetchUrl}) => { return ( diff --git a/src/components/dashboard/user-management/index.jsx b/src/components/dashboard/user-management/index.jsx index 596c7e6..fc235e5 100644 --- a/src/components/dashboard/user-management/index.jsx +++ b/src/components/dashboard/user-management/index.jsx @@ -34,9 +34,9 @@ function DashboardUserManagementComponent() { ), }, { - accessorFn: (row) => row.name, - id: "name", - header: t("UserManagement.name"), + accessorFn: (row) => row.navgan_id, + id: "navgan_id", + header: t("UserManagement.navgan_id"), enableColumnFilter: true, datatype: "text", filterFn: "contains", @@ -114,9 +114,9 @@ function DashboardUserManagementComponent() { ), }, { - accessorFn: (row) => row.state_name, - id: "state_id", - header: t("UserManagement.state_name"), + accessorFn: (row) => row.type_name, + id: "type_name", + header: t("UserManagement.type_name"), enableColumnFilter: false, datatype: "numeric", Cell: ({renderedCellValue}) => (