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.level == 1 ? 'Admin' : ''}