2022-12-02 17:45:14 +01:00
|
|
|
import { FC, useState } from "react";
|
|
|
|
|
import Iframe from "react-iframe";
|
|
|
|
|
|
|
|
|
|
type ZammadWrapperProps = {
|
|
|
|
|
url: string;
|
|
|
|
|
hideSidebar?: boolean;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const ZammadWrapper: FC<ZammadWrapperProps> = ({
|
|
|
|
|
url,
|
|
|
|
|
hideSidebar = true,
|
|
|
|
|
}) => {
|
|
|
|
|
const [display, setDisplay] = useState("none");
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Iframe
|
|
|
|
|
id="link"
|
|
|
|
|
url={url}
|
|
|
|
|
width="100%"
|
|
|
|
|
height="100%"
|
|
|
|
|
frameBorder={0}
|
|
|
|
|
styles={{ display }}
|
|
|
|
|
onLoad={() => {
|
|
|
|
|
const linkElement = document.querySelector("iframe");
|
|
|
|
|
if (
|
|
|
|
|
linkElement.contentDocument &&
|
2023-01-11 16:18:56 +01:00
|
|
|
linkElement.contentDocument?.querySelector &&
|
|
|
|
|
linkElement.contentDocument.querySelector("#navigation") &&
|
|
|
|
|
linkElement.contentDocument.querySelector("body") &&
|
|
|
|
|
linkElement.contentDocument.querySelector(".sidebar")
|
2022-12-02 17:45:14 +01:00
|
|
|
) {
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
linkElement.contentDocument.querySelector("#navigation").style =
|
|
|
|
|
"display: none";
|
2022-12-14 13:24:50 +01:00
|
|
|
// @ts-ignore
|
|
|
|
|
linkElement.contentDocument.querySelector("body").style =
|
|
|
|
|
"font-family: Arial";
|
2022-12-02 17:45:14 +01:00
|
|
|
|
|
|
|
|
if (hideSidebar) {
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
linkElement.contentDocument.querySelector(".sidebar").style =
|
|
|
|
|
"display: none";
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-11 16:18:56 +01:00
|
|
|
setDisplay("inherit");
|
2022-12-02 17:45:14 +01:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
};
|