-
-
- {processGroups.map(processGroup => (
-
- - {processGroup.id} - - ))} -
diff --git a/src/routes/ProcessGroups.js b/src/routes/ProcessGroups.js index db1c666..84ece6e 100644 --- a/src/routes/ProcessGroups.js +++ b/src/routes/ProcessGroups.js @@ -1,17 +1,23 @@ import React, { useEffect, useState } from "react"; -import { Link } from "react-router-dom"; +import { Link, useSearchParams } from "react-router-dom"; import { BACKEND_BASE_URL } from '../config'; import { HOT_AUTH_TOKEN } from '../config'; import ProcessBreadcrumb from '../components/ProcessBreadcrumb' -import Button from 'react-bootstrap/Button' +import { Button, Table } from 'react-bootstrap' +import PaginationForTable, { DEFAULT_PER_PAGE, DEFAULT_PAGE } from '../components/PaginationForTable' // Example process group json // {'admin': False, 'display_name': 'Test Workflows', 'display_order': 0, 'id': 'test_process_group'} export default function ProcessGroups() { + const [searchParams] = useSearchParams(); + const [processGroups, setProcessGroups] = useState([]); + const [pagination, setPagination] = useState(null); useEffect(() => { - fetch(`${BACKEND_BASE_URL}/process-groups`, { + const page = searchParams.get('page') || DEFAULT_PAGE; + const perPage = parseInt(searchParams.get('per_page') || DEFAULT_PER_PAGE); + fetch(`${BACKEND_BASE_URL}/process-groups?per_page=${perPage}&page=${page}`, { headers: new Headers({ 'Authorization': `Bearer ${HOT_AUTH_TOKEN}` }) @@ -20,6 +26,7 @@ export default function ProcessGroups() { .then( (result) => { setProcessGroups(result.results); + setPagination(result.pagination); }, // Note: it's important to handle errors here // instead of a catch() block so that we don't swallow @@ -28,9 +35,37 @@ export default function ProcessGroups() { console.log(newError); } ) - }, []); + }, [searchParams]); - if (processGroups) { + const buildTable = (() => { + const rows = processGroups.map((row,index) => { + return ( +
Process Group Id | +Display Name | +
---|