|
1 |
| -import { useEffect } from 'react'; |
| 1 | +import { useEffect, useState } from 'react'; |
2 | 2 | import { shallowEqual } from 'react-redux';
|
3 | 3 | import { Helmet } from 'react-helmet';
|
4 | 4 |
|
@@ -38,19 +38,39 @@ export default (): JSX.Element => {
|
38 | 38 | // eslint-disable-next-line
|
39 | 39 | }, [dispatch]);
|
40 | 40 |
|
41 |
| - const onClickSearch = (values: SearchActivitiesValues) => { |
| 41 | + const [searchOptions, setSearchOptions] = useState<SearchActivitiesValues>( |
| 42 | + {} |
| 43 | + ); |
| 44 | + |
| 45 | + const search = () => |
42 | 46 | dispatch(
|
43 | 47 | searchDeployments({
|
44 |
| - start: values.period ? values.period[0].toDate() : undefined, |
45 |
| - end: values.period ? values.period[1].toDate() : undefined, |
46 |
| - productionOnly: values.productionOnly ? values.productionOnly : false, |
| 48 | + start: searchOptions.period |
| 49 | + ? searchOptions.period[0].toDate() |
| 50 | + : undefined, |
| 51 | + end: searchOptions.period |
| 52 | + ? searchOptions.period[1].toDate() |
| 53 | + : undefined, |
| 54 | + productionOnly: searchOptions.productionOnly |
| 55 | + ? searchOptions.productionOnly |
| 56 | + : false, |
47 | 57 | })
|
48 | 58 | );
|
| 59 | + |
| 60 | + const onClickSearch = (values: SearchActivitiesValues) => { |
| 61 | + setSearchOptions(values); |
| 62 | + search(); |
49 | 63 | };
|
50 | 64 |
|
51 |
| - const onClickPrev = () => dispatch(actions.decreasePage()); |
| 65 | + const onClickPrev = () => { |
| 66 | + dispatch(actions.decreasePage()); |
| 67 | + search(); |
| 68 | + }; |
52 | 69 |
|
53 |
| - const onClickNext = () => dispatch(actions.increasePage()); |
| 70 | + const onClickNext = () => { |
| 71 | + dispatch(actions.increasePage()); |
| 72 | + search(); |
| 73 | + }; |
54 | 74 |
|
55 | 75 | return (
|
56 | 76 | <Main>
|
|
0 commit comments