Sidebar and edit updates

This commit is contained in:
Darren Clarke 2023-10-16 09:20:40 +02:00
parent d73b194d1f
commit f13530f043
32 changed files with 3057 additions and 1114 deletions

View file

@ -1,6 +1,7 @@
"use client";
import { FC, PropsWithChildren, useState } from "react";
import { FC, PropsWithChildren, useState, useEffect } from "react";
import { usePathname } from "next/navigation";
import { CssBaseline } from "@mui/material";
import { CookiesProvider } from "react-cookie";
import { SessionProvider } from "next-auth/react";
@ -31,22 +32,45 @@ export const MultiProvider: FC<PropsWithChildren> = ({ children }) => {
});
const messages: any = { en: locales.en, fr: locales.fr };
const locale = "en";
const graphQLFetcher = async ({ document, variables }: any) => {
const fetchAndCheckAuth = async ({ document, variables }: any) => {
const requestHeaders = {
"X-CSRF-Token": csrfToken,
};
const { data, headers } = await client.rawRequest(
const { data, headers, status } = await client.rawRequest(
document,
variables,
requestHeaders,
);
if (status !== 200) {
const res = await fetch("/zammad/auth/sso", {
method: "GET",
redirect: "manual",
});
console.log({ checkAuth: res });
return null;
}
const token = headers.get("CSRF-Token");
setCsrfToken(token);
return data;
};
const graphQLFetcher = async ({ document, variables }: any) => {
let checks = 0;
let data = null;
while (!data && checks < 2) {
data = await fetchAndCheckAuth({ document, variables });
checks++;
}
return data;
};
return (
<>
<CssBaseline />