Skip to content

Commit 74eb986

Browse files
committed
convert company to nested filter
move limit to top 50 from the matched company filters delete company filter, passing title to props update nested filter test remove show less logic, update icon, update unit tests adding plus icon remove typo updat eyarn.lock update lintstaged update dist update dist Rever package.lock
1 parent cddab0f commit 74eb986

15 files changed

Lines changed: 109 additions & 224 deletions

File tree

dist/ccdb5.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ccdb5.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ccdb5.js

Lines changed: 54 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ccdb5.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Common/Icon/iconMap.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { ReactComponent as LineChart } from '../../../icons/line-chart-custom.sv
1414
import { ReactComponent as List } from '../../../icons/list.svg';
1515
import { ReactComponent as Map } from '../../../icons/map.svg';
1616
import { ReactComponent as MinusRound } from '../../../icons/minus-round.svg';
17+
import { ReactComponent as Plus } from '../../../icons/plus.svg';
1718
import { ReactComponent as PlusRound } from '../../../icons/plus-round.svg';
1819
import { ReactComponent as Printer } from '../../../icons/print.svg';
1920
import { ReactComponent as Right } from '../../../icons/right.svg';
@@ -52,6 +53,7 @@ const iconMap = {
5253
map: <Map />,
5354
// cf-icon-svg--minus-round
5455
'minus-round': <MinusRound />,
56+
plus: <Plus />,
5557
// cf-icon-svg--plus-round
5658
'plus-round': <PlusRound />,
5759
// cf-icon-svg--print

src/components/Filters/Company/Company.js

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/components/Filters/Company/Company.spec.js

Lines changed: 0 additions & 75 deletions
This file was deleted.

src/components/Filters/Company/fixture.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/components/Filters/FilterPanel/FilterPanel.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import './FilterPanel.scss';
2-
import { Company } from '../Company/Company';
32
import { CompanyReceivedFilter } from '../Date/CompanyReceivedFilter';
43
import { useDispatch, useSelector } from 'react-redux';
54
import { DateFilter } from '../Date/DateFilter';
@@ -55,6 +54,7 @@ export const FilterPanel = () => {
5554
'in the complaint'
5655
}
5756
fieldName="product"
57+
filterTitle="Product / Sub-product"
5858
/>
5959
<hr />
6060
<NestedFilter
@@ -63,13 +63,21 @@ export const FilterPanel = () => {
6363
'in the complaint'
6464
}
6565
fieldName="issue"
66+
filterTitle="Issue / Sub-issue"
6667
/>
6768
<hr />
6869
<FederalState />
6970
<hr />
7071
<ZipCode />
7172
<hr />
72-
<Company />
73+
<NestedFilter
74+
desc={
75+
'The type of issue and sub-issue the consumer identified ' +
76+
'in the complaint'
77+
}
78+
fieldName="company"
79+
filterTitle="Company"
80+
/>
7381
<hr />
7482
<SimpleFilter
7583
title="Did company provide a timely response?"

src/components/Filters/MoreOrLess/MoreOrLess.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,22 @@ import { createElement, useState } from 'react';
33
import { coalesce, sortOptions } from '../../../utils';
44
import { useSelector } from 'react-redux';
55
import { selectFiltersRoot } from '../../../reducers/filters/selectors';
6+
import getIcon from '../../Common/Icon/iconMap';
67

78
export const MoreOrLess = ({
89
fieldName,
910
listComponent,
1011
options,
1112
perBucketProps = (bucket, props) => props,
12-
hasMore = false,
1313
}) => {
14-
const [currentlyHasMore, setCurrentlyHasMore] = useState(hasMore);
1514
const filters = useSelector(selectFiltersRoot);
1615
const selectedFilters = coalesce(filters, fieldName, []);
16+
const [limit, setLimit] = useState(5);
1717
const all = sortOptions(options, selectedFilters, fieldName);
18-
const some = all.length > 5 ? all.slice(0, 5) : all;
19-
const remain = all.length - 5;
20-
18+
const step = 50;
19+
const some = options.slice(0, limit);
20+
// either 50, or remaining count
21+
const nextStep = step < all.length ? step : all.length - limit;
2122
const buildListComponent = (bucket) => {
2223
const itemProps = perBucketProps(bucket, {
2324
fieldName,
@@ -31,25 +32,20 @@ export const MoreOrLess = ({
3132
};
3233

3334
const toggleShowMore = () => {
34-
setCurrentlyHasMore(!currentlyHasMore);
35+
setLimit(limit + nextStep);
3536
};
3637

3738
return (
3839
<>
39-
<ul>
40-
{currentlyHasMore
41-
? all.map((bucket) => buildListComponent(bucket))
42-
: some.map((bucket) => buildListComponent(bucket))}
43-
</ul>
44-
{remain > 0 ? (
40+
<ul>{some.map((bucket) => buildListComponent(bucket))}</ul>
41+
{some.length < options.length && (
4542
<div>
4643
<button className="a-btn a-btn--link more" onClick={toggleShowMore}>
47-
{currentlyHasMore
48-
? `- Show ${remain} less`
49-
: `+ Show ${remain} more`}
44+
{getIcon('plus')}
45+
<span>{`Show ${nextStep} more`}</span>
5046
</button>
5147
</div>
52-
) : null}
48+
)}
5349
</>
5450
);
5551
};
@@ -63,5 +59,4 @@ MoreOrLess.propTypes = {
6359
]).isRequired,
6460
options: PropTypes.array.isRequired,
6561
perBucketProps: PropTypes.func,
66-
hasMore: PropTypes.bool,
6762
};

0 commit comments

Comments
 (0)