- Unified localStorage key to 'theme-preference' across all components
- Fixed header.tsx using wrong localStorage key ('theme' instead of 'theme-preference')
- Added localStorage hybrid persistence for instant theme changes
- Removed router.refresh() which was causing stale data revert
- Replaced Blue theme with Sepia
- Consolidated auth() calls to prevent race conditions
- Updated UserSettingsData types to include all themes
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import { auth } from '@/auth'
|
|
import { redirect } from 'next/navigation'
|
|
import { ProfileForm } from './profile-form'
|
|
import prisma from '@/lib/prisma'
|
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
|
|
import { Sparkles } from 'lucide-react'
|
|
import { ProfilePageHeader } from '@/components/profile-page-header'
|
|
import { AISettingsLinkCard } from './ai-settings-link-card'
|
|
|
|
export default async function ProfilePage() {
|
|
const session = await auth()
|
|
|
|
if (!session?.user?.id) {
|
|
redirect('/login')
|
|
}
|
|
|
|
const user = await prisma.user.findUnique({
|
|
where: { id: session.user.id },
|
|
select: { name: true, email: true, role: true }
|
|
})
|
|
|
|
if (!user) {
|
|
redirect('/login')
|
|
}
|
|
|
|
// Get user AI settings
|
|
let userAISettings = { preferredLanguage: 'auto', showRecentNotes: false }
|
|
try {
|
|
const aiSettings = await prisma.userAISettings.findUnique({
|
|
where: { userId: session.user.id }
|
|
})
|
|
|
|
if (aiSettings) {
|
|
userAISettings = {
|
|
preferredLanguage: aiSettings.preferredLanguage || 'auto',
|
|
showRecentNotes: aiSettings.showRecentNotes ?? false
|
|
}
|
|
}
|
|
} catch (error) {
|
|
console.error('Error fetching AI settings:', error)
|
|
}
|
|
|
|
return (
|
|
<div className="max-w-2xl">
|
|
<ProfilePageHeader />
|
|
<ProfileForm user={user} userAISettings={userAISettings} />
|
|
|
|
{/* AI Settings Link */}
|
|
<AISettingsLinkCard />
|
|
</div>
|
|
)
|
|
}
|