Last active
May 17, 2016 02:20
-
-
Save natew/efd45091542c479d8e49b2a83520edf6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Database from '$stores/db' | |
| import Select from 'react-select' | |
| import * as T from '../../types' | |
| type HeaderState = { value: number } | |
| type PropsState = { data: { items: Array<T.ItemEntry> } } | |
| @Database.provide() | |
| @component | |
| export default class Header { | |
| props: PropsState; | |
| state: HeaderState = { value: 0 } | |
| deleteItem: () = () => { | |
| Database.remove(this.state.value) | |
| this.setState({ value: 0 }) | |
| }; | |
| onChange: ((newValue: string) => void) = newValue => { | |
| this.setState({ value: newValue.value }) | |
| }; | |
| render() { | |
| return ( | |
| <div> | |
| <h3 style={{color: '#ff3300'}}>Item removal</h3> | |
| <Select | |
| name="form-field-name" | |
| value={this.state.value} | |
| options={this.props.data.items.map(i => ({ value: i.key, label: i.value.text || i.value.color || '' }))} | |
| onChange={this.onChange} | |
| /> | |
| <button className="btn btn-danger btn-small" onClick={this.deleteItem}>Delete the selected Item</button> | |
| </div> | |
| ) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment