import React from 'react'; import Form from '../Modules/Form'; import AddressBox from '../Modules/AddressBox'; import ArraySelector from '../Modules/ArraySelector'; import AddressInputs from '../Inputs/AddressInput'; import Toast from '../helpers/Toast'; import Merge from '../helpers/Merge'; import Dictionary from '../Services/DictionaryService'; import { Button } from 'react-materialize'; class Addresses extends React.Component { constructor(props) { super(props); this.state = { addresses: [], showAddressForm: false, selectedAddress: {}, edit: false } this.updateService(props.service); } componentWillReceiveProps(props) { if(props.service) { let service = props.service; this.updateService(service); } } updateService(service) { service.getPage(1, 100).then((addresses) => { this.setState({ addresses, showAddressForm: false }); }) } edit(address) { this.setState({ showAddressForm: true, edit: true, editAddress: address }) } delete(address) { this.props.update && this.props.update('' + Math.random() * Math.random()); if(window.confirm(Dictionary.get("Delete address ?"))) this.props.service.update(address.id, {deleted: true}).then(() => this.updateService(this.props.service)) } getAddressForm() { return