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' const TinyEditor = React.lazy(() => import('@/Components/TinyMCE')) export default function Form(props) { const { banner } = props const { data, setData, post, processing, errors } = useForm({ title: '', description: '', 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(banner) === false) { post(route('banner.update', banner)) return } post(route('banner.store')) } useEffect(() => { if (isEmpty(banner) === false) { setData({ title: banner.title, description: banner.description, image_url: banner.image_url, }) } }, [banner]) return (
Banner
setData('image', e.target.files[0]) } error={errors.image} preview={ isEmpty(data.image_url) === false && ( preview ) } />
Loading...
}> { setData( 'description', editor.getContent() ) }} />
) }