Merge branch 'hotfix/fixed_notification'

This commit is contained in:
Amirhossein Mahmoodi
2024-12-23 12:20:03 +03:30
14 changed files with 25 additions and 27 deletions

View File

@@ -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"

View File

@@ -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 (
<StyledForm onSubmit={handleSubmit(onSubmit)}>

View File

@@ -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 (
<StyledForm onSubmit={handleSubmit(onSubmit)}>

View File

@@ -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 (
<StyledForm onSubmit={handleSubmit(onSubmit)}>

View File

@@ -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,

View File

@@ -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,

View File

@@ -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);

View File

@@ -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);
});

View File

@@ -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 (
<>

View File

@@ -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 (

View File

@@ -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")

View File

@@ -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();
});

View File

@@ -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")

View File

@@ -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
);