add button to dashboard
This commit is contained in:
@@ -95,23 +95,22 @@ const LatestBandiTableAsync = () => {
|
|||||||
</Link>
|
</Link>
|
||||||
<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)}/>
|
onClick={() => handleDownloadRanking(rowData.id)}/>
|
||||||
</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');
|
||||||
@@ -123,7 +122,7 @@ const LatestBandiTableAsync = () => {
|
|||||||
setLocalAsyncRequest(false);
|
setLocalAsyncRequest(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const errCsvReportCallback = (resp) => {
|
const downloadErrorCallback = (resp) => {
|
||||||
set404FromErrorResponse(resp);
|
set404FromErrorResponse(resp);
|
||||||
setLocalAsyncRequest(false);
|
setLocalAsyncRequest(false);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user