add download csv ranking
This commit is contained in:
@@ -6,6 +6,7 @@ import translationStrings from '../../../../translationStringsForComponents';
|
||||
|
||||
// api
|
||||
import BandoService from '../../../../service/bando-service';
|
||||
import ApplicationService from '../../../../service/application-service';
|
||||
|
||||
// tools
|
||||
import getTimeParsedFromString from '../../../../helpers/getTimeParsedFromString';
|
||||
@@ -23,6 +24,8 @@ import ProperBandoLabel from '../../../../components/ProperBandoLabel';
|
||||
import { Dropdown } from 'primereact/dropdown';
|
||||
import { Tag } from 'primereact/tag';
|
||||
import { Calendar } from 'primereact/calendar';
|
||||
import { storeSet } from '../../../../store';
|
||||
|
||||
|
||||
const AllBandiPreInstructorTableAsync = () => {
|
||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||
@@ -86,10 +89,37 @@ const AllBandiPreInstructorTableAsync = () => {
|
||||
};
|
||||
|
||||
const actionsBodyTemplate = (rowData) => {
|
||||
return <Link to={`/bandi/${rowData.id}`}>
|
||||
<Button severity="info" label={__('Mostra', 'gepafin')} icon="pi pi-eye" size="small" iconPos="right" />
|
||||
<Button severity="info" label={__('Scarica graduatoria', 'gepafin')} icon="pi pi-download" size="small" iconPos="right" style={{marginTop:'10px'}}/>
|
||||
</Link>
|
||||
return (
|
||||
<div className="p-d-flex p-flex-column">
|
||||
<Link to={`/bandi/${rowData.id}`}>
|
||||
<Button severity="info" label={__('Mostra', 'gepafin')} icon="pi pi-eye" size="small" iconPos="right" />
|
||||
</Link>
|
||||
<Button severity="info" label={__('Scarica graduatoria', 'gepafin')} icon="pi pi-download" size="small" iconPos="right" style={{marginTop:'10px'}} onClick={() => handleDownloadRanking(rowData.id)}/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const downloadSuccessCallback = (resp, callId) => {
|
||||
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-${callId}-applications-report.csv`);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
setLocalAsyncRequest(false);
|
||||
}
|
||||
|
||||
const downloadErrorCallback = (resp) => {
|
||||
setLocalAsyncRequest(false);
|
||||
}
|
||||
|
||||
const handleDownloadRanking = (callId)=>{
|
||||
setLocalAsyncRequest(true);
|
||||
ApplicationService.downloadRanking(callId,
|
||||
(resp)=>downloadSuccessCallback(resp,callId),
|
||||
downloadErrorCallback)
|
||||
}
|
||||
|
||||
const statusBodyTemplate = (rowData) => {
|
||||
|
||||
Reference in New Issue
Block a user