Skip to content

Commit

Permalink
refactor: Make it simpler to add new help dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
ptbrowne committed Jul 31, 2024
1 parent 0ccbb20 commit fdb6810
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions src/components/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,19 @@ export const Footer = () => {
const locale = useLocale();
const [{ period }] = useQueryStateSingle();

const {
isOpen: isHelpCalculationOpen,
open: openHelpCalculation,
close: closeHelpCalculation,
} = useDisclosure();

const {
isOpen: isHelpCsvDownloadOpen,
open: openHelpCsvDownload,
close: closeHelpCsvDownload,
} = useDisclosure();
const helpCalculationDisclosure = useDisclosure();
const helpCsvDisclosure = useDisclosure();

const handleOpenCalculation = (ev: React.MouseEvent<HTMLElement>) => {
ev.preventDefault();
openHelpCalculation();
helpCalculationDisclosure.open();
};

const handleOpenCsvDownload = (ev: React.MouseEvent<HTMLElement>) => {
ev.preventDefault();
openHelpCsvDownload();
helpCsvDisclosure.open();
};

};

return (
Expand Down Expand Up @@ -119,21 +112,21 @@ export const Footer = () => {
</FooterLink>

<HelpDialog
close={closeHelpCalculation}
close={helpCalculationDisclosure.close}
label={t({
id: "help.calculation",
message: `Berechnungsgrundlage`,
})}
open={isHelpCalculationOpen}
open={helpCalculationDisclosure.isOpen}
slug="help-calculation"
/>
<HelpDialog
close={closeHelpCsvDownload}
close={helpCsvDisclosure.close}
label={t({
id: "help.csv-download",
message: `Daten als .csv`,
})}
open={isHelpCsvDownloadOpen}
open={helpCsvDisclosure.isOpen}
slug="help-download-raw-data"
/>
<FooterLink
Expand Down

0 comments on commit fdb6810

Please sign in to comment.