|
|
|
@ -1,12 +1,12 @@
|
|
|
|
import { useState } from "react";
|
|
|
|
import { useState } from "react";
|
|
|
|
// {items: [string], heading: string}
|
|
|
|
// {items: [string], heading: string}
|
|
|
|
interface Props {
|
|
|
|
interface Props {
|
|
|
|
items: string [];
|
|
|
|
items: string[];
|
|
|
|
heading: string;
|
|
|
|
heading: string;
|
|
|
|
|
|
|
|
onSelectItem: (item: string) => void;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function ListGroup({items, heading}: Props) {
|
|
|
|
function ListGroup({ items, heading, onSelectItem }: Props) {
|
|
|
|
|
|
|
|
|
|
|
|
const [selectedIndex, setSelectedIndex] = useState(-1);
|
|
|
|
const [selectedIndex, setSelectedIndex] = useState(-1);
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
@ -22,7 +22,10 @@ function ListGroup({items, heading}: Props) {
|
|
|
|
: "list-group-item"
|
|
|
|
: "list-group-item"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
key={item}
|
|
|
|
key={item}
|
|
|
|
onClick={()=>setSelectedIndex(index)}
|
|
|
|
onClick={() => {
|
|
|
|
|
|
|
|
setSelectedIndex(index);
|
|
|
|
|
|
|
|
onSelectItem(item);
|
|
|
|
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{item}
|
|
|
|
{item}
|
|
|
|
</li>
|
|
|
|
</li>
|
|
|
|
|