Skip to content

Commit

Permalink
Auto stash before merge of "dev" and "origin/dev"
Browse files Browse the repository at this point in the history
  • Loading branch information
skamril committed Jan 28, 2025
1 parent 07a0c1f commit 86e6c6d
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 29 deletions.
12 changes: 6 additions & 6 deletions webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"lodash": "4.17.21",
"material-react-table": "3.0.1",
"moment": "2.30.1",
"notistack": "3.0.1",
"notistack": "3.0.2",
"plotly.js": "2.35.2",
"ramda": "0.30.1",
"ramda-adjunct": "5.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const FIRST_JANUARY_OPTIONS = Object.values(WeekDay);
////////////////////////////////////////////////////////////////

function makeRequestURL(studyId: StudyMetadata["id"]): string {
return `v1/studies/${studyId}/config/general/form`;
return `v1/studies/${studyId}/config/generadl/form`;
}

export async function getGeneralFormFields(
Expand Down
42 changes: 29 additions & 13 deletions webapp/src/components/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@
*/

import { BrowserRouter as Router, Navigate, Route, Routes, Outlet } from "react-router-dom";
import { CssBaseline, IconButton, ThemeProvider } from "@mui/material";
import { SnackbarProvider, useSnackbar, type SnackbarKey } from "notistack";
import { Alert, CssBaseline, IconButton, ThemeProvider } from "@mui/material";
import {
closeSnackbar,
SnackbarProvider,
useSnackbar,
type CustomContentProps,
type SharedProps,
} from "notistack";
import maintheme from "../../theme";
import MenuWrapper from "../wrappers/MenuWrapper";
import Studies from "./Studies";
Expand Down Expand Up @@ -62,18 +68,21 @@ import ThermalForm from "./Singlestudy/explore/Modelization/Areas/Thermal/Form";
import Renewables from "./Singlestudy/explore/Modelization/Areas/Renewables";
import RenewableForm from "./Singlestudy/explore/Modelization/Areas/Renewables/Form";
import SplitHydroMatrix from "./Singlestudy/explore/Modelization/Areas/Hydro/SplitHydroMatrix";
import CloseIcon from "@mui/icons-material/Close";
import { forwardRef } from "react";

// TODO: replace 'notistack' by 'sonner' (https://sonner.emilkowal.ski/)
function SnackbarCloseButton({ snackbarKey }: { snackbarKey: SnackbarKey }) {
const { closeSnackbar } = useSnackbar();
const Notification = forwardRef<HTMLDivElement, CustomContentProps>(
({ id, message, variant }, ref) => {
const severity = variant === "default" ? undefined : variant;

return (
<IconButton onClick={() => closeSnackbar(snackbarKey)}>
<CloseIcon />
</IconButton>
);
}
return (
<Alert ref={ref} severity={severity} variant="filled" onClose={() => closeSnackbar(id)}>
{message}
</Alert>
);
},
);

Notification.displayName = "Notification";

function App() {
return (
Expand All @@ -82,7 +91,14 @@ function App() {
<SnackbarProvider
maxSnack={5}
autoHideDuration={3000}
action={(key) => <SnackbarCloseButton snackbarKey={key} />}
Components={{
default: Notification,
error: Notification,
info: Notification,
success: Notification,
warning: Notification,
}}
//preventDuplicate
>
<CssBaseline />
<MaintenanceWrapper>
Expand Down
13 changes: 13 additions & 0 deletions webapp/src/components/common/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ import {
import { useTranslation } from "react-i18next";
import * as RA from "ramda-adjunct";
import {
Alert,
Box,
CircularProgress,
Divider,
IconButton,
setRef,
Snackbar,
Tooltip,
type SxProps,
type Theme,
Expand All @@ -55,6 +57,7 @@ import useFormApiPlus from "./useFormApiPlus";
import useFormUndoRedo from "./useFormUndoRedo";
import { mergeSxProp } from "../../../utils/muiUtils";
import useFormCloseProtection from "@/hooks/useCloseFormSecurity";
import { enqueueSnackbar } from "notistack";

export interface AutoSubmitConfig {
enable: boolean;
Expand Down Expand Up @@ -147,7 +150,17 @@ function Form<TFieldValues extends FieldValues, TContext>(
? () => {
const fn = config?.defaultValues as () => Promise<TFieldValues>;
return fn().catch((err) => {
enqueueSnackbar(t("form.asyncDefaultValues.error"), {
// variant: "error",
persist: true,
anchorOrigin: {
vertical: "bottom",
horizontal: "right",
},
});

enqueueErrorSnackbar(t("form.asyncDefaultValues.error"), err);

throw err;
});
}
Expand Down
8 changes: 0 additions & 8 deletions webapp/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,6 @@ const theme = createTheme({
},
},
},
MuiAlert: {
styleOverrides: {
root: {
backgroundColor: "#222333",
color: "#FFFFFF",
},
},
},
MuiPopover: {
styleOverrides: {
paper: {
Expand Down

0 comments on commit 86e6c6d

Please sign in to comment.