import React, { useEffect } from 'react'
import { isEmpty } from 'lodash'
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
import FormInput from '@/Components/FormInput'
import FormFile from '@/Components/FormFile'
import Button from '@/Components/Button'
import { Head, useForm } from '@inertiajs/react'
export default function Form(props) {
const { account } = props
const { data, setData, post, processing, errors } = useForm({
name: '',
bank_name: '',
holder_name: '',
account_number: '',
logo: null,
logo_url: ''
})
const handleOnChange = (event) => {
setData(
event.target.name,
event.target.type === 'checkbox'
? event.target.checked
? 1
: 0
: event.target.value
)
}
const handleSubmit = () => {
if (isEmpty(account) === false) {
post(route('account.update', account))
return
}
post(route('account.store'))
}
useEffect(() => {
if (isEmpty(account) === false) {
setData({
name: account.name,
bank_name: account.bank_name,
holder_name: account.holder_name,
account_number: account.account_number,
logo_url: account.logo_url
})
}
}, [account])
return (