import React from 'react'; class AssetManagement extends React.Component { constructor() { super(); this.state = { newAssetName: 'Name', newAssetSE: 'SE', newAssetWarranty: 12, }; } onNewAssetNameChange = target => { this.setState({ newAssetName: target.value, }); }; onNewAssetSEChange = target => { this.setState({ newAssetSE: target.value, }); }; onNewAssetWarrantyChange = target => { this.setState({ newAssetWarranty: target.value, }); }; onCreateNewAssetClicked = () => { this.props.onCreateAsset({ name: this.state.newAssetName, serial: this.state.newAssetSE, warranty_months: this.state.newAssetWarranty, }); } render() { const userAssets = []; if (this.props.assets) { this.props.assets.forEach(asset => { userAssets.push(
#{asset.asset_tag} {asset.name} {asset.supplier ? asset.supplier.name : ''} Expires: {asset.warranty_expires ? asset.warranty_expires.formatted : '-'}
{ this.props.onDeleteAsset(asset.id)}}>DELETE
); }); } return (
{userAssets}
); } } export default AssetManagement;