From bbabf61cbec3c6a81c20e0ecf1804dab81275162 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 28 Oct 2024 19:06:43 +0530 Subject: [PATCH] feat: show user email --- src/components/molecules/NavBar.tsx | 129 +++++++++++++++------------- 1 file changed, 67 insertions(+), 62 deletions(-) diff --git a/src/components/molecules/NavBar.tsx b/src/components/molecules/NavBar.tsx index 6fccbe1c..7de1e3a1 100644 --- a/src/components/molecules/NavBar.tsx +++ b/src/components/molecules/NavBar.tsx @@ -3,12 +3,11 @@ import axios from 'axios'; import styled from "styled-components"; import { stopRecording } from "../../api/recording"; import { useGlobalInfoStore } from "../../context/globalInfo"; -import { IconButton } from "@mui/material"; -import { RecordingIcon } from "../atoms/RecorderIcon"; -import { SaveRecording } from "./SaveRecording"; -import { Logout, Clear } from "@mui/icons-material"; +import { IconButton, Menu, MenuItem, Typography, Avatar } from "@mui/material"; +import { AccountCircle, Logout, Clear } from "@mui/icons-material"; import { useNavigate } from 'react-router-dom'; import { AuthContext } from '../../context/auth'; +import { SaveRecording } from '../molecules/SaveRecording'; interface NavBarProps { recordingName: string; @@ -16,14 +15,20 @@ interface NavBarProps { } export const NavBar: React.FC = ({ recordingName, isRecording }) => { - const { notify, browserId, setBrowserId, recordingUrl } = useGlobalInfoStore(); const { state, dispatch } = useContext(AuthContext); const { user } = state; - - console.log(`Recording URL: ${recordingUrl}`) - const navigate = useNavigate(); + + const [anchorEl, setAnchorEl] = useState(null); + + const handleMenuOpen = (event: React.MouseEvent) => { + setAnchorEl(event.currentTarget); + }; + + const handleMenuClose = () => { + setAnchorEl(null); + }; const logout = async () => { dispatch({ type: 'LOGOUT' }); @@ -33,8 +38,6 @@ export const NavBar: React.FC = ({ recordingName, isRecording }) => navigate('/login'); }; - // If recording is in progress, the resources and change page view by setting browserId to null - // else it won't affect the page const goToMainMenu = async () => { if (browserId) { await stopRecording(browserId); @@ -50,63 +53,65 @@ export const NavBar: React.FC = ({ recordingName, isRecording }) => display: 'flex', justifyContent: 'flex-start', }}> - +
Maxun
{ - user !== null ? ( - <> -
- { - !isRecording ? ( - <> - - - Logout - - ) : - <> - - - Discard - - - } -
- + user ? ( +
+ {!isRecording ? ( + <> + + + {user.email} + + + { handleMenuClose(); logout(); }}> + Logout + + + + ) : ( + <> + + + Discard + + + + )} +
) : "" } - ); };