|
@@ -1,9 +1,15 @@
|
|
|
import React, { useState } from 'react';
|
|
|
import mechData from './mech-data.json'
|
|
|
+import MechObserver from '../MechObserver';
|
|
|
+import Mech from '../Mech';
|
|
|
|
|
|
-function MechPicker() {
|
|
|
+function MechPicker({observers} : { observers: {[key: string]: MechObserver }}) {
|
|
|
const [searchText, setSearchText] = useState("");
|
|
|
|
|
|
+ function notifyObservers(mech: Mech) {
|
|
|
+ console.log("Mech clicked is ", mech);
|
|
|
+ }
|
|
|
+
|
|
|
return (
|
|
|
<aside className='mech-picker'>
|
|
|
<h2>Mech picker</h2>
|
|
@@ -13,7 +19,10 @@ function MechPicker() {
|
|
|
{mechData
|
|
|
.filter(mech => mech.name.toLowerCase().includes(searchText.toLocaleLowerCase()))
|
|
|
.map(mech => (
|
|
|
- <li key={mech.id}>{mech.name}</li>
|
|
|
+ <li key={mech.id}>
|
|
|
+ {mech.name}
|
|
|
+ <button onClick={event => notifyObservers(mech)}>+</button>
|
|
|
+ </li>
|
|
|
))}
|
|
|
</ul>
|
|
|
</aside>
|