Change validation error toast to a user friendly message

This commit is contained in:
Alex Holliday committed 2024-10-17 11:59:31 +08:00
1 parent d8e2b06eca
commit 2b6c2bad6a
1 file changed
+16 -12
@@ -46,9 +46,7 @@ const CreateMonitor = () => {
useEffect(() => { useEffect(() => {
const fetchMonitor = async () => { const fetchMonitor = async () => {
if (monitorId) { if (monitorId) {
const action = await dispatch( const action = await dispatch(getUptimeMonitorById({ authToken, monitorId }));
getUptimeMonitorById({ authToken, monitorId })
);
if (action.payload.success) { if (action.payload.success) {
const data = action.payload.data; const data = action.payload.data;
@@ -146,7 +144,7 @@ const CreateMonitor = () => {
newErrors[err.path[0]] = err.message; newErrors[err.path[0]] = err.message;
}); });
setErrors(newErrors); setErrors(newErrors);
createToast({ body: "Error validation data." }); createToast({ body: "Please check your input for errors and try again" });
} else { } else {
form = { form = {
...form, ...form,
@@ -155,9 +153,7 @@ const CreateMonitor = () => {
userId: user._id, userId: user._id,
notifications: monitor.notifications, notifications: monitor.notifications,
}; };
const action = await dispatch( const action = await dispatch(createUptimeMonitor({ authToken, monitor: form }));
createUptimeMonitor({ authToken, monitor: form })
);
if (action.meta.requestStatus === "fulfilled") { if (action.meta.requestStatus === "fulfilled") {
createToast({ body: "Monitor created successfully!" }); createToast({ body: "Monitor created successfully!" });
navigate("/monitors"); navigate("/monitors");
@@ -193,8 +189,14 @@ const CreateMonitor = () => {
gap={theme.spacing(12)} gap={theme.spacing(12)}
mt={theme.spacing(6)} mt={theme.spacing(6)}
> >
<Typography component="h1" variant="h1"> <Typography
<Typography component="span" fontSize="inherit"> component="h1"
variant="h1"
>
<Typography
component="span"
fontSize="inherit"
>
Create your{" "} Create your{" "}
</Typography> </Typography>
<Typography <Typography
@@ -210,8 +212,7 @@ const CreateMonitor = () => {
<Box> <Box>
<Typography component="h2">General settings</Typography> <Typography component="h2">General settings</Typography>
<Typography component="p"> <Typography component="p">
Here you can select the URL of the host, together with the type of Here you can select the URL of the host, together with the type of monitor.
monitor.
</Typography> </Typography>
</Box> </Box>
<Stack gap={theme.spacing(15)}> <Stack gap={theme.spacing(15)}>
@@ -368,7 +369,10 @@ const CreateMonitor = () => {
/> />
</Stack> </Stack>
</ConfigBox> </ConfigBox>
<Stack direction="row" justifyContent="flex-end"> <Stack
direction="row"
justifyContent="flex-end"
>
<Button <Button
variant="contained" variant="contained"
color="primary" color="primary"