layout.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use client';
  2. import "./style.scss";
  3. import Image from 'next/image';
  4. import Link from 'next/link';
  5. import { useRouter, usePathname } 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 pathname = usePathname();
  13. const { isAuthenticated, isLoading } = useAuth();
  14. const config = useConfigContext();
  15. // 이미 로그인된 상태면 홈으로 리다이렉트 (Google 로그인 완료 페이지 제외)
  16. useEffect(() => {
  17. if (!isLoading && isAuthenticated && !pathname.startsWith('/login/google/complete')) {
  18. router.replace('/');
  19. }
  20. }, [isAuthenticated, isLoading, router, pathname]);
  21. return (
  22. <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)]">
  23. <div className="flex flex-col items-center gap-10">
  24. <Link href="/" className="inline-block w-28 sm:w-30 md:w-36 lg:w-44">
  25. <Image src="/resources/m-logo.png" alt="bitforum" width={256} height={64} className="w-full h-auto" priority />
  26. </Link>
  27. <GoogleOAuthProvider clientId={config?.external?.googleClientId ?? ''} nonce="" locale="ko">
  28. {children}
  29. </GoogleOAuthProvider>
  30. </div>
  31. <address>
  32. <hr />
  33. <small>© 2025 PLAYR. All rights reserved.</small>
  34. </address>
  35. </div>
  36. );
  37. }