diff --git a/app/layout.tsx b/app/layout.tsx index 14a96ac..3549cec 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,4 +1,4 @@ -import type { Metadata } from "next" +import type { Metadata, Viewport } from "next" import { Inter } from "next/font/google" import "./globals.css" @@ -7,7 +7,6 @@ const inter = Inter({ subsets: ["latin"], variable: "--font-inter" }) export const metadata: Metadata = { title: "EduEasy", description: "Plataforma educativa infantil", - viewport: "width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover", appleWebApp: { capable: true, statusBarStyle: "default", @@ -15,6 +14,13 @@ export const metadata: Metadata = { }, } +export const viewport: Viewport = { + width: "device-width", + initialScale: 1, + maximumScale: 1, + viewportFit: "cover", +} + export default function RootLayout({ children, }: { diff --git a/app/parent/auth/login/page.tsx b/app/parent/auth/login/page.tsx index 93bba28..d954f79 100644 --- a/app/parent/auth/login/page.tsx +++ b/app/parent/auth/login/page.tsx @@ -2,7 +2,7 @@ import { useState } from "react" import { useRouter } from "next/navigation" -import { authClient } from "@/lib/auth-client" +import { getAuth } from "@/lib/auth-client" export default function LoginPage() { const [email, setEmail] = useState("") @@ -16,7 +16,14 @@ export default function LoginPage() { setLoading(true) setError("") - const { error: err } = await authClient.signIn.email({ + const auth = getAuth() + if (!auth) { + setError("Error de inicialización") + setLoading(false) + return + } + + const { error: err } = await auth.signIn.email({ email, password, }) diff --git a/app/parent/auth/pairing/page.tsx b/app/parent/auth/pairing/page.tsx index c8ac948..bd1f797 100644 --- a/app/parent/auth/pairing/page.tsx +++ b/app/parent/auth/pairing/page.tsx @@ -1,7 +1,7 @@ "use client" import { useState } from "react" -import { authClient } from "@/lib/auth-client" +import { getAuth } from "@/lib/auth-client" import { useRouter } from "next/navigation" import { GatoMascota } from "@/components/child/gato-mascota" @@ -10,7 +10,8 @@ export default function PairingPage() { const [loading, setLoading] = useState(false) const [error, setError] = useState("") const [paired, setPaired] = useState(false) - const { data: session } = authClient.useSession() + const auth = getAuth() + const { data: session } = auth?.useSession() ?? { data: null } const router = useRouter() const handlePairing = async (e: React.FormEvent) => { diff --git a/app/parent/configuracion/page.tsx b/app/parent/configuracion/page.tsx index 9b827bc..eff31c4 100644 --- a/app/parent/configuracion/page.tsx +++ b/app/parent/configuracion/page.tsx @@ -1,10 +1,11 @@ "use client" -import { authClient } from "@/lib/auth-client" +import { getAuth } from "@/lib/auth-client" import { useRouter } from "next/navigation" export default function ConfigPage() { - const { data: session } = authClient.useSession() + const auth = getAuth() + const { data: session } = auth?.useSession() ?? { data: null } const router = useRouter() return ( diff --git a/app/parent/dashboard/page.tsx b/app/parent/dashboard/page.tsx index 975abd5..b5971fc 100644 --- a/app/parent/dashboard/page.tsx +++ b/app/parent/dashboard/page.tsx @@ -1,16 +1,21 @@ "use client" +import { useEffect } from "react" import { useRouter } from "next/navigation" -import { authClient } from "@/lib/auth-client" +import { getAuth } from "@/lib/auth-client" export default function ParentDashboard() { - const { data: session } = authClient.useSession() + const auth = getAuth() + const { data: session } = auth?.useSession() ?? { data: null } const router = useRouter() - if (!session) { - router.push("/parent/auth/login") - return null - } + useEffect(() => { + if (session === null) { + router.push("/parent/auth/login") + } + }, [session, router]) + + if (!session) return null return (