import { Button, InputNumber, Select, Table } from "antd"; import { observer } from "mobx-react"; import React from "react"; import { huntOptimizerStore, WantedItem } from "../../stores/HuntOptimizerStore"; import { itemStore } from "../../stores/ItemStore"; import './WantedItemsComponent.css'; @observer export class WantedItemsComponent extends React.Component { render() { // Make sure render is called on updates. huntOptimizerStore.wantedItems.slice(0, 0); return (

Wanted Items

wanted.item.name} pagination={false} > title="Amount" dataIndex="amount" render={(_, wanted) => ( )} /> render={(_, wanted) => (
); } private addWanted = (itemName: string) => { let added = huntOptimizerStore.wantedItems.find(w => w.item.name === itemName); if (!added) { const item = itemStore.items.current.value.find(i => i.name === itemName)!; huntOptimizerStore.wantedItems.push(new WantedItem(item, 1)); } } private removeWanted = (wanted: WantedItem) => () => { const i = huntOptimizerStore.wantedItems.findIndex(w => w === wanted); if (i !== -1) { huntOptimizerStore.wantedItems.splice(i, 1); } } } @observer class WantedAmountCell extends React.Component<{ wantedItem: WantedItem }> { render() { const wanted = this.props.wantedItem; return ( ); } private wantedAmountChanged = (value?: number) => { if (value && value >= 1) { this.props.wantedItem.amount = value; } } }