import Grid from '@material-ui/core/Grid'; import IconButton from '@material-ui/core/IconButton'; import Paper from '@material-ui/core/Paper'; import Table from '@material-ui/core/Table'; import TableBody from '@material-ui/core/TableBody'; import TableCell from '@material-ui/core/TableCell'; import TableHead from '@material-ui/core/TableHead'; import TableRow from '@material-ui/core/TableRow'; import Delete from '@material-ui/icons/Delete'; import React, {Component, SFC} from 'react'; import ConfirmDialog from '../common/ConfirmDialog'; import DefaultPage from '../common/DefaultPage'; import ToggleVisibility from '../common/ToggleVisibility'; import AddClientDialog from './AddClientDialog'; import {observer} from 'mobx-react'; import {observable} from 'mobx'; import {inject, Stores} from '../inject'; @observer class Clients extends Component> { @observable private showDialog = false; @observable private deleteId: false | number = false; public componentDidMount = () => this.props.clientStore.refresh(); public render() { const { deleteId, showDialog, props: {clientStore}, } = this; const clients = clientStore.getItems(); return ( (this.showDialog = true)}> Name token {clients.map((client: IClient) => { return ( (this.deleteId = client.id)} /> ); })}
{showDialog && ( (this.showDialog = false)} fOnSubmit={clientStore.create} /> )} {deleteId !== false && ( (this.deleteId = false)} fOnSubmit={() => clientStore.remove(deleteId)} /> )}
); } } interface IRowProps { name: string; value: string; fDelete: VoidFunction; } const Row: SFC = ({name, value, fDelete}) => ( {name} ); export default inject('clientStore')(Clients);