|
|
|
@ -68,6 +68,13 @@ const Resource = ({ params }) => {
|
|
|
|
|
getDataMaterialR() |
|
|
|
|
}, [search, rowsPerPage, currentPage]) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
const cekData = dataExport || [] |
|
|
|
|
if (cekData.length > 0) { |
|
|
|
|
exportExcel() |
|
|
|
|
} |
|
|
|
|
}, [dataExport]) |
|
|
|
|
|
|
|
|
|
const getDataMaterialR = async () => { |
|
|
|
|
|
|
|
|
|
let start = 0; |
|
|
|
@ -163,6 +170,17 @@ const Resource = ({ params }) => {
|
|
|
|
|
setTypeDialog(type) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const exportExcel = () => { |
|
|
|
|
const dataExcel = dataExport || []; |
|
|
|
|
const fileName = `Data ${pageName}.xlsx`; |
|
|
|
|
const ws = XLSX.utils.json_to_sheet(dataExcel); |
|
|
|
|
const wb = XLSX.utils.book_new(); |
|
|
|
|
XLSX.utils.book_append_sheet(wb, ws, `Data ${pageName}`); |
|
|
|
|
XLSX.writeFile(wb, fileName); |
|
|
|
|
setDataExport([]) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleExportExcel = async () => { |
|
|
|
|
|
|
|
|
|
const payload = { |
|
|
|
@ -177,6 +195,7 @@ const Resource = ({ params }) => {
|
|
|
|
|
] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const result = await axios |
|
|
|
|
.post(PROYEK_SEARCH, payload, HEADER) |
|
|
|
|
.then(res => res) |
|
|
|
|