import React, { useState } from 'react' import { Link, useForm } from '@inertiajs/inertia-react'; import { toast } from 'react-toastify'; import { Inertia } from '@inertiajs/inertia' export default function ModalClosing() { const {data, setData} = useForm({ is_rolling: 0, }) const [loading, setLoading] = useState(false) const handleDownload = () => { const confirm = window.confirm('hapus transaksi dan buat budget baru ?') if(!confirm){ return } setLoading(true) fetch(`${route('close')}?is_rolling=${data.is_rolling}`, { method: 'GET' }) .then((response) => response.blob()) .then((blob) => { const url = window.URL.createObjectURL( new Blob([blob]), ); const link = document.createElement('a'); link.href = url; link.setAttribute('download', `summary.xlsx`); document.body.appendChild(link); link.click(); link.parentNode.removeChild(link); }) .finally(() => { toast.success('berhasil mendownload, silahkan klik close') setLoading(false) setTimeout(() => { Inertia.visit(route('summary')) }, 3000) }); } return (

Monthly Closing

Download
Close
) }