'use client' import { useActionState, useState } from 'react' import { changePassword, deleteUser } from './actions' import { KeyRound, Trash2, ChevronDown, ChevronUp, Shield } from 'lucide-react' type User = { id: number username: string role: string created_at: Date } function ChangePasswordForm({ userId }: { userId: number }) { const action = changePassword.bind(null, userId) const [state, formAction, isPending] = useActionState(action, undefined) return (
{state?.success && (

{state.message}

)} {state?.error && (

{state.error}

)}
) } function UserRow({ user }: { user: User }) { const [expanded, setExpanded] = useState(false) async function handleDelete() { if (!confirm(`"${user.username}" kullanıcısını silmek istediğinize emin misiniz?`)) return const res = await deleteUser(user.id) if (res?.error) alert(res.error) } return (
{user.username[0]}

{user.username}

{new Date(user.created_at).toLocaleDateString('tr-TR', { day: 'numeric', month: 'long', year: 'numeric' })}

{user.role}
{expanded && }
) } export default function UserList({ users }: { users: User[] }) { return (

Mevcut Kullanıcılar ({users.length})

{users.length === 0 ? (

Henüz kullanıcı yok.

) : (
{users.map(user => ( ))}
)}
) }