import React, { useEffect, Suspense } from 'react' import { isEmpty } from 'lodash' import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout' import FormInput from '@/Components/FormInput' import Button from '@/Components/Button' import { Head, useForm } from '@inertiajs/react' import FormFile from '@/Components/FormFile' import FormInputWith from '@/Components/FormInputWith' import TextArea from '@/Components/TextArea' export default function Form(props) { const { customer } = props const { data, setData, post, processing, errors } = useForm({ username: '', password: '', name: '', fullname: '', address: '', phone: '', image: '', image_url: '', }) 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: customer.image, image_url: customer.image_url, }) } }, [customer]) return (
Customer
+62
} name="phone" value={data.phone} onChange={handleOnChange} error={errors.phone} formClassName={'pl-10'} label="Whatsapp" />