-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Combine POST endpoint frontend and backend
- Loading branch information
1 parent
17e6a8d
commit 3a5c4c3
Showing
4 changed files
with
90 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import Snackbar from "@mui/material/Snackbar"; | ||
import Alert from "@mui/material/Alert"; | ||
import { Dispatch, SetStateAction, SyntheticEvent } from "react"; | ||
import { ApiResponseStatusSnackbar } from "../../types/Api.ts"; | ||
|
||
type ApiStatusSnackbarProps = { | ||
apiRequestStatusSnackbar: ApiResponseStatusSnackbar; | ||
setApiRequestStatusSnackbar: Dispatch< | ||
SetStateAction<ApiResponseStatusSnackbar> | ||
>; | ||
}; | ||
|
||
export default function ApiStatusSnackbar({ | ||
apiRequestStatusSnackbar, | ||
setApiRequestStatusSnackbar, | ||
}: Readonly<ApiStatusSnackbarProps>) { | ||
const handleClose = (_event?: SyntheticEvent | Event, reason?: string) => { | ||
if (reason === "clickaway") { | ||
return; | ||
} | ||
|
||
setApiRequestStatusSnackbar({ ...apiRequestStatusSnackbar, open: false }); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Snackbar | ||
open={apiRequestStatusSnackbar.open} | ||
autoHideDuration={6000} | ||
onClose={handleClose} | ||
> | ||
<Alert | ||
onClose={handleClose} | ||
severity={apiRequestStatusSnackbar.severity} | ||
variant="filled" | ||
sx={{ width: "100%" }} | ||
> | ||
{apiRequestStatusSnackbar.message} | ||
</Alert> | ||
</Snackbar> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export type ApiResponseStatusSnackbar = { | ||
open: boolean; | ||
severity: "success" | "error"; | ||
message: string; | ||
}; |