migrated from redux to recoil

This commit is contained in:
2023-07-31 12:27:36 +02:00
parent 8327d1e94c
commit b5731759b0
36 changed files with 810 additions and 741 deletions

View File

@@ -1,16 +1,19 @@
import { useDispatch } from "react-redux"
import { setMessage } from "../features/ui/toastSlice"
import { AlertColor } from "@mui/material"
import { AlertColor } from '@mui/material'
import { useRecoilState } from 'recoil'
import { toastListState } from '../atoms/toast'
export const useToast = () => {
const dispatch = useDispatch()
const [toasts, setToasts] = useRecoilState(toastListState)
return {
pushMessage: (message: string, severity?: AlertColor) => {
dispatch(setMessage({
setToasts([{
open: true,
message: message,
severity: severity
}))
severity: severity,
autoClose: true,
createdAt: Date.now()
}, ...toasts])
}
}
}