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