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 FormInputNumeric from '@/Components/FormInputNumeric' 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: '', admin_fee: 0, 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, admin_fee: account.admin_fee, logo_url: account.logo_url, }) } }, [account]) return (
Bank Akun
setData('logo', e.target.files[0])} error={errors.logo} preview={ isEmpty(data.logo_url) === false && ( preview ) } />
) }