Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Fix the pagination bug in the activities page #434

Merged
merged 1 commit into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions ui/src/views/activities/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect } from 'react';
import { useEffect, useState } from 'react';
import { shallowEqual } from 'react-redux';
import { Helmet } from 'react-helmet';

Expand Down Expand Up @@ -38,19 +38,39 @@ export default (): JSX.Element => {
// eslint-disable-next-line
}, [dispatch]);

const onClickSearch = (values: SearchActivitiesValues) => {
const [searchOptions, setSearchOptions] = useState<SearchActivitiesValues>(
{}
);

const search = () =>
dispatch(
searchDeployments({
start: values.period ? values.period[0].toDate() : undefined,
end: values.period ? values.period[1].toDate() : undefined,
productionOnly: values.productionOnly ? values.productionOnly : false,
start: searchOptions.period
? searchOptions.period[0].toDate()
: undefined,
end: searchOptions.period
? searchOptions.period[1].toDate()
: undefined,
productionOnly: searchOptions.productionOnly
? searchOptions.productionOnly
: false,
})
);

const onClickSearch = (values: SearchActivitiesValues) => {
setSearchOptions(values);
search();
};

const onClickPrev = () => dispatch(actions.decreasePage());
const onClickPrev = () => {
dispatch(actions.decreasePage());
search();
};

const onClickNext = () => dispatch(actions.increasePage());
const onClickNext = () => {
dispatch(actions.increasePage());
search();
};

return (
<Main>
Expand Down
1 change: 1 addition & 0 deletions ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"noImplicitAny": false,
"jsx": "react-jsx"
},
"include": ["src"]
Expand Down