add scarica graduatoria button

This commit is contained in:
Noemi
2025-07-02 12:59:28 +02:00
parent 430b3e30dd
commit d6b4bc98e0

View File

@@ -96,23 +96,23 @@ const AllBandiTableAsync = () => {
{['PUBLISH', 'EXPIRED'].includes(rowData.status) {['PUBLISH', 'EXPIRED'].includes(rowData.status)
? <Button type="button" ? <Button type="button"
size="small" size="small"
icon="pi pi-receipt" severity='info'
icon="pi pi-download"
iconPos="right" iconPos="right"
label={__('CSV', 'gepafin')} label={__('Scarica graduatoria', 'gepafin')}
onClick={() => exportToCSV(rowData.id)}/> : null} onClick={() => handleDownloadRanking(rowData.id)}
/> : null}
</div> </div>
} }
const exportToCSV = (applicationId) => { const handleDownloadRanking = (callId) => {
setLocalAsyncRequest(true); setLocalAsyncRequest(true);
ApplicationService.downloadCsvReport( ApplicationService.downloadRanking(callId,
applicationId, (resp) => downloadSuccessCallback(resp, callId),
(resp) => getCsvReportback(resp, applicationId), downloadErrorCallback)
errCsvReportCallback
)
} }
const getCsvReportback = (resp, applicationId) => { const downloadSuccessCallback = (resp, applicationId) => {
const file = new Blob([resp], { type: 'text/csv' }); const file = new Blob([resp], { type: 'text/csv' });
const url = window.URL.createObjectURL(file); const url = window.URL.createObjectURL(file);
const link = document.createElement('a'); const link = document.createElement('a');
@@ -124,7 +124,7 @@ const AllBandiTableAsync = () => {
setLocalAsyncRequest(false); setLocalAsyncRequest(false);
} }
const errCsvReportCallback = (resp) => { const downloadErrorCallback = (resp) => {
set404FromErrorResponse(resp); set404FromErrorResponse(resp);
setLocalAsyncRequest(false); setLocalAsyncRequest(false);
} }