diff options
Diffstat (limited to 'client/src/components/GuestLogin.tsx')
-rw-r--r-- | client/src/components/GuestLogin.tsx | 42 |
1 files changed, 11 insertions, 31 deletions
diff --git a/client/src/components/GuestLogin.tsx b/client/src/components/GuestLogin.tsx index acf229f..0e5dcb6 100644 --- a/client/src/components/GuestLogin.tsx +++ b/client/src/components/GuestLogin.tsx @@ -1,32 +1,12 @@ import React, { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { useDispatch } from 'react-redux'; -import { - Alert, - Button, - Paper, - Snackbar, - TextField, - Typography, -} from '@mui/material'; +import { Button, Paper, Snackbar, TextField, Typography } from '@mui/material'; import { useForm } from 'react-hook-form'; import { setGuest } from '../slices/auth/guestSlice'; import { useLoginGuestMutation } from '../slices/api/guestSlice'; import type { Name, StatusProps } from '../models'; -import { isFetchBaseQueryError } from '../error'; -import type { Data } from '../error'; - -const Status = ({ error, setOpen }: StatusProps) => { - return isFetchBaseQueryError(error) ? ( - <Alert severity="error" onClose={() => setOpen(false)}> - {(error.data as Data).message} - </Alert> - ) : ( - <Alert severity="error" onClose={() => setOpen(false)}> - Guest login failed - </Alert> - ); -}; +import Status from './Status'; function GuestLogin() { const dispatch = useDispatch(); @@ -104,16 +84,16 @@ function GuestLogin() { <Button type="submit" variant="contained" fullWidth sx={{ mt: 2 }}> Log in </Button> + <Snackbar + open={!isLoading && open} + onClose={() => setOpen(false)} + autoHideDuration={5000} + > + <div> + <Status {...({ error, setOpen, type: 'Guest' } as StatusProps)} /> + </div> + </Snackbar> </Paper> - <Snackbar - open={!isLoading && open} - onClose={() => setOpen(false)} - autoHideDuration={5000} - > - <div> - <Status {...({ error, setOpen } as StatusProps)} /> - </div> - </Snackbar> </form> ); } |