From 39d8a8f2124f3b01e9383434af878067557bae61 Mon Sep 17 00:00:00 2001 From: Haziq Khairi Date: Mon, 8 Jan 2024 05:25:13 +0800 Subject: [PATCH] feat: add more list to autocomplete navbar alphabetically --- src/components/Navbar.jsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/Navbar.jsx b/src/components/Navbar.jsx index 6112875..5923ea4 100644 --- a/src/components/Navbar.jsx +++ b/src/components/Navbar.jsx @@ -13,13 +13,12 @@ import { } from '@nextui-org/react'; import { Link } from 'react-router-dom'; import { FaSearch } from 'react-icons/fa'; -import { abstractsList } from '../data/list'; -import { matchSorter } from 'match-sorter'; +import { allLists } from '../data/list'; -const sortedAbstractsList = matchSorter(abstractsList, '', { keys: ['name'] }); -const SearchAutocomplete = () => ( +const SearchAutocomplete = ({ allLists }) => ( ( ); const NavbarComponent = () => { + const allItems = Object.values(allLists).flat(); + const sortedAllList = allItems.sort((a, b) => a.name.localeCompare(b.name)); return ( @@ -118,7 +119,7 @@ const NavbarComponent = () => { - +