* added error snackbar for api fails * improved error page to be shown only for userdata errors and to allow retrying * fixed test breaking only in local because of timezone and reduced warnings for easier reading of tests results * added error management for failure inside calendars imports * added error snackbar for api fails * improved error page to be shown only for userdata errors and to allow retrying * added error management for failure inside calendars imports Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
@@ -1,13 +1,51 @@
|
||||
import Snackbar from "@mui/material/Snackbar";
|
||||
import Alert from "@mui/material/Alert";
|
||||
import Button from "@mui/material/Button";
|
||||
import { useAppDispatch } from "../../app/hooks";
|
||||
import { clearError as calendarClearError } from "../../features/Calendars/CalendarSlice";
|
||||
import { clearError as userClearError } from "../../features/User/userSlice";
|
||||
|
||||
interface Props {
|
||||
messages: string[];
|
||||
onClose: () => void;
|
||||
export function ErrorSnackbar({
|
||||
error,
|
||||
type,
|
||||
}: {
|
||||
error: string | null;
|
||||
type: "user" | "calendar";
|
||||
}) {
|
||||
const dispatch = useAppDispatch();
|
||||
const handleCloseSnackbar = () => {
|
||||
dispatch(type === "calendar" ? calendarClearError() : userClearError());
|
||||
};
|
||||
|
||||
return (
|
||||
<Snackbar
|
||||
open={!!error}
|
||||
onClose={handleCloseSnackbar}
|
||||
anchorOrigin={{ vertical: "bottom", horizontal: "center" }}
|
||||
>
|
||||
<Alert
|
||||
severity="error"
|
||||
onClose={handleCloseSnackbar}
|
||||
sx={{ width: "100%" }}
|
||||
action={
|
||||
<Button color="inherit" size="small" onClick={handleCloseSnackbar}>
|
||||
OK
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
{error}
|
||||
</Alert>
|
||||
</Snackbar>
|
||||
);
|
||||
}
|
||||
|
||||
export function EventErrorSnackbar({ messages, onClose }: Props) {
|
||||
export function EventErrorSnackbar({
|
||||
messages,
|
||||
onClose,
|
||||
}: {
|
||||
messages: string[];
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const open = messages.length > 0;
|
||||
const summary =
|
||||
messages.length === 1
|
||||
|
||||
Reference in New Issue
Block a user