diff --git a/src/components/imprint.tsx b/src/components/imprint.tsx index 9444096..232c56e 100644 --- a/src/components/imprint.tsx +++ b/src/components/imprint.tsx @@ -82,6 +82,13 @@ const useImprintData = () => { return { imprintData, fetchImprintData }; }; +const onClose = () => { + if (window.location.href.endsWith("#imprint")) { + let location = window.location.href.replace("#imprint", ""); + window.location.href = location; + } +}; + const Imprint = () => { const { imprintData: { name, address, phone, email, url, error }, @@ -99,7 +106,12 @@ const Imprint = () => { Imprint - + onClose()} + > Legal Disclosure {error && {error}} diff --git a/src/components/modal.tsx b/src/components/modal.tsx index 25d3c1e..b6cc0c4 100644 --- a/src/components/modal.tsx +++ b/src/components/modal.tsx @@ -34,27 +34,31 @@ interface IModalInterface { element: string; icon?: string; text?: string; + condition?: boolean; + onClose?: () => void; children: React.ReactNode; } const Modal = (props: IModalInterface) => { - const [modalHidden, setModalHidden] = useState(true); + const [modalHidden, setModalHidden] = useState(props.condition ?? true); + + const closeModal = () => { + if (props.onClose) props.onClose(); + setModalHidden(!modalHidden); + }; return ( <> {props.element === "icon" && ( - setModalHidden(!modalHidden)} - /> + closeModal()} /> )} {props.element === "text" && ( - setModalHidden(!modalHidden)}>{props.text} + closeModal()}>{props.text} )}