Skip to content

Commit

Permalink
chore: Drop filter which hid excpetional nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Sep 10, 2024
1 parent 8da07a2 commit fd4224f
Showing 1 changed file with 17 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import List from "@mui/material/List";
import ListItem from "@mui/material/ListItem";
import { styled } from "@mui/material/styles";
import Typography from "@mui/material/Typography";
import { ComponentType, IndexedNode } from "@opensystemslab/planx-core/types";
import { IndexedNode } from "@opensystemslab/planx-core/types";
import type { SearchResults } from "hooks/useSearch";
import React from "react";

Expand All @@ -17,32 +17,20 @@ export const Root = styled(List)(({ theme }) => ({

export const NodeSearchResults: React.FC<{
results: SearchResults<IndexedNode>;
}> = ({ results }) => {
/** Temporary guard function to filter out component types not yet supported by SearchResultCard */
const isSupportedNodeType = (
result: SearchResults<IndexedNode>[number],
): boolean =>
![
ComponentType.FileUploadAndLabel,
ComponentType.Calculate,
ComponentType.List,
].includes(result.item.type);
}> = ({ results }) => (
<>
<Typography variant="h3" mb={1}>
{!results.length && "No matches found"}
{results.length === 1 && "1 result:"}
{results.length > 1 && `${results.length} results:`}
</Typography>

return (
<>
<Typography variant="h3" mb={1}>
{!results.length && "No matches found"}
{results.length === 1 && "1 result:"}
{results.length > 1 && `${results.length} results:`}
</Typography>

<Root>
{results.filter(isSupportedNodeType).map((result) => (
<ListItem key={result.item.id} disablePadding>
<SearchResultCard result={result} />
</ListItem>
))}
</Root>
</>
);
};
<Root>
{results.map((result) => (
<ListItem key={result.item.id} disablePadding>
<SearchResultCard result={result} />
</ListItem>
))}
</Root>
</>
);

0 comments on commit fd4224f

Please sign in to comment.