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 (