profi sayfası
This commit is contained in:
@@ -1,14 +1,40 @@
|
||||
import { createClient } from "@/lib/supabase-server"
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { Label } from "@/components/ui/label"
|
||||
import { UserForm } from "@/components/dashboard/user-form"
|
||||
import { notFound } from "next/navigation"
|
||||
import { getProfile } from "@/lib/data"
|
||||
|
||||
export default async function ProfilePage() {
|
||||
const supabase = createClient()
|
||||
const { data: { user } } = await supabase.auth.getUser()
|
||||
|
||||
if (!user) {
|
||||
// Should be protected by middleware but just in case
|
||||
return <div>Lütfen giriş yapın.</div>
|
||||
}
|
||||
|
||||
// Fetch profile data
|
||||
const profile = await getProfile(user.id)
|
||||
|
||||
if (!profile) {
|
||||
// Fallback for user without profile row?
|
||||
// Or create one on the fly?
|
||||
return <div>Profil verisi bulunamadı.</div>
|
||||
}
|
||||
|
||||
const parts = (profile.full_name || "").split(' ')
|
||||
const firstName = parts[0] || ""
|
||||
const lastName = parts.slice(1).join(' ') || ""
|
||||
|
||||
const initialData = {
|
||||
firstName,
|
||||
lastName,
|
||||
phone: profile.phone || "",
|
||||
email: user.email || "",
|
||||
role: profile.role || "user"
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex-1 space-y-4 p-8 pt-6">
|
||||
<div className="flex items-center justify-between space-y-2">
|
||||
@@ -20,28 +46,18 @@ export default async function ProfilePage() {
|
||||
<CardHeader>
|
||||
<CardTitle>Genel Bilgiler</CardTitle>
|
||||
<CardDescription>
|
||||
Kişisel profil bilgileriniz.
|
||||
Kişisel profil bilgilerinizi buradan güncelleyebilirsiniz.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
<div className="flex items-center space-x-4">
|
||||
<div className="flex items-center space-x-4 mb-6">
|
||||
<Avatar className="h-20 w-20">
|
||||
<AvatarImage src="/avatars/01.png" alt="@parakasa" />
|
||||
<AvatarFallback>PK</AvatarFallback>
|
||||
</Avatar>
|
||||
<Button variant="outline">Fotoğraf Değiştir</Button>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="email">E-posta</Label>
|
||||
<Input id="email" value={user?.email || ""} disabled />
|
||||
<p className="text-xs text-muted-foreground">E-posta adresi değiştirilemez.</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="role">Rol</Label>
|
||||
<Input id="role" value={user?.role === 'authenticated' ? 'Yönetici' : 'Kullanıcı'} disabled />
|
||||
</div>
|
||||
<UserForm initialData={initialData} mode="profile" />
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user