Skip to content

Commit

Permalink
Disable button on submit (#782)
Browse files Browse the repository at this point in the history
  • Loading branch information
AudunSorheim authored Dec 5, 2024
1 parent 1114126 commit f558333
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/components/Form/OppfolgingStep/OnskerOppfolgingStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Step } from '@/components/Step/Step'

interface Props {
goToPreviousStep: () => void
isSubmitting: boolean
}

const Description = (): ReactElement => {
Expand All @@ -21,7 +22,7 @@ const Description = (): ReactElement => {
)
}

export const OnskerOppfolgingStep = ({ goToPreviousStep }: Props): ReactElement => {
export const OnskerOppfolgingStep = ({ goToPreviousStep, isSubmitting }: Props): ReactElement => {
useEffect(() => {
window.scrollTo(0, 0)
}, [])
Expand All @@ -32,6 +33,7 @@ export const OnskerOppfolgingStep = ({ goToPreviousStep }: Props): ReactElement
goToPreviousStep={goToPreviousStep}
customNextButtonIcon={<PaperplaneIcon aria-hidden />}
customNextButtonLabel="Send inn svarene"
isSubmitting={isSubmitting}
>
<RadioGroupForQuestion questionName="BEHOV_FOR_OPPFOLGING" description={<Description />} />
</Step>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/StepHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const StepHandler = ({ senOppfolgingStatus }: LandingContentProps): React
case 'INFO':
return <InfoStep goToPreviousStep={goToPreviousStep} />
case 'KONTAKT':
return <OnskerOppfolgingStep goToPreviousStep={goToPreviousStep} />
return <OnskerOppfolgingStep goToPreviousStep={goToPreviousStep} isSubmitting={mutation.isLoading} />
default:
return null
}
Expand Down
9 changes: 8 additions & 1 deletion src/components/Step/Step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface Props {
goToPreviousStep?: () => void
customNextButtonLabel?: string
customNextButtonIcon?: ReactNode
isSubmitting?: boolean
}

export const Step = ({
Expand All @@ -16,6 +17,7 @@ export const Step = ({
goToPreviousStep,
customNextButtonLabel,
customNextButtonIcon,
isSubmitting = false,
}: Props): ReactElement => {
return (
<>
Expand All @@ -36,7 +38,12 @@ export const Step = ({
Tilbake
</Button>
)}
<Button type="submit" icon={customNextButtonIcon ?? <ArrowRightIcon aria-hidden />} iconPosition="right">
<Button
type="submit"
disabled={isSubmitting}
icon={customNextButtonIcon ?? <ArrowRightIcon aria-hidden />}
iconPosition="right"
>
{customNextButtonLabel ?? 'Neste'}
</Button>
</HStack>
Expand Down

0 comments on commit f558333

Please sign in to comment.