From 4fa9a2f26d48ef3e94ddb71c8e29429a8ed3dde8 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Mon, 30 Oct 2023 10:42:37 +0330 Subject: [PATCH 01/18] pull request --- package-lock.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1815fa2..3dfb5da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "dashboard", - "version": "0.1.0", + "name": "LoanFacilitiesDashboard", + "version": "1.7.5", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "dashboard", - "version": "0.1.0", + "name": "LoanFacilitiesDashboard", + "version": "1.7.5", "dependencies": { "@emotion/react": "^11.10.6", "@emotion/server": "^11.10.0", From c41b64ffdecb32709c3698b55118996e52db6591 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Mon, 30 Oct 2023 15:25:43 +0330 Subject: [PATCH 02/18] LFFE-1 add disabled condition --- src/components/dashboard/change-password/index.jsx | 2 +- src/components/dashboard/commercial-chief/Form/RejectForm.jsx | 2 +- src/components/dashboard/commercial-chief/index.jsx | 1 + .../dashboard/development-assistant/Form/RejectForm.jsx | 2 +- src/components/dashboard/development-assistant/index.jsx | 1 + .../Form/ChangePassword/ChangePasswordContent.jsx | 2 +- .../expert-management/Form/CreateForm/CreateContent.jsx | 2 +- .../expert-management/Form/UpdateForm/UpdateContent.jsx | 2 +- src/components/dashboard/expert-management/index.jsx | 1 + src/components/dashboard/inspector-expert/Form/RejectForm.jsx | 2 +- src/components/dashboard/inspector-expert/Form/ReviseForm.jsx | 2 +- src/components/dashboard/inspector-expert/index.jsx | 1 + src/components/dashboard/machinary-office/Form/ConfirmForm.jsx | 2 +- src/components/dashboard/machinary-office/Form/RejectForm.jsx | 2 +- src/components/dashboard/machinary-office/index.jsx | 1 + .../dashboard/navgan-loan-management/Form/UpdateForm.jsx | 2 +- src/components/dashboard/navgan-loan-management/index.jsx | 1 + .../dashboard/navgan-province-manager/Form/RejectForm.jsx | 2 +- src/components/dashboard/navgan-province-manager/index.jsx | 1 + src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx | 2 +- src/components/dashboard/passenger-boss/Form/RejectForm.jsx | 2 +- src/components/dashboard/passenger-boss/index.jsx | 1 + src/components/dashboard/passenger-office/Form/RejectForm.jsx | 2 +- src/components/dashboard/passenger-office/index.jsx | 1 + .../dashboard/province-head-expert/Form/RejectForm.jsx | 2 +- .../dashboard/province-head-expert/Form/ReviceForm.jsx | 2 +- src/components/dashboard/province-head-expert/index.jsx | 1 + .../dashboard/refahi-loan-management/Form/UpdateForm.jsx | 2 +- src/components/dashboard/refahi-loan-management/index.jsx | 1 + .../dashboard/refahi-province-manager/Form/RejectForm.jsx | 2 +- src/components/dashboard/refahi-province-manager/index.jsx | 1 + .../dashboard/role-management/Form/CreateForm/CreateContent.jsx | 2 +- src/components/dashboard/role-management/Form/UpdateForm.jsx | 2 +- .../dashboard/transportation-assistance/Form/RejectForm.jsx | 2 +- src/components/dashboard/transportation-assistance/index.jsx | 1 + .../dashboard/user-management/Form/CreateForm/CreateContent.jsx | 2 +- src/components/login-expert/index.jsx | 2 +- 37 files changed, 37 insertions(+), 24 deletions(-) diff --git a/src/components/dashboard/change-password/index.jsx b/src/components/dashboard/change-password/index.jsx index cd2b9fd..07213e6 100644 --- a/src/components/dashboard/change-password/index.jsx +++ b/src/components/dashboard/change-password/index.jsx @@ -133,7 +133,7 @@ const DashboardChangePasswordComponent = () => { variant="contained" color="primary" size="large" - disabled={props.isSubmitting} + disabled={props.isSubmitting || !props.dirty || !props.isValid} > {props.isSubmitting ? t("SubmitButton.button_while_submit") diff --git a/src/components/dashboard/commercial-chief/Form/RejectForm.jsx b/src/components/dashboard/commercial-chief/Form/RejectForm.jsx index fd8becb..ec27a31 100644 --- a/src/components/dashboard/commercial-chief/Form/RejectForm.jsx +++ b/src/components/dashboard/commercial-chief/Form/RejectForm.jsx @@ -135,7 +135,7 @@ const Reject = ({rowId, fetchUrl, mutate}) => { {t("RejectDialog.button-cancel")} diff --git a/src/components/dashboard/commercial-chief/index.jsx b/src/components/dashboard/commercial-chief/index.jsx index b04253a..546bd73 100644 --- a/src/components/dashboard/commercial-chief/index.jsx +++ b/src/components/dashboard/commercial-chief/index.jsx @@ -124,6 +124,7 @@ function DashboardCommercialChiefComponent() { ], [] ); + return ( diff --git a/src/components/dashboard/development-assistant/Form/RejectForm.jsx b/src/components/dashboard/development-assistant/Form/RejectForm.jsx index eb4e4a1..5b78c6c 100644 --- a/src/components/dashboard/development-assistant/Form/RejectForm.jsx +++ b/src/components/dashboard/development-assistant/Form/RejectForm.jsx @@ -135,7 +135,7 @@ const Reject = ({rowId, fetchUrl, mutate}) => { {t("RejectDialog.button-cancel")} diff --git a/src/components/dashboard/development-assistant/index.jsx b/src/components/dashboard/development-assistant/index.jsx index 0e058dd..2c09de2 100644 --- a/src/components/dashboard/development-assistant/index.jsx +++ b/src/components/dashboard/development-assistant/index.jsx @@ -125,6 +125,7 @@ function DashboardDevelopmentAssistantComponent() { ], [] ); + return ( diff --git a/src/components/dashboard/expert-management/Form/ChangePassword/ChangePasswordContent.jsx b/src/components/dashboard/expert-management/Form/ChangePassword/ChangePasswordContent.jsx index b1c708c..b0a9157 100644 --- a/src/components/dashboard/expert-management/Form/ChangePassword/ChangePasswordContent.jsx +++ b/src/components/dashboard/expert-management/Form/ChangePassword/ChangePasswordContent.jsx @@ -81,7 +81,7 @@ const ChnagePasswordContent = ({rowId, fetchUrl, mutate, setOpenChangePasswordDi {t("ExpertMangement.button-cancel")} diff --git a/src/components/dashboard/expert-management/Form/CreateForm/CreateContent.jsx b/src/components/dashboard/expert-management/Form/CreateForm/CreateContent.jsx index dc9e62f..3757087 100644 --- a/src/components/dashboard/expert-management/Form/CreateForm/CreateContent.jsx +++ b/src/components/dashboard/expert-management/Form/CreateForm/CreateContent.jsx @@ -374,7 +374,7 @@ const CreateContent = ({setOpenCreateDialog, mutate, fetchUrl}) => { {t("ExpertMangement.button-cancel")} diff --git a/src/components/dashboard/expert-management/Form/UpdateForm/UpdateContent.jsx b/src/components/dashboard/expert-management/Form/UpdateForm/UpdateContent.jsx index dc6864c..a53a7c6 100644 --- a/src/components/dashboard/expert-management/Form/UpdateForm/UpdateContent.jsx +++ b/src/components/dashboard/expert-management/Form/UpdateForm/UpdateContent.jsx @@ -332,7 +332,7 @@ const UpdateContent = ({row, fetchUrl, mutate, setOpenUpdateDialog}) => { {t("ExpertMangement.button-cancel")} diff --git a/src/components/dashboard/expert-management/index.jsx b/src/components/dashboard/expert-management/index.jsx index 2c711c5..a69a550 100644 --- a/src/components/dashboard/expert-management/index.jsx +++ b/src/components/dashboard/expert-management/index.jsx @@ -138,6 +138,7 @@ function DashboardExpertManagementComponent() { ], [] ); + return ( diff --git a/src/components/dashboard/inspector-expert/Form/RejectForm.jsx b/src/components/dashboard/inspector-expert/Form/RejectForm.jsx index f59758d..87f7c47 100644 --- a/src/components/dashboard/inspector-expert/Form/RejectForm.jsx +++ b/src/components/dashboard/inspector-expert/Form/RejectForm.jsx @@ -137,7 +137,7 @@ const Reject = ({rowId, fetchUrl, mutate}) => { {t("RejectDialog.button-cancel")} diff --git a/src/components/dashboard/inspector-expert/Form/ReviseForm.jsx b/src/components/dashboard/inspector-expert/Form/ReviseForm.jsx index 92e1a1e..b53d8e0 100644 --- a/src/components/dashboard/inspector-expert/Form/ReviseForm.jsx +++ b/src/components/dashboard/inspector-expert/Form/ReviseForm.jsx @@ -93,7 +93,7 @@ const Revise = ({rowId, fetchUrl, mutate}) => { {t("ReviseDialog.button-cancel")} diff --git a/src/components/dashboard/inspector-expert/index.jsx b/src/components/dashboard/inspector-expert/index.jsx index d1c959e..137775f 100644 --- a/src/components/dashboard/inspector-expert/index.jsx +++ b/src/components/dashboard/inspector-expert/index.jsx @@ -124,6 +124,7 @@ function DashboardInspectorExpertComponent() { ], [] ); + return ( diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx index 555c580..9d1f696 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx @@ -176,7 +176,7 @@ const Confirm = ({rowId, fetchUrl, mutate}) => { {t("ConfirmDialog.button-cancel")} diff --git a/src/components/dashboard/machinary-office/Form/RejectForm.jsx b/src/components/dashboard/machinary-office/Form/RejectForm.jsx index 61cec90..38bab2f 100644 --- a/src/components/dashboard/machinary-office/Form/RejectForm.jsx +++ b/src/components/dashboard/machinary-office/Form/RejectForm.jsx @@ -137,7 +137,7 @@ const Reject = ({rowId, fetchUrl, mutate}) => { {t("RejectDialog.button-cancel")} diff --git a/src/components/dashboard/machinary-office/index.jsx b/src/components/dashboard/machinary-office/index.jsx index 2dfbbb1..a1b75d6 100644 --- a/src/components/dashboard/machinary-office/index.jsx +++ b/src/components/dashboard/machinary-office/index.jsx @@ -155,6 +155,7 @@ function DashboardMachinaryOfficeComponent() { ], [] ); + return ( diff --git a/src/components/dashboard/navgan-loan-management/Form/UpdateForm.jsx b/src/components/dashboard/navgan-loan-management/Form/UpdateForm.jsx index 7ac4ff6..c020b18 100644 --- a/src/components/dashboard/navgan-loan-management/Form/UpdateForm.jsx +++ b/src/components/dashboard/navgan-loan-management/Form/UpdateForm.jsx @@ -136,7 +136,7 @@ const Update = ({rowId, fetchUrl, mutate}) => { {t("UpdateDialog.button-cancel")} diff --git a/src/components/dashboard/navgan-loan-management/index.jsx b/src/components/dashboard/navgan-loan-management/index.jsx index 27cf5c0..3664ccb 100644 --- a/src/components/dashboard/navgan-loan-management/index.jsx +++ b/src/components/dashboard/navgan-loan-management/index.jsx @@ -134,6 +134,7 @@ function DashboardNavganLoanManagementComponent() { ], [] ); + return ( diff --git a/src/components/dashboard/navgan-province-manager/Form/RejectForm.jsx b/src/components/dashboard/navgan-province-manager/Form/RejectForm.jsx index 6f81b4a..e4cb4a3 100644 --- a/src/components/dashboard/navgan-province-manager/Form/RejectForm.jsx +++ b/src/components/dashboard/navgan-province-manager/Form/RejectForm.jsx @@ -137,7 +137,7 @@ const Reject = ({rowId, fetchUrl, mutate}) => { {t("RejectDialog.button-cancel")} diff --git a/src/components/dashboard/navgan-province-manager/index.jsx b/src/components/dashboard/navgan-province-manager/index.jsx index d2dc745..4ca0e0b 100644 --- a/src/components/dashboard/navgan-province-manager/index.jsx +++ b/src/components/dashboard/navgan-province-manager/index.jsx @@ -156,6 +156,7 @@ function DashboardNavganProvinceManagerComponent() { ], [] ); + return ( diff --git a/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx b/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx index 135b921..0654985 100644 --- a/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx +++ b/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx @@ -178,7 +178,7 @@ const Confirm = ({rowId, fetchUrl, mutate}) => { {t("ConfirmDialog.button-cancel")} diff --git a/src/components/dashboard/passenger-boss/Form/RejectForm.jsx b/src/components/dashboard/passenger-boss/Form/RejectForm.jsx index 3688ae7..01dcfc8 100644 --- a/src/components/dashboard/passenger-boss/Form/RejectForm.jsx +++ b/src/components/dashboard/passenger-boss/Form/RejectForm.jsx @@ -137,7 +137,7 @@ const Reject = ({rowId, fetchUrl, mutate}) => { {t("RejectDialog.button-cancel")} diff --git a/src/components/dashboard/passenger-boss/index.jsx b/src/components/dashboard/passenger-boss/index.jsx index 392cac3..0283fc3 100644 --- a/src/components/dashboard/passenger-boss/index.jsx +++ b/src/components/dashboard/passenger-boss/index.jsx @@ -156,6 +156,7 @@ function DashboardPassengerOfficeComponent() { ], [] ); + return ( diff --git a/src/components/dashboard/passenger-office/Form/RejectForm.jsx b/src/components/dashboard/passenger-office/Form/RejectForm.jsx index b187a2b..b8bfb35 100644 --- a/src/components/dashboard/passenger-office/Form/RejectForm.jsx +++ b/src/components/dashboard/passenger-office/Form/RejectForm.jsx @@ -137,7 +137,7 @@ const Reject = ({rowId, fetchUrl, mutate}) => { {t("RejectDialog.button-cancel")} diff --git a/src/components/dashboard/passenger-office/index.jsx b/src/components/dashboard/passenger-office/index.jsx index 7d9e39a..84953e9 100644 --- a/src/components/dashboard/passenger-office/index.jsx +++ b/src/components/dashboard/passenger-office/index.jsx @@ -156,6 +156,7 @@ function DashboardPassengerOfficeComponent() { ], [] ); + return ( diff --git a/src/components/dashboard/province-head-expert/Form/RejectForm.jsx b/src/components/dashboard/province-head-expert/Form/RejectForm.jsx index e41f95a..d027924 100644 --- a/src/components/dashboard/province-head-expert/Form/RejectForm.jsx +++ b/src/components/dashboard/province-head-expert/Form/RejectForm.jsx @@ -137,7 +137,7 @@ const Reject = ({rowId, fetchUrl, mutate}) => { {t("RejectDialog.button-cancel")} diff --git a/src/components/dashboard/province-head-expert/Form/ReviceForm.jsx b/src/components/dashboard/province-head-expert/Form/ReviceForm.jsx index 864d607..415ced5 100644 --- a/src/components/dashboard/province-head-expert/Form/ReviceForm.jsx +++ b/src/components/dashboard/province-head-expert/Form/ReviceForm.jsx @@ -97,7 +97,7 @@ const Revise = ({rowId, fetchUrl, mutate}) => { {t("ReviseDialog.button-cancel")} diff --git a/src/components/dashboard/province-head-expert/index.jsx b/src/components/dashboard/province-head-expert/index.jsx index a647af9..6995d26 100644 --- a/src/components/dashboard/province-head-expert/index.jsx +++ b/src/components/dashboard/province-head-expert/index.jsx @@ -125,6 +125,7 @@ function DashboardProvinceHeadExpertComponent() { ], [] ); + return ( diff --git a/src/components/dashboard/refahi-loan-management/Form/UpdateForm.jsx b/src/components/dashboard/refahi-loan-management/Form/UpdateForm.jsx index fec5b4c..c4d6605 100644 --- a/src/components/dashboard/refahi-loan-management/Form/UpdateForm.jsx +++ b/src/components/dashboard/refahi-loan-management/Form/UpdateForm.jsx @@ -136,7 +136,7 @@ const Update = ({rowId, fetchUrl, mutate}) => { {t("UpdateDialog.button-cancel")} diff --git a/src/components/dashboard/refahi-loan-management/index.jsx b/src/components/dashboard/refahi-loan-management/index.jsx index 4ae7238..3125654 100644 --- a/src/components/dashboard/refahi-loan-management/index.jsx +++ b/src/components/dashboard/refahi-loan-management/index.jsx @@ -134,6 +134,7 @@ function DashboardRefahiLoanManagementComponent() { ], [] ); + return ( diff --git a/src/components/dashboard/refahi-province-manager/Form/RejectForm.jsx b/src/components/dashboard/refahi-province-manager/Form/RejectForm.jsx index f253844..ea7eb72 100644 --- a/src/components/dashboard/refahi-province-manager/Form/RejectForm.jsx +++ b/src/components/dashboard/refahi-province-manager/Form/RejectForm.jsx @@ -137,7 +137,7 @@ const Reject = ({rowId, fetchUrl, mutate}) => { {t("RejectDialog.button-cancel")} diff --git a/src/components/dashboard/refahi-province-manager/index.jsx b/src/components/dashboard/refahi-province-manager/index.jsx index b649948..b7c13ce 100644 --- a/src/components/dashboard/refahi-province-manager/index.jsx +++ b/src/components/dashboard/refahi-province-manager/index.jsx @@ -125,6 +125,7 @@ function DashboardRefahiProvinceManagerComponent() { ], [] ); + return ( diff --git a/src/components/dashboard/role-management/Form/CreateForm/CreateContent.jsx b/src/components/dashboard/role-management/Form/CreateForm/CreateContent.jsx index a7f5f37..e6500eb 100644 --- a/src/components/dashboard/role-management/Form/CreateForm/CreateContent.jsx +++ b/src/components/dashboard/role-management/Form/CreateForm/CreateContent.jsx @@ -127,7 +127,7 @@ const CreateContent = ({mutate, fetchUrl, setOpenConfirmDialog}) => { {t("AddDialog.button-cancel")} diff --git a/src/components/dashboard/role-management/Form/UpdateForm.jsx b/src/components/dashboard/role-management/Form/UpdateForm.jsx index 7fd4459..0705af0 100644 --- a/src/components/dashboard/role-management/Form/UpdateForm.jsx +++ b/src/components/dashboard/role-management/Form/UpdateForm.jsx @@ -146,7 +146,7 @@ const UpdateForm = ({row, fetchUrl, mutate}) => { {t("UpdateDialog.button-cancel")} diff --git a/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx b/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx index d7a41df..2330e0b 100644 --- a/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx +++ b/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx @@ -137,7 +137,7 @@ const Reject = ({rowId, fetchUrl, mutate}) => { {t("RejectDialog.button-cancel")} diff --git a/src/components/dashboard/transportation-assistance/index.jsx b/src/components/dashboard/transportation-assistance/index.jsx index 0786159..97640b8 100644 --- a/src/components/dashboard/transportation-assistance/index.jsx +++ b/src/components/dashboard/transportation-assistance/index.jsx @@ -156,6 +156,7 @@ function DashboardTransportationAssistanceComponent() { ], [] ); + return ( diff --git a/src/components/dashboard/user-management/Form/CreateForm/CreateContent.jsx b/src/components/dashboard/user-management/Form/CreateForm/CreateContent.jsx index 1ab35f9..0a1b5e2 100644 --- a/src/components/dashboard/user-management/Form/CreateForm/CreateContent.jsx +++ b/src/components/dashboard/user-management/Form/CreateForm/CreateContent.jsx @@ -153,7 +153,7 @@ const CreateContent = ({mutate, fetchUrl, setOpenConfirmDialog}) => { {t("AddDialog.button-cancel")} diff --git a/src/components/login-expert/index.jsx b/src/components/login-expert/index.jsx index 9e8d3b3..221c530 100644 --- a/src/components/login-expert/index.jsx +++ b/src/components/login-expert/index.jsx @@ -120,7 +120,7 @@ const LoginComponent = () => { fullWidth size="medium" endIcon={} - disabled={props.isSubmitting} + disabled={props.isSubmitting || !props.dirty || !props.isValid} > {t("LoginPage.button_submit")} From 5e5a025afb98e8201ff84d0ab94a11ac8dc7258a Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Tue, 31 Oct 2023 10:22:48 +0330 Subject: [PATCH 03/18] LFFE-1 enhance commercial chief structure --- .../commercial-chief/Form/ConfirmForm.jsx | 142 ----------------- .../Form/ConfirmForm/ConfirmContent.jsx | 116 ++++++++++++++ .../Form/ConfirmForm/index.jsx | 31 ++++ .../commercial-chief/Form/RejectForm.jsx | 146 ------------------ .../Form/RejectForm/RejectContent.jsx | 122 +++++++++++++++ .../Form/RejectForm/index.jsx | 25 +++ .../commercial-chief/TableRowActions.jsx | 9 +- .../dashboard/commercial-chief/index.jsx | 4 + 8 files changed, 302 insertions(+), 293 deletions(-) delete mode 100644 src/components/dashboard/commercial-chief/Form/ConfirmForm.jsx create mode 100644 src/components/dashboard/commercial-chief/Form/ConfirmForm/ConfirmContent.jsx create mode 100644 src/components/dashboard/commercial-chief/Form/ConfirmForm/index.jsx delete mode 100644 src/components/dashboard/commercial-chief/Form/RejectForm.jsx create mode 100644 src/components/dashboard/commercial-chief/Form/RejectForm/RejectContent.jsx create mode 100644 src/components/dashboard/commercial-chief/Form/RejectForm/index.jsx diff --git a/src/components/dashboard/commercial-chief/Form/ConfirmForm.jsx b/src/components/dashboard/commercial-chief/Form/ConfirmForm.jsx deleted file mode 100644 index c2025ab..0000000 --- a/src/components/dashboard/commercial-chief/Form/ConfirmForm.jsx +++ /dev/null @@ -1,142 +0,0 @@ -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography -} from "@mui/material"; -import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; -import UploadSystem from "@/core/components/UploadSystem"; -import {useFormik} from "formik"; -import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; -import {CONFIRM_COMMERCIAL_CHIEF} from "@/core/data/apiRoutes"; -import useRequest from "@/lib/app/hooks/useRequest"; -import useNotification from "@/lib/app/hooks/useNotification"; - - -const Confirm = ({rowId, fetchUrl, mutate}) => { - const t = useTranslations(); - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); - const [openConfirmDialog, setOpenConfirmDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const formik = useFormik({ - initialValues: { - description: "", - confirm_img: null - }, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - if (values.description != "") formData.append("description", values.description); - if (values.confirm_img != null) formData.append("attachment", values.confirm_img); - - requestServer(`${CONFIRM_COMMERCIAL_CHIEF}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) - }; - - const handleUploadChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(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 ( - <> - - { - setOpenConfirmDialog(true) - }} - > - - - - - {t("ConfirmDialog.confirm")} - - - - - {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} - value={formik.values.description} - onChange={handleDescriptionChange} - fullWidth - variant="outlined" - sx={{mt: 1}} - /> - - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - - - - - - - - - - ); -}; -export default Confirm; \ No newline at end of file diff --git a/src/components/dashboard/commercial-chief/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/commercial-chief/Form/ConfirmForm/ConfirmContent.jsx new file mode 100644 index 0000000..f68dd36 --- /dev/null +++ b/src/components/dashboard/commercial-chief/Form/ConfirmForm/ConfirmContent.jsx @@ -0,0 +1,116 @@ +import UploadSystem from "@/core/components/UploadSystem"; +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import {CONFIRM_COMMERCIAL_CHIEF} from "@/core/data/apiRoutes"; +import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; +import { useState } from "react"; + +const ConfirmContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => { + const t = useTranslations(); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const formik = useFormik({ + initialValues: { + description: "", + confirm_img: null + }, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + if (values.description != "") formData.append("description", values.description); + if (values.confirm_img != null) formData.append("attachment", values.confirm_img); + + requestServer(`${CONFIRM_COMMERCIAL_CHIEF}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", event.target.value) + }; + + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(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.description")}{t("ConfirmDialog.optional")}} + value={formik.values.description} + onChange={handleDescriptionChange} + fullWidth + variant="outlined" + sx={{mt: 1}} + /> + + + {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + + + + + + + + + ) + +} +export default ConfirmContent \ No newline at end of file diff --git a/src/components/dashboard/commercial-chief/Form/ConfirmForm/index.jsx b/src/components/dashboard/commercial-chief/Form/ConfirmForm/index.jsx new file mode 100644 index 0000000..3683d82 --- /dev/null +++ b/src/components/dashboard/commercial-chief/Form/ConfirmForm/index.jsx @@ -0,0 +1,31 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; +import { useState } from "react"; +import ConfirmContent from "./ConfirmContent"; + +const Confirm = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + return( + <> + + { + setOpenConfirmDialog(true) + }} + > + + + + + {t("ConfirmDialog.confirm")} + + + + ) + +} +export default Confirm; \ No newline at end of file diff --git a/src/components/dashboard/commercial-chief/Form/RejectForm.jsx b/src/components/dashboard/commercial-chief/Form/RejectForm.jsx deleted file mode 100644 index ec27a31..0000000 --- a/src/components/dashboard/commercial-chief/Form/RejectForm.jsx +++ /dev/null @@ -1,146 +0,0 @@ -import {REJECT_COMMERCIAL_CHIEF} from "@/core/data/apiRoutes"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography, -} from "@mui/material"; -import {useTranslations} from "next-intl"; -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 ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import useRequest from "@/lib/app/hooks/useRequest"; -import useNotification from "@/lib/app/hooks/useNotification"; - - -const Reject = ({rowId, fetchUrl, mutate}) => { - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); - const t = useTranslations(); - const [openRejectDialog, setOpenRejectDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const validationSchema = Yup.object().shape({ - description: Yup.string().required(t("RejectDialog.description_error")), - }); - - const formik = useFormik({ - initialValues: { - description: "", - reject_img: null - }, - validationSchema, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - formData.append("description", values.description); - if (values.reject_img != null) formData.append("attachment", values.reject_img); - - requestServer(`${REJECT_COMMERCIAL_CHIEF}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", 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(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 ( - <> - - setOpenRejectDialog(true)}> - - - - - {t("RejectDialog.reject")} - - - - - - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - - - - - - - - - - ); -}; -export default Reject; \ No newline at end of file diff --git a/src/components/dashboard/commercial-chief/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/commercial-chief/Form/RejectForm/RejectContent.jsx new file mode 100644 index 0000000..98f3528 --- /dev/null +++ b/src/components/dashboard/commercial-chief/Form/RejectForm/RejectContent.jsx @@ -0,0 +1,122 @@ +import UploadSystem from "@/core/components/UploadSystem" +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import * as Yup from "yup"; +import {REJECT_COMMERCIAL_CHIEF} from "@/core/data/apiRoutes"; + +const RejectContent = ({rowId, fetchUrl, mutate, setOpenRejectDialog}) => { + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const t = useTranslations(); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("RejectDialog.description_error")), + }); + + const formik = useFormik({ + initialValues: { + description: "", + reject_img: null + }, + validationSchema, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + formData.append("description", values.description); + if (values.reject_img != null) formData.append("attachment", values.reject_img); + + requestServer(`${REJECT_COMMERCIAL_CHIEF}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", 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(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("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + + + + + + + + + ) +} +export default RejectContent \ No newline at end of file diff --git a/src/components/dashboard/commercial-chief/Form/RejectForm/index.jsx b/src/components/dashboard/commercial-chief/Form/RejectForm/index.jsx new file mode 100644 index 0000000..678a842 --- /dev/null +++ b/src/components/dashboard/commercial-chief/Form/RejectForm/index.jsx @@ -0,0 +1,25 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material" +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import RejectContent from "./RejectContent"; +import ThumbDownIcon from "@mui/icons-material/ThumbDown"; + +const Reject = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openRejectDialog, setOpenRejectDialog] = useState(false); + return ( + <> + + setOpenRejectDialog(true)}> + + + + + {t("RejectDialog.reject")} + + + + ) +} +export default Reject \ No newline at end of file diff --git a/src/components/dashboard/commercial-chief/TableRowActions.jsx b/src/components/dashboard/commercial-chief/TableRowActions.jsx index 601240f..498f1e4 100644 --- a/src/components/dashboard/commercial-chief/TableRowActions.jsx +++ b/src/components/dashboard/commercial-chief/TableRowActions.jsx @@ -1,17 +1,16 @@ import {Box} from "@mui/material"; -import ConfirmForm from "./Form/ConfirmForm" -import RejectForm from "./Form/RejectForm" +import Confirm from "./Form/ConfirmForm"; +import Reject from "./Form/RejectForm"; const TableRow = ({row, mutate, fetchUrl}) => { - return ( - - Date: Tue, 31 Oct 2023 10:25:00 +0330 Subject: [PATCH 04/18] LFFE-1 delete fake data --- src/components/dashboard/commercial-chief/index.jsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/components/dashboard/commercial-chief/index.jsx b/src/components/dashboard/commercial-chief/index.jsx index 55c7dab..546bd73 100644 --- a/src/components/dashboard/commercial-chief/index.jsx +++ b/src/components/dashboard/commercial-chief/index.jsx @@ -124,15 +124,11 @@ function DashboardCommercialChiefComponent() { ], [] ); - const data = [{ - id : 1 - }] return ( Date: Tue, 31 Oct 2023 11:24:25 +0330 Subject: [PATCH 05/18] LFFE-1 development assistant enhancement --- .../Form/ConfirmForm.jsx | 141 ----------------- .../Form/ConfirmForm/ConfirmContent.jsx | 116 ++++++++++++++ .../Form/ConfirmForm/index.jsx | 31 ++++ .../development-assistant/Form/RejectForm.jsx | 146 ------------------ .../Form/RejectForm/RejectContent.jsx | 122 +++++++++++++++ .../Form/RejectForm/index.jsx | 25 +++ .../development-assistant/TableRowActions.jsx | 8 +- 7 files changed, 298 insertions(+), 291 deletions(-) delete mode 100644 src/components/dashboard/development-assistant/Form/ConfirmForm.jsx create mode 100644 src/components/dashboard/development-assistant/Form/ConfirmForm/ConfirmContent.jsx create mode 100644 src/components/dashboard/development-assistant/Form/ConfirmForm/index.jsx delete mode 100644 src/components/dashboard/development-assistant/Form/RejectForm.jsx create mode 100644 src/components/dashboard/development-assistant/Form/RejectForm/RejectContent.jsx create mode 100644 src/components/dashboard/development-assistant/Form/RejectForm/index.jsx diff --git a/src/components/dashboard/development-assistant/Form/ConfirmForm.jsx b/src/components/dashboard/development-assistant/Form/ConfirmForm.jsx deleted file mode 100644 index 07b3253..0000000 --- a/src/components/dashboard/development-assistant/Form/ConfirmForm.jsx +++ /dev/null @@ -1,141 +0,0 @@ -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography -} from "@mui/material"; -import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; -import UploadSystem from "@/core/components/UploadSystem"; -import {useFormik} from "formik"; -import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; -import {CONFIRM_DEVELOPMENT_ASSISTANT} from "@/core/data/apiRoutes"; -import useRequest from "@/lib/app/hooks/useRequest"; -import useNotification from "@/lib/app/hooks/useNotification"; - - -const Confirm = ({rowId, fetchUrl, mutate}) => { - const t = useTranslations(); - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); - const [openConfirmDialog, setOpenConfirmDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const formik = useFormik({ - initialValues: { - description: "", - confirm_img: null - }, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - if (values.description != "") formData.append("description", values.description); - if (values.confirm_img != null) formData.append("attachment", values.confirm_img); - - requestServer(`${CONFIRM_DEVELOPMENT_ASSISTANT}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) - }; - const handleUploadChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(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 ( - <> - - { - setOpenConfirmDialog(true) - }} - > - - - - - {t("ConfirmDialog.confirm")} - - - - - {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} - value={formik.values.description} - onChange={handleDescriptionChange} - fullWidth - variant="outlined" - sx={{mt: 1}} - /> - - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - - - - - - - - - - ); -}; -export default Confirm; \ No newline at end of file diff --git a/src/components/dashboard/development-assistant/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/development-assistant/Form/ConfirmForm/ConfirmContent.jsx new file mode 100644 index 0000000..b548620 --- /dev/null +++ b/src/components/dashboard/development-assistant/Form/ConfirmForm/ConfirmContent.jsx @@ -0,0 +1,116 @@ +import UploadSystem from "@/core/components/UploadSystem"; +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import {CONFIRM_DEVELOPMENT_ASSISTANT} from "@/core/data/apiRoutes"; +import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; +import { useState } from "react"; + +const ConfirmContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => { + const t = useTranslations(); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const formik = useFormik({ + initialValues: { + description: "", + confirm_img: null + }, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + if (values.description != "") formData.append("description", values.description); + if (values.confirm_img != null) formData.append("attachment", values.confirm_img); + + requestServer(`${CONFIRM_DEVELOPMENT_ASSISTANT}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", event.target.value) + }; + + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(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.description")}{t("ConfirmDialog.optional")}} + value={formik.values.description} + onChange={handleDescriptionChange} + fullWidth + variant="outlined" + sx={{mt: 1}} + /> + + + {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + + + + + + + + + ) + +} +export default ConfirmContent \ No newline at end of file diff --git a/src/components/dashboard/development-assistant/Form/ConfirmForm/index.jsx b/src/components/dashboard/development-assistant/Form/ConfirmForm/index.jsx new file mode 100644 index 0000000..3683d82 --- /dev/null +++ b/src/components/dashboard/development-assistant/Form/ConfirmForm/index.jsx @@ -0,0 +1,31 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; +import { useState } from "react"; +import ConfirmContent from "./ConfirmContent"; + +const Confirm = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + return( + <> + + { + setOpenConfirmDialog(true) + }} + > + + + + + {t("ConfirmDialog.confirm")} + + + + ) + +} +export default Confirm; \ No newline at end of file diff --git a/src/components/dashboard/development-assistant/Form/RejectForm.jsx b/src/components/dashboard/development-assistant/Form/RejectForm.jsx deleted file mode 100644 index 5b78c6c..0000000 --- a/src/components/dashboard/development-assistant/Form/RejectForm.jsx +++ /dev/null @@ -1,146 +0,0 @@ -import {REJECT_DEVELOPMENT_ASSISTANT} from "@/core/data/apiRoutes"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography, -} from "@mui/material"; -import {useTranslations} from "next-intl"; -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 ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import useRequest from "@/lib/app/hooks/useRequest"; -import useNotification from "@/lib/app/hooks/useNotification"; - - -const Reject = ({rowId, fetchUrl, mutate}) => { - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); - const t = useTranslations(); - const [openRejectDialog, setOpenRejectDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const validationSchema = Yup.object().shape({ - description: Yup.string().required(t("RejectDialog.description_error")), - }); - - const formik = useFormik({ - initialValues: { - description: "", - reject_img: null - }, - validationSchema, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - formData.append("description", values.description); - if (values.reject_img != null) formData.append("attachment", values.reject_img); - - requestServer(`${REJECT_DEVELOPMENT_ASSISTANT}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", 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(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 ( - <> - - setOpenRejectDialog(true)}> - - - - - {t("RejectDialog.reject")} - - - - - - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - - - - - - - - - - ); -}; -export default Reject; \ No newline at end of file diff --git a/src/components/dashboard/development-assistant/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/development-assistant/Form/RejectForm/RejectContent.jsx new file mode 100644 index 0000000..2b33cb2 --- /dev/null +++ b/src/components/dashboard/development-assistant/Form/RejectForm/RejectContent.jsx @@ -0,0 +1,122 @@ +import UploadSystem from "@/core/components/UploadSystem" +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import * as Yup from "yup"; +import {REJECT_DEVELOPMENT_ASSISTANT} from "@/core/data/apiRoutes"; + +const RejectContent = ({rowId, fetchUrl, mutate, setOpenRejectDialog}) => { + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const t = useTranslations(); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("RejectDialog.description_error")), + }); + + const formik = useFormik({ + initialValues: { + description: "", + reject_img: null + }, + validationSchema, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + formData.append("description", values.description); + if (values.reject_img != null) formData.append("attachment", values.reject_img); + + requestServer(`${REJECT_DEVELOPMENT_ASSISTANT}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", 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(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("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + + + + + + + + + ) +} +export default RejectContent \ No newline at end of file diff --git a/src/components/dashboard/development-assistant/Form/RejectForm/index.jsx b/src/components/dashboard/development-assistant/Form/RejectForm/index.jsx new file mode 100644 index 0000000..678a842 --- /dev/null +++ b/src/components/dashboard/development-assistant/Form/RejectForm/index.jsx @@ -0,0 +1,25 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material" +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import RejectContent from "./RejectContent"; +import ThumbDownIcon from "@mui/icons-material/ThumbDown"; + +const Reject = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openRejectDialog, setOpenRejectDialog] = useState(false); + return ( + <> + + setOpenRejectDialog(true)}> + + + + + {t("RejectDialog.reject")} + + + + ) +} +export default Reject \ No newline at end of file diff --git a/src/components/dashboard/development-assistant/TableRowActions.jsx b/src/components/dashboard/development-assistant/TableRowActions.jsx index 601240f..121d4e0 100644 --- a/src/components/dashboard/development-assistant/TableRowActions.jsx +++ b/src/components/dashboard/development-assistant/TableRowActions.jsx @@ -1,17 +1,17 @@ import {Box} from "@mui/material"; -import ConfirmForm from "./Form/ConfirmForm" -import RejectForm from "./Form/RejectForm" +import Confirm from "./Form/ConfirmForm"; +import Reject from "./Form/RejectForm"; const TableRow = ({row, mutate, fetchUrl}) => { return ( - - Date: Tue, 31 Oct 2023 11:57:14 +0330 Subject: [PATCH 06/18] LFFE-1 inspector expert structure enhancement --- .../inspector-expert/Form/ConfirmForm.jsx | 141 ----------------- .../Form/ConfirmForm/ConfirmContent.jsx | 116 ++++++++++++++ .../Form/ConfirmForm/index.jsx | 31 ++++ .../inspector-expert/Form/RejectForm.jsx | 148 ------------------ .../Form/RejectForm/RejectContent.jsx | 122 +++++++++++++++ .../Form/RejectForm/index.jsx | 25 +++ .../inspector-expert/Form/ReviseForm.jsx | 104 ------------ .../Form/ReviseForm/ReviseContent.jsx | 80 ++++++++++ .../Form/ReviseForm/index.jsx | 31 ++++ .../inspector-expert/TableRowActions.jsx | 12 +- 10 files changed, 411 insertions(+), 399 deletions(-) delete mode 100644 src/components/dashboard/inspector-expert/Form/ConfirmForm.jsx create mode 100644 src/components/dashboard/inspector-expert/Form/ConfirmForm/ConfirmContent.jsx create mode 100644 src/components/dashboard/inspector-expert/Form/ConfirmForm/index.jsx delete mode 100644 src/components/dashboard/inspector-expert/Form/RejectForm.jsx create mode 100644 src/components/dashboard/inspector-expert/Form/RejectForm/RejectContent.jsx create mode 100644 src/components/dashboard/inspector-expert/Form/RejectForm/index.jsx delete mode 100644 src/components/dashboard/inspector-expert/Form/ReviseForm.jsx create mode 100644 src/components/dashboard/inspector-expert/Form/ReviseForm/ReviseContent.jsx create mode 100644 src/components/dashboard/inspector-expert/Form/ReviseForm/index.jsx diff --git a/src/components/dashboard/inspector-expert/Form/ConfirmForm.jsx b/src/components/dashboard/inspector-expert/Form/ConfirmForm.jsx deleted file mode 100644 index 409ba94..0000000 --- a/src/components/dashboard/inspector-expert/Form/ConfirmForm.jsx +++ /dev/null @@ -1,141 +0,0 @@ -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography -} from "@mui/material"; -import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; -import UploadSystem from "@/core/components/UploadSystem"; -import {useFormik} from "formik"; -import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; -import {CONFIRM_INSPECTOR_EXPERT} from "@/core/data/apiRoutes"; -import useRequest from "@/lib/app/hooks/useRequest"; -import useNotification from "@/lib/app/hooks/useNotification"; - - -const Confirm = ({rowId, fetchUrl, mutate}) => { - const t = useTranslations(); - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); - const [openConfirmDialog, setOpenConfirmDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const formik = useFormik({ - initialValues: { - description: "", - confirm_img: null - }, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - if (values.description != "") formData.append("description", values.description); - if (values.confirm_img != null) formData.append("attachment", values.confirm_img); - - requestServer(`${CONFIRM_INSPECTOR_EXPERT}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) - }; - const handleUploadChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(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 ( - <> - - { - setOpenConfirmDialog(true) - }} - > - - - - - {t("ConfirmDialog.confirm")} - - - - - {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} - value={formik.values.description} - onChange={handleDescriptionChange} - fullWidth - variant="outlined" - sx={{mt: 1}} - /> - - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - - - - - - - - - - ); -}; -export default Confirm; \ No newline at end of file diff --git a/src/components/dashboard/inspector-expert/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/inspector-expert/Form/ConfirmForm/ConfirmContent.jsx new file mode 100644 index 0000000..195bdda --- /dev/null +++ b/src/components/dashboard/inspector-expert/Form/ConfirmForm/ConfirmContent.jsx @@ -0,0 +1,116 @@ +import UploadSystem from "@/core/components/UploadSystem"; +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import {CONFIRM_INSPECTOR_EXPERT} from "@/core/data/apiRoutes"; +import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; +import { useState } from "react"; + +const ConfirmContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => { + const t = useTranslations(); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const formik = useFormik({ + initialValues: { + description: "", + confirm_img: null + }, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + if (values.description != "") formData.append("description", values.description); + if (values.confirm_img != null) formData.append("attachment", values.confirm_img); + + requestServer(`${CONFIRM_INSPECTOR_EXPERT}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", event.target.value) + }; + + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(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.description")}{t("ConfirmDialog.optional")}} + value={formik.values.description} + onChange={handleDescriptionChange} + fullWidth + variant="outlined" + sx={{mt: 1}} + /> + + + {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + + + + + + + + + ) + +} +export default ConfirmContent \ No newline at end of file diff --git a/src/components/dashboard/inspector-expert/Form/ConfirmForm/index.jsx b/src/components/dashboard/inspector-expert/Form/ConfirmForm/index.jsx new file mode 100644 index 0000000..3683d82 --- /dev/null +++ b/src/components/dashboard/inspector-expert/Form/ConfirmForm/index.jsx @@ -0,0 +1,31 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; +import { useState } from "react"; +import ConfirmContent from "./ConfirmContent"; + +const Confirm = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + return( + <> + + { + setOpenConfirmDialog(true) + }} + > + + + + + {t("ConfirmDialog.confirm")} + + + + ) + +} +export default Confirm; \ No newline at end of file diff --git a/src/components/dashboard/inspector-expert/Form/RejectForm.jsx b/src/components/dashboard/inspector-expert/Form/RejectForm.jsx deleted file mode 100644 index 87f7c47..0000000 --- a/src/components/dashboard/inspector-expert/Form/RejectForm.jsx +++ /dev/null @@ -1,148 +0,0 @@ -import {REJECT_INSPECTOR_EXPERT} from "@/core/data/apiRoutes"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography, -} from "@mui/material"; -import {useTranslations} from "next-intl"; -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"; -import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import useRequest from "@/lib/app/hooks/useRequest"; -import useNotification from "@/lib/app/hooks/useNotification"; - - -const Reject = ({rowId, fetchUrl, mutate}) => { - 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 [openRejectDialog, setOpenRejectDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const validationSchema = Yup.object().shape({ - description: Yup.string().required(t("RejectDialog.description_error")), - }); - - const formik = useFormik({ - initialValues: { - description: "", - reject_img: null - }, - validationSchema, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - formData.append("description", values.description); - if (values.reject_img != null) formData.append("attachment", values.reject_img); - - requestServer(`${REJECT_INSPECTOR_EXPERT}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", 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(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 ( - <> - - setOpenRejectDialog(true)}> - - - - - {t("RejectDialog.reject")} - - - - - - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - - - - - - - - - - ); -}; -export default Reject; \ No newline at end of file diff --git a/src/components/dashboard/inspector-expert/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/inspector-expert/Form/RejectForm/RejectContent.jsx new file mode 100644 index 0000000..1055bab --- /dev/null +++ b/src/components/dashboard/inspector-expert/Form/RejectForm/RejectContent.jsx @@ -0,0 +1,122 @@ +import UploadSystem from "@/core/components/UploadSystem" +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import * as Yup from "yup"; +import {REJECT_INSPECTOR_EXPERT} from "@/core/data/apiRoutes"; + +const RejectContent = ({rowId, fetchUrl, mutate, setOpenRejectDialog}) => { + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const t = useTranslations(); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("RejectDialog.description_error")), + }); + + const formik = useFormik({ + initialValues: { + description: "", + reject_img: null + }, + validationSchema, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + formData.append("description", values.description); + if (values.reject_img != null) formData.append("attachment", values.reject_img); + + requestServer(`${REJECT_INSPECTOR_EXPERT}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", 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(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("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + + + + + + + + + ) +} +export default RejectContent \ No newline at end of file diff --git a/src/components/dashboard/inspector-expert/Form/RejectForm/index.jsx b/src/components/dashboard/inspector-expert/Form/RejectForm/index.jsx new file mode 100644 index 0000000..678a842 --- /dev/null +++ b/src/components/dashboard/inspector-expert/Form/RejectForm/index.jsx @@ -0,0 +1,25 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material" +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import RejectContent from "./RejectContent"; +import ThumbDownIcon from "@mui/icons-material/ThumbDown"; + +const Reject = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openRejectDialog, setOpenRejectDialog] = useState(false); + return ( + <> + + setOpenRejectDialog(true)}> + + + + + {t("RejectDialog.reject")} + + + + ) +} +export default Reject \ No newline at end of file diff --git a/src/components/dashboard/inspector-expert/Form/ReviseForm.jsx b/src/components/dashboard/inspector-expert/Form/ReviseForm.jsx deleted file mode 100644 index b53d8e0..0000000 --- a/src/components/dashboard/inspector-expert/Form/ReviseForm.jsx +++ /dev/null @@ -1,104 +0,0 @@ -import {REVISE_INSPECTOR_EXPERT} from "@/core/data/apiRoutes"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, -} from "@mui/material"; -import {useTranslations} from "next-intl"; -import {useFormik} from "formik"; -import * as Yup from "yup"; -import {useState} from "react"; -import useRequest from "@/lib/app/hooks/useRequest"; -import ReplyIcon from '@mui/icons-material/Reply'; -import useNotification from "@/lib/app/hooks/useNotification"; - - -const Revise = ({rowId, fetchUrl, mutate}) => { - const t = useTranslations(); - const [openRejectDialog, setOpenRejectDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const validationSchema = Yup.object().shape({ - description: Yup.string().required(t("ReviseDialog.description_error")), - }); - - const formik = useFormik({ - initialValues: { - description: "", - }, - validationSchema, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - formData.append("description", values.description); - - requestServer(`${REVISE_INSPECTOR_EXPERT}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value); - formik.handleChange(event); - }; - - return ( - <> - - setOpenRejectDialog(true)}> - - - - - {t("ReviseDialog.revise")} - - - - - - - - - - - - - - ); -}; -export default Revise; \ No newline at end of file diff --git a/src/components/dashboard/inspector-expert/Form/ReviseForm/ReviseContent.jsx b/src/components/dashboard/inspector-expert/Form/ReviseForm/ReviseContent.jsx new file mode 100644 index 0000000..0322572 --- /dev/null +++ b/src/components/dashboard/inspector-expert/Form/ReviseForm/ReviseContent.jsx @@ -0,0 +1,80 @@ +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import * as Yup from "yup"; +import {REVISE_INSPECTOR_EXPERT} from "@/core/data/apiRoutes"; + +const ReviseContent = ({rowId, fetchUrl, mutate, setOpenReviseDialog}) => { + const t = useTranslations(); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("ReviseDialog.description_error")), + }); + + const formik = useFormik({ + initialValues: { + description: "", + }, + validationSchema, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + formData.append("description", values.description); + + requestServer(`${REVISE_INSPECTOR_EXPERT}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", event.target.value); + formik.handleChange(event); + }; + return( + <> + + + + + + + + + + + + + ) +} +export default ReviseContent \ No newline at end of file diff --git a/src/components/dashboard/inspector-expert/Form/ReviseForm/index.jsx b/src/components/dashboard/inspector-expert/Form/ReviseForm/index.jsx new file mode 100644 index 0000000..32ed64a --- /dev/null +++ b/src/components/dashboard/inspector-expert/Form/ReviseForm/index.jsx @@ -0,0 +1,31 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import ReplyIcon from '@mui/icons-material/Reply'; +import { useState } from "react"; +import ReviseContent from "./ReviseContent"; + +const Revise = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openReviseDialog, setOpenReviseDialog] = useState(false); + return( + <> + + { + setOpenReviseDialog(true) + }} + > + + + + + {t("ReviseDialog.revise")} + + + + ) + +} +export default Revise; \ No newline at end of file diff --git a/src/components/dashboard/inspector-expert/TableRowActions.jsx b/src/components/dashboard/inspector-expert/TableRowActions.jsx index f76c2d2..577ad28 100644 --- a/src/components/dashboard/inspector-expert/TableRowActions.jsx +++ b/src/components/dashboard/inspector-expert/TableRowActions.jsx @@ -1,23 +1,23 @@ import {Box} from "@mui/material"; -import ConfirmForm from "./Form/ConfirmForm" -import RejectForm from "./Form/RejectForm" -import ReviseForm from "./Form/ReviseForm" +import Confirm from "./Form/ConfirmForm"; +import Reject from "./Form/RejectForm"; +import Revise from "./Form/ReviseForm"; const TableRow = ({row, mutate, fetchUrl}) => { return ( - - - Date: Tue, 31 Oct 2023 12:09:07 +0330 Subject: [PATCH 07/18] LFFE-1 machinary office structure enhancement --- .../machinary-office/Form/ConfirmForm.jsx | 187 ------------------ .../Form/ConfirmForm/ConfirmContent.jsx | 152 ++++++++++++++ .../Form/ConfirmForm/index.jsx | 31 +++ .../machinary-office/Form/RejectForm.jsx | 148 -------------- .../Form/RejectForm/RejectContent.jsx | 122 ++++++++++++ .../Form/RejectForm/index.jsx | 25 +++ .../machinary-office/TableRowActions.jsx | 8 +- .../dashboard/machinary-office/index.jsx | 1 - 8 files changed, 334 insertions(+), 340 deletions(-) delete mode 100644 src/components/dashboard/machinary-office/Form/ConfirmForm.jsx create mode 100644 src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx create mode 100644 src/components/dashboard/machinary-office/Form/ConfirmForm/index.jsx delete mode 100644 src/components/dashboard/machinary-office/Form/RejectForm.jsx create mode 100644 src/components/dashboard/machinary-office/Form/RejectForm/RejectContent.jsx create mode 100644 src/components/dashboard/machinary-office/Form/RejectForm/index.jsx diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx deleted file mode 100644 index 9d1f696..0000000 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm.jsx +++ /dev/null @@ -1,187 +0,0 @@ -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography -} from "@mui/material"; -import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; -import UploadSystem from "@/core/components/UploadSystem"; -import {useFormik} from "formik"; -import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; -import {CONFIRM_MACHINARY_OFFICE} from "@/core/data/apiRoutes"; -import * as Yup from "yup"; -import useRequest from "@/lib/app/hooks/useRequest"; -import useNotification from "@/lib/app/hooks/useNotification"; -import PriceField from "@/core/components/PriceField"; - - -const Confirm = ({rowId, fetchUrl, mutate}) => { - const t = useTranslations(); - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); - const [openConfirmDialog, setOpenConfirmDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const validationSchema = Yup.object().shape({ - proposed_amount: Yup.mixed().test( - "is-number", - `${t("ConfirmDialog.approved_amount_number")}`, - (value) => !isNaN(value) - ).test("positive", `${t("ConfirmDialog.proposed_amount_positive")}`, (value) => value >= 0) - .required(t("ConfirmDialog.proposed_amount_error")) - }) - const formik = useFormik({ - initialValues: { - description: "", - proposed_amount: "", - confirm_img: null - }, - validationSchema, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - formData.append("proposed_amount", values.proposed_amount); - if (values.description != "") formData.append("expert_description", values.description); - if (values.confirm_img != null) formData.append("attachment", values.confirm_img); - - requestServer(`${CONFIRM_MACHINARY_OFFICE}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) - }; - const handleAmountChange = (event) => { - if (!isNaN(event.target.value)) { - formik.setFieldValue("proposed_amount", event.target.value) - } else { - formik.setFieldValue("proposed_amount", formik.values.proposed_amount) - } - }; - const handleUploadChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(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 ( - <> - - { - setOpenConfirmDialog(true) - }} - > - - - - - {t("ConfirmDialog.confirm")} - - - - - {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} - value={formik.values.description} - onChange={handleDescriptionChange} - fullWidth - variant="outlined" - sx={{mt: 1}} - /> - - - - {t("ConfirmDialog.proposed_amount")}{t("ConfirmDialog.unit")}} - type="text" - inputProps={{ - inputMode: "number", - min: 0, - pattern: "[0-9]*", - }} - variant="outlined" - value={formik.values.proposed_amount} - 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 - /> - - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - - - - - - - - - - ); -}; -export default Confirm; \ No newline at end of file diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx new file mode 100644 index 0000000..f47a3b8 --- /dev/null +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx @@ -0,0 +1,152 @@ +import UploadSystem from "@/core/components/UploadSystem"; +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import {CONFIRM_MACHINARY_OFFICE} from "@/core/data/apiRoutes"; +import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; +import { useState } from "react"; +import PriceField from "@/core/components/PriceField"; + +const ConfirmContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => { + const t = useTranslations(); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const formik = useFormik({ + initialValues: { + description: "", + proposed_amount: "", + confirm_img: null + }, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + formData.append("proposed_amount", values.proposed_amount); + if (values.description != "") formData.append("description", values.description); + if (values.confirm_img != null) formData.append("attachment", values.confirm_img); + + requestServer(`${CONFIRM_MACHINARY_OFFICE}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", event.target.value) + }; + + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(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 handleAmountChange = (event) => { + if (!isNaN(event.target.value)) { + formik.setFieldValue("proposed_amount", event.target.value) + } else { + formik.setFieldValue("proposed_amount", formik.values.proposed_amount) + } + }; + + return( + <> + + + + + {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} + value={formik.values.description} + onChange={handleDescriptionChange} + fullWidth + variant="outlined" + sx={{mt: 1}} + /> + + + + {t("ConfirmDialog.proposed_amount")}{t("ConfirmDialog.unit")}} + type="text" + inputProps={{ + inputMode: "number", + min: 0, + pattern: "[0-9]*", + }} + variant="outlined" + value={formik.values.proposed_amount} + 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 + /> + + + {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + + + + + + + + + ) + +} +export default ConfirmContent \ No newline at end of file diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm/index.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm/index.jsx new file mode 100644 index 0000000..3683d82 --- /dev/null +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm/index.jsx @@ -0,0 +1,31 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; +import { useState } from "react"; +import ConfirmContent from "./ConfirmContent"; + +const Confirm = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + return( + <> + + { + setOpenConfirmDialog(true) + }} + > + + + + + {t("ConfirmDialog.confirm")} + + + + ) + +} +export default Confirm; \ No newline at end of file diff --git a/src/components/dashboard/machinary-office/Form/RejectForm.jsx b/src/components/dashboard/machinary-office/Form/RejectForm.jsx deleted file mode 100644 index 38bab2f..0000000 --- a/src/components/dashboard/machinary-office/Form/RejectForm.jsx +++ /dev/null @@ -1,148 +0,0 @@ -import {REJECT_MACHINARY_OFFICE} from "@/core/data/apiRoutes"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography, -} from "@mui/material"; -import {useTranslations} from "next-intl"; -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"; -import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import useRequest from "@/lib/app/hooks/useRequest"; -import useNotification from "@/lib/app/hooks/useNotification"; - - -const Reject = ({rowId, fetchUrl, mutate}) => { - 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 [openRejectDialog, setOpenRejectDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const validationSchema = Yup.object().shape({ - description: Yup.string().required(t("RejectDialog.description_error")), - }); - - const formik = useFormik({ - initialValues: { - description: "", - reject_img: null - }, - validationSchema, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - formData.append("expert_description", values.description); - if (values.reject_img != null) formData.append("attachment", values.reject_img); - - requestServer(`${REJECT_MACHINARY_OFFICE}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", 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(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 ( - <> - - setOpenRejectDialog(true)}> - - - - - {t("RejectDialog.reject")} - - - - - - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - - - - - - - - - - ); -}; -export default Reject; \ No newline at end of file diff --git a/src/components/dashboard/machinary-office/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/machinary-office/Form/RejectForm/RejectContent.jsx new file mode 100644 index 0000000..1055bab --- /dev/null +++ b/src/components/dashboard/machinary-office/Form/RejectForm/RejectContent.jsx @@ -0,0 +1,122 @@ +import UploadSystem from "@/core/components/UploadSystem" +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import * as Yup from "yup"; +import {REJECT_INSPECTOR_EXPERT} from "@/core/data/apiRoutes"; + +const RejectContent = ({rowId, fetchUrl, mutate, setOpenRejectDialog}) => { + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const t = useTranslations(); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("RejectDialog.description_error")), + }); + + const formik = useFormik({ + initialValues: { + description: "", + reject_img: null + }, + validationSchema, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + formData.append("description", values.description); + if (values.reject_img != null) formData.append("attachment", values.reject_img); + + requestServer(`${REJECT_INSPECTOR_EXPERT}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", 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(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("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + + + + + + + + + ) +} +export default RejectContent \ No newline at end of file diff --git a/src/components/dashboard/machinary-office/Form/RejectForm/index.jsx b/src/components/dashboard/machinary-office/Form/RejectForm/index.jsx new file mode 100644 index 0000000..678a842 --- /dev/null +++ b/src/components/dashboard/machinary-office/Form/RejectForm/index.jsx @@ -0,0 +1,25 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material" +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import RejectContent from "./RejectContent"; +import ThumbDownIcon from "@mui/icons-material/ThumbDown"; + +const Reject = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openRejectDialog, setOpenRejectDialog] = useState(false); + return ( + <> + + setOpenRejectDialog(true)}> + + + + + {t("RejectDialog.reject")} + + + + ) +} +export default Reject \ No newline at end of file diff --git a/src/components/dashboard/machinary-office/TableRowActions.jsx b/src/components/dashboard/machinary-office/TableRowActions.jsx index 601240f..121d4e0 100644 --- a/src/components/dashboard/machinary-office/TableRowActions.jsx +++ b/src/components/dashboard/machinary-office/TableRowActions.jsx @@ -1,17 +1,17 @@ import {Box} from "@mui/material"; -import ConfirmForm from "./Form/ConfirmForm" -import RejectForm from "./Form/RejectForm" +import Confirm from "./Form/ConfirmForm"; +import Reject from "./Form/RejectForm"; const TableRow = ({row, mutate, fetchUrl}) => { return ( - - From 5a036b1cdc619fa788adb6d93ddc6241007410c2 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Tue, 31 Oct 2023 13:21:37 +0330 Subject: [PATCH 08/18] LFFE-1 navgan loan management structure enhancement --- .../Form/UpdateForm.jsx | 147 ------------------ .../Form/UpdateForm/UpdateContent.jsx | 113 ++++++++++++++ .../Form/UpdateForm/index.jsx | 30 ++++ 3 files changed, 143 insertions(+), 147 deletions(-) delete mode 100644 src/components/dashboard/navgan-loan-management/Form/UpdateForm.jsx create mode 100644 src/components/dashboard/navgan-loan-management/Form/UpdateForm/UpdateContent.jsx create mode 100644 src/components/dashboard/navgan-loan-management/Form/UpdateForm/index.jsx diff --git a/src/components/dashboard/navgan-loan-management/Form/UpdateForm.jsx b/src/components/dashboard/navgan-loan-management/Form/UpdateForm.jsx deleted file mode 100644 index c020b18..0000000 --- a/src/components/dashboard/navgan-loan-management/Form/UpdateForm.jsx +++ /dev/null @@ -1,147 +0,0 @@ -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 ChangeCircleIcon from '@mui/icons-material/ChangeCircle'; -import {UPDATE_LOAN_MANAGEMENT_NAVGAN} from "@/core/data/apiRoutes"; -import useRequest from "@/lib/app/hooks/useRequest"; -import useNotification from "@/lib/app/hooks/useNotification"; -import * as Yup from "yup"; -import useLoanStateNavgan from "@/lib/prefetchDataTable/hooks/useLoanStateNavgan"; - - -const Update = ({rowId, fetchUrl, mutate}) => { - const t = useTranslations(); - const {loan_state_navgan} = useLoanStateNavgan() - const [openConfirmDialog, setOpenConfirmDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const validationSchema = Yup.object().shape({ - description: Yup.string().required(t("UpdateDialog.description_error")), - next_state_id: Yup.number().required(t("UpdateDialog.next-state-id-error")) - }); - - const formik = useFormik({ - initialValues: { - description: "", - next_state_id: "" - }, - validationSchema, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - formData.append("expert_description", values.description); - formData.append("next_state_id", values.next_state_id); - - requestServer(`${UPDATE_LOAN_MANAGEMENT_NAVGAN}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) - }; - const handleNextStateIDChange = (event) => { - formik.setFieldValue("next_state_id", event.target.value) - }; - - return ( - <> - - { - setOpenConfirmDialog(true) - }} - > - - - - - {t("UpdateDialog.update")} - - - - - - - - {t("UpdateDialog.next-state-id")} - - - {formik.touched.next_state_id && formik.errors.next_state_id} - - - - - - - - - - - - ); -}; -export default Update; \ No newline at end of file diff --git a/src/components/dashboard/navgan-loan-management/Form/UpdateForm/UpdateContent.jsx b/src/components/dashboard/navgan-loan-management/Form/UpdateForm/UpdateContent.jsx new file mode 100644 index 0000000..f3ee9c5 --- /dev/null +++ b/src/components/dashboard/navgan-loan-management/Form/UpdateForm/UpdateContent.jsx @@ -0,0 +1,113 @@ +import { UPDATE_LOAN_MANAGEMENT_NAVGAN } from "@/core/data/apiRoutes"; +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import useLoanStateNavgan from "@/lib/prefetchDataTable/hooks/useLoanStateNavgan"; +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 UpdateContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => { + const t = useTranslations(); + const {loan_state_navgan} = useLoanStateNavgan() + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("UpdateDialog.description_error")), + next_state_id: Yup.number().required(t("UpdateDialog.next-state-id-error")) + }); + + const formik = useFormik({ + initialValues: { + description: "", + next_state_id: "" + }, + validationSchema, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + formData.append("expert_description", values.description); + formData.append("next_state_id", values.next_state_id); + + requestServer(`${UPDATE_LOAN_MANAGEMENT_NAVGAN}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", event.target.value) + }; + const handleNextStateIDChange = (event) => { + formik.setFieldValue("next_state_id", event.target.value) + }; + return( + <> + + + + + + + + {t("UpdateDialog.next-state-id")} + + + {formik.touched.next_state_id && formik.errors.next_state_id} + + + + + + + + + + + ) +} +export default UpdateContent \ No newline at end of file diff --git a/src/components/dashboard/navgan-loan-management/Form/UpdateForm/index.jsx b/src/components/dashboard/navgan-loan-management/Form/UpdateForm/index.jsx new file mode 100644 index 0000000..66e7521 --- /dev/null +++ b/src/components/dashboard/navgan-loan-management/Form/UpdateForm/index.jsx @@ -0,0 +1,30 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import ChangeCircleIcon from '@mui/icons-material/ChangeCircle'; +import { useState } from "react"; +import UpdateContent from "./UpdateContent"; + +const Update = ({rowId, 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 From 25054649971c52401ff51f2ac78e6e17cfef23fa Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Tue, 31 Oct 2023 13:28:42 +0330 Subject: [PATCH 09/18] LFFE-1 navgan province manager structure enhancement --- .../Form/ConfirmForm.jsx | 143 ----------------- .../Form/ConfirmForm/ConfirmContent.jsx | 116 ++++++++++++++ .../Form/ConfirmForm/index.jsx | 31 ++++ .../Form/RejectForm.jsx | 148 ------------------ .../Form/RejectForm/RejectContent.jsx | 122 +++++++++++++++ .../Form/RejectForm/index.jsx | 25 +++ .../TableRowActions.jsx | 8 +- 7 files changed, 298 insertions(+), 295 deletions(-) delete mode 100644 src/components/dashboard/navgan-province-manager/Form/ConfirmForm.jsx create mode 100644 src/components/dashboard/navgan-province-manager/Form/ConfirmForm/ConfirmContent.jsx create mode 100644 src/components/dashboard/navgan-province-manager/Form/ConfirmForm/index.jsx delete mode 100644 src/components/dashboard/navgan-province-manager/Form/RejectForm.jsx create mode 100644 src/components/dashboard/navgan-province-manager/Form/RejectForm/RejectContent.jsx create mode 100644 src/components/dashboard/navgan-province-manager/Form/RejectForm/index.jsx diff --git a/src/components/dashboard/navgan-province-manager/Form/ConfirmForm.jsx b/src/components/dashboard/navgan-province-manager/Form/ConfirmForm.jsx deleted file mode 100644 index a4d0c1a..0000000 --- a/src/components/dashboard/navgan-province-manager/Form/ConfirmForm.jsx +++ /dev/null @@ -1,143 +0,0 @@ -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography -} from "@mui/material"; -import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; -import UploadSystem from "@/core/components/UploadSystem"; -import useDirection from "@/lib/app/hooks/useDirection"; -import {useFormik} from "formik"; -import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; -import {CONFIRM_NAVGAN_PROVINCE_MANAGER} from "@/core/data/apiRoutes"; -import useRequest from "@/lib/app/hooks/useRequest"; -import useNotification from "@/lib/app/hooks/useNotification"; - - -const Confirm = ({rowId, fetchUrl, mutate}) => { - const t = useTranslations(); - const {directionApp} = useDirection(); - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); - const [openConfirmDialog, setOpenConfirmDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const formik = useFormik({ - initialValues: { - description: "", - confirm_img: null - }, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - if (values.description != "") formData.append("expert_description", values.description); - if (values.confirm_img != null) formData.append("attachment", values.confirm_img); - - requestServer(`${CONFIRM_NAVGAN_PROVINCE_MANAGER}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) - }; - const handleUploadChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(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 ( - <> - - { - setOpenConfirmDialog(true) - }} - > - - - - - {t("ConfirmDialog.confirm")} - - - - - {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} - value={formik.values.description} - onChange={handleDescriptionChange} - fullWidth - variant="outlined" - sx={{mt: 1}} - /> - - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - - - - - - - - - - ); -}; -export default Confirm; \ No newline at end of file diff --git a/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/ConfirmContent.jsx new file mode 100644 index 0000000..cb67d3f --- /dev/null +++ b/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/ConfirmContent.jsx @@ -0,0 +1,116 @@ +import UploadSystem from "@/core/components/UploadSystem"; +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import {CONFIRM_NAVGAN_PROVINCE_MANAGER} from "@/core/data/apiRoutes"; +import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; +import { useState } from "react"; + +const ConfirmContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => { + const t = useTranslations(); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const formik = useFormik({ + initialValues: { + description: "", + confirm_img: null + }, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + if (values.description != "") formData.append("description", values.description); + if (values.confirm_img != null) formData.append("attachment", values.confirm_img); + + requestServer(`${CONFIRM_NAVGAN_PROVINCE_MANAGER}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", event.target.value) + }; + + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(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.description")}{t("ConfirmDialog.optional")}} + value={formik.values.description} + onChange={handleDescriptionChange} + fullWidth + variant="outlined" + sx={{mt: 1}} + /> + + + {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + + + + + + + + + ) + +} +export default ConfirmContent \ No newline at end of file diff --git a/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/index.jsx b/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/index.jsx new file mode 100644 index 0000000..3683d82 --- /dev/null +++ b/src/components/dashboard/navgan-province-manager/Form/ConfirmForm/index.jsx @@ -0,0 +1,31 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; +import { useState } from "react"; +import ConfirmContent from "./ConfirmContent"; + +const Confirm = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + return( + <> + + { + setOpenConfirmDialog(true) + }} + > + + + + + {t("ConfirmDialog.confirm")} + + + + ) + +} +export default Confirm; \ No newline at end of file diff --git a/src/components/dashboard/navgan-province-manager/Form/RejectForm.jsx b/src/components/dashboard/navgan-province-manager/Form/RejectForm.jsx deleted file mode 100644 index e4cb4a3..0000000 --- a/src/components/dashboard/navgan-province-manager/Form/RejectForm.jsx +++ /dev/null @@ -1,148 +0,0 @@ -import {REJECT_NAVGAN_PROVINCE_MANAGER} from "@/core/data/apiRoutes"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography, -} from "@mui/material"; -import {useTranslations} from "next-intl"; -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"; -import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import useRequest from "@/lib/app/hooks/useRequest"; -import useNotification from "@/lib/app/hooks/useNotification"; - - -const Reject = ({rowId, fetchUrl, mutate}) => { - 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 [openRejectDialog, setOpenRejectDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const validationSchema = Yup.object().shape({ - description: Yup.string().required(t("RejectDialog.description_error")), - }); - - const formik = useFormik({ - initialValues: { - description: "", - reject_img: null - }, - validationSchema, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - formData.append("expert_description", values.description); - if (values.reject_img != null) formData.append("attachment", values.reject_img); - - requestServer(`${REJECT_NAVGAN_PROVINCE_MANAGER}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", 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(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 ( - <> - - setOpenRejectDialog(true)}> - - - - - {t("RejectDialog.reject")} - - - - - - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - - - - - - - - - - ); -}; -export default Reject; \ No newline at end of file diff --git a/src/components/dashboard/navgan-province-manager/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/navgan-province-manager/Form/RejectForm/RejectContent.jsx new file mode 100644 index 0000000..dd420b2 --- /dev/null +++ b/src/components/dashboard/navgan-province-manager/Form/RejectForm/RejectContent.jsx @@ -0,0 +1,122 @@ +import UploadSystem from "@/core/components/UploadSystem" +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import * as Yup from "yup"; +import {REJECT_NAVGAN_PROVINCE_MANAGER} from "@/core/data/apiRoutes"; + +const RejectContent = ({rowId, fetchUrl, mutate, setOpenRejectDialog}) => { + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const t = useTranslations(); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("RejectDialog.description_error")), + }); + + const formik = useFormik({ + initialValues: { + description: "", + reject_img: null + }, + validationSchema, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + formData.append("description", values.description); + if (values.reject_img != null) formData.append("attachment", values.reject_img); + + requestServer(`${REJECT_NAVGAN_PROVINCE_MANAGER}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", 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(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("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + + + + + + + + + ) +} +export default RejectContent \ No newline at end of file diff --git a/src/components/dashboard/navgan-province-manager/Form/RejectForm/index.jsx b/src/components/dashboard/navgan-province-manager/Form/RejectForm/index.jsx new file mode 100644 index 0000000..678a842 --- /dev/null +++ b/src/components/dashboard/navgan-province-manager/Form/RejectForm/index.jsx @@ -0,0 +1,25 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material" +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import RejectContent from "./RejectContent"; +import ThumbDownIcon from "@mui/icons-material/ThumbDown"; + +const Reject = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openRejectDialog, setOpenRejectDialog] = useState(false); + return ( + <> + + setOpenRejectDialog(true)}> + + + + + {t("RejectDialog.reject")} + + + + ) +} +export default Reject \ No newline at end of file diff --git a/src/components/dashboard/navgan-province-manager/TableRowActions.jsx b/src/components/dashboard/navgan-province-manager/TableRowActions.jsx index 601240f..121d4e0 100644 --- a/src/components/dashboard/navgan-province-manager/TableRowActions.jsx +++ b/src/components/dashboard/navgan-province-manager/TableRowActions.jsx @@ -1,17 +1,17 @@ import {Box} from "@mui/material"; -import ConfirmForm from "./Form/ConfirmForm" -import RejectForm from "./Form/RejectForm" +import Confirm from "./Form/ConfirmForm"; +import Reject from "./Form/RejectForm"; const TableRow = ({row, mutate, fetchUrl}) => { return ( - - Date: Tue, 31 Oct 2023 14:01:22 +0330 Subject: [PATCH 10/18] LFFE-1 passenger boss structure enhancement --- .../Form/ConfirmForm/ConfirmContent.jsx | 14 +- .../ConfirmContent.jsx} | 169 ++++++++---------- .../passenger-boss/Form/ConfirmForm/index.jsx | 31 ++++ .../passenger-boss/Form/RejectForm.jsx | 148 --------------- .../Form/RejectForm/RejectContent.jsx | 122 +++++++++++++ .../passenger-boss/Form/RejectForm/index.jsx | 25 +++ .../passenger-boss/TableRowActions.jsx | 7 +- .../dashboard/passenger-office/index.jsx | 1 - 8 files changed, 265 insertions(+), 252 deletions(-) rename src/components/dashboard/passenger-boss/Form/{ConfirmForm.jsx => ConfirmForm/ConfirmContent.jsx} (53%) create mode 100644 src/components/dashboard/passenger-boss/Form/ConfirmForm/index.jsx delete mode 100644 src/components/dashboard/passenger-boss/Form/RejectForm.jsx create mode 100644 src/components/dashboard/passenger-boss/Form/RejectForm/RejectContent.jsx create mode 100644 src/components/dashboard/passenger-boss/Form/RejectForm/index.jsx diff --git a/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx index f47a3b8..00d8c2f 100644 --- a/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/machinary-office/Form/ConfirmForm/ConfirmContent.jsx @@ -8,6 +8,7 @@ import {CONFIRM_MACHINARY_OFFICE} from "@/core/data/apiRoutes"; import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; import { useState } from "react"; import PriceField from "@/core/components/PriceField"; +import * as Yup from "yup"; const ConfirmContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => { const t = useTranslations(); @@ -18,12 +19,21 @@ const ConfirmContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => { const requestServer = useRequest({auth: true}) const {update_notification} = useNotification() + const validationSchema = Yup.object().shape({ + proposed_amount: Yup.mixed().test( + "is-number", + `${t("ConfirmDialog.proposed_amount_number")}`, + (value) => !isNaN(value) + ).test("positive", `${t("ConfirmDialog.proposed_amount_positive")}`, (value) => value >= 0) + .required(t("ConfirmDialog.proposed_amount_error")) + }); + const formik = useFormik({ initialValues: { description: "", proposed_amount: "", confirm_img: null - }, + },validationSchema, onSubmit: (values, {setSubmitting}) => { const formData = new FormData(); formData.append("proposed_amount", values.proposed_amount); @@ -141,7 +151,7 @@ const ConfirmContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => { {t("ConfirmDialog.button-cancel")} diff --git a/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx b/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx similarity index 53% rename from src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx rename to src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx index 0654985..6c229e0 100644 --- a/src/components/dashboard/passenger-boss/Form/ConfirmForm.jsx +++ b/src/components/dashboard/passenger-boss/Form/ConfirmForm/ConfirmContent.jsx @@ -1,37 +1,21 @@ -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography -} from "@mui/material"; -import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; import UploadSystem from "@/core/components/UploadSystem"; -import useDirection from "@/lib/app/hooks/useDirection"; -import {useFormik} from "formik"; -import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; -import * as Yup from "yup"; -import useRequest from "@/lib/app/hooks/useRequest"; -import {CONFIRM_PASSENGER_BOSS} from "@/core/data/apiRoutes"; import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import {CONFIRM_PASSENGER_BOSS} from "@/core/data/apiRoutes"; +import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; +import { useState } from "react"; import PriceField from "@/core/components/PriceField"; +import * as Yup from "yup"; - -const Confirm = ({rowId, fetchUrl, mutate}) => { +const ConfirmContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => { const t = useTranslations(); - const {directionApp} = useDirection(); const [selectedImage, setSelectedImage] = useState(""); const [fileType, setfileType] = useState(null); const [fileName, setfileName] = useState(null); const [showAddIcon, setShowAddIcon] = useState(true); - const [openConfirmDialog, setOpenConfirmDialog] = useState(false); const requestServer = useRequest({auth: true}) const {update_notification} = useNotification() @@ -43,17 +27,17 @@ const Confirm = ({rowId, fetchUrl, mutate}) => { ).test("positive", `${t("ConfirmDialog.approved_amount_positive")}`, (value) => value >= 0) .required(t("ConfirmDialog.approved_amount_error")) }); + const formik = useFormik({ initialValues: { description: "", approved_amount: "", confirm_img: null - }, - validationSchema, + },validationSchema, onSubmit: (values, {setSubmitting}) => { const formData = new FormData(); formData.append("approved_amount", values.approved_amount); - if (values.description != "") formData.append("expert_description", values.description); + if (values.description != "") formData.append("description", values.description); if (values.confirm_img != null) formData.append("attachment", values.confirm_img); requestServer(`${CONFIRM_PASSENGER_BOSS}/${rowId}`, 'post', { @@ -71,13 +55,7 @@ const Confirm = ({rowId, fetchUrl, mutate}) => { const handleDescriptionChange = (event) => { formik.setFieldValue("description", event.target.value) }; - const handleAmountChange = (event) => { - if (!isNaN(event.target.value)) { - formik.setFieldValue("approved_amount", event.target.value) - } else { - formik.setFieldValue("approved_amount", formik.values.approved_amount) - } - }; + const handleUploadChange = (event) => { const uploadedFile = event.target?.files?.[0]; if (uploadedFile) { @@ -97,38 +75,33 @@ const Confirm = ({rowId, fetchUrl, mutate}) => { setShowAddIcon(false); } }; - return ( + const handleAmountChange = (event) => { + if (!isNaN(event.target.value)) { + formik.setFieldValue("approved_amount", event.target.value) + } else { + formik.setFieldValue("approved_amount", formik.values.approved_amount) + } + }; + + return( <> - - { - setOpenConfirmDialog(true) - }} - > - - - - - {t("ConfirmDialog.confirm")} - - - - - {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} - value={formik.values.description} - onChange={handleDescriptionChange} - fullWidth - variant="outlined" - sx={{mt: 1}} - /> - - + + + + + {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} + value={formik.values.description} + onChange={handleDescriptionChange} + fullWidth + variant="outlined" + sx={{mt: 1}} + /> + + @@ -139,9 +112,9 @@ const Confirm = ({rowId, fetchUrl, mutate}) => { min: 0, pattern: "[0-9]*", }} - onChange={handleAmountChange} variant="outlined" value={formik.values.approved_amount} + onChange={handleAmountChange} onBlur={formik.handleBlur("approved_amount")} error={ formik.touched.approved_amount && @@ -154,36 +127,36 @@ const Confirm = ({rowId, fetchUrl, mutate}) => { fullWidth /> - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - + + {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + - - - - - - + + + + + + - ); -}; -export default Confirm; \ No newline at end of file + ) + +} +export default ConfirmContent \ No newline at end of file diff --git a/src/components/dashboard/passenger-boss/Form/ConfirmForm/index.jsx b/src/components/dashboard/passenger-boss/Form/ConfirmForm/index.jsx new file mode 100644 index 0000000..3683d82 --- /dev/null +++ b/src/components/dashboard/passenger-boss/Form/ConfirmForm/index.jsx @@ -0,0 +1,31 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; +import { useState } from "react"; +import ConfirmContent from "./ConfirmContent"; + +const Confirm = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + return( + <> + + { + setOpenConfirmDialog(true) + }} + > + + + + + {t("ConfirmDialog.confirm")} + + + + ) + +} +export default Confirm; \ No newline at end of file diff --git a/src/components/dashboard/passenger-boss/Form/RejectForm.jsx b/src/components/dashboard/passenger-boss/Form/RejectForm.jsx deleted file mode 100644 index 01dcfc8..0000000 --- a/src/components/dashboard/passenger-boss/Form/RejectForm.jsx +++ /dev/null @@ -1,148 +0,0 @@ -import {REJECT_PASSENGER_BOSS} from "@/core/data/apiRoutes"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography, -} from "@mui/material"; -import {useTranslations} from "next-intl"; -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"; -import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import useRequest from "@/lib/app/hooks/useRequest"; -import useNotification from "@/lib/app/hooks/useNotification"; - - -const Reject = ({rowId, fetchUrl, mutate}) => { - 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 [openRejectDialog, setOpenRejectDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const validationSchema = Yup.object().shape({ - description: Yup.string().required(t("RejectDialog.description_error")), - }); - - const formik = useFormik({ - initialValues: { - description: "", - reject_img: null - }, - validationSchema, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - formData.append("expert_description", values.description); - if (values.reject_img != null) formData.append("attachment", values.reject_img); - - requestServer(`${REJECT_PASSENGER_BOSS}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", 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(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 ( - <> - - setOpenRejectDialog(true)}> - - - - - {t("RejectDialog.reject")} - - - - - - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - - - - - - - - - - ); -}; -export default Reject; \ No newline at end of file diff --git a/src/components/dashboard/passenger-boss/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/passenger-boss/Form/RejectForm/RejectContent.jsx new file mode 100644 index 0000000..3583903 --- /dev/null +++ b/src/components/dashboard/passenger-boss/Form/RejectForm/RejectContent.jsx @@ -0,0 +1,122 @@ +import UploadSystem from "@/core/components/UploadSystem" +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import * as Yup from "yup"; +import {REJECT_PASSENGER_BOSS} from "@/core/data/apiRoutes"; + +const RejectContent = ({rowId, fetchUrl, mutate, setOpenRejectDialog}) => { + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const t = useTranslations(); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("RejectDialog.description_error")), + }); + + const formik = useFormik({ + initialValues: { + description: "", + reject_img: null + }, + validationSchema, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + formData.append("description", values.description); + if (values.reject_img != null) formData.append("attachment", values.reject_img); + + requestServer(`${REJECT_PASSENGER_BOSS}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", 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(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("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + + + + + + + + + ) +} +export default RejectContent \ No newline at end of file diff --git a/src/components/dashboard/passenger-boss/Form/RejectForm/index.jsx b/src/components/dashboard/passenger-boss/Form/RejectForm/index.jsx new file mode 100644 index 0000000..678a842 --- /dev/null +++ b/src/components/dashboard/passenger-boss/Form/RejectForm/index.jsx @@ -0,0 +1,25 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material" +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import RejectContent from "./RejectContent"; +import ThumbDownIcon from "@mui/icons-material/ThumbDown"; + +const Reject = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openRejectDialog, setOpenRejectDialog] = useState(false); + return ( + <> + + setOpenRejectDialog(true)}> + + + + + {t("RejectDialog.reject")} + + + + ) +} +export default Reject \ No newline at end of file diff --git a/src/components/dashboard/passenger-boss/TableRowActions.jsx b/src/components/dashboard/passenger-boss/TableRowActions.jsx index 601240f..c22cf80 100644 --- a/src/components/dashboard/passenger-boss/TableRowActions.jsx +++ b/src/components/dashboard/passenger-boss/TableRowActions.jsx @@ -1,17 +1,18 @@ import {Box} from "@mui/material"; -import ConfirmForm from "./Form/ConfirmForm" import RejectForm from "./Form/RejectForm" +import Confirm from "./Form/ConfirmForm"; +import Reject from "./Form/RejectForm"; const TableRow = ({row, mutate, fetchUrl}) => { return ( - - From 1f9c96fb86dbc6edf33ad6632f66505e0c8f0834 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Tue, 31 Oct 2023 14:35:31 +0330 Subject: [PATCH 11/18] LFFE-1 passenger office structure enhancement --- .../passenger-office/Form/ConfirmForm.jsx | 142 ----------------- .../Form/ConfirmForm/ConfirmContent.jsx | 116 ++++++++++++++ .../Form/ConfirmForm/index.jsx | 31 ++++ .../passenger-office/Form/RejectForm.jsx | 148 ------------------ .../Form/RejectForm/RejectContent.jsx | 122 +++++++++++++++ .../Form/RejectForm/index.jsx | 25 +++ .../passenger-office/TableRowActions.jsx | 8 +- 7 files changed, 298 insertions(+), 294 deletions(-) delete mode 100644 src/components/dashboard/passenger-office/Form/ConfirmForm.jsx create mode 100644 src/components/dashboard/passenger-office/Form/ConfirmForm/ConfirmContent.jsx create mode 100644 src/components/dashboard/passenger-office/Form/ConfirmForm/index.jsx delete mode 100644 src/components/dashboard/passenger-office/Form/RejectForm.jsx create mode 100644 src/components/dashboard/passenger-office/Form/RejectForm/RejectContent.jsx create mode 100644 src/components/dashboard/passenger-office/Form/RejectForm/index.jsx diff --git a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx b/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx deleted file mode 100644 index 1be22c8..0000000 --- a/src/components/dashboard/passenger-office/Form/ConfirmForm.jsx +++ /dev/null @@ -1,142 +0,0 @@ -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography -} from "@mui/material"; -import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; -import UploadSystem from "@/core/components/UploadSystem"; -import useDirection from "@/lib/app/hooks/useDirection"; -import {useFormik} from "formik"; -import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; -import useRequest from "@/lib/app/hooks/useRequest"; -import {CONFIRM_PASSENGER_OFFICE} from "@/core/data/apiRoutes"; -import useNotification from "@/lib/app/hooks/useNotification"; - -const Confirm = ({rowId, fetchUrl, mutate}) => { - const t = useTranslations(); - const {directionApp} = useDirection(); - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); - const [openConfirmDialog, setOpenConfirmDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const formik = useFormik({ - initialValues: { - description: "", - confirm_img: null - }, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - if (values.description != "") formData.append("expert_description", values.description); - if (values.confirm_img != null) formData.append("attachment", values.confirm_img); - - requestServer(`${CONFIRM_PASSENGER_OFFICE}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) - }; - const handleUploadChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(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 ( - <> - - { - setOpenConfirmDialog(true) - }} - > - - - - - {t("ConfirmDialog.confirm")} - - - - - {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} - value={formik.values.description} - onChange={handleDescriptionChange} - fullWidth - variant="outlined" - sx={{mt: 1}} - /> - - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - - - - - - - - - - ); -}; -export default Confirm; \ No newline at end of file diff --git a/src/components/dashboard/passenger-office/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/passenger-office/Form/ConfirmForm/ConfirmContent.jsx new file mode 100644 index 0000000..09c5d4e --- /dev/null +++ b/src/components/dashboard/passenger-office/Form/ConfirmForm/ConfirmContent.jsx @@ -0,0 +1,116 @@ +import UploadSystem from "@/core/components/UploadSystem"; +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import {CONFIRM_PASSENGER_OFFICE} from "@/core/data/apiRoutes"; +import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; +import { useState } from "react"; + +const ConfirmContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => { + const t = useTranslations(); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const formik = useFormik({ + initialValues: { + description: "", + confirm_img: null + }, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + if (values.description != "") formData.append("description", values.description); + if (values.confirm_img != null) formData.append("attachment", values.confirm_img); + + requestServer(`${CONFIRM_PASSENGER_OFFICE}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", event.target.value) + }; + + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(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.description")}{t("ConfirmDialog.optional")}} + value={formik.values.description} + onChange={handleDescriptionChange} + fullWidth + variant="outlined" + sx={{mt: 1}} + /> + + + {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + + + + + + + + + ) + +} +export default ConfirmContent \ No newline at end of file diff --git a/src/components/dashboard/passenger-office/Form/ConfirmForm/index.jsx b/src/components/dashboard/passenger-office/Form/ConfirmForm/index.jsx new file mode 100644 index 0000000..3683d82 --- /dev/null +++ b/src/components/dashboard/passenger-office/Form/ConfirmForm/index.jsx @@ -0,0 +1,31 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; +import { useState } from "react"; +import ConfirmContent from "./ConfirmContent"; + +const Confirm = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + return( + <> + + { + setOpenConfirmDialog(true) + }} + > + + + + + {t("ConfirmDialog.confirm")} + + + + ) + +} +export default Confirm; \ No newline at end of file diff --git a/src/components/dashboard/passenger-office/Form/RejectForm.jsx b/src/components/dashboard/passenger-office/Form/RejectForm.jsx deleted file mode 100644 index b8bfb35..0000000 --- a/src/components/dashboard/passenger-office/Form/RejectForm.jsx +++ /dev/null @@ -1,148 +0,0 @@ -import {REJECT_PASSENGER_OFFICE} from "@/core/data/apiRoutes"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography, -} from "@mui/material"; -import {useTranslations} from "next-intl"; -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"; -import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import useRequest from "@/lib/app/hooks/useRequest"; -import useNotification from "@/lib/app/hooks/useNotification"; - - -const Reject = ({rowId, fetchUrl, mutate}) => { - 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 [openRejectDialog, setOpenRejectDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const validationSchema = Yup.object().shape({ - description: Yup.string().required(t("RejectDialog.description_error")), - }); - - const formik = useFormik({ - initialValues: { - description: "", - reject_img: null - }, - validationSchema, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - formData.append("expert_description", values.description); - if (values.reject_img != null) formData.append("attachment", values.reject_img); - - requestServer(`${REJECT_PASSENGER_OFFICE}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", 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(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 ( - <> - - setOpenRejectDialog(true)}> - - - - - {t("RejectDialog.reject")} - - - - - - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - - - - - - - - - - ); -}; -export default Reject; \ No newline at end of file diff --git a/src/components/dashboard/passenger-office/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/passenger-office/Form/RejectForm/RejectContent.jsx new file mode 100644 index 0000000..cf4879e --- /dev/null +++ b/src/components/dashboard/passenger-office/Form/RejectForm/RejectContent.jsx @@ -0,0 +1,122 @@ +import UploadSystem from "@/core/components/UploadSystem" +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import * as Yup from "yup"; +import {REJECT_PASSENGER_OFFICE} from "@/core/data/apiRoutes"; + +const RejectContent = ({rowId, fetchUrl, mutate, setOpenRejectDialog}) => { + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const t = useTranslations(); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("RejectDialog.description_error")), + }); + + const formik = useFormik({ + initialValues: { + description: "", + reject_img: null + }, + validationSchema, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + formData.append("description", values.description); + if (values.reject_img != null) formData.append("attachment", values.reject_img); + + requestServer(`${REJECT_PASSENGER_OFFICE}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", 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(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("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + + + + + + + + + ) +} +export default RejectContent \ No newline at end of file diff --git a/src/components/dashboard/passenger-office/Form/RejectForm/index.jsx b/src/components/dashboard/passenger-office/Form/RejectForm/index.jsx new file mode 100644 index 0000000..678a842 --- /dev/null +++ b/src/components/dashboard/passenger-office/Form/RejectForm/index.jsx @@ -0,0 +1,25 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material" +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import RejectContent from "./RejectContent"; +import ThumbDownIcon from "@mui/icons-material/ThumbDown"; + +const Reject = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openRejectDialog, setOpenRejectDialog] = useState(false); + return ( + <> + + setOpenRejectDialog(true)}> + + + + + {t("RejectDialog.reject")} + + + + ) +} +export default Reject \ No newline at end of file diff --git a/src/components/dashboard/passenger-office/TableRowActions.jsx b/src/components/dashboard/passenger-office/TableRowActions.jsx index 601240f..121d4e0 100644 --- a/src/components/dashboard/passenger-office/TableRowActions.jsx +++ b/src/components/dashboard/passenger-office/TableRowActions.jsx @@ -1,17 +1,17 @@ import {Box} from "@mui/material"; -import ConfirmForm from "./Form/ConfirmForm" -import RejectForm from "./Form/RejectForm" +import Confirm from "./Form/ConfirmForm"; +import Reject from "./Form/RejectForm"; const TableRow = ({row, mutate, fetchUrl}) => { return ( - - Date: Tue, 31 Oct 2023 14:47:39 +0330 Subject: [PATCH 12/18] LFFE-1 province head expert structure enhancement --- .../province-head-expert/Form/ConfirmForm.jsx | 141 ----------------- .../Form/ConfirmForm/ConfirmContent.jsx | 116 ++++++++++++++ .../Form/ConfirmForm/index.jsx | 31 ++++ .../province-head-expert/Form/RejectForm.jsx | 148 ------------------ .../Form/RejectForm/RejectContent.jsx | 122 +++++++++++++++ .../Form/RejectForm/index.jsx | 25 +++ .../province-head-expert/Form/ReviceForm.jsx | 108 ------------- .../Form/ReviseForm/ReviseContent.jsx | 80 ++++++++++ .../Form/ReviseForm/index.jsx | 31 ++++ .../province-head-expert/TableRowActions.jsx | 12 +- .../dashboard/province-head-expert/index.jsx | 1 - 11 files changed, 411 insertions(+), 404 deletions(-) delete mode 100644 src/components/dashboard/province-head-expert/Form/ConfirmForm.jsx create mode 100644 src/components/dashboard/province-head-expert/Form/ConfirmForm/ConfirmContent.jsx create mode 100644 src/components/dashboard/province-head-expert/Form/ConfirmForm/index.jsx delete mode 100644 src/components/dashboard/province-head-expert/Form/RejectForm.jsx create mode 100644 src/components/dashboard/province-head-expert/Form/RejectForm/RejectContent.jsx create mode 100644 src/components/dashboard/province-head-expert/Form/RejectForm/index.jsx delete mode 100644 src/components/dashboard/province-head-expert/Form/ReviceForm.jsx create mode 100644 src/components/dashboard/province-head-expert/Form/ReviseForm/ReviseContent.jsx create mode 100644 src/components/dashboard/province-head-expert/Form/ReviseForm/index.jsx diff --git a/src/components/dashboard/province-head-expert/Form/ConfirmForm.jsx b/src/components/dashboard/province-head-expert/Form/ConfirmForm.jsx deleted file mode 100644 index c4cc607..0000000 --- a/src/components/dashboard/province-head-expert/Form/ConfirmForm.jsx +++ /dev/null @@ -1,141 +0,0 @@ -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography -} from "@mui/material"; -import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; -import UploadSystem from "@/core/components/UploadSystem"; -import {useFormik} from "formik"; -import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; -import {CONFIRM_PROVINCE_HEAD_EXPERT} from "@/core/data/apiRoutes"; -import useRequest from "@/lib/app/hooks/useRequest"; -import useNotification from "@/lib/app/hooks/useNotification"; - - -const Confirm = ({rowId, fetchUrl, mutate}) => { - const t = useTranslations(); - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); - const [openConfirmDialog, setOpenConfirmDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const formik = useFormik({ - initialValues: { - description: "", - confirm_img: null - }, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - if (values.description != "") formData.append("description", values.description); - if (values.confirm_img != null) formData.append("attachment", values.confirm_img); - - requestServer(`${CONFIRM_PROVINCE_HEAD_EXPERT}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) - }; - const handleUploadChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(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 ( - <> - - { - setOpenConfirmDialog(true) - }} - > - - - - - {t("ConfirmDialog.confirm")} - - - - - {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} - value={formik.values.description} - onChange={handleDescriptionChange} - fullWidth - variant="outlined" - sx={{mt: 1}} - /> - - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - - - - - - - - - - ); -}; -export default Confirm; \ No newline at end of file diff --git a/src/components/dashboard/province-head-expert/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/province-head-expert/Form/ConfirmForm/ConfirmContent.jsx new file mode 100644 index 0000000..a095a89 --- /dev/null +++ b/src/components/dashboard/province-head-expert/Form/ConfirmForm/ConfirmContent.jsx @@ -0,0 +1,116 @@ +import UploadSystem from "@/core/components/UploadSystem"; +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import {CONFIRM_PROVINCE_HEAD_EXPERT} from "@/core/data/apiRoutes"; +import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; +import { useState } from "react"; + +const ConfirmContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => { + const t = useTranslations(); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const formik = useFormik({ + initialValues: { + description: "", + confirm_img: null + }, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + if (values.description != "") formData.append("description", values.description); + if (values.confirm_img != null) formData.append("attachment", values.confirm_img); + + requestServer(`${CONFIRM_PROVINCE_HEAD_EXPERT}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", event.target.value) + }; + + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(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.description")}{t("ConfirmDialog.optional")}} + value={formik.values.description} + onChange={handleDescriptionChange} + fullWidth + variant="outlined" + sx={{mt: 1}} + /> + + + {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + + + + + + + + + ) + +} +export default ConfirmContent \ No newline at end of file diff --git a/src/components/dashboard/province-head-expert/Form/ConfirmForm/index.jsx b/src/components/dashboard/province-head-expert/Form/ConfirmForm/index.jsx new file mode 100644 index 0000000..3683d82 --- /dev/null +++ b/src/components/dashboard/province-head-expert/Form/ConfirmForm/index.jsx @@ -0,0 +1,31 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; +import { useState } from "react"; +import ConfirmContent from "./ConfirmContent"; + +const Confirm = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + return( + <> + + { + setOpenConfirmDialog(true) + }} + > + + + + + {t("ConfirmDialog.confirm")} + + + + ) + +} +export default Confirm; \ No newline at end of file diff --git a/src/components/dashboard/province-head-expert/Form/RejectForm.jsx b/src/components/dashboard/province-head-expert/Form/RejectForm.jsx deleted file mode 100644 index d027924..0000000 --- a/src/components/dashboard/province-head-expert/Form/RejectForm.jsx +++ /dev/null @@ -1,148 +0,0 @@ -import {REJECT_PROVINCE_HEAD_EXPERT} from "@/core/data/apiRoutes"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography, -} from "@mui/material"; -import {useTranslations} from "next-intl"; -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"; -import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import useRequest from "@/lib/app/hooks/useRequest"; -import useNotification from "@/lib/app/hooks/useNotification"; - - -const Reject = ({rowId, fetchUrl, mutate}) => { - 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 [openRejectDialog, setOpenRejectDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const validationSchema = Yup.object().shape({ - description: Yup.string().required(t("RejectDialog.description_error")), - }); - - const formik = useFormik({ - initialValues: { - description: "", - reject_img: null - }, - validationSchema, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - formData.append("description", values.description); - if (values.reject_img != null) formData.append("attachment", values.reject_img); - - requestServer(`${REJECT_PROVINCE_HEAD_EXPERT}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", 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(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 ( - <> - - setOpenRejectDialog(true)}> - - - - - {t("RejectDialog.reject")} - - - - - - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - - - - - - - - - - ); -}; -export default Reject; \ No newline at end of file diff --git a/src/components/dashboard/province-head-expert/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/province-head-expert/Form/RejectForm/RejectContent.jsx new file mode 100644 index 0000000..6bf7ed0 --- /dev/null +++ b/src/components/dashboard/province-head-expert/Form/RejectForm/RejectContent.jsx @@ -0,0 +1,122 @@ +import UploadSystem from "@/core/components/UploadSystem" +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import * as Yup from "yup"; +import {REJECT_PROVINCE_HEAD_EXPERT} from "@/core/data/apiRoutes"; + +const RejectContent = ({rowId, fetchUrl, mutate, setOpenRejectDialog}) => { + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const t = useTranslations(); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("RejectDialog.description_error")), + }); + + const formik = useFormik({ + initialValues: { + description: "", + reject_img: null + }, + validationSchema, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + formData.append("description", values.description); + if (values.reject_img != null) formData.append("attachment", values.reject_img); + + requestServer(`${REJECT_PROVINCE_HEAD_EXPERT}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", 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(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("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + + + + + + + + + ) +} +export default RejectContent \ No newline at end of file diff --git a/src/components/dashboard/province-head-expert/Form/RejectForm/index.jsx b/src/components/dashboard/province-head-expert/Form/RejectForm/index.jsx new file mode 100644 index 0000000..678a842 --- /dev/null +++ b/src/components/dashboard/province-head-expert/Form/RejectForm/index.jsx @@ -0,0 +1,25 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material" +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import RejectContent from "./RejectContent"; +import ThumbDownIcon from "@mui/icons-material/ThumbDown"; + +const Reject = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openRejectDialog, setOpenRejectDialog] = useState(false); + return ( + <> + + setOpenRejectDialog(true)}> + + + + + {t("RejectDialog.reject")} + + + + ) +} +export default Reject \ No newline at end of file diff --git a/src/components/dashboard/province-head-expert/Form/ReviceForm.jsx b/src/components/dashboard/province-head-expert/Form/ReviceForm.jsx deleted file mode 100644 index 415ced5..0000000 --- a/src/components/dashboard/province-head-expert/Form/ReviceForm.jsx +++ /dev/null @@ -1,108 +0,0 @@ -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, -} from "@mui/material"; -import {useFormik} from "formik"; -import ReplyIcon from '@mui/icons-material/Reply'; -import {REVISE_PROVINCE_HEAD_EXPERT} from "@/core/data/apiRoutes"; -import useRequest from "@/lib/app/hooks/useRequest"; -import * as Yup from "yup"; -import useNotification from "@/lib/app/hooks/useNotification"; - - -const Revise = ({rowId, fetchUrl, mutate}) => { - const t = useTranslations(); - const [openConfirmDialog, setOpenConfirmDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const validationSchema = Yup.object().shape({ - description: Yup.string().required(t("RejectDialog.description_error")), - }); - - const formik = useFormik({ - initialValues: { - description: "", - }, - validationSchema, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - if (values.description != "") formData.append("description", values.description); - - requestServer(`${REVISE_PROVINCE_HEAD_EXPERT}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) - }; - - return ( - <> - - { - setOpenConfirmDialog(true) - }} - > - - - - - {t("ReviseDialog.revise")} - - - - - - - - - - - - - - ); -}; -export default Revise; \ No newline at end of file diff --git a/src/components/dashboard/province-head-expert/Form/ReviseForm/ReviseContent.jsx b/src/components/dashboard/province-head-expert/Form/ReviseForm/ReviseContent.jsx new file mode 100644 index 0000000..9775d24 --- /dev/null +++ b/src/components/dashboard/province-head-expert/Form/ReviseForm/ReviseContent.jsx @@ -0,0 +1,80 @@ +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import * as Yup from "yup"; +import {REVISE_PROVINCE_HEAD_EXPERT} from "@/core/data/apiRoutes"; + +const ReviseContent = ({rowId, fetchUrl, mutate, setOpenReviseDialog}) => { + const t = useTranslations(); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("ReviseDialog.description_error")), + }); + + const formik = useFormik({ + initialValues: { + description: "", + }, + validationSchema, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + formData.append("description", values.description); + + requestServer(`${REVISE_PROVINCE_HEAD_EXPERT}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", event.target.value); + formik.handleChange(event); + }; + return( + <> + + + + + + + + + + + + + ) +} +export default ReviseContent \ No newline at end of file diff --git a/src/components/dashboard/province-head-expert/Form/ReviseForm/index.jsx b/src/components/dashboard/province-head-expert/Form/ReviseForm/index.jsx new file mode 100644 index 0000000..32ed64a --- /dev/null +++ b/src/components/dashboard/province-head-expert/Form/ReviseForm/index.jsx @@ -0,0 +1,31 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import ReplyIcon from '@mui/icons-material/Reply'; +import { useState } from "react"; +import ReviseContent from "./ReviseContent"; + +const Revise = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openReviseDialog, setOpenReviseDialog] = useState(false); + return( + <> + + { + setOpenReviseDialog(true) + }} + > + + + + + {t("ReviseDialog.revise")} + + + + ) + +} +export default Revise; \ No newline at end of file diff --git a/src/components/dashboard/province-head-expert/TableRowActions.jsx b/src/components/dashboard/province-head-expert/TableRowActions.jsx index b92f311..2ae3d42 100644 --- a/src/components/dashboard/province-head-expert/TableRowActions.jsx +++ b/src/components/dashboard/province-head-expert/TableRowActions.jsx @@ -1,23 +1,23 @@ import {Box} from "@mui/material"; -import ConfirmForm from "./Form/ConfirmForm" -import RejectForm from "./Form/RejectForm" -import ReviseForm from "@/components/dashboard/province-head-expert/Form/ReviceForm"; +import Confirm from "./Form/ConfirmForm"; +import Reject from "./Form/RejectForm"; +import Revise from "./Form/ReviseForm"; const TableRowActions = ({row, mutate, fetchUrl}) => { return ( - - - From bd27e680c5460085ee6ffc1253bff072fa9ed6a4 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Tue, 31 Oct 2023 14:56:30 +0330 Subject: [PATCH 13/18] LFFE-1 refahi loan management structure enhancement --- .../Form/UpdateForm.jsx | 147 ------------------ .../Form/UpdateForm/UpdateContent.jsx | 113 ++++++++++++++ .../Form/UpdateForm/index.jsx | 30 ++++ .../TableRowActions.jsx | 2 +- 4 files changed, 144 insertions(+), 148 deletions(-) delete mode 100644 src/components/dashboard/refahi-loan-management/Form/UpdateForm.jsx create mode 100644 src/components/dashboard/refahi-loan-management/Form/UpdateForm/UpdateContent.jsx create mode 100644 src/components/dashboard/refahi-loan-management/Form/UpdateForm/index.jsx diff --git a/src/components/dashboard/refahi-loan-management/Form/UpdateForm.jsx b/src/components/dashboard/refahi-loan-management/Form/UpdateForm.jsx deleted file mode 100644 index c4d6605..0000000 --- a/src/components/dashboard/refahi-loan-management/Form/UpdateForm.jsx +++ /dev/null @@ -1,147 +0,0 @@ -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 ChangeCircleIcon from '@mui/icons-material/ChangeCircle'; -import {UPDATE_LOAN_MANAGEMENT_REFAHI} from "@/core/data/apiRoutes"; -import useRequest from "@/lib/app/hooks/useRequest"; -import useNotification from "@/lib/app/hooks/useNotification"; -import * as Yup from "yup"; -import useLoanStateRefahi from "@/lib/prefetchDataTable/hooks/useLoanStateRefahi"; - - -const Update = ({rowId, fetchUrl, mutate}) => { - const t = useTranslations(); - const {loan_state_refahi} = useLoanStateRefahi() - const [openConfirmDialog, setOpenConfirmDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const validationSchema = Yup.object().shape({ - description: Yup.string().required(t("UpdateDialog.description_error")), - next_state_id: Yup.number().required(t("UpdateDialog.next-state-id-error")) - }); - - const formik = useFormik({ - initialValues: { - description: "", - next_state_id: "" - }, - validationSchema, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - formData.append("description", values.description); - formData.append("next_state_id", values.next_state_id); - - requestServer(`${UPDATE_LOAN_MANAGEMENT_REFAHI}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) - }; - const handleNextStateIDChange = (event) => { - formik.setFieldValue("next_state_id", event.target.value) - }; - - return ( - <> - - { - setOpenConfirmDialog(true) - }} - > - - - - - {t("UpdateDialog.update")} - - - - - - - - {t("UpdateDialog.next-state-id")} - - - {formik.touched.next_state_id && formik.errors.next_state_id} - - - - - - - - - - - - ); -}; -export default Update; \ No newline at end of file diff --git a/src/components/dashboard/refahi-loan-management/Form/UpdateForm/UpdateContent.jsx b/src/components/dashboard/refahi-loan-management/Form/UpdateForm/UpdateContent.jsx new file mode 100644 index 0000000..7dc79bf --- /dev/null +++ b/src/components/dashboard/refahi-loan-management/Form/UpdateForm/UpdateContent.jsx @@ -0,0 +1,113 @@ +import {UPDATE_LOAN_MANAGEMENT_REFAHI} from "@/core/data/apiRoutes"; +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import useLoanStateRefahi from "@/lib/prefetchDataTable/hooks/useLoanStateRefahi"; +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 UpdateContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => { + const t = useTranslations(); + const {loan_state_refahi} = useLoanStateRefahi() + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("UpdateDialog.description_error")), + next_state_id: Yup.number().required(t("UpdateDialog.next-state-id-error")) + }); + + const formik = useFormik({ + initialValues: { + description: "", + next_state_id: "" + }, + validationSchema, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + formData.append("expert_description", values.description); + formData.append("next_state_id", values.next_state_id); + + requestServer(`${UPDATE_LOAN_MANAGEMENT_REFAHI}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", event.target.value) + }; + const handleNextStateIDChange = (event) => { + formik.setFieldValue("next_state_id", event.target.value) + }; + return( + <> + + + + + + + + {t("UpdateDialog.next-state-id")} + + + {formik.touched.next_state_id && formik.errors.next_state_id} + + + + + + + + + + + ) +} +export default UpdateContent \ No newline at end of file diff --git a/src/components/dashboard/refahi-loan-management/Form/UpdateForm/index.jsx b/src/components/dashboard/refahi-loan-management/Form/UpdateForm/index.jsx new file mode 100644 index 0000000..66e7521 --- /dev/null +++ b/src/components/dashboard/refahi-loan-management/Form/UpdateForm/index.jsx @@ -0,0 +1,30 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import ChangeCircleIcon from '@mui/icons-material/ChangeCircle'; +import { useState } from "react"; +import UpdateContent from "./UpdateContent"; + +const Update = ({rowId, 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/refahi-loan-management/TableRowActions.jsx b/src/components/dashboard/refahi-loan-management/TableRowActions.jsx index fd599f9..0604922 100644 --- a/src/components/dashboard/refahi-loan-management/TableRowActions.jsx +++ b/src/components/dashboard/refahi-loan-management/TableRowActions.jsx @@ -1,5 +1,5 @@ import {Box} from "@mui/material"; -import Update from "./Form/UpdateForm" +import Update from "./Form/UpdateForm"; const TableRowActions = ({row, mutate, fetchUrl}) => { From aa569d4dec2a91256bff479c201a1a60ed3c0de8 Mon Sep 17 00:00:00 2001 From: AminGhasempoor Date: Tue, 31 Oct 2023 15:04:35 +0330 Subject: [PATCH 14/18] LFFE-1 refahi province manager structure enhancement --- .../Form/ConfirmForm.jsx | 143 ----------------- .../Form/ConfirmForm/ConfirmContent.jsx | 116 ++++++++++++++ .../Form/ConfirmForm/index.jsx | 31 ++++ .../Form/RejectForm.jsx | 148 ------------------ .../Form/RejectForm/RejectContent.jsx | 122 +++++++++++++++ .../Form/RejectForm/index.jsx | 25 +++ .../TableRowActions.jsx | 8 +- .../refahi-province-manager/index.jsx | 4 + 8 files changed, 302 insertions(+), 295 deletions(-) delete mode 100644 src/components/dashboard/refahi-province-manager/Form/ConfirmForm.jsx create mode 100644 src/components/dashboard/refahi-province-manager/Form/ConfirmForm/ConfirmContent.jsx create mode 100644 src/components/dashboard/refahi-province-manager/Form/ConfirmForm/index.jsx delete mode 100644 src/components/dashboard/refahi-province-manager/Form/RejectForm.jsx create mode 100644 src/components/dashboard/refahi-province-manager/Form/RejectForm/RejectContent.jsx create mode 100644 src/components/dashboard/refahi-province-manager/Form/RejectForm/index.jsx diff --git a/src/components/dashboard/refahi-province-manager/Form/ConfirmForm.jsx b/src/components/dashboard/refahi-province-manager/Form/ConfirmForm.jsx deleted file mode 100644 index f14421c..0000000 --- a/src/components/dashboard/refahi-province-manager/Form/ConfirmForm.jsx +++ /dev/null @@ -1,143 +0,0 @@ -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography -} from "@mui/material"; -import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; -import UploadSystem from "@/core/components/UploadSystem"; -import useDirection from "@/lib/app/hooks/useDirection"; -import {useFormik} from "formik"; -import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; -import useRequest from "@/lib/app/hooks/useRequest"; -import {CONFIRM_REFAHI_PROVINCE_MANAGER} from "@/core/data/apiRoutes"; -import useNotification from "@/lib/app/hooks/useNotification"; - - -const Confirm = ({rowId, fetchUrl, mutate}) => { - const t = useTranslations(); - const {directionApp} = useDirection(); - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); - const [openConfirmDialog, setOpenConfirmDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const formik = useFormik({ - initialValues: { - description: "", - confirm_img: null - }, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - if (values.description != "") formData.append("description", values.description); - if (values.confirm_img != null) formData.append("attachment", values.confirm_img); - - requestServer(`${CONFIRM_REFAHI_PROVINCE_MANAGER}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) - }; - const handleUploadChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(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 ( - <> - - { - setOpenConfirmDialog(true) - }} - > - - - - - {t("ConfirmDialog.confirm")} - - - - - {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} - value={formik.values.description} - onChange={handleDescriptionChange} - fullWidth - variant="outlined" - sx={{mt: 1}} - /> - - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - - - - - - - - - - ); -}; -export default Confirm; \ No newline at end of file diff --git a/src/components/dashboard/refahi-province-manager/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/refahi-province-manager/Form/ConfirmForm/ConfirmContent.jsx new file mode 100644 index 0000000..78c8953 --- /dev/null +++ b/src/components/dashboard/refahi-province-manager/Form/ConfirmForm/ConfirmContent.jsx @@ -0,0 +1,116 @@ +import UploadSystem from "@/core/components/UploadSystem"; +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import {CONFIRM_REFAHI_PROVINCE_MANAGER} from "@/core/data/apiRoutes"; +import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; +import { useState } from "react"; + +const ConfirmContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => { + const t = useTranslations(); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const formik = useFormik({ + initialValues: { + description: "", + confirm_img: null + }, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + if (values.description != "") formData.append("description", values.description); + if (values.confirm_img != null) formData.append("attachment", values.confirm_img); + + requestServer(`${CONFIRM_REFAHI_PROVINCE_MANAGER}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", event.target.value) + }; + + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(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.description")}{t("ConfirmDialog.optional")}} + value={formik.values.description} + onChange={handleDescriptionChange} + fullWidth + variant="outlined" + sx={{mt: 1}} + /> + + + {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + + + + + + + + + ) + +} +export default ConfirmContent \ No newline at end of file diff --git a/src/components/dashboard/refahi-province-manager/Form/ConfirmForm/index.jsx b/src/components/dashboard/refahi-province-manager/Form/ConfirmForm/index.jsx new file mode 100644 index 0000000..3683d82 --- /dev/null +++ b/src/components/dashboard/refahi-province-manager/Form/ConfirmForm/index.jsx @@ -0,0 +1,31 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; +import { useState } from "react"; +import ConfirmContent from "./ConfirmContent"; + +const Confirm = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + return( + <> + + { + setOpenConfirmDialog(true) + }} + > + + + + + {t("ConfirmDialog.confirm")} + + + + ) + +} +export default Confirm; \ No newline at end of file diff --git a/src/components/dashboard/refahi-province-manager/Form/RejectForm.jsx b/src/components/dashboard/refahi-province-manager/Form/RejectForm.jsx deleted file mode 100644 index ea7eb72..0000000 --- a/src/components/dashboard/refahi-province-manager/Form/RejectForm.jsx +++ /dev/null @@ -1,148 +0,0 @@ -import {REJECT_REFAHI_PROVINCE_MANAGER} from "@/core/data/apiRoutes"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography, -} from "@mui/material"; -import {useTranslations} from "next-intl"; -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"; -import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import useRequest from "@/lib/app/hooks/useRequest"; -import useNotification from "@/lib/app/hooks/useNotification"; - - -const Reject = ({rowId, fetchUrl, mutate}) => { - 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 [openRejectDialog, setOpenRejectDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const validationSchema = Yup.object().shape({ - description: Yup.string().required(t("RejectDialog.description_error")), - }); - - const formik = useFormik({ - initialValues: { - description: "", - reject_img: null - }, - validationSchema, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - formData.append("description", values.description); - if (values.reject_img != null) formData.append("attachment", values.reject_img); - - requestServer(`${REJECT_REFAHI_PROVINCE_MANAGER}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", 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(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 ( - <> - - setOpenRejectDialog(true)}> - - - - - {t("RejectDialog.reject")} - - - - - - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - - - - - - - - - - ); -}; -export default Reject; \ No newline at end of file diff --git a/src/components/dashboard/refahi-province-manager/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/refahi-province-manager/Form/RejectForm/RejectContent.jsx new file mode 100644 index 0000000..5eaf16e --- /dev/null +++ b/src/components/dashboard/refahi-province-manager/Form/RejectForm/RejectContent.jsx @@ -0,0 +1,122 @@ +import UploadSystem from "@/core/components/UploadSystem" +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import * as Yup from "yup"; +import {REJECT_REFAHI_PROVINCE_MANAGER} from "@/core/data/apiRoutes"; + +const RejectContent = ({rowId, fetchUrl, mutate, setOpenRejectDialog}) => { + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const t = useTranslations(); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("RejectDialog.description_error")), + }); + + const formik = useFormik({ + initialValues: { + description: "", + reject_img: null + }, + validationSchema, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + formData.append("description", values.description); + if (values.reject_img != null) formData.append("attachment", values.reject_img); + + requestServer(`${REJECT_REFAHI_PROVINCE_MANAGER}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", 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(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("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + + + + + + + + + ) +} +export default RejectContent \ No newline at end of file diff --git a/src/components/dashboard/refahi-province-manager/Form/RejectForm/index.jsx b/src/components/dashboard/refahi-province-manager/Form/RejectForm/index.jsx new file mode 100644 index 0000000..678a842 --- /dev/null +++ b/src/components/dashboard/refahi-province-manager/Form/RejectForm/index.jsx @@ -0,0 +1,25 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material" +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import RejectContent from "./RejectContent"; +import ThumbDownIcon from "@mui/icons-material/ThumbDown"; + +const Reject = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openRejectDialog, setOpenRejectDialog] = useState(false); + return ( + <> + + setOpenRejectDialog(true)}> + + + + + {t("RejectDialog.reject")} + + + + ) +} +export default Reject \ No newline at end of file diff --git a/src/components/dashboard/refahi-province-manager/TableRowActions.jsx b/src/components/dashboard/refahi-province-manager/TableRowActions.jsx index 601240f..121d4e0 100644 --- a/src/components/dashboard/refahi-province-manager/TableRowActions.jsx +++ b/src/components/dashboard/refahi-province-manager/TableRowActions.jsx @@ -1,17 +1,17 @@ import {Box} from "@mui/material"; -import ConfirmForm from "./Form/ConfirmForm" -import RejectForm from "./Form/RejectForm" +import Confirm from "./Form/ConfirmForm"; +import Reject from "./Form/RejectForm"; const TableRow = ({row, mutate, fetchUrl}) => { return ( - - Date: Tue, 31 Oct 2023 15:26:22 +0330 Subject: [PATCH 15/18] LFFE-1 role management structure enhancement --- .../refahi-province-manager/index.jsx | 4 -- .../Form/CreateForm/CreateContent.jsx | 2 +- .../UpdateContent.jsx} | 60 +++++-------------- .../role-management/Form/UpdateForm/index.jsx | 31 ++++++++++ .../role-management/TableRowActions.jsx | 4 +- 5 files changed, 48 insertions(+), 53 deletions(-) rename src/components/dashboard/role-management/Form/{UpdateForm.jsx => UpdateForm/UpdateContent.jsx} (82%) create mode 100644 src/components/dashboard/role-management/Form/UpdateForm/index.jsx diff --git a/src/components/dashboard/refahi-province-manager/index.jsx b/src/components/dashboard/refahi-province-manager/index.jsx index a3e15d6..b7c13ce 100644 --- a/src/components/dashboard/refahi-province-manager/index.jsx +++ b/src/components/dashboard/refahi-province-manager/index.jsx @@ -125,15 +125,11 @@ function DashboardRefahiProvinceManagerComponent() { ], [] ); - const data =[{ - id : 1 - }] return ( { <> - + { +const UpdateContent = ({row, fetchUrl, mutate, setOpenConfirmDialog}) => { const t = useTranslations(); - const [openConfirmDialog, setOpenConfirmDialog] = useState(false); const requestServer = useRequest({auth: true}) const {update_notification} = useNotification() const {permissions_list} = usePermissions() @@ -62,24 +43,11 @@ const UpdateForm = ({row, fetchUrl, mutate}) => { }); }, }); - - return (<> - - { - setOpenConfirmDialog(true) - }} - > - - - - - {t("UpdateDialog.update")} + return( + <> - + { {t("UpdateDialog.button-update")} - - ); -}; -export default UpdateForm; \ No newline at end of file + + ) +} +export default UpdateContent \ No newline at end of file diff --git a/src/components/dashboard/role-management/Form/UpdateForm/index.jsx b/src/components/dashboard/role-management/Form/UpdateForm/index.jsx new file mode 100644 index 0000000..2654f0e --- /dev/null +++ b/src/components/dashboard/role-management/Form/UpdateForm/index.jsx @@ -0,0 +1,31 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material" +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import EditIcon from '@mui/icons-material/Edit'; +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/role-management/TableRowActions.jsx b/src/components/dashboard/role-management/TableRowActions.jsx index 5b0f031..8eb5a35 100644 --- a/src/components/dashboard/role-management/TableRowActions.jsx +++ b/src/components/dashboard/role-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 ( - Date: Tue, 31 Oct 2023 15:34:40 +0330 Subject: [PATCH 16/18] LFFE-1 transportation assistant structure enhancement --- .../Form/ConfirmForm.jsx | 141 ----------------- .../Form/ConfirmForm/ConfirmContent.jsx | 116 ++++++++++++++ .../Form/ConfirmForm/index.jsx | 31 ++++ .../Form/RejectForm.jsx | 148 ------------------ .../Form/RejectForm/RejectContent.jsx | 122 +++++++++++++++ .../Form/RejectForm/index.jsx | 25 +++ .../TableRowActions.jsx | 8 +- .../transportation-assistance/index.jsx | 5 +- 8 files changed, 302 insertions(+), 294 deletions(-) delete mode 100644 src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx create mode 100644 src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx create mode 100644 src/components/dashboard/transportation-assistance/Form/ConfirmForm/index.jsx delete mode 100644 src/components/dashboard/transportation-assistance/Form/RejectForm.jsx create mode 100644 src/components/dashboard/transportation-assistance/Form/RejectForm/RejectContent.jsx create mode 100644 src/components/dashboard/transportation-assistance/Form/RejectForm/index.jsx diff --git a/src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx b/src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx deleted file mode 100644 index 6319be8..0000000 --- a/src/components/dashboard/transportation-assistance/Form/ConfirmForm.jsx +++ /dev/null @@ -1,141 +0,0 @@ -import {useTranslations} from "next-intl"; -import {useState} from "react"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography -} from "@mui/material"; -import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; -import UploadSystem from "@/core/components/UploadSystem"; -import {useFormik} from "formik"; -import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; -import {CONFIRM_TRANSPORTATION_ASSISTANCE} from "@/core/data/apiRoutes"; -import useRequest from "@/lib/app/hooks/useRequest"; -import useNotification from "@/lib/app/hooks/useNotification"; - - -const Confirm = ({rowId, fetchUrl, mutate}) => { - const t = useTranslations(); - const [selectedImage, setSelectedImage] = useState(""); - const [fileType, setfileType] = useState(null); - const [fileName, setfileName] = useState(null); - const [showAddIcon, setShowAddIcon] = useState(true); - const [openConfirmDialog, setOpenConfirmDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const formik = useFormik({ - initialValues: { - description: "", - confirm_img: null - }, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - if (values.description != "") formData.append("expert_description", values.description); - if (values.confirm_img != null) formData.append("attachment", values.confirm_img); - - requestServer(`${CONFIRM_TRANSPORTATION_ASSISTANCE}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", event.target.value) - }; - const handleUploadChange = (event) => { - const uploadedFile = event.target?.files?.[0]; - if (uploadedFile) { - const maxFileSize = 2 * 1024 * 1024; - if (uploadedFile.size > maxFileSize) { - UploadFileNotification(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 ( - <> - - { - setOpenConfirmDialog(true) - }} - > - - - - - {t("ConfirmDialog.confirm")} - - - - - {t("ConfirmDialog.description")}{t("ConfirmDialog.optional")}} - value={formik.values.description} - onChange={handleDescriptionChange} - fullWidth - variant="outlined" - sx={{mt: 1}} - /> - - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - - - - - - - - - - ); -}; -export default Confirm; \ No newline at end of file diff --git a/src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx new file mode 100644 index 0000000..70013f4 --- /dev/null +++ b/src/components/dashboard/transportation-assistance/Form/ConfirmForm/ConfirmContent.jsx @@ -0,0 +1,116 @@ +import UploadSystem from "@/core/components/UploadSystem"; +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import {CONFIRM_TRANSPORTATION_ASSISTANCE} from "@/core/data/apiRoutes"; +import UploadFileNotification from "@/core/components/notifications/UploadFileNotification"; +import { useState } from "react"; + +const ConfirmContent = ({rowId, fetchUrl, mutate, setOpenConfirmDialog}) => { + const t = useTranslations(); + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const formik = useFormik({ + initialValues: { + description: "", + confirm_img: null + }, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + if (values.description != "") formData.append("description", values.description); + if (values.confirm_img != null) formData.append("attachment", values.confirm_img); + + requestServer(`${CONFIRM_TRANSPORTATION_ASSISTANCE}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", event.target.value) + }; + + const handleUploadChange = (event) => { + const uploadedFile = event.target?.files?.[0]; + if (uploadedFile) { + const maxFileSize = 2 * 1024 * 1024; + if (uploadedFile.size > maxFileSize) { + UploadFileNotification(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.description")}{t("ConfirmDialog.optional")}} + value={formik.values.description} + onChange={handleDescriptionChange} + fullWidth + variant="outlined" + sx={{mt: 1}} + /> + + + {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + + + + + + + + + ) + +} +export default ConfirmContent \ No newline at end of file diff --git a/src/components/dashboard/transportation-assistance/Form/ConfirmForm/index.jsx b/src/components/dashboard/transportation-assistance/Form/ConfirmForm/index.jsx new file mode 100644 index 0000000..3683d82 --- /dev/null +++ b/src/components/dashboard/transportation-assistance/Form/ConfirmForm/index.jsx @@ -0,0 +1,31 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { useTranslations } from "next-intl"; +import ThumbUpAltIcon from "@mui/icons-material/ThumbUpAlt"; +import { useState } from "react"; +import ConfirmContent from "./ConfirmContent"; + +const Confirm = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openConfirmDialog, setOpenConfirmDialog] = useState(false); + return( + <> + + { + setOpenConfirmDialog(true) + }} + > + + + + + {t("ConfirmDialog.confirm")} + + + + ) + +} +export default Confirm; \ No newline at end of file diff --git a/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx b/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx deleted file mode 100644 index 2330e0b..0000000 --- a/src/components/dashboard/transportation-assistance/Form/RejectForm.jsx +++ /dev/null @@ -1,148 +0,0 @@ -import {REJECT_TRANSPORTATION_ASSISTANCE} from "@/core/data/apiRoutes"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - Stack, - TextField, - Tooltip, - Typography, -} from "@mui/material"; -import {useTranslations} from "next-intl"; -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"; -import ThumbDownIcon from "@mui/icons-material/ThumbDown"; -import useRequest from "@/lib/app/hooks/useRequest"; -import useNotification from "@/lib/app/hooks/useNotification"; - - -const Reject = ({rowId, fetchUrl, mutate}) => { - 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 [openRejectDialog, setOpenRejectDialog] = useState(false); - const requestServer = useRequest({auth: true}) - const {update_notification} = useNotification() - - const validationSchema = Yup.object().shape({ - description: Yup.string().required(t("RejectDialog.description_error")), - }); - - const formik = useFormik({ - initialValues: { - description: "", - reject_img: null - }, - validationSchema, - onSubmit: (values, {setSubmitting}) => { - const formData = new FormData(); - formData.append("expert_description", values.description); - if (values.reject_img != null) formData.append("attachment", values.reject_img); - - requestServer(`${REJECT_TRANSPORTATION_ASSISTANCE}/${rowId}`, 'post', { - data: formData, - }).then((response) => { - mutate(fetchUrl) - update_notification() - }).catch(() => { - }).finally(() => { - setSubmitting(false); - }); - }, - }); - - const handleDescriptionChange = (event) => { - formik.setFieldValue("description", 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(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 ( - <> - - setOpenRejectDialog(true)}> - - - - - {t("RejectDialog.reject")} - - - - - - - {t("UploadSystem.upload_file")}{t("UploadSystem.optional")} - - - - - - - - - - - ); -}; -export default Reject; \ No newline at end of file diff --git a/src/components/dashboard/transportation-assistance/Form/RejectForm/RejectContent.jsx b/src/components/dashboard/transportation-assistance/Form/RejectForm/RejectContent.jsx new file mode 100644 index 0000000..3ce51e9 --- /dev/null +++ b/src/components/dashboard/transportation-assistance/Form/RejectForm/RejectContent.jsx @@ -0,0 +1,122 @@ +import UploadSystem from "@/core/components/UploadSystem" +import useNotification from "@/lib/app/hooks/useNotification"; +import useRequest from "@/lib/app/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, TextField, Typography } from "@mui/material" +import { useFormik } from "formik"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import * as Yup from "yup"; +import {REJECT_TRANSPORTATION_ASSISTANCE} from "@/core/data/apiRoutes"; + +const RejectContent = ({rowId, fetchUrl, mutate, setOpenRejectDialog}) => { + const [selectedImage, setSelectedImage] = useState(""); + const [fileType, setfileType] = useState(null); + const [fileName, setfileName] = useState(null); + const [showAddIcon, setShowAddIcon] = useState(true); + const t = useTranslations(); + const requestServer = useRequest({auth: true}) + const {update_notification} = useNotification() + + const validationSchema = Yup.object().shape({ + description: Yup.string().required(t("RejectDialog.description_error")), + }); + + const formik = useFormik({ + initialValues: { + description: "", + reject_img: null + }, + validationSchema, + onSubmit: (values, {setSubmitting}) => { + const formData = new FormData(); + formData.append("description", values.description); + if (values.reject_img != null) formData.append("attachment", values.reject_img); + + requestServer(`${REJECT_TRANSPORTATION_ASSISTANCE}/${rowId}`, 'post', { + data: formData, + }).then((response) => { + mutate(fetchUrl) + update_notification() + }).catch(() => { + }).finally(() => { + setSubmitting(false); + }); + }, + }); + + const handleDescriptionChange = (event) => { + formik.setFieldValue("description", 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(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("UploadSystem.upload_file")}{t("UploadSystem.optional")} + + + + + + + + + + ) +} +export default RejectContent \ No newline at end of file diff --git a/src/components/dashboard/transportation-assistance/Form/RejectForm/index.jsx b/src/components/dashboard/transportation-assistance/Form/RejectForm/index.jsx new file mode 100644 index 0000000..678a842 --- /dev/null +++ b/src/components/dashboard/transportation-assistance/Form/RejectForm/index.jsx @@ -0,0 +1,25 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material" +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import RejectContent from "./RejectContent"; +import ThumbDownIcon from "@mui/icons-material/ThumbDown"; + +const Reject = ({rowId, fetchUrl, mutate}) => { + const t = useTranslations(); + const [openRejectDialog, setOpenRejectDialog] = useState(false); + return ( + <> + + setOpenRejectDialog(true)}> + + + + + {t("RejectDialog.reject")} + + + + ) +} +export default Reject \ No newline at end of file diff --git a/src/components/dashboard/transportation-assistance/TableRowActions.jsx b/src/components/dashboard/transportation-assistance/TableRowActions.jsx index 601240f..121d4e0 100644 --- a/src/components/dashboard/transportation-assistance/TableRowActions.jsx +++ b/src/components/dashboard/transportation-assistance/TableRowActions.jsx @@ -1,17 +1,17 @@ import {Box} from "@mui/material"; -import ConfirmForm from "./Form/ConfirmForm" -import RejectForm from "./Form/RejectForm" +import Confirm from "./Form/ConfirmForm"; +import Reject from "./Form/RejectForm"; const TableRow = ({row, mutate, fetchUrl}) => { return ( - - Date: Tue, 31 Oct 2023 15:35:22 +0330 Subject: [PATCH 17/18] LFFE-1 transportation assistant --- src/components/dashboard/transportation-assistance/index.jsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/components/dashboard/transportation-assistance/index.jsx b/src/components/dashboard/transportation-assistance/index.jsx index 5674dd2..0786159 100644 --- a/src/components/dashboard/transportation-assistance/index.jsx +++ b/src/components/dashboard/transportation-assistance/index.jsx @@ -156,14 +156,10 @@ function DashboardTransportationAssistanceComponent() { ], [] ); - const data =[{ - id : 1 - }] return ( Date: Tue, 31 Oct 2023 16:07:24 +0330 Subject: [PATCH 18/18] LFFE-1 user management structure enhancement --- .../dashboard/passenger-boss/index.jsx | 1 - .../Form/ConfirmForm/ConfirmContent.jsx | 2 +- .../UpdateContent.jsx} | 61 +++++-------------- .../user-management/Form/UpdateForm/index.jsx | 30 +++++++++ .../user-management/TableRowActions.jsx | 4 +- 5 files changed, 48 insertions(+), 50 deletions(-) rename src/components/dashboard/user-management/Form/{UpdateForm.jsx => UpdateForm/UpdateContent.jsx} (83%) create mode 100644 src/components/dashboard/user-management/Form/UpdateForm/index.jsx 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 ( -