auto refresh tasks waiting for my groups on homepage
This commit is contained in:
parent
2cdd0d0259
commit
f4d40a72dc
|
@ -7,6 +7,7 @@ import {
|
||||||
convertSecondsToFormattedDateTime,
|
convertSecondsToFormattedDateTime,
|
||||||
getPageInfoFromSearchParams,
|
getPageInfoFromSearchParams,
|
||||||
modifyProcessIdentifierForPathParam,
|
modifyProcessIdentifierForPathParam,
|
||||||
|
refreshAtInterval,
|
||||||
} from '../helpers';
|
} from '../helpers';
|
||||||
import HttpService from '../services/HttpService';
|
import HttpService from '../services/HttpService';
|
||||||
import { PaginationObject } from '../interfaces';
|
import { PaginationObject } from '../interfaces';
|
||||||
|
@ -14,6 +15,8 @@ import TableCellWithTimeAgoInWords from './TableCellWithTimeAgoInWords';
|
||||||
|
|
||||||
const PER_PAGE_FOR_TASKS_ON_HOME_PAGE = 5;
|
const PER_PAGE_FOR_TASKS_ON_HOME_PAGE = 5;
|
||||||
const paginationQueryParamPrefix = 'tasks_waiting_for_my_groups';
|
const paginationQueryParamPrefix = 'tasks_waiting_for_my_groups';
|
||||||
|
const REFRESH_INTERVAL = 5;
|
||||||
|
const REFRESH_TIMEOUT = 600;
|
||||||
|
|
||||||
export default function TasksWaitingForMyGroups() {
|
export default function TasksWaitingForMyGroups() {
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
|
@ -21,6 +24,7 @@ export default function TasksWaitingForMyGroups() {
|
||||||
const [pagination, setPagination] = useState<PaginationObject | null>(null);
|
const [pagination, setPagination] = useState<PaginationObject | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
const getTasks = () => {
|
||||||
const { page, perPage } = getPageInfoFromSearchParams(
|
const { page, perPage } = getPageInfoFromSearchParams(
|
||||||
searchParams,
|
searchParams,
|
||||||
PER_PAGE_FOR_TASKS_ON_HOME_PAGE,
|
PER_PAGE_FOR_TASKS_ON_HOME_PAGE,
|
||||||
|
@ -35,6 +39,9 @@ export default function TasksWaitingForMyGroups() {
|
||||||
path: `/tasks/for-my-groups?per_page=${perPage}&page=${page}`,
|
path: `/tasks/for-my-groups?per_page=${perPage}&page=${page}`,
|
||||||
successCallback: setTasksFromResult,
|
successCallback: setTasksFromResult,
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
getTasks();
|
||||||
|
refreshAtInterval(REFRESH_INTERVAL, REFRESH_TIMEOUT, getTasks);
|
||||||
}, [searchParams]);
|
}, [searchParams]);
|
||||||
|
|
||||||
const buildTable = () => {
|
const buildTable = () => {
|
||||||
|
|
Loading…
Reference in New Issue