import React from 'react' import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout' import FormInput from '@/Components/FormInput' import Button from '@/Components/Button' import { Head, useForm } from '@inertiajs/react' import TextArea from '@/Components/TextArea' import { isEmpty } from 'lodash' const extractValue = (set, key) => { const find = set.find((s) => s.key === key) if (isEmpty(find) === false) { if (find.type === 'image') { return find?.url } return find?.value } return '' } export default function Setting(props) { const { setting } = props const { data, setData, post, processing, errors } = useForm({ name: extractValue(setting, 'name'), detail: extractValue(setting, 'detail'), target: extractValue(setting, 'target'), }) const handleOnChange = (event) => { setData( event.target.name, event.target.type === 'checkbox' ? event.target.checked ? 1 : 0 : event.target.value ) } const handleSubmit = () => { post(route('setting.update')) } return (
Setting