- added CSV download fo instructor manager;
This commit is contained in:
@@ -135,6 +135,12 @@ const LatestBandiTableInstructorManagerAsync = () => {
|
|||||||
label={__('Scarica graduatoria', 'gepafin')}
|
label={__('Scarica graduatoria', 'gepafin')}
|
||||||
onClick={() => handleDownloadRanking(rowData.id)}
|
onClick={() => handleDownloadRanking(rowData.id)}
|
||||||
/>
|
/>
|
||||||
|
<Button type="button"
|
||||||
|
size="small"
|
||||||
|
icon="pi pi-receipt"
|
||||||
|
iconPos="right"
|
||||||
|
label={__('CSV', 'gepafin')}
|
||||||
|
onClick={() => exportToCSV(rowData.id)}/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,6 +168,32 @@ const LatestBandiTableInstructorManagerAsync = () => {
|
|||||||
setLocalAsyncRequest(false);
|
setLocalAsyncRequest(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const exportToCSV = (applicationId) => {
|
||||||
|
setLocalAsyncRequest(true);
|
||||||
|
ApplicationService.downloadCsvReport(
|
||||||
|
applicationId,
|
||||||
|
(resp) => getCsvReportback(resp, applicationId),
|
||||||
|
errCsvReportCallback
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const getCsvReportback = (resp, applicationId) => {
|
||||||
|
const file = new Blob([resp], { type: 'text/csv' });
|
||||||
|
const url = window.URL.createObjectURL(file);
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = url;
|
||||||
|
link.setAttribute('download', `call-${applicationId}-applications-report.csv`);
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
link.remove();
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
const errCsvReportCallback = (resp) => {
|
||||||
|
set404FromErrorResponse(resp);
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
}
|
||||||
|
|
||||||
const clearFilter = () => {
|
const clearFilter = () => {
|
||||||
setLazyState({
|
setLazyState({
|
||||||
first: 0,
|
first: 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user