Skip to content

Commit

Permalink
adding more error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
avsomers25 committed Oct 10, 2024
1 parent 8a141fb commit 73e5c82
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
8 changes: 5 additions & 3 deletions app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,18 @@ export default function Dashboard() {
else{
console.log("THIS FIELD IS FAIL" + requiredFields[i])
trigger(requiredFields[i] as any, { shouldFocus: true });
alert(`Please scroll down and fill out ${fieldtext[i]} the entire profile before registering`);
alert(`Please scroll down and fill out ${fieldtext[i]} and the entire profile and save before registering`);
return;
}
}
}

await UploadWaiver(data);
if (Object.keys(errors).length === 0) {
RegisterSelf();
setUserData({ ...userData, registration_status: "registered" })
const resp = await RegisterSelf();
if (resp == "User updated successfully"){
setUserData({ ...userData, registration_status: "registered" })
}
}

//window.location.reload();
Expand Down
7 changes: 5 additions & 2 deletions app/lib/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,15 @@ export async function SetUser(data: any, user_email_to_update: string) {
.then(async (res) => {
let resJSON = await res.json();
if (resJSON.statusCode !== 200) {
if (resJSON.body) {
resp.error = resJSON.body;
if (resJSON?.error) {
resp.error = resJSON.error;
} else {
resp.error = 'Unexpected Error';
}
}
else{
resp.response = resJSON.message;
}
})
.catch((error) => {
resp.error = error + '; An error occurred retrieving data';
Expand Down
4 changes: 1 addition & 3 deletions app/lib/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,7 @@ export async function RegisterSelf() {
return resp.error;
}

return {
error: 'Something went wrong',
};
return 'Something went wrong';
}

export async function ConfirmComingOrNot(isComing: boolean): Promise<{
Expand Down

0 comments on commit 73e5c82

Please sign in to comment.