import React from 'react';
import Modularity from 'modularity-front';

import { Button, Card ,Collection ,  CollectionItem } from 'react-materialize';


import './AddressBox.css';



let Module = Modularity.Module;
class AddressBox extends Modularity.Module {
	constructor(props) {
		super(props);
		console.log("ADdress from here")
		console.log(this.Address.value)
	}

    
	render() {
		var address = this.Address.value;
		
		return(
			 <Collection header = {
			 	<div>
			 		<div className="AddressName">{address.name}</div>
			 		<div className="icons">
						{this.props.onEdit   && <i className="fa fa-edit" onClick={(e) => this.props.onEdit && e.stopPropagation() || this.props.onEdit(this.Address.value)}></i>}
						{this.props.onDelete && <i className="fa fa-trash" onClick={(e) => this.props.onDelete && e.stopPropagation() || this.props.onDelete(this.Address.value)}></i>}
					</div>
			 	</div>
			 }
			 className={"AddressBox " + (this.Selected.value ? 'selected' : '')} onClick={() => this.onSelect.set(address)} >
  				
  					<CollectionItem>{address.address}</CollectionItem>
  					<CollectionItem>{address.postalcode}</CollectionItem>
  					<CollectionItem>{address.city} </CollectionItem>
  					<CollectionItem>{address.state}</CollectionItem>
  					 
  					
  			
				
  			</Collection>
		);				    
	}
}

AddressBox.Inputs = {
	Address: {
		type: Module.Types.Object
	},
	Selected: {
		type: Module.Types.Boolean
	}
}

AddressBox.Outputs = {
	onSelect: {}
}



AddressBox.Category = "Nikatlas";
export default AddressBox;