import { zodResolver } from '@hookform/resolvers/zod' import { createFileRoute } from '@tanstack/react-router' import { useState } from 'react' import { useForm } from 'react-hook-form' import { z } from 'zod' import { Button } from '@/components/ui/button' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { Field, FieldDescription, FieldError, FieldGroup, FieldLabel } from '@/components/ui/field' import { Input } from '@/components/ui/input' import { Switch } from '@/components/ui/switch' import { useSession } from '@/lib/auth-client' export const Route = createFileRoute('/_authenticated/settings')({ component: SettingsPage, }) const profileSchema = z.object({ name: z.string().min(1, 'Name is required').max(80), email: z.email('Enter a valid email address'), }) type ProfileValues = z.infer function SettingsPage() { const { data: session } = useSession() const [saved, setSaved] = useState(false) const form = useForm({ resolver: zodResolver(profileSchema), defaultValues: { name: session?.user.name ?? '', email: session?.user.email ?? '', }, }) return (
Profile This is how other people will see you.
{ // Wire this to a `PATCH /users/me` feature on the API. setSaved(true) })} > Name Email We only use it to sign you in.
{saved && Saved locally.}
Appearance Notifications and display preferences. {[ { id: 'digest', label: 'Weekly digest', hint: 'A summary of your lists every Monday.' }, { id: 'mentions', label: 'Mentions', hint: 'Ping me when someone mentions my name.' }, ].map((option) => (

{option.label}

{option.hint}

))}
) }