Skip to content

Commit

Permalink
feat: блокировка кнопки отправки на форме подачи пьес на фестиваль (#548
Browse files Browse the repository at this point in the history
)

* feat: блокировка кнопки отправки заявки на форме подачи пьес на фестиваль

* fix: заменяет package-lock

---------

Co-authored-by: Aleksandra Shumkova <[email protected]>
  • Loading branch information
shumkova and shumkova authored Jul 23, 2024
1 parent b597ad2 commit 20ec335
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/pages/form/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ const validate = (values: ParticipationFormFields) => {

const Participation = () => {
const [errorOccurred, setErrorOccurred] = useState(false);
const [requestActive, setRequestActive] = useState(false);
const form = useForm<ParticipationFormFields>({
initialValues: initialFormValues,
validate: validate,
Expand Down Expand Up @@ -196,12 +197,15 @@ const Participation = () => {
return;
}
try {
setRequestActive(true);
await postParticipation(form.values);
router.push('/form/success');
} catch (error) {
handleSubmitError(error);

return;
} finally {
setRequestActive(false);
}
};

Expand Down Expand Up @@ -400,9 +404,11 @@ const Participation = () => {
border="full"
upperCase
fullWidth
disabled={!canSubmit}
disabled={!canSubmit || requestActive}
>
Отправить
{
requestActive ? 'Отправляется' : 'Отправить'
}
</Button>
</Form.Actions>
<Form.Disclaimer>
Expand Down

0 comments on commit 20ec335

Please sign in to comment.