Skip to content

Commit

Permalink
feat: wire up search and filter on Team page (#4265)
Browse files Browse the repository at this point in the history
  • Loading branch information
RODO94 authored Feb 6, 2025
1 parent aaf822b commit 438f7c7
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions editor.planx.uk/src/pages/Team.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
searchedFlows?.filter((flow) => filteredFlows?.includes(flow)) || null;
setMatchingflows(diffFlows);
}, [searchedFlows, filteredFlows]);

const sortOptions: SortableFields<FlowSummary>[] = [
{
Expand Down Expand Up @@ -223,6 +235,7 @@ const Team: React.FC = () => {
);
setFlows(sortedFlows);
setFilteredFlows(sortedFlows);
setSearchedFlows(sortedFlows);
});
}, [teamId, setFlows, getFlows]);

Expand Down Expand Up @@ -262,7 +275,7 @@ const Team: React.FC = () => {
{hasFeatureFlag("SORT_FLOWS") && flows && (
<SearchBox<FlowSummary>
records={flows}
setRecords={setFilteredFlows}
setRecords={setSearchedFlows}
searchKey={["name", "slug"]}
/>
)}
Expand Down Expand Up @@ -320,9 +333,9 @@ const Team: React.FC = () => {
</Box>
)}
</Box>
{filteredFlows && flows && (
{matchingFlows && flows && (
<DashboardList>
{filteredFlows.map((flow) => (
{matchingFlows.map((flow) => (
<FlowCard
flow={flow}
flows={flows}
Expand Down

0 comments on commit 438f7c7

Please sign in to comment.