Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*jshint esversion: 6 */
  2. import React from "react";
  3. import { Link } from 'react-router-dom';
  4. import EditName from "./EditName";
  5. import EditSurname from "./EditSurname"
  6. import EditInfo from "./EditInfo"
  7. import EditEmail from "./EditEmail"
  8. import axios from 'axios'
  9.  
  10. class EditProfile extends React.Component {
  11.  
  12.     handleSubmit = event => {
  13.         this.send()
  14.     };
  15.  
  16.     send() {
  17.         axios(
  18.             {
  19.                 headers: {
  20.                     'Access-Control-Allow-Origin': '*'
  21.                 },
  22.  
  23.                 method: 'POST',
  24.                 url: 'http://localhost:8080/api/editprofile',
  25.                 data: {
  26.                     'information': this.information.value,
  27.                     'name': this.name.value,
  28.                     'surname': this.surname.value,
  29.                     'email': this.email.value,
  30.                 }
  31.             }
  32.         ).then((response) => {
  33.                 if (response.data.result === "good") {
  34.                 }
  35.                 else {
  36.                     console.log(response);
  37.                     document.getElementById("error").innerHTML = response.data.result;
  38.                 }
  39.             },
  40.             (err) => {
  41.                 console.log(err);
  42.             });
  43.         return false;
  44.     }
  45.  
  46.     constructor(props) {
  47.         super(props);
  48.     }
  49.  
  50.  
  51.     render() {
  52.         return (
  53.             <div>
  54.  
  55.                 <EditInfo ref={(input) => {
  56.                     this.information = input
  57.                 }}/>
  58.                 <br/>
  59.                 <EditName ref={(input) => {
  60.                     this.name = input
  61.                 }}/>
  62.                 <br/>
  63.                 <EditSurname ref={(input) => {
  64.                     this.surname = input
  65.                 }}/>
  66.                 <br/>
  67.                 <EditEmail ref={(input) => {
  68.                     this.email = input
  69.                 }}/>
  70.                 <br/>
  71.                 <Link className="btn btn-outline-success my-2 my-sm-0" to="editpassword">Хотите изменить пароль?</Link>
  72.                 <br/>
  73.                 <br/>
  74.                 <Link className="btn btn-lg btn-primary btn-block" to='/profile' onClick={this.handleSubmit}>Сохранить</Link>
  75.             </div>
  76.         );
  77.     };
  78. }
  79. export default EditProfile;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement