import React, { useEffect, useRef } from 'react' import { useForm } from '@inertiajs/react' import Modal from '@/Components/Modal' import Button from '@/Components/Button' export default function ImportModal(props) { const { modalState } = props const { data, setData, post, progress, processing, errors, clearErrors } = useForm({ file: null, }) const inputFileImport = useRef() const handleReset = () => { setData({ file: null }) inputFileImport.current.value = '' clearErrors() } const handleCancel = () => { modalState.toggle() handleReset() } const handleClose = () => { handleReset() modalState.toggle() } function handleSubmit(e) { e.preventDefault() post(route('customer-point.import'), { forceFormData: false, onSuccess: () => Promise.all([handleReset(), modalState.toggle()]), }) return } return (
{ console.log(inputFileImport.current.click()) }} >
Pilih File:{' '}
{data.file ? data.file.name : 'Pilih File'}
{errors.file}
setData('file', e.target.files[0])} /> {progress && (
{' '} {progress.percentage}%
)}

Unduh format file import{' '} disini

) }