Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: join form submit restriction #881

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 34 additions & 44 deletions app/components/stepper.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,50 +65,40 @@ export default class StepperComponent extends Component {
}

@action async joinHandler() {
/* @todo-1 remove this toast and return statement when join flow gets opened*/
return this.toast.info(
"Currently we're not taking applications please keep an eye on our website for openings",
'Hey there👋',
TOAST_OPTIONS,
);
/* @todo-1 ends here*/
const firstName = localStorage.getItem('first_name');
const lastName = localStorage.getItem('last_name');
const data = JSON.stringify({
firstName,
lastName,
...this.stepOneData,
...this.stepTwoData,
...this.stepThreeData,
});
try {
const response = await fetch(this.JOIN_URL, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
body: data,
});

/* @todo-2 uncomment this part when join flow gets opened */
// const firstName = localStorage.getItem('first_name');
// const lastName = localStorage.getItem('last_name');
// const data = JSON.stringify({
// firstName,
// lastName,
// ...this.stepOneData,
// ...this.stepTwoData,
// ...this.stepThreeData,
// });
// try {
// const response = await fetch(this.JOIN_URL, {
// method: 'PUT',
// headers: { 'Content-Type': 'application/json' },
// credentials: 'include',
// body: data,
// });

// if (response.status === 201) {
// this.toast.success(
// 'Successfully submitted the form',
// 'Success!',
// TOAST_OPTIONS,
// );
// this.incrementStep();
// } else if (response.status === 409) {
// this.toast.error(
// 'You have already filled the form',
// 'User Exist!',
// TOAST_OPTIONS,
// );
// }
// } catch (err) {
// this.toast.error('Some error occured', 'Error ocurred!', TOAST_OPTIONS);
// console.log('Error: ', err);
// }
/*@todo-2 ends here */
if (response.status === 201) {
this.toast.success(
'Successfully submitted the form',
'Success!',
TOAST_OPTIONS,
);
this.incrementStep();
} else if (response.status === 409) {
this.toast.error(
'You have already filled the form',
'User Exist!',
TOAST_OPTIONS,
);
}
} catch (err) {
this.toast.error('Some error occured', 'Error ocurred!', TOAST_OPTIONS);
console.log('Error: ', err);
}
}
}
Loading