Skip to content

Commit

Permalink
Fix error handling and loading state in sign-in and sign-up pages
Browse files Browse the repository at this point in the history
  • Loading branch information
etienne committed Feb 18, 2024
1 parent 0021562 commit 61fe33e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions frontend/src/app/signin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ export default function SignIn() {
});

if (response.status === 404) {
setIsLoading(false);
alert("User not found");
setIsLoading(false);
} else if (response.status === 401) {
setIsLoading(false);
alert("Invalid password");
setIsLoading(false);
} else if (response.status === 200) {
Expand All @@ -61,6 +63,7 @@ export default function SignIn() {
localStorage.setItem("name", username);
router.push("/chat");
} else {
setIsLoading(false);
console.log(response);
alert(response);
}
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/app/signup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,15 @@ export default function SignUp() {
});

if (response.status === 408) {
setIsLoading(false);
alert("This user already exists");
} else if (response.status === 409) {
setIsLoading(false);
alert("This email already exists");
} else if (response.status === 201) {
router.push("/signin");
} else {
setIsLoading(false);
console.log(response);
alert(response);
}
Expand Down

0 comments on commit 61fe33e

Please sign in to comment.