diff --git a/src/CustomerDetails.js b/src/CustomerDetails.js index c9c7be66..759113ab 100644 --- a/src/CustomerDetails.js +++ b/src/CustomerDetails.js @@ -1,56 +1,57 @@ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import Panel from 'react-bootstrap/lib/Panel' -import axios from 'axios' +// Видалено: import axios from 'axios' +import { getCustomerDetailData } from './services/CustomerService'; -//This Component is a child Component of Customers Component +// This Component is a child Component of Customers Component export default class CustomerDetails extends Component { - constructor(props) { - super(props); - this.state = {} - } + constructor(props) { + super(props); + this.state = {} + } - //Function which is called when the component loads for the first time - componentDidMount() { - this.getCustomerDetails(this.props.val) - } + // Function which is called when the component loads for the first time + componentDidMount() { + this.getCustomerDetails(this.props.val) + } - //Function which is called whenver the component is updated - componentDidUpdate(prevProps) { + // Function which is called whenver the component is updated + componentDidUpdate(prevProps) { - //get Customer Details only if props has changed - if (this.props.val !== prevProps.val) { - this.getCustomerDetails(this.props.val) + // get Customer Details only if props has changed + if (this.props.val !== prevProps.val) { + this.getCustomerDetails(this.props.val) + } } - } - //Function to Load the customerdetails data from json. - getCustomerDetails(id) { - axios.get('assets/samplejson/customer' + id + '.json').then(response => { - this.setState({customerDetails: response}) - }) - }; + // Function to Load the customerdetails data from json. - тепер використовує сервіс + getCustomerDetails = (id) => { + getCustomerDetailData(id).then(response => { + this.setState({customerDetails: response}) + }) + }; - render() { - if (!this.state.customerDetails) - return (
Loading Data
) - return (Name : {this.state.customerDetails.data.name}
-Email : {this.state.customerDetails.data.email}
-Phone : {this.state.customerDetails.data.phone}
-City : {this.state.customerDetails.data.city}
-State : {this.state.customerDetails.data.state}
-Country : {this.state.customerDetails.data.country}
-Organization : {this.state.customerDetails.data.organization}
-Job Profile : {this.state.customerDetails.data.jobProfile}
-Additional Info : {this.state.customerDetails.data.additionalInfo}
-Loading Data
) + return (Name : {this.state.customerDetails.data.name}
+Email : {this.state.customerDetails.data.email}
+Phone : {this.state.customerDetails.data.phone}
+City : {this.state.customerDetails.data.city}
+State : {this.state.customerDetails.data.state}
+Country : {this.state.customerDetails.data.country}
+Organization : {this.state.customerDetails.data.organization}
+Job Profile : {this.state.customerDetails.data.jobProfile}
+Additional Info : {this.state.customerDetails.data.additionalInfo}
+Loading data
) - return ({customer.email}
-{customer.phone}
- - -Loading data
) + return ({customer.email}
+{customer.phone}
+ + +