From 969cdcaa168450edd668c8d632e60f24d1239844 Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Fri, 24 Jun 2022 12:32:59 -0500 Subject: [PATCH] Search group contracts --- web/pages/group/[...slugs]/index.tsx | 33 +++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/web/pages/group/[...slugs]/index.tsx b/web/pages/group/[...slugs]/index.tsx index b38de6d5..caa08314 100644 --- a/web/pages/group/[...slugs]/index.tsx +++ b/web/pages/group/[...slugs]/index.tsx @@ -118,7 +118,20 @@ export default function GroupPage(props: { const group = useGroup(props.group?.id) ?? props.group const [contracts, setContracts] = useState(undefined) + const [query, setQuery] = useState('') + const messages = useCommentsOnGroup(group?.id) + const debouncedQuery = debounce(setQuery, 50) + const filteredContracts = + query != '' && contracts + ? contracts.filter( + (c) => + checkAgainstQuery(query, c.question) || + checkAgainstQuery(query, c.description || '') || + checkAgainstQuery(query, c.creatorName) || + checkAgainstQuery(query, c.creatorUsername) + ) + : [] useEffect(() => { if (group) @@ -218,14 +231,22 @@ export default function GroupPage(props: { { title: 'Questions', content: ( -
+
{contracts ? ( contracts.length > 0 ? ( - {}} - /> + <> + debouncedQuery(e.target.value)} + placeholder="Search the group's questions" + className="input input-bordered mb-4 w-full" + /> + {}} + /> + ) : (
No questions yet. 🦗... Why not add one?