diff --git a/src/components/Editprofileform/Editprofileform.js b/src/components/Editprofileform/Editprofileform.js index c3a03c4..171c078 100644 --- a/src/components/Editprofileform/Editprofileform.js +++ b/src/components/Editprofileform/Editprofileform.js @@ -1,47 +1,61 @@ -import Button from 'react-bootstrap/Button'; -import Form from 'react-bootstrap/Form'; -import axiosInstance from '../../utils/axios' +import React, { Component } from 'react' +import { Form } from 'react-bootstrap'; +import axiosInstance from '../../utils/axios'; import baseUrl from '../../utils/Urls'; -import {useState} from 'react' - -function Editprofileform() { - - const[actualname,setActualname]=useState('') - const[phno,setPhno]=useState('') - const[userimg,setUserimg]=useState() +import Button from 'react-bootstrap/Button'; - +export class Editprofileform extends Component { + + state = { + actual_name: '', + phno: '', + user_image: null, + user_foreign: localStorage.getItem('userid') + }; - const handleSubmit=(e)=>{ + handleChange = (e) => { + this.setState({ + [e.target.id]: e.target.value + }) + }; - const uploaddata=new FormData() - // uploaddata.append('actual_name',actualname) - uploaddata.append('userimg',userimg) + handleImageChange = (e) => { + this.setState({ + user_image: e.target.files[0] + }) + }; - axiosInstance.post(`${baseUrl}/user-detail/`,{ - actual_name:actualname, - phno:phno, - user_image:uploaddata.userimg, - user_foreign:localStorage.getItem('userid') - }).then((response)=>{ - console.log(response) + handleSubmit = (e) => { + e.preventDefault(); + console.log(this.state); + let form_data = new FormData(); + form_data.append('user_image', this.state.user_image, this.state.user_image.name); + form_data.append('actual_name', this.state.actual_name); + form_data.append('phno', this.state.phno); + form_data.append('user_foreign', this.state.user_foreign); + let url = `${baseUrl}/user-detail/`; + axiosInstance.post(url, form_data, { + headers: { + 'content-type': 'multipart/form-data' + } + }) + .then(res => { + console.log(res.data); }) - - e.preventDefault(); - -} - - - return ( -