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 ( -
+ .catch(err => console.log(err)) + }; + render() { + return ( +
Name
setActualname(e.target.value)} + name="actual_name" + id="actual_name" + value={this.state.actual_name} + onChange = { this.handleChange } />

@@ -50,9 +64,10 @@ function Editprofileform() { setUserimg(e.target.files[0])} + onChange = { this.handleImageChange } />
@@ -62,20 +77,21 @@ function Editprofileform() { setPhno(e.target.value)} + name="phno" + value={this.state.phno} + id="phno" + onChange = { this.handleChange } />
- - - ); + ) + } } -export default Editprofileform; \ No newline at end of file +export default Editprofileform \ No newline at end of file diff --git a/src/pages/Dashboard/Dashboard.js b/src/pages/Dashboard/Dashboard.js index ad08e97..c3aa2f4 100644 --- a/src/pages/Dashboard/Dashboard.js +++ b/src/pages/Dashboard/Dashboard.js @@ -21,6 +21,7 @@ const Dashboard = () => { const[userimg,setUserimg]=useState() const[frame,setFrame]=useState('places') const [show, setShow] = useState(false); + const[userImage,setUserImage]=useState() const handleClose = () => setShow(false); const[userDetailId,setUserDetailId]=useState(0) const parachuteEffect={ @@ -48,6 +49,7 @@ const Dashboard = () => { response.data.forEach((item)=>{ if(item.user_foreign===currUserid) { + setUserImage(item.user_image) setUserDetailId(item.id) setActualname(item.actual_name) setPhno(item.phno) @@ -64,7 +66,7 @@ const Dashboard = () => { {/* profile main starts here */}
- your_image + your_image
Name:
{actualname}
Phone no:

{phno}