import React from 'react' import { Head, useForm, router } from '@inertiajs/react' import { isEmpty } from 'lodash' import { useModalState } from '@/hooks' import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout' import FormInput from '@/Components/FormInput' import Button from '@/Components/Button' import ModalConfirm from '@/Components/ModalConfirm' 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({ app_name: extractValue(setting, 'app_name'), }) 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')) } const confirmModal = useModalState() const onReset = () => { router.post(route('setting.reset')) } return (
Setting
) }