Overview & recent fixes, auth updates, SWR fixes

This commit is contained in:
Darren Clarke 2023-11-10 14:17:09 +01:00
parent 7df947f35a
commit 8d86db882d
29 changed files with 1252 additions and 1221 deletions

View file

@ -18,12 +18,24 @@ export const ZammadWrapper: FC<ZammadWrapperProps> = ({
const router = useRouter();
const { data: session } = useSession({ required: true });
const timeoutRef = useRef(null);
const [hashCheckComplete, setHashCheckComplete] = useState(false);
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 hash = window?.location?.hash;
if (hash && hash.startsWith("#ticket/zoom/")) {
const ticketID = hash.split("/").pop();
router.push(`/tickets/${ticketID}`);
}
setHashCheckComplete(true);
});
useEffect(() => {
if (!hashCheckComplete) return;
const checkAuthenticated = async () => {
const res = await fetch("/zammad/auth/sso", {
method: "GET",
@ -38,7 +50,7 @@ export const ZammadWrapper: FC<ZammadWrapperProps> = ({
};
checkAuthenticated();
}, [path]);
}, [path, hashCheckComplete]);
useEffect(() => {
if (session === null) {