Merge pull request #53 from Kitzanos/task/1473
Adjust actions for super instructor
This commit is contained in:
@@ -45,10 +45,11 @@ const AllBandiPreInstructorTableAsync = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
const statuses = ['DRAFT', 'PUBLISH', 'EXPIRED'];
|
const statuses = ['DRAFT', 'PUBLISH', 'EXPIRED'];
|
||||||
|
const initialFetchStatuses = ['PUBLISH', 'EXPIRED'];
|
||||||
|
|
||||||
const role = storeGet('getRole')
|
const role = storeGet('getRole')
|
||||||
|
|
||||||
const getPaginationQuery = useCallback(() => getQueryParamsForPaginatedEndpoint(lazyState, statuses, 'id'), [lazyState]);
|
const getPaginationQuery = useCallback(() => getQueryParamsForPaginatedEndpoint(lazyState, initialFetchStatuses, 'id'), [lazyState]);
|
||||||
|
|
||||||
const onPage = (event) => {
|
const onPage = (event) => {
|
||||||
setLazyState(event);
|
setLazyState(event);
|
||||||
@@ -174,7 +175,7 @@ const AllBandiPreInstructorTableAsync = () => {
|
|||||||
const paginationQuery = getPaginationQuery();
|
const paginationQuery = getPaginationQuery();
|
||||||
|
|
||||||
BandoService.getBandiPaginated(paginationQuery, getCallback, errGetCallbacks);
|
BandoService.getBandiPaginated(paginationQuery, getCallback, errGetCallbacks);
|
||||||
}, [lazyState]);
|
}, [lazyState, getPaginationQuery]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="appPageSection__table">
|
<div className="appPageSection__table">
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ const LatestBandiTableAsync = () => {
|
|||||||
name: { value: null, matchMode: 'contains' },
|
name: { value: null, matchMode: 'contains' },
|
||||||
startDate: { value: null, matchMode: 'dateIs' },
|
startDate: { value: null, matchMode: 'dateIs' },
|
||||||
endDate: { value: null, matchMode: 'dateIs' },
|
endDate: { value: null, matchMode: 'dateIs' },
|
||||||
status: { value: null, matchMode: 'equals' }
|
status: { value: 'PUBLISH', matchMode: 'equals' }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const statuses = ['PUBLISH', 'EXPIRED'];
|
const statuses = ['PUBLISH'];
|
||||||
|
|
||||||
const getPaginationQuery = useCallback(() => getQueryParamsForPaginatedEndpoint(lazyState, statuses, 'id'), [lazyState]);
|
const getPaginationQuery = useCallback(() => getQueryParamsForPaginatedEndpoint(lazyState, statuses, 'id'), [lazyState]);
|
||||||
|
|
||||||
@@ -197,7 +197,7 @@ const LatestBandiTableAsync = () => {
|
|||||||
const paginationQuery = getPaginationQuery();
|
const paginationQuery = getPaginationQuery();
|
||||||
|
|
||||||
BandoService.getBandiPaginated(paginationQuery, getCallback, errGetCallbacks);
|
BandoService.getBandiPaginated(paginationQuery, getCallback, errGetCallbacks);
|
||||||
}, [lazyState]);
|
}, [lazyState, getPaginationQuery]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="appPageSection__table">
|
<div className="appPageSection__table">
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useState, useCallback } from 'react';
|
import React, { useEffect, useState, useCallback, useMemo } from 'react';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
|
|
||||||
import translationStrings from '../../../../translationStringsForComponents';
|
import translationStrings from '../../../../translationStringsForComponents';
|
||||||
@@ -39,10 +39,10 @@ const LatestBandiTableInstructorManagerAsync = () => {
|
|||||||
name: { value: null, matchMode: 'contains' },
|
name: { value: null, matchMode: 'contains' },
|
||||||
startDate: { value: null, matchMode: 'dateIs' },
|
startDate: { value: null, matchMode: 'dateIs' },
|
||||||
endDate: { value: null, matchMode: 'dateIs' },
|
endDate: { value: null, matchMode: 'dateIs' },
|
||||||
status: { value: null, matchMode: 'equals' }
|
status: { value: 'PUBLISH', matchMode: 'equals' }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const statuses = ['PUBLISH', 'EXPIRED'];
|
const statuses = ['PUBLISH'];
|
||||||
|
|
||||||
const getPaginationQuery = useCallback(() => getQueryParamsForPaginatedEndpoint(lazyState, statuses, 'id'), [lazyState]);
|
const getPaginationQuery = useCallback(() => getQueryParamsForPaginatedEndpoint(lazyState, statuses, 'id'), [lazyState]);
|
||||||
|
|
||||||
@@ -128,23 +128,23 @@ const LatestBandiTableInstructorManagerAsync = () => {
|
|||||||
return <div className="appPageSection__tableActions">
|
return <div className="appPageSection__tableActions">
|
||||||
<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');
|
||||||
@@ -156,7 +156,7 @@ const LatestBandiTableInstructorManagerAsync = () => {
|
|||||||
setLocalAsyncRequest(false);
|
setLocalAsyncRequest(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const errCsvReportCallback = (resp) => {
|
const downloadErrorCallback = (resp) => {
|
||||||
set404FromErrorResponse(resp);
|
set404FromErrorResponse(resp);
|
||||||
setLocalAsyncRequest(false);
|
setLocalAsyncRequest(false);
|
||||||
}
|
}
|
||||||
@@ -172,7 +172,7 @@ const LatestBandiTableInstructorManagerAsync = () => {
|
|||||||
name: { value: null, matchMode: 'contains' },
|
name: { value: null, matchMode: 'contains' },
|
||||||
startDate: { value: null, matchMode: 'dateIs' },
|
startDate: { value: null, matchMode: 'dateIs' },
|
||||||
endDate: { value: null, matchMode: 'dateIs' },
|
endDate: { value: null, matchMode: 'dateIs' },
|
||||||
status: { value: null, matchMode: 'equals' }
|
status: { value: 'PUBLISH', matchMode: 'equals' }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -192,7 +192,7 @@ const LatestBandiTableInstructorManagerAsync = () => {
|
|||||||
const paginationQuery = getPaginationQuery();
|
const paginationQuery = getPaginationQuery();
|
||||||
|
|
||||||
BandoService.getBandiPaginated(paginationQuery, getCallback, errGetCallbacks);
|
BandoService.getBandiPaginated(paginationQuery, getCallback, errGetCallbacks);
|
||||||
}, [lazyState]);
|
}, [lazyState, getPaginationQuery]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="appPageSection__table">
|
<div className="appPageSection__table">
|
||||||
|
|||||||
Reference in New Issue
Block a user