|
|
|
@ -1,4 +1,4 @@ |
|
|
|
import { Component, FC, useState } from "react"; |
|
|
|
import { Component, FC, ReactEventHandler, useState } from "react"; |
|
|
|
|
|
|
|
interface ItemProps<Item> { |
|
|
|
name: string; |
|
|
|
@ -6,11 +6,18 @@ interface ItemProps<Item> { |
|
|
|
} |
|
|
|
|
|
|
|
interface ListProps<Item> { |
|
|
|
title: string; |
|
|
|
onRefresh: ReactEventHandler; |
|
|
|
component: Component<ItemProps<Item>>; |
|
|
|
map: { [key: string]: Item }; |
|
|
|
} |
|
|
|
|
|
|
|
const SearchableList: FC<ListProps<Item>> = ({ component, map }) => { |
|
|
|
const SearchableList: FC<ListProps<Item>> = ({ |
|
|
|
title, |
|
|
|
onRefresh, |
|
|
|
component, |
|
|
|
map, |
|
|
|
}) => { |
|
|
|
const [filter, setFilter] = useState<string>(""); |
|
|
|
|
|
|
|
const onChange: ReactEventHandler = (event) => { |
|
|
|
@ -25,7 +32,15 @@ const SearchableList: FC<ListProps<Item>> = ({ component, map }) => { |
|
|
|
} |
|
|
|
|
|
|
|
return ( |
|
|
|
<div className="flex flex-col h-full px-3"> |
|
|
|
<div className="flex flex-col px-3 h-full"> |
|
|
|
<div className="flex justify-between p-3"> |
|
|
|
<h1 className="pl-3 text-2xl font-bold text-yellow-800 text-center"> |
|
|
|
{title} |
|
|
|
</h1> |
|
|
|
<button onClick={onRefresh} className="button"> |
|
|
|
Refresh |
|
|
|
</button> |
|
|
|
</div> |
|
|
|
<form className="flex gap-3 p-3"> |
|
|
|
<label htmlFor="filter" className="self-center"> |
|
|
|
Filter: |
|
|
|
|