Skip to content

Commit

Permalink
fix: disable button while loading (#16396)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
disaerna and kodiakhq[bot] authored Oct 18, 2024
1 parent d6b0e01 commit 99fbfdb
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,16 @@ export const Form2 = () => {
: OPT_OUT
const [radioValue, setRadioValue] = useState<string | undefined>(donorStatus)

const [updateDonorStatus] = useUpdateOrganDonationInfoMutation({
onCompleted: () => {
toast.success(formatMessage(messages.registrationComplete))
navigate(HealthPaths.HealthOrganDonation, { replace: true })
},
onError: () => {
toast.error(formatMessage(messages.registrationFailed))
},
})
const [updateDonorStatus, { loading: submitLoading }] =
useUpdateOrganDonationInfoMutation({
onCompleted: () => {
toast.success(formatMessage(messages.registrationComplete))
navigate(HealthPaths.HealthOrganDonation, { replace: true })
},
onError: () => {
toast.error(formatMessage(messages.registrationFailed))
},
})

useEffect(() => {
if (radioValue !== donorStatus) {
Expand Down Expand Up @@ -178,7 +179,7 @@ export const Form2 = () => {
size="small"
type="submit"
loading={loading}
disabled={radioValue === undefined}
disabled={radioValue === undefined || submitLoading}
>
{formatMessage(coreMessages.codeConfirmation)}
</Button>
Expand Down

0 comments on commit 99fbfdb

Please sign in to comment.