Added function to access imprint with "#imprint"
This commit is contained in:
parent
759ceac608
commit
aaeeb54b73
2 changed files with 24 additions and 8 deletions
|
@ -82,6 +82,13 @@ const useImprintData = () => {
|
||||||
return { imprintData, fetchImprintData };
|
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 Imprint = () => {
|
||||||
const {
|
const {
|
||||||
imprintData: { name, address, phone, email, url, error },
|
imprintData: { name, address, phone, email, url, error },
|
||||||
|
@ -99,7 +106,12 @@ const Imprint = () => {
|
||||||
<ItemList>
|
<ItemList>
|
||||||
<ItemContainer>
|
<ItemContainer>
|
||||||
<SHl>Imprint</SHl>
|
<SHl>Imprint</SHl>
|
||||||
<Modal element="text" text="View Imprint">
|
<Modal
|
||||||
|
element="text"
|
||||||
|
text="View Imprint"
|
||||||
|
condition={!window.location.href.endsWith("#imprint")}
|
||||||
|
onClose={() => onClose()}
|
||||||
|
>
|
||||||
<Headline>Legal Disclosure</Headline>
|
<Headline>Legal Disclosure</Headline>
|
||||||
{error && <ErrorMessage>{error}</ErrorMessage>}
|
{error && <ErrorMessage>{error}</ErrorMessage>}
|
||||||
<ModalSubHeadline>
|
<ModalSubHeadline>
|
||||||
|
|
|
@ -34,27 +34,31 @@ interface IModalInterface {
|
||||||
element: string;
|
element: string;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
text?: string;
|
text?: string;
|
||||||
|
condition?: boolean;
|
||||||
|
onClose?: () => void;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Modal = (props: IModalInterface) => {
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
{props.element === "icon" && (
|
{props.element === "icon" && (
|
||||||
<IconButton
|
<IconButton icon={props.icon ?? ""} onClick={() => closeModal()} />
|
||||||
icon={props.icon ? props.icon : ""}
|
|
||||||
onClick={() => setModalHidden(!modalHidden)}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{props.element === "text" && (
|
{props.element === "text" && (
|
||||||
<Text onClick={() => setModalHidden(!modalHidden)}>{props.text}</Text>
|
<Text onClick={() => closeModal()}>{props.text}</Text>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<ModalContainer hidden={modalHidden}>
|
<ModalContainer hidden={modalHidden}>
|
||||||
<IconButton icon="close" onClick={() => setModalHidden(!modalHidden)} />
|
<IconButton icon="close" onClick={() => closeModal()} />
|
||||||
{props.children}
|
{props.children}
|
||||||
</ModalContainer>
|
</ModalContainer>
|
||||||
</>
|
</>
|
||||||
|
|
Loading…
Add table
Reference in a new issue