43 lines
1,004 B
TypeScript
43 lines
1,004 B
TypeScript
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 &&
|
|
linkElement.contentDocument?.querySelector
|
|
) {
|
|
// @ts-ignore
|
|
linkElement.contentDocument.querySelector("#navigation").style =
|
|
"display: none";
|
|
|
|
if (hideSidebar) {
|
|
// @ts-ignore
|
|
linkElement.contentDocument.querySelector(".sidebar").style =
|
|
"display: none";
|
|
}
|
|
setDisplay("inherit");
|
|
}
|
|
}}
|
|
/>
|
|
);
|
|
};
|