feat: add first_name and last_name to users and implement inline editing in user-list
All checks were successful
Staging Build / build (push) Successful in 2m40s
All checks were successful
Staging Build / build (push) Successful in 2m40s
This commit is contained in:
@@ -13,7 +13,7 @@ import {
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
|
||||
import { Key, Trash2, Mail, Loader2, Building2, Ban, Unlock, Search } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { deleteUser, resetPassword, updateUserRole } from '@/lib/actions/users'
|
||||
import { deleteUser, resetPassword, updateUserRole, updateUserProfile } from '@/lib/actions/users'
|
||||
import { assignCompanyToUser } from '@/lib/actions/companies'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
|
||||
@@ -208,9 +208,57 @@ export function UserList({ initialUsers, companies }: UserListProps) {
|
||||
)}
|
||||
<TableRow className="border-white/5 hover:bg-white/5 transition-colors">
|
||||
<TableCell className="font-medium text-white">
|
||||
<div className="flex items-center gap-2">
|
||||
<Mail className="w-4 h-4 text-slate-500" />
|
||||
{user.email}
|
||||
<div className="flex flex-col">
|
||||
<div className="flex items-center gap-2">
|
||||
<Mail className="w-4 h-4 text-slate-500" />
|
||||
<span>{user.email}</span>
|
||||
</div>
|
||||
<div className="flex gap-2 mt-1 pl-6">
|
||||
<input
|
||||
type="text"
|
||||
defaultValue={user.first_name || ''}
|
||||
placeholder="Vorname"
|
||||
onBlur={async (e) => {
|
||||
const val = e.target.value.trim()
|
||||
if (val !== (user.first_name || '')) {
|
||||
try {
|
||||
await updateUserProfile(user.id, { first_name: val || null, last_name: user.last_name })
|
||||
router.refresh()
|
||||
} catch (err) {
|
||||
console.error('Failed to update first name:', err)
|
||||
}
|
||||
}
|
||||
}}
|
||||
onKeyDown={async (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
(e.target as HTMLInputElement).blur()
|
||||
}
|
||||
}}
|
||||
className="bg-transparent border-b border-transparent hover:border-white/20 focus:border-primary focus:outline-none text-xs text-slate-400 w-20 px-1 py-0.5 transition-all placeholder:text-slate-600 placeholder:italic"
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
defaultValue={user.last_name || ''}
|
||||
placeholder="Nachname"
|
||||
onBlur={async (e) => {
|
||||
const val = e.target.value.trim()
|
||||
if (val !== (user.last_name || '')) {
|
||||
try {
|
||||
await updateUserProfile(user.id, { first_name: user.first_name, last_name: val || null })
|
||||
router.refresh()
|
||||
} catch (err) {
|
||||
console.error('Failed to update last name:', err)
|
||||
}
|
||||
}
|
||||
}}
|
||||
onKeyDown={async (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
(e.target as HTMLInputElement).blur()
|
||||
}
|
||||
}}
|
||||
className="bg-transparent border-b border-transparent hover:border-white/20 focus:border-primary focus:outline-none text-xs text-slate-400 w-24 px-1 py-0.5 transition-all placeholder:text-slate-600 placeholder:italic"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
|
||||
Reference in New Issue
Block a user