import React, { useEffect } from 'react' import { usePage, useForm } from '@inertiajs/react' import { isEmpty } from 'lodash' import FormInput from '@/Components/FormInput' import FormInputWith from '@/Components/FormInputWith' import TextArea from '@/Components/TextArea' import FormFile from '@/Components/FormFile' import Button from '@/Components/Button' export default function Profile() { const { props: { customer, statuses }, } = usePage() const { data, setData, post, processing, errors } = useForm({ username: '', password: '', name: '', fullname: '', address: '', phone: '', image: '', image_url: '', status: 0, }) const handleOnChange = (event) => { setData( event.target.name, event.target.type === 'checkbox' ? event.target.checked ? 1 : 0 : event.target.value ) } const handleSubmit = () => { if (isEmpty(customer) === false) { post(route('customer.update', customer)) return } post(route('customer.store')) } useEffect(() => { if (isEmpty(customer) === false) { setData({ username: customer.username, password: customer.password, name: customer.name, fullname: customer.fullname, address: customer.address, phone: customer.phone, image_url: customer.image_url, status: customer.status, }) } }, [customer]) return (
Profile
+62
} name="phone" value={data.phone} onChange={handleOnChange} error={errors.phone} formClassName={'pl-10'} label="Whatsapp" />