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'
const TinyEditor = React.lazy(() => import('@/Components/TinyMCE'))
export default function Form(props) {
const { info } = props
const { data, setData, post, put, processing, errors } = useForm({
title: '',
description: '',
is_publish: 1,
})
const handleOnChange = (event) => {
setData(
event.target.name,
event.target.type === 'checkbox'
? event.target.checked
? 1
: 0
: event.target.value
)
}
const handleSubmit = () => {
if (isEmpty(info) === false) {
put(route('info.update', info))
return
}
post(route('info.store'))
}
useEffect(() => {
if (isEmpty(info) === false) {
setData({
title: info.title,
description: info.description,
is_publish: info.is_publish,
})
}
}, [info])
return (