Princeaka's picture
Upload 44 files
0ff9b81 verified
import React from 'react'
import { useStore } from '../state/store'
import { NotificationBell } from './notifications/NotificationBell'
export function Topbar(){
const { auth, setAuth, ui, setUi } = useStore()
function toggleMic(){
const will = !auth.mic
const next = { ...auth, mic: will }
setAuth(next); localStorage.setItem('chb_auth', JSON.stringify(next))
setUi(u=>({...u, toast: will ? 'Microphone enabled' : 'Microphone disabled'}))
}
function logout(){
setAuth({ token:'', role:'', name:'', nickname:'', mic:false })
localStorage.removeItem('chb_auth')
window.location.href = '/login'
}
return (
<div className="topbar">
<div className="pill">CHB β€’ Universal Brain</div>
<div className="top-actions">
<button className="btn" onClick={toggleMic} title="Mic permission">
{auth.mic ? 'πŸŽ™οΈ On' : '🎀 Off'}
</button>
<NotificationBell/>
<div className="pill">{auth.role || 'user'} Β· {auth.name || 'guest'}</div>
<button className="btn" onClick={logout}>Logout</button>
</div>
</div>
)
}