layout.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 'use client';
  2. import "./style.scss";
  3. import Image from 'next/image';
  4. import Link from 'next/link';
  5. import { useRouter } from 'next/navigation';
  6. import { useEffect } from 'react';
  7. import { GoogleOAuthProvider } from '@react-oauth/google';
  8. import useAuth from '@/hooks/useAuth';
  9. import { useConfigContext } from '@/contexts/configProvider';
  10. export default function Layout({ children }: { children: React.ReactNode }) {
  11. const router = useRouter();
  12. const { isAuthenticated, isLoading } = useAuth();
  13. const config = useConfigContext();
  14. // 이미 로그인된 상태면 홈으로 리다이렉트
  15. useEffect(() => {
  16. if (!isLoading && isAuthenticated) {
  17. router.replace('/');
  18. }
  19. }, [isAuthenticated, isLoading, router]);
  20. return (
  21. <div className="grid grid-rows-[1fr_20px] items-center justify-items-center min-h-screen p-4 sm:p-20 font-[family-name:var(--font-geist-sans)]">
  22. <div className="flex flex-col items-center gap-10">
  23. <Link href="/" className="inline-block w-28 sm:w-30 md:w-36 lg:w-44">
  24. <Image src="/resources/m-logo.png" alt="bitforum" width={256} height={64} className="w-full h-auto" priority />
  25. </Link>
  26. <GoogleOAuthProvider clientId={config?.external?.googleClientId ?? ''} nonce="" locale="ko">
  27. {children}
  28. </GoogleOAuthProvider>
  29. </div>
  30. <address>
  31. <hr />
  32. <small>© 2025 PLAYR. All rights reserved.</small>
  33. </address>
  34. </div>
  35. );
  36. }