import React, { useRef } from 'react' import { useForm } from '@inertiajs/react' export default function ModalImport(props) { const { modalState } = props const { data, setData, post, progress, errors, clearErrors } = useForm({ file: null, }); const inputFileImport = useRef(); const handleReset = () => { setData({file: null}); inputFileImport.current.value = "" clearErrors(); }; const handleCancel = () => { modalState.toggle() handleReset(); }; function handleSubmit(e) { e.preventDefault(); post(route("docs.import"), { forceFormData: false, onSuccess: () => Promise.all([handleReset(), modalState.toggle()]), }); return; } return (

Import

{ console.log(inputFileImport.current.click()) }} >Pilih File:
{data.file ? data.file.name : 'Pilih File'}
setData("file", e.target.files[0]) } /> {progress && ( {progress.percentage}% )}
{errors.file}

Unduh format file import{" "} disini

Upload
Batal
) }