mirror of
https://github.com/ershisan99/it-incubator-todolist-ts-17-live-2024-08-17.git
synced 2026-02-03 21:02:12 +00:00
chore: add prettier and run it on all files
This commit is contained in:
@@ -1,37 +1,53 @@
|
||||
import React from 'react'
|
||||
import {useDispatch, useSelector} from 'react-redux'
|
||||
import {AppRootStateType} from '../../app/store'
|
||||
import {setAppErrorAC} from '../../app/app-reducer'
|
||||
import { useDispatch, useSelector } from 'react-redux'
|
||||
import { AppRootStateType } from '../../app/store'
|
||||
import { setAppErrorAC } from '../../app/app-reducer'
|
||||
import { AlertProps, Snackbar } from '@mui/material'
|
||||
import MuiAlert from '@mui/material/Alert';
|
||||
import MuiAlert from '@mui/material/Alert'
|
||||
|
||||
const Alert = React.forwardRef<HTMLDivElement, AlertProps>(function Alert(
|
||||
props,
|
||||
ref,
|
||||
) {
|
||||
return <MuiAlert elevation={6} ref={ref} variant="filled" {...props} />;
|
||||
});
|
||||
const Alert = React.forwardRef<HTMLDivElement, AlertProps>(
|
||||
function Alert(props, ref) {
|
||||
return (
|
||||
<MuiAlert
|
||||
elevation={6}
|
||||
ref={ref}
|
||||
variant='filled'
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
export function ErrorSnackbar() {
|
||||
const error = useSelector<AppRootStateType, string | null>(
|
||||
(state) => state.app.error
|
||||
)
|
||||
const dispatch = useDispatch()
|
||||
|
||||
const error = useSelector<AppRootStateType, string | null>(state => state.app.error);
|
||||
const dispatch = useDispatch()
|
||||
|
||||
const handleClose = (event?: React.SyntheticEvent | Event, reason?: string) => {
|
||||
if (reason === 'clickaway') {
|
||||
return
|
||||
}
|
||||
dispatch(setAppErrorAC(null));
|
||||
const handleClose = (
|
||||
event?: React.SyntheticEvent | Event,
|
||||
reason?: string
|
||||
) => {
|
||||
if (reason === 'clickaway') {
|
||||
return
|
||||
}
|
||||
dispatch(setAppErrorAC(null))
|
||||
}
|
||||
|
||||
const isOpen = error !== null
|
||||
|
||||
const isOpen = error !== null;
|
||||
|
||||
return (
|
||||
<Snackbar open={isOpen} autoHideDuration={6000} onClose={handleClose}>
|
||||
<Alert onClose={handleClose} severity="error">
|
||||
{error}
|
||||
</Alert>
|
||||
</Snackbar>
|
||||
)
|
||||
return (
|
||||
<Snackbar
|
||||
open={isOpen}
|
||||
autoHideDuration={6000}
|
||||
onClose={handleClose}
|
||||
>
|
||||
<Alert
|
||||
onClose={handleClose}
|
||||
severity='error'
|
||||
>
|
||||
{error}
|
||||
</Alert>
|
||||
</Snackbar>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user