Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): add close button on success notifications and change auto hide duration #1995

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ function AddDialog({
dispatch(setCurrentBindingConst(createdConstraint.id));
enqueueSnackbar(t("study.success.addBindingConst"), {
variant: "success",
autoHideDuration: 1500,
});
onClose();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ function AddConstraintTermDialog({

enqueueSnackbar(t("study.success.createConstraintTerm"), {
variant: "success",
autoHideDuration: 2000,
});
} catch (e) {
enqueueErrorSnackbar(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ function BindingConstForm({ study, options, constraintId }: Props) {

enqueueSnackbar(t("global.update.success"), {
variant: "success",
autoHideDuration: 1500,
});
} catch (error) {
enqueueErrorSnackbar(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ function BindingConstView({ constraintId }: Props) {

enqueueSnackbar(t("study.success.deleteConstraint"), {
variant: "success",
autoHideDuration: 1500,
});
} catch (e) {
enqueueErrorSnackbar(t("study.error.deleteConstraint"), e as AxiosError);
Expand Down
22 changes: 19 additions & 3 deletions webapp/src/components/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
Routes,
Outlet,
} from "react-router-dom";
import { CssBaseline, ThemeProvider } from "@mui/material";
import { SnackbarProvider } from "notistack";
import { CssBaseline, IconButton, ThemeProvider } from "@mui/material";
import { SnackbarKey, SnackbarProvider, useSnackbar } from "notistack";
import maintheme from "../../theme";
import MenuWrapper from "../wrappers/MenuWrapper";
import Studies from "./Studies";
Expand Down Expand Up @@ -54,12 +54,28 @@ import StorageForm from "./Singlestudy/explore/Modelization/Areas/Storages/Form"
import ThermalForm from "./Singlestudy/explore/Modelization/Areas/Thermal/Form";
import RenewablesForm from "./Singlestudy/explore/Modelization/Areas/Renewables/Form";
import SplitHydroMatrix from "./Singlestudy/explore/Modelization/Areas/Hydro/SplitHydroMatrix";
import CloseIcon from "@mui/icons-material/Close";

// TODO: replace 'notistack' by 'sonner' (https://sonner.emilkowal.ski/)
function SnackbarCloseButton({ snackbarKey }: { snackbarKey: SnackbarKey }) {
const { closeSnackbar } = useSnackbar();

return (
<IconButton onClick={() => closeSnackbar(snackbarKey)}>
<CloseIcon />
</IconButton>
);
}

function App() {
return (
<Router>
<ThemeProvider theme={maintheme}>
<SnackbarProvider maxSnack={5}>
<SnackbarProvider
maxSnack={5}
autoHideDuration={3000}
action={(key) => <SnackbarCloseButton snackbarKey={key} />}
>
<CssBaseline />
<MaintenanceWrapper>
<LoginWrapper>
Expand Down
Loading