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 initialFetchStatuses = ['PUBLISH', 'EXPIRED'];
|
||||
|
||||
const role = storeGet('getRole')
|
||||
|
||||
const getPaginationQuery = useCallback(() => getQueryParamsForPaginatedEndpoint(lazyState, statuses, 'id'), [lazyState]);
|
||||
const getPaginationQuery = useCallback(() => getQueryParamsForPaginatedEndpoint(lazyState, initialFetchStatuses, 'id'), [lazyState]);
|
||||
|
||||
const onPage = (event) => {
|
||||
setLazyState(event);
|
||||
@@ -174,7 +175,7 @@ const AllBandiPreInstructorTableAsync = () => {
|
||||
const paginationQuery = getPaginationQuery();
|
||||
|
||||
BandoService.getBandiPaginated(paginationQuery, getCallback, errGetCallbacks);
|
||||
}, [lazyState]);
|
||||
}, [lazyState, getPaginationQuery]);
|
||||
|
||||
return (
|
||||
<div className="appPageSection__table">
|
||||
|
||||
@@ -40,10 +40,10 @@ const LatestBandiTableAsync = () => {
|
||||
name: { value: null, matchMode: 'contains' },
|
||||
startDate: { 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]);
|
||||
|
||||
@@ -197,7 +197,7 @@ const LatestBandiTableAsync = () => {
|
||||
const paginationQuery = getPaginationQuery();
|
||||
|
||||
BandoService.getBandiPaginated(paginationQuery, getCallback, errGetCallbacks);
|
||||
}, [lazyState]);
|
||||
}, [lazyState, getPaginationQuery]);
|
||||
|
||||
return (
|
||||
<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 translationStrings from '../../../../translationStringsForComponents';
|
||||
@@ -39,10 +39,10 @@ const LatestBandiTableInstructorManagerAsync = () => {
|
||||
name: { value: null, matchMode: 'contains' },
|
||||
startDate: { 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]);
|
||||
|
||||
@@ -128,23 +128,23 @@ const LatestBandiTableInstructorManagerAsync = () => {
|
||||
return <div className="appPageSection__tableActions">
|
||||
<Button type="button"
|
||||
size="small"
|
||||
icon="pi pi-receipt"
|
||||
severity="info"
|
||||
icon="pi pi-download"
|
||||
iconPos="right"
|
||||
label={__('CSV', 'gepafin')}
|
||||
onClick={() => exportToCSV(rowData.id)}/>
|
||||
label={__('Scarica graduatoria', 'gepafin')}
|
||||
onClick={() => handleDownloadRanking(rowData.id)}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
|
||||
const exportToCSV = (applicationId) => {
|
||||
const handleDownloadRanking = (callId) => {
|
||||
setLocalAsyncRequest(true);
|
||||
ApplicationService.downloadCsvReport(
|
||||
applicationId,
|
||||
(resp) => getCsvReportback(resp, applicationId),
|
||||
errCsvReportCallback
|
||||
)
|
||||
ApplicationService.downloadRanking(callId,
|
||||
(resp) => downloadSuccessCallback(resp, callId),
|
||||
downloadErrorCallback)
|
||||
}
|
||||
|
||||
const getCsvReportback = (resp, applicationId) => {
|
||||
const downloadSuccessCallback = (resp, applicationId) => {
|
||||
const file = new Blob([resp], { type: 'text/csv' });
|
||||
const url = window.URL.createObjectURL(file);
|
||||
const link = document.createElement('a');
|
||||
@@ -156,7 +156,7 @@ const LatestBandiTableInstructorManagerAsync = () => {
|
||||
setLocalAsyncRequest(false);
|
||||
}
|
||||
|
||||
const errCsvReportCallback = (resp) => {
|
||||
const downloadErrorCallback = (resp) => {
|
||||
set404FromErrorResponse(resp);
|
||||
setLocalAsyncRequest(false);
|
||||
}
|
||||
@@ -172,7 +172,7 @@ const LatestBandiTableInstructorManagerAsync = () => {
|
||||
name: { value: null, matchMode: 'contains' },
|
||||
startDate: { 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();
|
||||
|
||||
BandoService.getBandiPaginated(paginationQuery, getCallback, errGetCallbacks);
|
||||
}, [lazyState]);
|
||||
}, [lazyState, getPaginationQuery]);
|
||||
|
||||
return (
|
||||
<div className="appPageSection__table">
|
||||
|
||||
Reference in New Issue
Block a user