diff --git a/src/components/dashboard/passenger-boss/index.jsx b/src/components/dashboard/passenger-boss/index.jsx index 0283fc3..392cac3 100644 --- a/src/components/dashboard/passenger-boss/index.jsx +++ b/src/components/dashboard/passenger-boss/index.jsx @@ -156,7 +156,6 @@ function DashboardPassengerOfficeComponent() { ], [] ); - return ( diff --git a/src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx index 70013f4..c5533ee 100644 --- a/src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx @@ -105,7 +105,7 @@ const ConfirmContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => { {t("ConfirmDialog.button-cancel")} diff --git a/src/components/dashboard/user-management/Form/UpdateForm.jsx b/src/components/dashboard/user-management/Form/UpdateForm/UpdateContent.jsx similarity index 83% rename from src/components/dashboard/user-management/Form/UpdateForm.jsx rename to src/components/dashboard/user-management/Form/UpdateForm/UpdateContent.jsx index 77e495f..01db763 100644 --- a/src/components/dashboard/user-management/Form/UpdateForm.jsx +++ b/src/components/dashboard/user-management/Form/UpdateForm/UpdateContent.jsx @@ -1,37 +1,19 @@ -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - FormControl, - FormHelperText, - IconButton, - InputLabel, - MenuItem, - Select, - Stack, - TextField, - Tooltip -} from "@mui/material"; -import {useFormik} from "formik"; -import EditIcon from '@mui/icons-material/Edit'; -import {UPDATE_USER_MANAGEMENT} from "@/core/data/apiRoutes"; -import useRequest from "@/lib/app/hooks/useRequest"; +import { UPDATE_USER_MANAGEMENT } from "@/core/data/apiRoutes"; import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, FormControl, FormHelperText, InputLabel, MenuItem, Select, Stack, TextField } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; import * as Yup from "yup"; -const UpdateForm = ({row, fetchUrl, mutate}) => { +const UpdateContent = ({row, fetchUrl, mutate, setOpenConfirmDialog}) => { const t = useTranslations(); - const [openConfirmDialog, setOpenConfirmDialog] = useState(false); const requestServer = useRequest({auth: true}) const {update_notification} = useNotification() 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) + .test("max", `${t("AddDialog.phone_number_max")}`, (value) => value.length == 11) .required(t("AddDialog.phone_number_error")), national_id: Yup.mixed().test("is-number", `${t("AddDialog.national_id_number")}`, (value) => !isNaN(value)).test("positive", `${t("AddDialog.national_id_positive")}`, (value) => value >= 0) .test("max", `${t("AddDialog.national_id_max")}`, (value) => value.length <= 10) @@ -49,7 +31,7 @@ const UpdateForm = ({row, fetchUrl, mutate}) => { phone_number: row.getValue("phone_number"), national_id: row.getValue("national_id"), type_id: row.original.type_id, - navgan_id: row.getValue("navgan_id"), + navgan_id:row.original.type_id === 1 ? row.getValue("navgan_id") : '', }, validationSchema, onSubmit: (values, {setSubmitting}) => { const formData = new FormData(); formData.append("phone_number", values.phone_number); @@ -67,21 +49,8 @@ const UpdateForm = ({row, fetchUrl, mutate}) => { }); }, }); - - return (<> - - { - setOpenConfirmDialog(true) - }} - > - - - - - {t("UpdateDialog.update")} + return( + <> @@ -168,11 +137,11 @@ const UpdateForm = ({row, fetchUrl, mutate}) => { {t("UpdateDialog.button-cancel")} - - ); -}; -export default UpdateForm; \ No newline at end of file + + ) +} +export default UpdateContent \ No newline at end of file diff --git a/src/components/dashboard/user-management/Form/UpdateForm/index.jsx b/src/components/dashboard/user-management/Form/UpdateForm/index.jsx new file mode 100644 index 0000000..93f89f8 --- /dev/null +++ b/src/components/dashboard/user-management/Form/UpdateForm/index.jsx @@ -0,0 +1,30 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material" +import EditIcon from '@mui/icons-material/Edit'; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import UpdateContent from "./UpdateContent"; + +const Update = ({row, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + return ( + <> + + { + setOpenConfirmDialog(true) + }} + > + + + + + {t("UpdateDialog.update")} + + + + ) +} +export default Update \ 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 5b0f031..8eb5a35 100644 --- a/src/components/dashboard/user-management/TableRowActions.jsx +++ b/src/components/dashboard/user-management/TableRowActions.jsx @@ -1,12 +1,12 @@ import {Box} from "@mui/material"; import DeleteForm from "./Form/DeleteForm" -import UpdateForm from "./Form/UpdateForm" +import Update from "./Form/UpdateForm"; const TableRowActions = ({row, mutate, fetchUrl}) => { return ( -