import React, { useState, useEffect } from 'react'; import { useForm, usePage } from '@inertiajs/react'; import { useDispatch } from 'react-redux'; import { setPageTitle } from '@/Components/features/common/headerSlice'; import { Head } from '@inertiajs/react'; export default function ProfilePage() { const { auth } = usePage().props; const [preview, setPreview] = useState(null); const id = auth.user.id const { data, setData, post, processing, errors } = useForm({ nama: auth.user.nama || '', alamat: auth.user.alamat || '', no_telp: auth.user.no_telp || '', jk: auth.user.jk || 'laki laki', tanggal_lahir: auth.user.tanggal_lahir || '', password: '', foto: null }); const dispatch = useDispatch(); useEffect(() => { dispatch(setPageTitle("Profile Page")); }, [dispatch]); const handleSubmit = (e) => { e.preventDefault(); post(route('profile.update', id)); }; const handlePhotoChange = (e) => { const file = e.target.files[0]; if (file) { const reader = new FileReader(); reader.onloadend = () => { setPreview(reader.result); }; reader.readAsDataURL(file); setData('foto', file); } }; return (

{auth.user.nama}

{auth.user.level == 1 ? 'Admin' : ''}

); } function Input({ label, name, value, onChange, type = 'text', error, placeholder = '' }) { return (
onChange(name, e.target.value)} placeholder={placeholder} className={`w-full px-4 py-2 bg-gray-50 border ${error ? 'border-red-500' : 'border-gray-200'} rounded-md focus:outline-none`} /> {error &&
{error}
}
); } function Select({ label, name, value, onChange, options = [], error }) { return (
{error &&
{error}
}
); }