-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented basic working fuzzy search
toward #35
- Loading branch information
1 parent
0dee324
commit 5cba00e
Showing
3 changed files
with
67 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 24 additions & 13 deletions
37
src/components/PageContent/PageBlock/Shortcode/DirectorySection.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,28 @@ | ||
import DirectoryGrid from "components/Directory/DirectoryGrid"; | ||
import DirectorySearch from "components/Directory/DirectorySearch"; | ||
import { getDirectorySearch, prepareMemberList } from "lib/directory"; | ||
import { useState } from "react"; | ||
import DirectoryGrid from "components/Directory/DirectoryGrid" | ||
import DirectorySearch from "components/Directory/DirectorySearch" | ||
import { getDirectorySearch, prepareMemberList } from "lib/directory" | ||
import { useEffect, useState } from "react" | ||
|
||
export default function DirectorySection(props) { | ||
// Filter artists that are marked de-listed in DatoCMS | ||
let fullMemberList = prepareMemberList(props.pageSpecificData) | ||
const [filtersAreVisible, setFilterVisibility] = useState(false) | ||
const [searchResults, setSearchResults] = useState(fullMemberList) | ||
const searcher = getDirectorySearch(fullMemberList, ['firstName', 'lastName']) | ||
// Filter artists that are marked de-listed in DatoCMS | ||
let fullMemberList = prepareMemberList(props.pageSpecificData) | ||
const [filtersAreVisible, setFilterVisibility] = useState(false) | ||
|
||
return <> | ||
<DirectorySearch searcher={searcher} searchResults={searchResults} setSearchResults={setSearchResults} /> | ||
<DirectoryGrid artists={searchResults} /> | ||
const [searchResults, setSearchResults] = useState(fullMemberList) | ||
const resetSearchResults = () => setSearchResults(fullMemberList) | ||
const searcher = getDirectorySearch(fullMemberList, ["firstName", "lastName"]) | ||
|
||
useEffect(() => console.log({ searchResults }), [searchResults]) | ||
|
||
return ( | ||
<> | ||
<DirectorySearch | ||
searcher={searcher} | ||
searchResults={searchResults} | ||
setSearchResults={setSearchResults} | ||
resetSearchResults={resetSearchResults} | ||
/> | ||
<DirectoryGrid artists={searchResults} /> | ||
</> | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters