Skip to content

Commit

Permalink
errors
Browse files Browse the repository at this point in the history
  • Loading branch information
NishantGupt786 committed Mar 17, 2024
1 parent 5c2826f commit fd65c83
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
18 changes: 17 additions & 1 deletion devsoc24-portal-fe/src/app/edit-idea/edit-idea-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,23 @@ export default function EditIdeaForm() {
void toast.promise(handleSubmit(), {
loading: `Cooking..`,
success: `Idea updated successfully!`,
error: `Something went wrong!`,
error: (err: AxiosError) => {
switch (err.response?.status) {
case 404:
return `Account not found!`;
case 403:
return `User is not a leader`;
case 409:
return `User is not in a team`;
case 400:
return `Please check your input and try again!`;
case 401:
void router.push("/");
return `Session Expired`;
default:
return `Something went wrong!`;
}
},
});
}

Expand Down
18 changes: 17 additions & 1 deletion devsoc24-portal-fe/src/app/edit-project/edit-subject-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,23 @@ export default function EditProjectForm() {
void toast.promise(handleSubmit(), {
loading: "Cooking...",
success: `Project submitted successfully!`,
error: `Something went wrong!`,
error: (err: AxiosError) => {
switch (err.response?.status) {
case 404:
return `Account not found!`;
case 403:
return `User is not a leader`;
case 409:
return `User is not in a team`;
case 400:
return `Please check your input and try again!`;
case 401:
void router.push("/");
return `Session Expired`;
default:
return `Something went wrong!`;
}
},
});
}

Expand Down
4 changes: 3 additions & 1 deletion devsoc24-portal-fe/src/app/submit-idea/submit-idea-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ export default function SubmitIdeaForm() {
switch (err.response?.status) {
case 404:
return `Account not found!`;
case 403:
return `User is not a leader`;
case 409:
return `Incorrect credentials`;
return `User is not in a team`;
case 400:
return `Please check your input and try again!`;
case 401:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ export default function SubmitProjectForm() {
},
error: (err: AxiosError) => {
switch (err.response?.status) {
case 403:
return `User is not a leader`;
case 409:
return `User is not in a team`;
case 404:
return `Account not found!`;
case 401:
Expand Down

0 comments on commit fd65c83

Please # to comment.