Guest User

Untitled

a guest
Dec 21st, 2024
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export default async function RootLayout({ children }) {
  2.   // get the nonce and use it
  3.   const nonce = headers().get('x-nonce') || "";
  4.  
  5.   // fetch currently logged in user
  6.   const { data: { userMeta, userProfile } = {} } = await getClient().query(
  7.     GET_USER,
  8.     { userInput: null },
  9.   );
  10.   const user = { ...userMeta, ...userProfile };
  11.  
  12.   // if user is a club, display the club's logo as profile img
  13.   if (user?.role === "club") {
  14.     const { data: { club } = {} } = await getClient().query(GET_CLUB, {
  15.       clubInput: { cid: user?.uid },
  16.     });
  17.     user.img = club?.logo;
  18.   }
  19.  
  20.   return (
  21.     <html lang="en">
  22.       <body className={fontClass}>
  23.         <ModeProvider>
  24.           <ThemeRegistry nonce={nonce}>
  25.             <Progressbar />
  26.             <LocalizationWrapper>
  27.               <AuthProvider user={user}>
  28.                 <ToastProvider>
  29.                   <Navigation />
  30.                   <Content>
  31.                     <TransitionProvider>{children}</TransitionProvider>
  32.                   </Content>
  33.                   <Toast />
  34.                 </ToastProvider>
  35.               </AuthProvider>
  36.             </LocalizationWrapper>
  37.           </ThemeRegistry>
  38.         </ModeProvider>
  39.       </body>
  40.     </html>
  41.   );
  42. }
Advertisement
Add Comment
Please, Sign In to add comment