Skip to content

Commit

Permalink
switch original records out and add in flows
Browse files Browse the repository at this point in the history
  • Loading branch information
RODO94 committed Jan 28, 2025
1 parent db5a9fa commit f99c311
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion editor.planx.uk/src/pages/Team.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const Team: React.FC = () => {
</Box>
{hasFeatureFlag("SORT_FLOWS") && flows && (
<SearchBox<FlowSummary>
records={filteredFlows}
records={flows}
setRecords={setFilteredFlows}
searchKey={["name", "slug"]}
/>
Expand Down
7 changes: 3 additions & 4 deletions editor.planx.uk/src/ui/shared/SearchBox/SearchBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export const SearchBox = <T extends object>({
}: SearchBoxProps<T>) => {
const [isSearching, setIsSearching] = useState(false);
const [searchedTerm, setSearchedTerm] = useState<string>();
const [originalRecords] = useState(records);

const searchKeys = useMemo(() => searchKey, []);

Expand All @@ -40,7 +39,7 @@ export const SearchBox = <T extends object>({
});

const { results, search } = useSearch({
list: originalRecords || [],
list: records || [],
keys: searchKeys,
});

Expand All @@ -60,9 +59,9 @@ export const SearchBox = <T extends object>({
setRecords(mappedResults);
}
if (results && !searchedTerm) {
originalRecords && setRecords(originalRecords);
records && setRecords(records);
}
}, [results, setRecords, searchedTerm, originalRecords]);
}, [results, setRecords, searchedTerm, records]);

return (
<Box maxWidth={360}>
Expand Down

0 comments on commit f99c311

Please sign in to comment.