diff --git a/src/components/DeleteDialogue.tsx b/src/components/DeleteDialogue.tsx index 1cafb17..712e002 100644 --- a/src/components/DeleteDialogue.tsx +++ b/src/components/DeleteDialogue.tsx @@ -3,13 +3,9 @@ import agent from '../api/agent' import { useNavigate } from 'react-router-dom' import { Data } from '../models/game' import { - AlertDialog, - AlertDialogBody, - AlertDialogContent, AlertDialogFooter, - AlertDialogHeader, - AlertDialogOverlay, - Button, Icon, Text + Button, Text } from '@chakra-ui/react' +import {DialogBody, DialogContent, DialogFooter, DialogHeader, DialogRoot} from './ui/dialog' type Props = { id: string @@ -44,34 +40,31 @@ export default function DeleteDialogue({ } } - const cancelRef = useRef(null) + const cancelRef = useRef(null) return ( - - - - - Delete? - - Are you sure you would like to delete {game.title}? - - - - - - - - + { if (!e.open) handleClose() }} role="alertdialog" initialFocusEl={() => cancelRef.current}> + + Delete? + + Are you sure you would like to delete {game.title}? + + + + + + + ) } diff --git a/src/components/authComponents/AdminMode.tsx b/src/components/authComponents/AdminMode.tsx index 51122a2..26bc7dc 100644 --- a/src/components/authComponents/AdminMode.tsx +++ b/src/components/authComponents/AdminMode.tsx @@ -1,5 +1,6 @@ import React from 'react' -import { Checkbox, Text } from '@chakra-ui/react' +import { Text } from '@chakra-ui/react' +import {Checkbox} from '../ui/checkbox' import { adminModeToggle, loggedInUser, adminMode } from '../../stateManagement/userState' import { useHookstate } from '@hookstate/core' @@ -8,8 +9,8 @@ export default function AdminMode() { const admin = useHookstate(adminMode).get() return ( - adminModeToggle()} isChecked={admin} isDisabled={!(user.role === 'admin')}> + adminModeToggle()} checked={admin} disabled={!(user.role === 'admin')}> Administrator Mode ) -} \ No newline at end of file +} diff --git a/src/components/authComponents/ForgotPassword.tsx b/src/components/authComponents/ForgotPassword.tsx index 4348f7f..adb9ad6 100644 --- a/src/components/authComponents/ForgotPassword.tsx +++ b/src/components/authComponents/ForgotPassword.tsx @@ -3,11 +3,11 @@ import { useForm } from 'react-hook-form' import { Container, Button, - FormControl, - FormLabel, Input, - useColorModeValue, FormErrorMessage, useToast, } from '@chakra-ui/react' +import {Field} from '../ui/field' +import {useColorModeValue} from '../ui/color-mode' +import {toaster} from '../ui/toaster' import agent from '../../api/agent' import { IForgotPassword } from '../../models/user' @@ -18,7 +18,6 @@ export default function ForgotPassword() { handleSubmit, formState: { errors, isSubmitting, isDirty }, } = useForm() - const toast = useToast() interface Message { success: boolean @@ -27,27 +26,25 @@ export default function ForgotPassword() { const onSubmit = handleSubmit(async (values) => { const message = await agent.Account.forgot(values as IForgotPassword) as Message - toast({ + toaster.create({ title: 'Email Sent', - status: 'success', + type: 'success', description: message.data, - isClosable: true, + closable: true, duration: 10000, - position: 'top' }) }) return (
- - Email + - - {errors.email?.type === 'required' && errors.email.message?.toString()} - {errors.email?.type === 'pattern' && 'Invalid Email Address'} - - +
diff --git a/src/components/authComponents/LoginForm.tsx b/src/components/authComponents/LoginForm.tsx index 5e5ba8f..47ab793 100644 --- a/src/components/authComponents/LoginForm.tsx +++ b/src/components/authComponents/LoginForm.tsx @@ -5,11 +5,10 @@ import { login } from '../../stateManagement/userState' import { Container, Button, - FormControl, - FormLabel, - Input, - useColorModeValue, HStack, Center, FormErrorMessage, + Input, HStack, Center, } from '@chakra-ui/react' +import {Field} from '../ui/field' +import {useColorModeValue} from '../ui/color-mode' import { Link } from 'react-router-dom' export default function LoginForm() { @@ -38,14 +37,13 @@ export default function LoginForm() { return ( - - Email + - - {errors.email?.type === 'required' && errors.email.message?.toString()} - {errors.email?.type === 'pattern' && 'Invalid Email Address'} - - - - Password + + - - {errors.password && errors.password.message?.toString()} - - +
- +
diff --git a/src/components/authComponents/ResetPassword.tsx b/src/components/authComponents/ResetPassword.tsx index aec3cc9..3cdc3d3 100644 --- a/src/components/authComponents/ResetPassword.tsx +++ b/src/components/authComponents/ResetPassword.tsx @@ -4,10 +4,11 @@ import { IResetPassword } from '../../models/user' import { Button, Container, - FormControl, - FormLabel, - Input, useToast, useColorModeValue, FormErrorMessage, + Input, } from '@chakra-ui/react' +import {Field} from '../ui/field' +import {useColorModeValue} from '../ui/color-mode' +import {toaster} from '../ui/toaster' import agent from '../../api/agent' import { useNavigate, useParams } from 'react-router-dom' @@ -17,7 +18,7 @@ interface Message { } interface URL { - token: string + token?: string } export default function ResetPassword() { @@ -27,32 +28,29 @@ export default function ResetPassword() { watch, formState: { errors, isSubmitting, isDirty }, } = useForm() - const { token } = useParams() + const { token } = useParams() const history = useNavigate() - const toast = useToast() const password = useRef({}) password.current = watch('password', '') const onSubmit = handleSubmit(async (data) => { - const message = await agent.Account.reset(token, data as IResetPassword) as Message + const message = await agent.Account.reset(token!, data as IResetPassword) as Message if (message.success) { setTimeout(() => history('/login'), 3000) - toast({ + toaster.create({ title: 'Password Reset', - status: 'success', + type: 'success', description: 'Your password has been reset. You will be redirected to login automatically', - isClosable: true, + closable: true, duration: 5000, - position: 'top', }) } else { - toast({ + toaster.create({ title: 'Password Not Reset', - status: 'error', + type: 'error', description: 'Something went wrong, please contact the website administrator', - isClosable: true, + closable: true, duration: 10000, - position: 'top', }) } }) @@ -62,15 +60,14 @@ export default function ResetPassword() { return (
- - Password + - - {errors.password && errors.password.message?.toString()} - - - - Repeat Password + + - - {errors.repeat_password && errors.repeat_password.message?.toString()} - - +
diff --git a/src/components/userComponents/CreateUser.tsx b/src/components/userComponents/CreateUser.tsx index 8e3cc58..88ea2fe 100644 --- a/src/components/userComponents/CreateUser.tsx +++ b/src/components/userComponents/CreateUser.tsx @@ -3,15 +3,13 @@ import { useForm } from 'react-hook-form' import { UserFormValues } from '../../models/user' import { createUser } from '../../stateManagement/userState' import { - Alert, - AlertDescription, - AlertIcon, Button, Container, - FormControl, FormErrorMessage, - FormLabel, - Input, useColorModeValue, + Input, } from '@chakra-ui/react' +import {Field} from '../ui/field' +import {Alert} from '../ui/alert' +import {useColorModeValue} from '../ui/color-mode' export default function CreateUser() { const { @@ -44,59 +42,52 @@ export default function CreateUser() { return ( - - Full Name + - {errors.name && { errors.name.message?.toString()}} - - - Display Name + + - {errors.displayName && { errors.displayName.message?.toString()}} - - - Email + + - {errors.email && { errors.email.message?.toString()}} - - - Password + + - {errors.password && { errors.password.message?.toString()}} - + {errors.password && ( <> - - - {errors.password.message?.toString()} - {/**/} + + {errors.password.message?.toString()}
)} - - Repeat Password + - {errors.repeat_password && { errors.repeat_password.message?.toString()}} - + {errors.repeat_password && ( <> - - - {errors.repeat_password.message?.toString()} - {/**/} + + {errors.repeat_password.message?.toString()} )}
diff --git a/src/components/userComponents/EditUser.tsx b/src/components/userComponents/EditUser.tsx index fec1405..5acfecb 100644 --- a/src/components/userComponents/EditUser.tsx +++ b/src/components/userComponents/EditUser.tsx @@ -5,14 +5,14 @@ import { loadedPreferences, loggedInUser, updateUserPreferences } from '../../st import { Button, Container, Flex, - FormControl, - FormLabel, Heading, Input, - Stack, Switch, - useColorModeValue, - useToast, + Stack, } from '@chakra-ui/react' +import {Field} from '../ui/field' +import {Switch} from '../ui/switch' +import {useColorModeValue} from '../ui/color-mode' +import {toaster} from '../ui/toaster' import { useHookstate } from '@hookstate/core' import agent from '../../api/agent' import { useNavigate } from 'react-router-dom' @@ -43,12 +43,10 @@ export default function EditUser() { const history = useNavigate() useEffect(() => { - reset(user) + reset(user as any) return }, [user.name !== '']) - const toast = useToast() - interface Message { success: boolean data: string @@ -66,13 +64,12 @@ export default function EditUser() { const engageChangePassword = async (values: IForgotPassword) => { const message = await agent.Account.forgot(values as IForgotPassword) as Message - toast({ + toaster.create({ title: 'Email Sent', - status: 'success', + type: 'success', description: message.data, - isClosable: true, + closable: true, duration: 10000, - position: 'top' }) } @@ -90,78 +87,70 @@ export default function EditUser() { Edit {user.displayName} - - Full Name + - - - Display Name + + - - - Email + + - - - - Dark Mode: + + ( - + onChange(checked)} ref={ref} /> )} /> - - - - - Sticky Navbar: + + ( - + onChange(checked)} ref={ref} /> )} /> - - +
- + @@ -42,28 +40,28 @@ const UserProfile = () => { - - - - - - - - - - - - - - - - - - - - -
Display Name: {user.displayName}
Full Name: {user.name}
Email: {user.email}
Role: {user.role}
-
+ + + + + Display Name: + {user.displayName} + + + Full Name: + {user.name} + + + Email: + {user.email} + + + Role: + {user.role} + + + +
diff --git a/src/errors/NotFound.tsx b/src/errors/NotFound.tsx index eb554c0..704ef71 100644 --- a/src/errors/NotFound.tsx +++ b/src/errors/NotFound.tsx @@ -29,8 +29,8 @@ export default function NotFound() { It looks like you hit a{' '} {DEAD} end! - }>