-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: wire up search and filter on Team page #4265
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,6 +158,18 @@ const Team: React.FC = () => { | |
const [filteredFlows, setFilteredFlows] = useState<FlowSummary[] | null>( | ||
null, | ||
); | ||
const [searchedFlows, setSearchedFlows] = useState<FlowSummary[] | null>( | ||
null, | ||
); | ||
const [matchingFlows, setMatchingflows] = useState<FlowSummary[] | null>( | ||
null, | ||
); | ||
|
||
useEffect(() => { | ||
const diffFlows = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an intersection we're checking for, not a difference. An intersection is an item which is in both lists, a difference would be items in one list but not the other. |
||
searchedFlows?.filter((flow) => filteredFlows?.includes(flow)) || null; | ||
setMatchingflows(diffFlows); | ||
}, [searchedFlows, filteredFlows]); | ||
|
||
const sortOptions: SortableFields<FlowSummary>[] = [ | ||
{ | ||
|
@@ -223,6 +235,7 @@ const Team: React.FC = () => { | |
); | ||
setFlows(sortedFlows); | ||
setFilteredFlows(sortedFlows); | ||
setSearchedFlows(sortedFlows); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't need to |
||
}); | ||
}, [teamId, setFlows, getFlows]); | ||
|
||
|
@@ -262,7 +275,7 @@ const Team: React.FC = () => { | |
{hasFeatureFlag("SORT_FLOWS") && flows && ( | ||
<SearchBox<FlowSummary> | ||
records={flows} | ||
setRecords={setFilteredFlows} | ||
setRecords={setSearchedFlows} | ||
searchKey={["name", "slug"]} | ||
/> | ||
)} | ||
|
@@ -294,9 +307,9 @@ const Team: React.FC = () => { | |
/> | ||
)} | ||
</Box> | ||
{filteredFlows && flows && ( | ||
{matchingFlows && flows && ( | ||
<DashboardList> | ||
{filteredFlows.map((flow) => ( | ||
{matchingFlows.map((flow) => ( | ||
<FlowCard | ||
flow={flow} | ||
flows={flows} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going through a few iterations, this seemed the easiest to read, while functionally working as expected.