From 47ddf039d416b1e37853445a85a5ebecf3f53a89 Mon Sep 17 00:00:00 2001 From: pawan-dot <71133473+pawan-dot@users.noreply.github.com> Date: Thu, 3 Nov 2022 14:01:57 +0530 Subject: [PATCH] edit profile --- public/index.html | 2 +- src/views/Profile/EditProfile.js | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/public/index.html b/public/index.html index 19331ce..6fb9f6a 100644 --- a/public/index.html +++ b/public/index.html @@ -20,7 +20,7 @@ manifest.json provides metadata used when your web app is added to the homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/ --> - + diff --git a/src/views/Profile/EditProfile.js b/src/views/Profile/EditProfile.js index 240460c..6be7123 100644 --- a/src/views/Profile/EditProfile.js +++ b/src/views/Profile/EditProfile.js @@ -1,10 +1,11 @@ import React from 'react' -import { CForm, CCol, CFormLabel, CContainer, CRow, CCardGroup, CCard, CCardBody, CFormInput, CFormSelect, CFormCheck, CButton } from '@coreui/react' +import { CForm, CCol, CFormLabel, CContainer, CRow, CCardGroup, CCard, CCardBody, CFormInput, CButton } from '@coreui/react' import { useState, useEffect } from 'react' import axios from 'axios' import { useHistory } from 'react-router-dom' import { isAutheticated } from 'src/auth' + const EditProfile = () => { const [image, setImage] = useState(""); @@ -20,11 +21,7 @@ const EditProfile = () => { }) const history = useHistory() - useEffect(() => { - getData() - - }, []) const getData = async () => { let res = await axios.get(`/api/v1/user/details`, { @@ -35,6 +32,7 @@ const EditProfile = () => { if (res.data.success) { setOwnerDetails({ ...res.data.user }) + if (res.data.user.avatar) { setImagesPreview(res.data.user.avatar.url) } @@ -47,6 +45,7 @@ const EditProfile = () => { const { name, value } = event.target; setOwnerDetails({ ...ownerDetails, [name]: value }); }; + const handleImage = (e) => { const files = e.target.files[0]; @@ -66,7 +65,7 @@ const EditProfile = () => { // ----------------------------------------------------------------------------- }; async function handleSubmit() { - if (ownerDetails.name.trim() === '' || ownerDetails.email.trim() === '' || ownerDetails.phone === '') { + if (ownerDetails.name === '' || ownerDetails.email === '' || ownerDetails.phone === '') { swal({ title: 'Warning', text: 'Fill all mandatory fields', @@ -118,6 +117,11 @@ const EditProfile = () => { const handleCancle = () => { history.push('/dashboard') } + useEffect(() => { + + getData() + + }, []) return (