|
| 1 | +import React from 'react'; |
| 2 | +import { CardStack, Card } from 'react-cardstack'; |
| 3 | +import { Link } from 'react-router' |
| 4 | + |
| 5 | +import ClientService from 'services/Client' |
| 6 | +import Error from 'components/Error/Error' |
| 7 | +import styles from 'components/Client/Profile/styles.css' |
| 8 | + |
| 9 | +class Client extends React.Component |
| 10 | +{ |
| 11 | + constructor(props) { |
| 12 | + super(props); |
| 13 | + this.state = { |
| 14 | + client : null, |
| 15 | + error : '' |
| 16 | + }; |
| 17 | + this.getClient(this.props.params.id); |
| 18 | + } |
| 19 | + |
| 20 | + getClient(id) { |
| 21 | + ClientService.getClient(id).then((response) => { |
| 22 | + this.setState({client: response.data.client.shift()}); |
| 23 | + }).catch((error) => { |
| 24 | + this.setState({error: 'Error Found: Trying get client'}); |
| 25 | + if (typeof error.response.data.error !== 'undefined') { |
| 26 | + this.setState({error: error.response.data.error}); |
| 27 | + } |
| 28 | + }); |
| 29 | + } |
| 30 | + |
| 31 | + render() { |
| 32 | + if (this.state.error) { |
| 33 | + return (<Error error={this.state.error} />); |
| 34 | + } |
| 35 | + if (!this.state.client) { |
| 36 | + return <div>Loading...</div>; |
| 37 | + } |
| 38 | + |
| 39 | + return ( |
| 40 | + <div className="container column is-12"> |
| 41 | + <div className="section profile-heading profile-heading-color"> |
| 42 | + <div className="columns"> |
| 43 | + <div className="column is-2"> |
| 44 | + <div className="image is-128x128 avatar"> |
| 45 | + <img src="https://placehold.it/256x256" /> |
| 46 | + </div> |
| 47 | + </div> |
| 48 | + <div className="column is-6 name"> |
| 49 | + <p> |
| 50 | + <span className="title is-bold color-black"> |
| 51 | + <strong>{this.state.client.name}</strong> |
| 52 | + </span> |
| 53 | + </p> |
| 54 | + <p className="tagline"> |
| 55 | + {this.state.client.address} |
| 56 | + </p> |
| 57 | + <p> |
| 58 | + <strong>{this.state.client.city}</strong> |
| 59 | + </p> |
| 60 | + </div> |
| 61 | + <div className="column is-4 followers has-text-centered"> |
| 62 | + <p className="stat-val">Area</p> |
| 63 | + <p className="stat-key"><strong>{this.state.client.area._id}</strong></p> |
| 64 | + </div> |
| 65 | + </div> |
| 66 | + </div> |
| 67 | + <div className="profile-options"> |
| 68 | + <nav className="nav"> |
| 69 | + <div className="nav-center nav-menu is-active"> |
| 70 | + <span className="nav-item"> |
| 71 | + <a className="button" > |
| 72 | + <span className="icon"> |
| 73 | + <i className="fa fa-check"></i> |
| 74 | + </span> |
| 75 | + <span>Visited</span> |
| 76 | + </a> |
| 77 | + <a className="button" href="#"> |
| 78 | + <span className="icon"> |
| 79 | + <i className="fa fa-pencil"></i> |
| 80 | + </span> |
| 81 | + <span>Update</span> |
| 82 | + </a> |
| 83 | + </span> |
| 84 | + <span className="nav-item"> |
| 85 | + <a className="button" > |
| 86 | + <span className="icon"> |
| 87 | + <i className="fa fa-calendar"></i> |
| 88 | + </span> |
| 89 | + <span>Schedule</span> |
| 90 | + </a> |
| 91 | + <a className="button is-danger" href="#"> |
| 92 | + <span className="icon"> |
| 93 | + <i className="fa fa-close"></i> |
| 94 | + </span> |
| 95 | + <span>Delete</span> |
| 96 | + </a> |
| 97 | + </span> |
| 98 | + </div> |
| 99 | + </nav> |
| 100 | + </div> |
| 101 | + </div> |
| 102 | + ); |
| 103 | + } |
| 104 | +} |
| 105 | + |
| 106 | +export default Client; |
| 107 | + |
0 commit comments