Last active
July 17, 2018 13:12
-
-
Save IchrakMansour/de32494bae2192fcbaee1abe933b50a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { Badge, Col, Nav, NavItem, NavLink, Row, TabContent, TabPane } from 'reactstrap'; | |
import classnames from 'classnames'; | |
import axios from 'axios'; | |
class ViewClient extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
clients:[], | |
Code: '1111' | |
}; | |
this.toggle = this.toggle.bind(this); | |
this.state = { | |
activeTab: '1', | |
}; | |
} | |
toggle(tab) { | |
if (this.state.activeTab !== tab) { | |
this.setState({ | |
activeTab: tab, | |
}); | |
} | |
} | |
componentDidMount() { | |
const Code =this.state.Code | |
axios.get(`http://localhost:4000/app/viewclient/${Code}`) | |
.then(response => { | |
if (response && response.data) { | |
this.setState({ clients: response.data }); | |
} | |
}) | |
.catch(error => console.log(error)); | |
} | |
render() { | |
let { clients } = this.state; | |
// let { clients } = this.state; | |
return ( | |
<div className="animated fadeIn"> | |
<Row> | |
<Col xs="12" md="6" className="mb-4"> | |
<Nav tabs> | |
<NavItem> | |
<NavLink | |
className={classnames({ active: this.state.activeTab === '1' })} | |
onClick={() => { this.toggle('1'); }} | |
> | |
<i className="fa fa-info"></i> <span className={this.state.activeTab === '1' ? '' : 'd-none'}> Détails</span> | |
</NavLink> | |
</NavItem> | |
<NavItem> | |
<NavLink | |
className={classnames({ active: this.state.activeTab === '2' })} | |
onClick={() => { this.toggle('2'); }} | |
> | |
<i className="fa fa-credit-card"></i> <span | |
className={this.state.activeTab === '2' ? '' : 'd-none'}> Factures</span> | |
</NavLink> | |
</NavItem> | |
<NavItem> | |
<NavLink | |
className={classnames({ active: this.state.activeTab === '3' })} | |
onClick={() => { this.toggle('3'); }} | |
> | |
<i className="fa fa-truck"></i> <span className={this.state.activeTab === '3' ? '' : 'd-none'}> Bons de livraison</span> | |
</NavLink> | |
</NavItem> | |
</Nav> | |
<TabContent activeTab={this.state.activeTab} style={{ height:"420px"}}> | |
<TabPane tabId="1"> | |
<ul> | |
{ | |
clients && clients.map(client => ( | |
<li key={client.Code}> | |
<h1> Code client : {client.Code} </h1> | |
{client.Prenom} | |
{client.Nom} | |
{client.FAX} | |
{client.Telephone} | |
{client.Email} | |
{client.Adresse1} | |
{client.Adresse2} | |
</li> | |
))} | |
</ul> | |
</TabPane> | |
<TabPane tabId="2"> | |
</TabPane> | |
<TabPane tabId="3"> | |
</TabPane> | |
</TabContent> | |
</Col> | |
</Row> | |
</div> | |
); | |
} | |
} | |
export default ViewClient; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment