import React, { useEffect } from "react"; import Modal from "@/Components/Modal"; import { useForm, usePage } from "@inertiajs/inertia-react"; import { formatDate, formatIDR } from "@/Utils"; export default function FormModal(props) { const { auth: { user } } = usePage().props const { modalState } = props const { data, setData } = useForm({ id: null, name: "", description: "", job_number: "", date_expense: new Date(), amount: "", isIncome: 0, is_paid: 0, status: "" }) const handleClose = () => { modalState.toggle() } useEffect(() => { const expense = modalState.data if (expense !== null) { setData({ id: expense?.id, name: expense?.name, description: expense?.description, job_number: expense?.job_number, date_expense: expense?.date_expense, amount: expense?.amount, isIncome: expense?.isIncome, is_paid: expense?.is_paid, status: expense?.status, }) return } }, [modalState]) return ( {data.isIncome === 0 && ( <>
)}