feat(01-05): add protected dashboard layout and page
- Create UserNav component with logout functionality - Add dashboard layout with header, navigation, and user info - Create dashboard page displaying plan info and onboarding steps - All text in Italian for target audience Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
43
src/components/layout/user-nav.tsx
Normal file
43
src/components/layout/user-nav.tsx
Normal file
@@ -0,0 +1,43 @@
|
||||
'use client'
|
||||
|
||||
import { createClient } from '@/lib/supabase/client'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { useState } from 'react'
|
||||
|
||||
interface UserNavProps {
|
||||
email: string
|
||||
planName?: string
|
||||
}
|
||||
|
||||
export function UserNav({ email, planName }: UserNavProps) {
|
||||
const [loading, setLoading] = useState(false)
|
||||
const router = useRouter()
|
||||
const supabase = createClient()
|
||||
|
||||
async function handleSignOut() {
|
||||
setLoading(true)
|
||||
await supabase.auth.signOut()
|
||||
router.push('/login')
|
||||
router.refresh()
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="text-sm text-right">
|
||||
<p className="font-medium">{email}</p>
|
||||
{planName && (
|
||||
<p className="text-gray-500 text-xs capitalize">Piano {planName}</p>
|
||||
)}
|
||||
</div>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={handleSignOut}
|
||||
disabled={loading}
|
||||
>
|
||||
{loading ? 'Uscita...' : 'Esci'}
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user