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 { customer_level } = props const { data, setData, post, processing, errors } = useForm({ name: '', description: '', min_amount: 0, max_amount: 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 = () => { post(route('customer-level.update', customer_level.id)) } useEffect(() => { if (isEmpty(customer_level) === false) { setData({ name: customer_level.name, description: customer_level.description, min_amount: customer_level.min_amount, max_amount: customer_level.max_amount, logo_url: customer_level.logo_url, }) } }, [customer_level]) return (
Atur Level
setData('logo', e.target.files[0])} error={errors.logo} preview={ isEmpty(data.logo_url) === false && ( preview ) } />
Loading...
}> { setData( 'description', editor.getContent() ) }} />
) }