layout.tsx63 lines, 1.9 KB
| 1 | "use client"; |
| 2 | |
| 3 | import { useAuth } from "@/lib/hooks/auth"; |
| 4 | import Image from "next/image"; |
| 5 | import Link from "next/link"; |
| 6 | import { useRouter } from "next/navigation"; |
| 7 | import { useEffect } from "react"; |
| 8 | |
| 9 | export default function AuthLayout({ |
| 10 | children, |
| 11 | }: { |
| 12 | children: React.ReactNode; |
| 13 | }) { |
| 14 | const { user } = useAuth(); |
| 15 | const router = useRouter(); |
| 16 | |
| 17 | useEffect(() => { |
| 18 | if (user) { |
| 19 | router.push("/dashboard"); |
| 20 | } |
| 21 | }, [user, router]); |
| 22 | |
| 23 | return ( |
| 24 | <div className="container relative min-h-screen flex-col items-center justify-center grid lg:max-w-none lg:grid-cols-2 lg:px-0"> |
| 25 | <div className="relative hidden h-full flex-col bg-muted p-10 text-white lg:flex dark:border-r"> |
| 26 | <div className="absolute inset-0 bg-zinc-900" /> |
| 27 | <div className="relative z-20 flex items-center text-lg font-medium"> |
| 28 | <Image |
| 29 | src="/logo.svg" |
| 30 | alt="logo" |
| 31 | width={40} |
| 32 | height={40} |
| 33 | className="mr-2" |
| 34 | /> |
| 35 | </div> |
| 36 | <div className="relative z-20 mt-auto"> |
| 37 | <blockquote className="space-y-2"> |
| 38 | <p className="text-lg"> |
| 39 | "This platform has really helped me save time and improve my |
| 40 | productivity." |
| 41 | </p> |
| 42 | <footer className="text-sm">Sofia Davis</footer> |
| 43 | </blockquote> |
| 44 | </div> |
| 45 | </div> |
| 46 | <div className="lg:p-8"> |
| 47 | <div className="mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px]"> |
| 48 | {children} |
| 49 | <p className="px-8 text-center text-sm text-muted-foreground"> |
| 50 | By continuing, you agree to our{" "} |
| 51 | <Link href="/terms" className="underline"> |
| 52 | Terms of Service |
| 53 | </Link>{" "} |
| 54 | and{" "} |
| 55 | <Link href="/privacy" className="underline"> |
| 56 | Privacy Policy |
| 57 | </Link> |
| 58 | </p> |
| 59 | </div> |
| 60 | </div> |
| 61 | </div> |
| 62 | ); |
| 63 | } |