diff --git a/src/pages/BandiPreInstructor/components/AllBandiPreInstructorTableAsync/index.js b/src/pages/BandiPreInstructor/components/AllBandiPreInstructorTableAsync/index.js index 1ca8a0d..2356004 100644 --- a/src/pages/BandiPreInstructor/components/AllBandiPreInstructorTableAsync/index.js +++ b/src/pages/BandiPreInstructor/components/AllBandiPreInstructorTableAsync/index.js @@ -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 (
diff --git a/src/pages/Dashboard/components/LatestBandiTableAsync/index.js b/src/pages/Dashboard/components/LatestBandiTableAsync/index.js index b5b29de..548ad9a 100644 --- a/src/pages/Dashboard/components/LatestBandiTableAsync/index.js +++ b/src/pages/Dashboard/components/LatestBandiTableAsync/index.js @@ -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 (
diff --git a/src/pages/DashboardInstructorManager/components/LatestBandiTableInstructorManagerAsync/index.js b/src/pages/DashboardInstructorManager/components/LatestBandiTableInstructorManagerAsync/index.js index c696101..1bd8030 100644 --- a/src/pages/DashboardInstructorManager/components/LatestBandiTableInstructorManagerAsync/index.js +++ b/src/pages/DashboardInstructorManager/components/LatestBandiTableInstructorManagerAsync/index.js @@ -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
} - 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 (