mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-18 20:09:10 +00:00
parent
469a3831dc
commit
df0e24a56c
|
@ -1,3 +1,5 @@
|
|||
import { useMemo, useState } from 'react';
|
||||
import { useDebouncedCallback } from 'use-debounce';
|
||||
import { useLibraryQuery } from '@sd/client';
|
||||
import { SearchInput } from '@sd/ui';
|
||||
import { Heading } from '../../Layout';
|
||||
|
@ -7,6 +9,17 @@ import ListItem from './ListItem';
|
|||
export const Component = () => {
|
||||
const locations = useLibraryQuery(['locations.list']);
|
||||
|
||||
const [search, setSearch] = useState('');
|
||||
const updateSearch = useDebouncedCallback(setSearch, 750);
|
||||
|
||||
const filteredLocations = useMemo(
|
||||
() =>
|
||||
locations.data?.filter((location) =>
|
||||
location.name.toLowerCase().includes(search.toLowerCase())
|
||||
),
|
||||
[search]
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Heading
|
||||
|
@ -14,13 +27,17 @@ export const Component = () => {
|
|||
description="Manage your storage locations."
|
||||
rightArea={
|
||||
<div className="flex flex-row items-center space-x-5">
|
||||
<SearchInput placeholder="Search locations" className="h-[33px]" />
|
||||
<SearchInput
|
||||
placeholder="Search locations"
|
||||
className="h-[33px]"
|
||||
onChange={(e) => updateSearch(e.target.value)}
|
||||
/>
|
||||
<AddLocationButton variant="accent" size="md" />
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
<div className="grid space-y-2">
|
||||
{locations.data?.map((location) => (
|
||||
{filteredLocations?.map((location) => (
|
||||
<ListItem key={location.id} location={location} />
|
||||
))}
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue