From 7c2d64a712209481928fce698ab30bacef8976c7 Mon Sep 17 00:00:00 2001 From: Amin Ghasempoor Date: Mon, 11 Sep 2023 16:45:04 +0330 Subject: [PATCH] TF-98 user management debug --- public/locales/fa/app.json | 2 +- .../CreateContent.jsx} | 49 +++++-------------- .../user-management/Form/CreateForm/index.jsx | 35 +++++++++++++ .../user-management/TableToolbar.jsx | 4 +- 4 files changed, 51 insertions(+), 39 deletions(-) rename src/components/dashboard/user-management/Form/{AddForm.jsx => CreateForm/CreateContent.jsx} (86%) create mode 100644 src/components/dashboard/user-management/Form/CreateForm/index.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index baecc48..bd591f2 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -354,7 +354,7 @@ "button-delete": "حذف کردن" }, "AddDialog": { - "add": "کاربر جدید", + "add": "افزودن کاربر جدید", "phone_number": "شماره تلفن", "phone_number_positive": "شماره تلفن باید مثبت باشد", "phone_number_error": "وارد کردن شماره تلفن الزامیست", diff --git a/src/components/dashboard/user-management/Form/AddForm.jsx b/src/components/dashboard/user-management/Form/CreateForm/CreateContent.jsx similarity index 86% rename from src/components/dashboard/user-management/Form/AddForm.jsx rename to src/components/dashboard/user-management/Form/CreateForm/CreateContent.jsx index 97e6c3b..1ab35f9 100644 --- a/src/components/dashboard/user-management/Form/AddForm.jsx +++ b/src/components/dashboard/user-management/Form/CreateForm/CreateContent.jsx @@ -1,30 +1,24 @@ -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, FormControl, FormHelperText, InputLabel, MenuItem, Select, Stack, - TextField, - Tooltip + TextField } from "@mui/material"; +import {useTranslations} from "next-intl"; import useRequest from "@/lib/app/hooks/useRequest"; -import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; -import {useState} from "react"; +import * as Yup from "yup"; +import {useFormik} from "formik"; +import {ADD_USER_MANAGEMENT} from "@/core/data/apiRoutes"; -const AddForm = ({mutate, fetchUrl}) => { +const CreateContent = ({mutate, fetchUrl, setOpenConfirmDialog}) => { const t = useTranslations(); const requestServer = useRequest({auth: true}) - const [openConfirmDialog, setOpenConfirmDialog] = useState(false); 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) .test("max", `${t("AddDialog.phone_number_max")}`, (value) => value.length <= 11) @@ -40,8 +34,6 @@ const AddForm = ({mutate, fetchUrl}) => { }) }); - // validationSchema.describe({value: {type_id: true}}); - const formik = useFormik({ initialValues: { phone_number: "", @@ -67,24 +59,9 @@ const AddForm = ({mutate, fetchUrl}) => { }); }, }); - return ( - - - - - {t("AddDialog.add")} + + return ( + <> @@ -180,7 +157,7 @@ const AddForm = ({mutate, fetchUrl}) => { {t("AddDialog.button-add")} - - ); -}; -export default AddForm; \ No newline at end of file + + ) +} +export default CreateContent \ No newline at end of file diff --git a/src/components/dashboard/user-management/Form/CreateForm/index.jsx b/src/components/dashboard/user-management/Form/CreateForm/index.jsx new file mode 100644 index 0000000..58e5224 --- /dev/null +++ b/src/components/dashboard/user-management/Form/CreateForm/index.jsx @@ -0,0 +1,35 @@ +import {Button, Dialog, DialogTitle, Stack, Tooltip} from "@mui/material"; +import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; +import {useTranslations} from "next-intl"; +import {useState} from "react"; +import CreateContent from "@/components/dashboard/user-management/Form/CreateForm/CreateContent"; + +const CreateForm = ({mutate, fetchUrl}) => { + const t = useTranslations(); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + + return ( + + + + + + {t("AddDialog.add")} + + + + ) +} +export default CreateForm \ No newline at end of file diff --git a/src/components/dashboard/user-management/TableToolbar.jsx b/src/components/dashboard/user-management/TableToolbar.jsx index 558cdc5..9ea36f5 100644 --- a/src/components/dashboard/user-management/TableToolbar.jsx +++ b/src/components/dashboard/user-management/TableToolbar.jsx @@ -1,10 +1,10 @@ import {useTranslations} from "next-intl"; -import AddForm from "./Form/AddForm"; +import CreateForm from "@/components/dashboard/user-management/Form/CreateForm"; function TableToolbar({mutate, fetchUrl}) { const t = useTranslations(); - return + return }