From eed18a215dd72973bac4b1f263ab540818b1d4ad Mon Sep 17 00:00:00 2001 From: Benjamin Arias Date: Tue, 13 Aug 2024 10:59:51 +0200 Subject: [PATCH 1/3] feat: Disable the export data button if the poll has less than 3 participants --- src/components/organisations/ExportDataButton.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/organisations/ExportDataButton.tsx b/src/components/organisations/ExportDataButton.tsx index b5f8fca54..9f4fc48fc 100644 --- a/src/components/organisations/ExportDataButton.tsx +++ b/src/components/organisations/ExportDataButton.tsx @@ -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() } @@ -82,7 +88,12 @@ export default function ExportDataButton({ }) } return ( - From 99859ba0f0dd7c81bb0543e31fd1520775c4947b Mon Sep 17 00:00:00 2001 From: Benjamin Arias Date: Mon, 26 Aug 2024 10:28:24 +0200 Subject: [PATCH 2/3] :recycle: Refacto + remove useless aria-disabled --- src/components/organisations/ExportDataButton.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/organisations/ExportDataButton.tsx b/src/components/organisations/ExportDataButton.tsx index 9f4fc48fc..8082af0fd 100644 --- a/src/components/organisations/ExportDataButton.tsx +++ b/src/components/organisations/ExportDataButton.tsx @@ -25,7 +25,7 @@ export default function ExportDataButton({ }: ButtonProps & Props) { const [isLoading, setIsLoading] = useState(false) - const isDisabled = simulationRecaps?.length < 3 + const isDisabled = isLoading || simulationRecaps?.length < 3 function handleClick() { if (isDisabled) { @@ -89,9 +89,8 @@ export default function ExportDataButton({ } return (