"use client"; import { FC, useState, useEffect } from "react"; import { useRouter } from "next/navigation"; import Iframe from "react-iframe"; import { useSession } from "next-auth/react"; import { Box, Grid, CircularProgress } from "@mui/material"; type ZammadWrapperProps = { path: string; hideSidebar?: boolean; }; export const ZammadWrapper: FC = ({ path, hideSidebar = true, }) => { const router = useRouter(); const { data: session } = useSession(); const [authenticated, setAuthenticated] = useState(false); const [display, setDisplay] = useState("none"); const url = `/zammad${path}`; const id = url.replace(/[^a-zA-Z0-9]/g, ""); useEffect(() => { const checkAuthenticated = async () => { const res = await fetch("/zammad/auth/sso", { method: "GET", redirect: "manual", }); if (res.type === "opaqueredirect") { setAuthenticated(true); } else { setAuthenticated(false); } }; checkAuthenticated(); }, [path]); if (!session) { console.log("No session"); return ( ); } if (session && authenticated) { console.log("Session and authenticated"); return (