'use client' import { useActionState, useEffect, useState } from 'react' import { updatePetugas } from '@/app/actions' import { User, Phone, Lock, UserCog, CheckCircle, XCircle, X } from 'lucide-react' interface PetugasData { id: string nama: string username: string no_telp: string | null password: string } interface Props { petugas: PetugasData } interface ToastProps { message: string type: 'success' | 'error' onClose: () => void } function Toast({ message, type, onClose }: ToastProps) { useEffect(() => { const timer = setTimeout(onClose, 4000) return () => clearTimeout(timer) }, [onClose]) return (
{type === 'success' ? : } {message}
) } export function EditPetugasForm({ petugas }: Props) { const [state, formAction, isPending] = useActionState(updatePetugas, null) const [toast, setToast] = useState<{ message: string; type: 'success' | 'error' } | null>(null) useEffect(() => { if (state) { setToast({ message: state.message, type: state.success ? 'success' : 'error', }) } }, [state]) return ( <> {/* Toast Notification */} {toast && ( setToast(null)} /> )}
{/* Nama */}
{/* Username */}
{/* No Telp */}
{/* Password */}

Pastikan password anda aman dan mudah diingat.

) }