edit profile

This commit is contained in:
pawan-dot 2022-11-03 14:01:57 +05:30
parent 5b8234eb8f
commit 47ddf039d4
2 changed files with 11 additions and 7 deletions

View File

@ -20,7 +20,7 @@
manifest.json provides metadata used when your web app is added to the 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/ homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
--> -->
<!-- <link rel="manifest" href="%PUBLIC_URL%/manifest.json"> --> <link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<link rel="react" href="https://coreui.io/react/"> <link rel="react" href="https://coreui.io/react/">

View File

@ -1,10 +1,11 @@
import React from 'react' 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 { useState, useEffect } from 'react'
import axios from 'axios' import axios from 'axios'
import { useHistory } from 'react-router-dom' import { useHistory } from 'react-router-dom'
import { isAutheticated } from 'src/auth' import { isAutheticated } from 'src/auth'
const EditProfile = () => { const EditProfile = () => {
const [image, setImage] = useState(""); const [image, setImage] = useState("");
@ -20,11 +21,7 @@ const EditProfile = () => {
}) })
const history = useHistory() const history = useHistory()
useEffect(() => {
getData()
}, [])
const getData = async () => { const getData = async () => {
let res = await axios.get(`/api/v1/user/details`, { let res = await axios.get(`/api/v1/user/details`, {
@ -35,6 +32,7 @@ const EditProfile = () => {
if (res.data.success) { if (res.data.success) {
setOwnerDetails({ ...res.data.user }) setOwnerDetails({ ...res.data.user })
if (res.data.user.avatar) { if (res.data.user.avatar) {
setImagesPreview(res.data.user.avatar.url) setImagesPreview(res.data.user.avatar.url)
} }
@ -47,6 +45,7 @@ const EditProfile = () => {
const { name, value } = event.target; const { name, value } = event.target;
setOwnerDetails({ ...ownerDetails, [name]: value }); setOwnerDetails({ ...ownerDetails, [name]: value });
}; };
const handleImage = (e) => { const handleImage = (e) => {
const files = e.target.files[0]; const files = e.target.files[0];
@ -66,7 +65,7 @@ const EditProfile = () => {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
}; };
async function handleSubmit() { async function handleSubmit() {
if (ownerDetails.name.trim() === '' || ownerDetails.email.trim() === '' || ownerDetails.phone === '') { if (ownerDetails.name === '' || ownerDetails.email === '' || ownerDetails.phone === '') {
swal({ swal({
title: 'Warning', title: 'Warning',
text: 'Fill all mandatory fields', text: 'Fill all mandatory fields',
@ -118,6 +117,11 @@ const EditProfile = () => {
const handleCancle = () => { const handleCancle = () => {
history.push('/dashboard') history.push('/dashboard')
} }
useEffect(() => {
getData()
}, [])
return ( return (
<div > <div >