fix: Use username field instead of display_name in profile
- Updated profile-actions.ts to use username column - Updated ProfileForm.tsx to use username - Updated settings page to pass username - Matches database schema (profiles.username)
This commit is contained in:
@@ -44,7 +44,7 @@ export default async function SettingsPage() {
|
||||
<ProfileForm
|
||||
initialData={{
|
||||
email: profile?.email,
|
||||
display_name: profile?.display_name,
|
||||
username: profile?.username,
|
||||
}}
|
||||
/>
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@ import { updateProfile } from '@/services/profile-actions';
|
||||
interface ProfileFormProps {
|
||||
initialData: {
|
||||
email?: string;
|
||||
display_name?: string | null;
|
||||
username?: string | null;
|
||||
};
|
||||
}
|
||||
|
||||
export default function ProfileForm({ initialData }: ProfileFormProps) {
|
||||
const [displayName, setDisplayName] = useState(initialData.display_name || '');
|
||||
const [username, setUsername] = useState(initialData.username || '');
|
||||
const [isPending, startTransition] = useTransition();
|
||||
const [status, setStatus] = useState<'idle' | 'success' | 'error'>('idle');
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
@@ -24,7 +24,7 @@ export default function ProfileForm({ initialData }: ProfileFormProps) {
|
||||
setError(null);
|
||||
|
||||
const formData = new FormData();
|
||||
formData.set('display_name', displayName);
|
||||
formData.set('username', username);
|
||||
|
||||
startTransition(async () => {
|
||||
const result = await updateProfile(formData);
|
||||
@@ -66,16 +66,16 @@ export default function ProfileForm({ initialData }: ProfileFormProps) {
|
||||
<p className="mt-1 text-xs text-zinc-500">E-Mail kann nicht geändert werden</p>
|
||||
</div>
|
||||
|
||||
{/* Display Name */}
|
||||
{/* Username */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-zinc-400 mb-2">
|
||||
Anzeigename
|
||||
Benutzername
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={displayName}
|
||||
onChange={(e) => setDisplayName(e.target.value)}
|
||||
placeholder="Dein Name"
|
||||
value={username}
|
||||
onChange={(e) => setUsername(e.target.value)}
|
||||
placeholder="Dein Benutzername"
|
||||
className="w-full px-4 py-3 bg-zinc-800 border border-zinc-700 rounded-xl text-white placeholder-zinc-500 focus:outline-none focus:ring-2 focus:ring-orange-500 focus:border-transparent"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -20,13 +20,13 @@ export async function updateProfile(formData: FormData): Promise<ProfileUpdateRe
|
||||
return { success: false, error: 'Nicht autorisiert' };
|
||||
}
|
||||
|
||||
const displayName = formData.get('display_name') as string;
|
||||
const username = formData.get('username') as string;
|
||||
|
||||
const { error } = await supabase
|
||||
.from('profiles')
|
||||
.upsert({
|
||||
id: user.id,
|
||||
display_name: displayName?.trim() || null,
|
||||
username: username?.trim() || null,
|
||||
updated_at: new Date().toISOString(),
|
||||
});
|
||||
|
||||
@@ -98,14 +98,14 @@ export async function getProfile() {
|
||||
|
||||
const { data: profile } = await supabase
|
||||
.from('profiles')
|
||||
.select('id, display_name, avatar_url, created_at, updated_at')
|
||||
.select('id, username, avatar_url, updated_at')
|
||||
.eq('id', user.id)
|
||||
.single();
|
||||
|
||||
return {
|
||||
id: user.id,
|
||||
email: user.email,
|
||||
display_name: profile?.display_name || null,
|
||||
username: profile?.username || null,
|
||||
avatar_url: profile?.avatar_url || null,
|
||||
created_at: user.created_at,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user