layout.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  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 useAuth from '@/hooks/useAuth';
  8. export default function Layout({ children }: { children: React.ReactNode }) {
  9. const router = useRouter();
  10. const { isAuthenticated, isLoading } = useAuth();
  11. // 이미 로그인된 상태면 홈으로 리다이렉트
  12. useEffect(() => {
  13. if (!isLoading && isAuthenticated) {
  14. router.replace('/');
  15. }
  16. }, [isAuthenticated, isLoading, router]);
  17. return (
  18. <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)]">
  19. <div className="flex flex-col items-center gap-10">
  20. <Link href="/" className="inline-block w-28 sm:w-30 md:w-36 lg:w-44">
  21. <Image src="/resources/m-logo.png" alt="bitforum" width={256} height={64} className="w-full h-auto" priority />
  22. </Link>
  23. {children}
  24. </div>
  25. <address>
  26. <hr />
  27. <small>© 2025 PLAYR. All rights reserved.</small>
  28. </address>
  29. </div>
  30. );
  31. }