Skip to content

Commit

Permalink
feat: Disable the export data button if the poll has less than 3 part…
Browse files Browse the repository at this point in the history
…icipants
  • Loading branch information
bjlaa committed Aug 26, 2024
1 parent 29d7c02 commit 9870da7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/components/organisations/ExportDataButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ export default function ExportDataButton({
}: ButtonProps & Props) {
const [isLoading, setIsLoading] = useState(false)

const isDisabled = simulationRecaps?.length < 3

function handleClick() {
if (isDisabled) {
return
}

if (onClick) {
onClick()
}
Expand Down Expand Up @@ -82,7 +88,12 @@ export default function ExportDataButton({
})
}
return (
<Button color={color} disabled={isLoading} onClick={handleClick} {...props}>
<Button
aria-disabled={isDisabled}
color={color}
disabled={isLoading}
onClick={handleClick}
{...props}>
<DownloadIcon className="mr-2 fill-primary-700" />
<Trans>Exporter les données</Trans>
</Button>
Expand Down

0 comments on commit 9870da7

Please sign in to comment.