From a6eef76045a61b691448dd680abfb85a33a200b9 Mon Sep 17 00:00:00 2001 From: Amirhossein Mahmoodi Date: Mon, 23 Dec 2024 12:19:32 +0330 Subject: [PATCH 1/2] fixe notification --- .../RoadSafetyForm/RoadSafetyFormContext.jsx | 4 ++-- .../zaminGov/RowActions/Refer/ReferFormContext.jsx | 4 ++-- .../RoadSafetyForm/RoadSafetyFormContext.jsx | 4 ++-- .../zaminGov/RowActions/Refer/ReferFormContext.jsx | 2 +- .../RoadSafetyForm/RoadSaftyFormContext.jsx | 2 +- .../Actions/Create/Forms/CreateFormContent.jsx | 2 +- .../roadItems/operator/ExcelPrint/index.jsx | 4 ++-- .../operator/RowActions/EditForm/EditFormContent.jsx | 4 ++-- .../RowActions/ConfirmForm/ConfirmContent.jsx | 4 ++-- .../RowActions/DeleteForm/DeleteContent.jsx | 2 +- .../RowActions/RejectForm/RejectContent.jsx | 4 ++-- .../RowActions/RestoreForm/RestoreContent.jsx | 2 +- src/lib/hooks/useRequest.js | 12 +++++------- 13 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/RoadSafetyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/RoadSafetyFormContext.jsx index def0666..a1492fd 100644 --- a/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/RoadSafetyFormContext.jsx +++ b/src/components/dashboard/inquiryPrivacy/assistant/zaminGov/RowActions/RoadSafetyForm/RoadSafetyFormContext.jsx @@ -40,7 +40,7 @@ const RoadSafetyFormContext = ({ rowId, mutate, setOpenRoadSafetyForm }) => { const defaultValues = { description: "", }; - const requestServer = useRequest({ notification: { success: true, show: true } }); + const requestServer = useRequest({ notificationSuccess: true }); const { message, loadingMessage, errorMessage } = usePrevStateOpinion(); const { register, @@ -57,7 +57,7 @@ const RoadSafetyFormContext = ({ rowId, mutate, setOpenRoadSafetyForm }) => { setOpenRoadSafetyForm(false); mutate(); }) - .catch(() => {}); + .catch(() => { }); }; return ( diff --git a/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/Refer/ReferFormContext.jsx b/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/Refer/ReferFormContext.jsx index 10b8e38..01127c4 100644 --- a/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/Refer/ReferFormContext.jsx +++ b/src/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov/RowActions/Refer/ReferFormContext.jsx @@ -31,7 +31,7 @@ const ReferFormContext = ({ setOpenReferDialog, rowId, mutate }) => { city: "", }; const { cities, loadingCities, errorCities } = useCities(); - const requestServer = useRequest({ notification: { show: true, success: true } }); + const requestServer = useRequest({ notificationSuccess: true }); const { control, register, @@ -50,7 +50,7 @@ const ReferFormContext = ({ setOpenReferDialog, rowId, mutate }) => { setOpenReferDialog(false); mutate(); }) - .catch(() => {}); + .catch(() => { }); }; return ( diff --git a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/RoadSafetyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/RoadSafetyFormContext.jsx index 7ced8b8..8acd6f7 100644 --- a/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/RoadSafetyFormContext.jsx +++ b/src/components/dashboard/inquiryPrivacy/generalManager/zaminGov/RowActions/RoadSafetyForm/RoadSafetyFormContext.jsx @@ -40,7 +40,7 @@ const RoadSafetyFormContext = ({ rowId, mutate, setOpenRoadSafetyForm }) => { const defaultValues = { description: "", }; - const requestServer = useRequest({ notification: { success: true, show: true } }); + const requestServer = useRequest({ notificationSuccess: true }); const { message, loadingMessage, errorMessage } = usePrevStateOpinion(); const { register, @@ -57,7 +57,7 @@ const RoadSafetyFormContext = ({ rowId, mutate, setOpenRoadSafetyForm }) => { setOpenRoadSafetyForm(false); mutate(); }) - .catch(() => {}); + .catch(() => { }); }; return ( diff --git a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/Refer/ReferFormContext.jsx b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/Refer/ReferFormContext.jsx index e02512e..1284aa2 100644 --- a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/Refer/ReferFormContext.jsx +++ b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/Refer/ReferFormContext.jsx @@ -31,7 +31,7 @@ const ReferFormContext = ({ setOpenReferDialog, rowId, mutate }) => { province: "", }; const { provinces, loadingProvinces, errorProvinces } = useProvinces(); - const requestServer = useRequest({ notification: { show: true, success: true } }); + const requestServer = useRequest({ notificationSuccess: true }); const { control, register, diff --git a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/RoadSaftyFormContext.jsx b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/RoadSaftyFormContext.jsx index 861400a..05cb6e0 100644 --- a/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/RoadSaftyFormContext.jsx +++ b/src/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov/RowActions/RoadSafetyForm/RoadSaftyFormContext.jsx @@ -41,7 +41,7 @@ const RoadSafetyFormContext = ({ rowId, mutate, setOpenRoadSafetyForm }) => { description: "", RadioGroup: "", }; - const requestServer = useRequest({ notification: { success: true, show: true } }); + const requestServer = useRequest({ notificationSuccess: true }); const { register, handleSubmit, diff --git a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/CreateFormContent.jsx b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/CreateFormContent.jsx index c05d6d8..e05531b 100644 --- a/src/components/dashboard/roadItems/operator/Actions/Create/Forms/CreateFormContent.jsx +++ b/src/components/dashboard/roadItems/operator/Actions/Create/Forms/CreateFormContent.jsx @@ -87,7 +87,7 @@ const CreateFormContent = ({ setOpen, mutate, rowId }) => { const [itemsList, setItemsList] = useState(); const [subItemsList, setSubItemsList] = useState([]); const theme = useTheme(); - const requestServer = useRequest({ notification: { success: true } }); + const requestServer = useRequest({ notificationSuccess: true }); const isMobile = useMediaQuery(theme.breakpoints.down("sm")); const handleClose = () => { setOpen(false); diff --git a/src/components/dashboard/roadItems/operator/ExcelPrint/index.jsx b/src/components/dashboard/roadItems/operator/ExcelPrint/index.jsx index ad5d8b3..605018e 100644 --- a/src/components/dashboard/roadItems/operator/ExcelPrint/index.jsx +++ b/src/components/dashboard/roadItems/operator/ExcelPrint/index.jsx @@ -12,7 +12,7 @@ const PrintExcel = ({ table, filterData }) => { const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down("sm")); const [loading, setLoading] = useState(false); - const requestServer = useRequest({ notification: { success: true } }); + const requestServer = useRequest({ notificationSuccess: true }); const activeFilters = Object.entries(filterData).reduce((acc, [key, filter]) => { if (filter.value) { // Check if there's an active filter @@ -39,7 +39,7 @@ const PrintExcel = ({ table, filterData }) => { const filename = `خروجی کارتابل فعالیت روزانه تاریخ_${moment().format("jYYYY_jMM_jDD")}.xlsx`; FileSaver.saveAs(response.data, filename); }) - .catch(() => {}) + .catch(() => { }) .finally(() => { setLoading(false); }); diff --git a/src/components/dashboard/roadItems/operator/RowActions/EditForm/EditFormContent.jsx b/src/components/dashboard/roadItems/operator/RowActions/EditForm/EditFormContent.jsx index 9b3a12c..460d64d 100644 --- a/src/components/dashboard/roadItems/operator/RowActions/EditForm/EditFormContent.jsx +++ b/src/components/dashboard/roadItems/operator/RowActions/EditForm/EditFormContent.jsx @@ -97,14 +97,14 @@ const EditFormContent = ({ row, mutate, setOpenEditDialog, rowId, subItem }) => subItem.needs_end_point === 1 && formData.append("end_point", endPoint); requestServer(`${UPDATE_ROAD_ITEMS}/${rowId}`, "post", { - notification: { success: true }, + notificationSuccess: true, data: formData, }) .then((res) => { mutate(); setOpenEditDialog(false); }) - .catch((err) => {}); + .catch((err) => { }); }; return ( <> diff --git a/src/components/dashboard/roadItems/supervisor/RowActions/ConfirmForm/ConfirmContent.jsx b/src/components/dashboard/roadItems/supervisor/RowActions/ConfirmForm/ConfirmContent.jsx index 2f7af71..f4be809 100644 --- a/src/components/dashboard/roadItems/supervisor/RowActions/ConfirmForm/ConfirmContent.jsx +++ b/src/components/dashboard/roadItems/supervisor/RowActions/ConfirmForm/ConfirmContent.jsx @@ -4,7 +4,7 @@ import useRequest from "@/lib/hooks/useRequest"; import { VERIFY_BY_SUPERVISOR } from "@/core/utils/routes"; const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog }) => { - const requestServer = useRequest({ notification: { success: true } }); + const requestServer = useRequest({ notificationSuccess: true }); const { register, @@ -28,7 +28,7 @@ const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog }) => { mutate(); setOpenConfirmDialog(false); }) - .catch(() => {}); + .catch(() => { }); }; return ( diff --git a/src/components/dashboard/roadItems/supervisor/RowActions/DeleteForm/DeleteContent.jsx b/src/components/dashboard/roadItems/supervisor/RowActions/DeleteForm/DeleteContent.jsx index 9e61c1b..18198a8 100644 --- a/src/components/dashboard/roadItems/supervisor/RowActions/DeleteForm/DeleteContent.jsx +++ b/src/components/dashboard/roadItems/supervisor/RowActions/DeleteForm/DeleteContent.jsx @@ -5,7 +5,7 @@ import { DELETE_BY_SUPERVISOR } from "@/core/utils/routes"; const DeleteContent = ({ rowId, mutate, setOpenDeleteDialog }) => { const [submitting, setSubmitting] = useState(false); - const requestServer = useRequest({ notification: { success: true } }); + const requestServer = useRequest({ notificationSuccess: true }); const handleClick = () => { setSubmitting(true); requestServer(`${DELETE_BY_SUPERVISOR}/${rowId}`, "post") diff --git a/src/components/dashboard/roadItems/supervisor/RowActions/RejectForm/RejectContent.jsx b/src/components/dashboard/roadItems/supervisor/RowActions/RejectForm/RejectContent.jsx index 087e020..81cc311 100644 --- a/src/components/dashboard/roadItems/supervisor/RowActions/RejectForm/RejectContent.jsx +++ b/src/components/dashboard/roadItems/supervisor/RowActions/RejectForm/RejectContent.jsx @@ -6,7 +6,7 @@ import useRequest from "@/lib/hooks/useRequest"; import { REJECT_BY_SUPERVISOR } from "@/core/utils/routes"; const RejectContent = ({ rowId, mutate, setOpenRejectDialog }) => { - const requestServer = useRequest({ notification: { success: true } }); + const requestServer = useRequest({ notificationSuccess: true }); const validationSchema = Yup.object().shape({ description: Yup.string().required("توضیحات الزامیست!!!"), @@ -36,7 +36,7 @@ const RejectContent = ({ rowId, mutate, setOpenRejectDialog }) => { mutate(); setOpenRejectDialog(false); }) - .catch(() => {}) + .catch(() => { }) .finally(() => { reset(); }); diff --git a/src/components/dashboard/roadItems/supervisor/RowActions/RestoreForm/RestoreContent.jsx b/src/components/dashboard/roadItems/supervisor/RowActions/RestoreForm/RestoreContent.jsx index b412aa0..3155406 100644 --- a/src/components/dashboard/roadItems/supervisor/RowActions/RestoreForm/RestoreContent.jsx +++ b/src/components/dashboard/roadItems/supervisor/RowActions/RestoreForm/RestoreContent.jsx @@ -5,7 +5,7 @@ import { RESTORE_BY_SUPERVISOR } from "@/core/utils/routes"; const RestoreContent = ({ rowId, mutate, setOpenRestoreDialog }) => { const [submitting, setSubmitting] = useState(false); - const requestServer = useRequest({ notification: { success: true } }); + const requestServer = useRequest({ notificationSuccess: true }); const handleClick = () => { setSubmitting(true); requestServer(`${RESTORE_BY_SUPERVISOR}/${rowId}`, "post") diff --git a/src/lib/hooks/useRequest.js b/src/lib/hooks/useRequest.js index eb30a18..ef17e84 100644 --- a/src/lib/hooks/useRequest.js +++ b/src/lib/hooks/useRequest.js @@ -8,11 +8,9 @@ const defaultOptions = { requestOptions: { headers: {}, }, - notification: { - show: true, - success: false, - failed: true, - }, + notificationShow: true, + notificationSuccess: false, + notificationFailed: true }; const useRequest = (initOptions) => { @@ -31,13 +29,13 @@ const useRequest = (initOptions) => { withCredentials: true, ...mergedOptions.requestOptions, }); - successRequest(mergedOptions.notification.show && mergedOptions.notification.success, "request_data"); + successRequest(mergedOptions.notificationShow && mergedOptions.notificationSuccess, "request_data"); return response; } catch (error) { if (error.response) { errorResponse( error.response, - mergedOptions.notification.show && mergedOptions.notification.failed, + mergedOptions.notificationShow && mergedOptions.notificationFailed, "request_data", logout ); From 2bd9fe802ef901050fa2e6ce7962e3e45b8899d0 Mon Sep 17 00:00:00 2001 From: Amirhossein Mahmoodi Date: Mon, 23 Dec 2024 12:19:49 +0330 Subject: [PATCH 2/2] change version to 0.11.1 --- .env.local.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.local.example b/.env.local.example index 5350d24..8f5293b 100644 --- a/.env.local.example +++ b/.env.local.example @@ -1,3 +1,3 @@ -NEXT_PUBLIC_VERSION="0.11.0" +NEXT_PUBLIC_VERSION="0.11.1" NEXT_PUBLIC_API_URL="https://rms.witel.ir" NEXT_PUBLIC_MAPTILE_ENDPOINT="https://rmsmap.rmto.ir/141map" \ No newline at end of file