From 00c82ed962373fd2b4b6ba45b7bdcd91a3490a0e Mon Sep 17 00:00:00 2001 From: SimpPoseidon <120441879+TanishqMehrunkarIIPSDAVV@users.noreply.github.com> Date: Sun, 27 Oct 2024 01:16:41 +0530 Subject: [PATCH] image navbar --- src/Navbar/Navbar.jsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Navbar/Navbar.jsx b/src/Navbar/Navbar.jsx index 7948138..6bf2a79 100644 --- a/src/Navbar/Navbar.jsx +++ b/src/Navbar/Navbar.jsx @@ -1,14 +1,22 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { FaBars, FaTimes } from "react-icons/fa"; import { useNavigate, useLocation } from "react-router-dom"; import { FaPowerOff } from "react-icons/fa"; import "./Navbar.css"; import defaultPhoto from "../Assets/profile_photo.png"; +import axios from "axios"; const Navbar = () => { const [open, setOpen] = useState(false); const navigate = useNavigate(); const location = useLocation(); - const photo = localStorage.getItem("photo") || defaultPhoto; + + + const [photo,setPhoto] = useState(""); + useEffect(()=> + { + axios.post(`${process.env.REACT_APP_BACKEND_URL}/teacher/getteacherDetails`,{teacherId: localStorage.getItem("teacherId")}) + .then((res)=>{setPhoto(localStorage.getItem("photo") || res.data.teacher.photo || defaultPhoto)}).catch((err)=>{console.error(err)}); + },[]); const responsive = () => { const sidebar = document.getElementsByClassName("navbar-sidebar")[0]; @@ -35,7 +43,7 @@ const Navbar = () => {