diff --git a/src/app/api/setup/route.ts b/src/app/api/setup/route.ts index f78dcd3..b751777 100644 --- a/src/app/api/setup/route.ts +++ b/src/app/api/setup/route.ts @@ -1,17 +1,16 @@ import { NextResponse } from "next/server"; import { db } from "@/db"; -import { sql } from "drizzle-orm/postgres-js"; export async function GET() { try { // Create enums - await db.execute(sql`CREATE TYPE IF NOT EXISTS child_sex AS ENUM('male', 'female', 'other')`); - await db.execute(sql`CREATE TYPE IF NOT EXISTS child_stage AS ENUM('newborn', 'infant', 'solids_start', 'toddler_early', 'toddler_late', 'preschool')`); - await db.execute(sql`CREATE TYPE IF NOT EXISTS member_role AS ENUM('admin', 'caregiver', 'viewer')`); + await db.execute(`CREATE TYPE IF NOT EXISTS child_sex AS ENUM('male', 'female', 'other')`); + await db.execute(`CREATE TYPE IF NOT EXISTS child_stage AS ENUM('newborn', 'infant', 'solids_start', 'toddler_early', 'toddler_late', 'preschool')`); + await db.execute(`CREATE TYPE IF NOT EXISTS member_role AS ENUM('admin', 'caregiver', 'viewer')`); return NextResponse.json({ success: true, message: "Types created" }); } catch (error) { console.error(error); return NextResponse.json({ error: String(error) }, { status: 500 }); } -} \ No newline at end of file +} diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx index 7443e17..d516b29 100644 --- a/src/app/login/page.tsx +++ b/src/app/login/page.tsx @@ -1,14 +1,32 @@ "use client"; +import { useState } from "react"; import { useRouter } from "next/navigation"; export default function LoginPage() { + const [email, setEmail] = useState(""); + const [loading, setLoading] = useState(false); const router = useRouter(); - const handleLogin = () => { - // For demo: just go to home - // In real app, this connects to auth - router.push("/"); + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + setLoading(true); + + try { + const res = await fetch("/api/auth/signin", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ email }), + }); + + if (res.ok) { + router.push("/"); + } + } catch (err) { + console.error(err); + } + + setLoading(false); }; return ( @@ -16,13 +34,25 @@ export default function LoginPage() {
Your baby tracking companion
- + +