import React, { useState, useContext } from 'react'; import axios from 'axios'; import styled from "styled-components"; import { stopRecording } from "../../api/recording"; import { useGlobalInfoStore } from "../../context/globalInfo"; import { Button, IconButton } from "@mui/material"; import { RecordingIcon } from "../atoms/RecorderIcon"; import { SaveRecording } from "./SaveRecording"; import { Circle, Add, Logout, Clear } from "@mui/icons-material"; import MeetingRoomIcon from '@mui/icons-material/MeetingRoom'; import { Link, useLocation, useNavigate } from 'react-router-dom'; import { AuthContext } from '../../context/auth'; interface NavBarProps { newRecording: () => void; recordingName: string; isRecording: boolean; } export const NavBar: React.FC = ({ newRecording, recordingName, isRecording }) => { const { notify, browserId, setBrowserId, recordingLength } = useGlobalInfoStore(); const { state, dispatch } = useContext(AuthContext); const { user } = state; const navigate = useNavigate(); const logout = async () => { dispatch({ type: 'LOGOUT' }); window.localStorage.removeItem('user'); const { data } = await axios.get('http://localhost:8080/auth/logout'); notify('success', data.message); 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); notify('warning', 'Current Recording was terminated'); setBrowserId(null); } navigate('/'); }; const handleNewRecording = async () => { if (browserId) { setBrowserId(null); await stopRecording(browserId); } newRecording(); notify('info', 'New Recording started'); } return (
Maxun
{ user !== null ? ( <>
{ !isRecording ? ( <> Create Robot Logout ) : Discard } { recordingLength > 0 ? : null }
) : "" }
); }; const NavBarWrapper = styled.div` grid-area: navbar; background-color: white; padding:5px; display: flex; justify-content: space-between; `; const ProjectName = styled.b` color: #3f4853; font-size: 1.3em; `;