Update: add more toast notifications, update position

Also set Account page to use UserContext. Refactored api requests out of components.
This commit is contained in:
Aaron William Po
2023-05-22 22:41:37 -04:00
parent 27e72d3dcf
commit 4c30af27b6
16 changed files with 242 additions and 188 deletions

View File

@@ -32,15 +32,15 @@ const LoginForm = () => {
const { mutate } = useContext(UserContext);
const onSubmit: SubmitHandler<LoginT> = async (data) => {
const id = toast.loading('Logging in.');
const loadingToast = toast.loading('Logging in...');
try {
await sendLoginUserRequest(data);
await mutate!();
toast.remove(id);
toast.remove(loadingToast);
toast.success('Logged in!');
await router.push(`/user/current`);
} catch (error) {
toast.remove(id);
toast.remove(loadingToast);
createErrorToast(error);
reset();
}