Merge branch 'hotfix/fixed_notification'
This commit is contained in:
@@ -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_API_URL="https://rms.witel.ir"
|
||||||
NEXT_PUBLIC_MAPTILE_ENDPOINT="https://rmsmap.rmto.ir/141map"
|
NEXT_PUBLIC_MAPTILE_ENDPOINT="https://rmsmap.rmto.ir/141map"
|
||||||
@@ -40,7 +40,7 @@ const RoadSafetyFormContext = ({ rowId, mutate, setOpenRoadSafetyForm }) => {
|
|||||||
const defaultValues = {
|
const defaultValues = {
|
||||||
description: "",
|
description: "",
|
||||||
};
|
};
|
||||||
const requestServer = useRequest({ notification: { success: true, show: true } });
|
const requestServer = useRequest({ notificationSuccess: true });
|
||||||
const { message, loadingMessage, errorMessage } = usePrevStateOpinion();
|
const { message, loadingMessage, errorMessage } = usePrevStateOpinion();
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
@@ -57,7 +57,7 @@ const RoadSafetyFormContext = ({ rowId, mutate, setOpenRoadSafetyForm }) => {
|
|||||||
setOpenRoadSafetyForm(false);
|
setOpenRoadSafetyForm(false);
|
||||||
mutate();
|
mutate();
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => { });
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<StyledForm onSubmit={handleSubmit(onSubmit)}>
|
<StyledForm onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ const ReferFormContext = ({ setOpenReferDialog, rowId, mutate }) => {
|
|||||||
city: "",
|
city: "",
|
||||||
};
|
};
|
||||||
const { cities, loadingCities, errorCities } = useCities();
|
const { cities, loadingCities, errorCities } = useCities();
|
||||||
const requestServer = useRequest({ notification: { show: true, success: true } });
|
const requestServer = useRequest({ notificationSuccess: true });
|
||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
register,
|
register,
|
||||||
@@ -50,7 +50,7 @@ const ReferFormContext = ({ setOpenReferDialog, rowId, mutate }) => {
|
|||||||
setOpenReferDialog(false);
|
setOpenReferDialog(false);
|
||||||
mutate();
|
mutate();
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => { });
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<StyledForm onSubmit={handleSubmit(onSubmit)}>
|
<StyledForm onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ const RoadSafetyFormContext = ({ rowId, mutate, setOpenRoadSafetyForm }) => {
|
|||||||
const defaultValues = {
|
const defaultValues = {
|
||||||
description: "",
|
description: "",
|
||||||
};
|
};
|
||||||
const requestServer = useRequest({ notification: { success: true, show: true } });
|
const requestServer = useRequest({ notificationSuccess: true });
|
||||||
const { message, loadingMessage, errorMessage } = usePrevStateOpinion();
|
const { message, loadingMessage, errorMessage } = usePrevStateOpinion();
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
@@ -57,7 +57,7 @@ const RoadSafetyFormContext = ({ rowId, mutate, setOpenRoadSafetyForm }) => {
|
|||||||
setOpenRoadSafetyForm(false);
|
setOpenRoadSafetyForm(false);
|
||||||
mutate();
|
mutate();
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => { });
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<StyledForm onSubmit={handleSubmit(onSubmit)}>
|
<StyledForm onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ const ReferFormContext = ({ setOpenReferDialog, rowId, mutate }) => {
|
|||||||
province: "",
|
province: "",
|
||||||
};
|
};
|
||||||
const { provinces, loadingProvinces, errorProvinces } = useProvinces();
|
const { provinces, loadingProvinces, errorProvinces } = useProvinces();
|
||||||
const requestServer = useRequest({ notification: { show: true, success: true } });
|
const requestServer = useRequest({ notificationSuccess: true });
|
||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
register,
|
register,
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ const RoadSafetyFormContext = ({ rowId, mutate, setOpenRoadSafetyForm }) => {
|
|||||||
description: "",
|
description: "",
|
||||||
RadioGroup: "",
|
RadioGroup: "",
|
||||||
};
|
};
|
||||||
const requestServer = useRequest({ notification: { success: true, show: true } });
|
const requestServer = useRequest({ notificationSuccess: true });
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ const CreateFormContent = ({ setOpen, mutate, rowId }) => {
|
|||||||
const [itemsList, setItemsList] = useState();
|
const [itemsList, setItemsList] = useState();
|
||||||
const [subItemsList, setSubItemsList] = useState([]);
|
const [subItemsList, setSubItemsList] = useState([]);
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const requestServer = useRequest({ notification: { success: true } });
|
const requestServer = useRequest({ notificationSuccess: true });
|
||||||
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
|
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const PrintExcel = ({ table, filterData }) => {
|
|||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
|
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
|
||||||
const [loading, setLoading] = useState(false);
|
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]) => {
|
const activeFilters = Object.entries(filterData).reduce((acc, [key, filter]) => {
|
||||||
if (filter.value) {
|
if (filter.value) {
|
||||||
// Check if there's an active filter
|
// Check if there's an active filter
|
||||||
@@ -39,7 +39,7 @@ const PrintExcel = ({ table, filterData }) => {
|
|||||||
const filename = `خروجی کارتابل فعالیت روزانه تاریخ_${moment().format("jYYYY_jMM_jDD")}.xlsx`;
|
const filename = `خروجی کارتابل فعالیت روزانه تاریخ_${moment().format("jYYYY_jMM_jDD")}.xlsx`;
|
||||||
FileSaver.saveAs(response.data, filename);
|
FileSaver.saveAs(response.data, filename);
|
||||||
})
|
})
|
||||||
.catch(() => {})
|
.catch(() => { })
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -97,14 +97,14 @@ const EditFormContent = ({ row, mutate, setOpenEditDialog, rowId, subItem }) =>
|
|||||||
subItem.needs_end_point === 1 && formData.append("end_point", endPoint);
|
subItem.needs_end_point === 1 && formData.append("end_point", endPoint);
|
||||||
|
|
||||||
requestServer(`${UPDATE_ROAD_ITEMS}/${rowId}`, "post", {
|
requestServer(`${UPDATE_ROAD_ITEMS}/${rowId}`, "post", {
|
||||||
notification: { success: true },
|
notificationSuccess: true,
|
||||||
data: formData,
|
data: formData,
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
mutate();
|
mutate();
|
||||||
setOpenEditDialog(false);
|
setOpenEditDialog(false);
|
||||||
})
|
})
|
||||||
.catch((err) => {});
|
.catch((err) => { });
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import useRequest from "@/lib/hooks/useRequest";
|
|||||||
import { VERIFY_BY_SUPERVISOR } from "@/core/utils/routes";
|
import { VERIFY_BY_SUPERVISOR } from "@/core/utils/routes";
|
||||||
|
|
||||||
const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog }) => {
|
const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog }) => {
|
||||||
const requestServer = useRequest({ notification: { success: true } });
|
const requestServer = useRequest({ notificationSuccess: true });
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
@@ -28,7 +28,7 @@ const ConfirmContent = ({ rowId, mutate, setOpenConfirmDialog }) => {
|
|||||||
mutate();
|
mutate();
|
||||||
setOpenConfirmDialog(false);
|
setOpenConfirmDialog(false);
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => { });
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { DELETE_BY_SUPERVISOR } from "@/core/utils/routes";
|
|||||||
|
|
||||||
const DeleteContent = ({ rowId, mutate, setOpenDeleteDialog }) => {
|
const DeleteContent = ({ rowId, mutate, setOpenDeleteDialog }) => {
|
||||||
const [submitting, setSubmitting] = useState(false);
|
const [submitting, setSubmitting] = useState(false);
|
||||||
const requestServer = useRequest({ notification: { success: true } });
|
const requestServer = useRequest({ notificationSuccess: true });
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
requestServer(`${DELETE_BY_SUPERVISOR}/${rowId}`, "post")
|
requestServer(`${DELETE_BY_SUPERVISOR}/${rowId}`, "post")
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import useRequest from "@/lib/hooks/useRequest";
|
|||||||
import { REJECT_BY_SUPERVISOR } from "@/core/utils/routes";
|
import { REJECT_BY_SUPERVISOR } from "@/core/utils/routes";
|
||||||
|
|
||||||
const RejectContent = ({ rowId, mutate, setOpenRejectDialog }) => {
|
const RejectContent = ({ rowId, mutate, setOpenRejectDialog }) => {
|
||||||
const requestServer = useRequest({ notification: { success: true } });
|
const requestServer = useRequest({ notificationSuccess: true });
|
||||||
|
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = Yup.object().shape({
|
||||||
description: Yup.string().required("توضیحات الزامیست!!!"),
|
description: Yup.string().required("توضیحات الزامیست!!!"),
|
||||||
@@ -36,7 +36,7 @@ const RejectContent = ({ rowId, mutate, setOpenRejectDialog }) => {
|
|||||||
mutate();
|
mutate();
|
||||||
setOpenRejectDialog(false);
|
setOpenRejectDialog(false);
|
||||||
})
|
})
|
||||||
.catch(() => {})
|
.catch(() => { })
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
reset();
|
reset();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { RESTORE_BY_SUPERVISOR } from "@/core/utils/routes";
|
|||||||
|
|
||||||
const RestoreContent = ({ rowId, mutate, setOpenRestoreDialog }) => {
|
const RestoreContent = ({ rowId, mutate, setOpenRestoreDialog }) => {
|
||||||
const [submitting, setSubmitting] = useState(false);
|
const [submitting, setSubmitting] = useState(false);
|
||||||
const requestServer = useRequest({ notification: { success: true } });
|
const requestServer = useRequest({ notificationSuccess: true });
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
requestServer(`${RESTORE_BY_SUPERVISOR}/${rowId}`, "post")
|
requestServer(`${RESTORE_BY_SUPERVISOR}/${rowId}`, "post")
|
||||||
|
|||||||
@@ -8,11 +8,9 @@ const defaultOptions = {
|
|||||||
requestOptions: {
|
requestOptions: {
|
||||||
headers: {},
|
headers: {},
|
||||||
},
|
},
|
||||||
notification: {
|
notificationShow: true,
|
||||||
show: true,
|
notificationSuccess: false,
|
||||||
success: false,
|
notificationFailed: true
|
||||||
failed: true,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const useRequest = (initOptions) => {
|
const useRequest = (initOptions) => {
|
||||||
@@ -31,13 +29,13 @@ const useRequest = (initOptions) => {
|
|||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
...mergedOptions.requestOptions,
|
...mergedOptions.requestOptions,
|
||||||
});
|
});
|
||||||
successRequest(mergedOptions.notification.show && mergedOptions.notification.success, "request_data");
|
successRequest(mergedOptions.notificationShow && mergedOptions.notificationSuccess, "request_data");
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
errorResponse(
|
errorResponse(
|
||||||
error.response,
|
error.response,
|
||||||
mergedOptions.notification.show && mergedOptions.notification.failed,
|
mergedOptions.notificationShow && mergedOptions.notificationFailed,
|
||||||
"request_data",
|
"request_data",
|
||||||
logout
|
logout
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user