From 6effa5b4be9cae906a54e277615e0b7b39d0fea9 Mon Sep 17 00:00:00 2001 From: Giovanni Martire Date: Wed, 31 Jan 2024 23:44:25 +0100 Subject: [PATCH] Hide login button if user is logged --- app/page.tsx | 9 ------ components/Button/LoginButton.tsx | 46 +++++++++++++++++-------------- 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index ba2d83d..bb6878d 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -6,18 +6,9 @@ import decoration4 from '@/public/decorations/decoration-4.svg'; import fullLogo from '@/public/logos/full-logo.svg'; import Image from 'next/image'; import Balancer from 'react-wrap-balancer'; -import { getUserData } from './actions'; import styles from './page.module.css'; -export const revalidate = 60; - -const getUser = async () => { - return await getUserData(); -}; - export default async function Home() { - const user = await getUser(); - return (
diff --git a/components/Button/LoginButton.tsx b/components/Button/LoginButton.tsx index ee1a4a4..7983795 100644 --- a/components/Button/LoginButton.tsx +++ b/components/Button/LoginButton.tsx @@ -1,26 +1,30 @@ 'use client'; import { loginIntoWebsite } from '@/app/actions'; +import { useUser } from '@/util/hooks'; export default function LoginButton() { - return ( - - ); + const user = useUser(); + + if (!user?.osuId) + return ( + + ); }