Skip to content

Commit 96525fd

Browse files
committed
integrated tags into filters
1 parent 6fc3b82 commit 96525fd

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

src/user/Admin/Tickets/Filter/Filter.js

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ class Filter extends Component {
5959
(ele) => this.state.status.indexOf(ele.status) !== -1
6060
);
6161
}
62+
console.log(this.state.tags);
63+
if (this.state.tags.length) {
64+
filtered = filtered.filter((ele) =>
65+
this.state.tags.some((tag) => ele.tags.indexOf(tag) !== -1)
66+
);
67+
}
6268
console.log(filtered);
6369
this.props.setFiltered(filtered);
6470
};
@@ -85,13 +91,19 @@ class Filter extends Component {
8591
handleTagsChange = (tag) => {
8692
// in not present then add if already present then clicking on it will remove it
8793
if (this.state.tags.indexOf(tag) === -1) {
88-
this.setState({
89-
tags: [...this.state.tags, tag],
90-
});
94+
this.setState(
95+
{
96+
tags: [...this.state.tags, tag],
97+
},
98+
this.filter
99+
);
91100
} else {
92-
this.setState({
93-
tags: [...this.state.tags.filter((ele) => ele !== tag)],
94-
});
101+
this.setState(
102+
{
103+
tags: [...this.state.tags.filter((ele) => ele !== tag)],
104+
},
105+
this.filter
106+
);
95107
}
96108
};
97109

@@ -119,7 +131,8 @@ class Filter extends Component {
119131
{
120132
search: "",
121133
author: null,
122-
status: ["OPEN", "CLOSED", "PENDING", "SOLVED", "ON_HOLD"],
134+
status: [],
135+
tags: [],
123136
},
124137
this.props.clear
125138
);
@@ -162,10 +175,12 @@ class Filter extends Component {
162175
<div onClick={this.clearFilters} className="clear-filters">
163176
{this.state.search
164177
? "Clear Search and Filters"
165-
: (!this.state.author ||
166-
!this.state.tags.length ||
167-
!this.state.status.length) &&
168-
"Clear Filters"}
178+
: this.state.author ||
179+
this.state.tags.length ||
180+
this.state.status.length ||
181+
this.state.tags.length
182+
? "Clear Filters"
183+
: ""}
169184
</div>
170185
<Dropdown size="sm" alignRight>
171186
<Dropdown.Toggle variant="light" id="dropdown-basic">
@@ -211,9 +226,7 @@ class Filter extends Component {
211226
key={index}
212227
onClick={() => this.handleTagsChange(ele)}
213228
>
214-
{this.state.tags.indexOf(ele) !== -1 && (
215-
<CheckOutlinedIcon />
216-
)}
229+
{this.state.tags.indexOf(ele) !== -1 && <CheckOutlinedIcon />}
217230
{ele}
218231
</Dropdown.Item>
219232
))}

0 commit comments

Comments
 (0)