feat(v9d): add training types system + logout button
Phase 1: Training Types Basis ============================= Backend: - Migration 004: training_types table + seed data (24 types) - New router: /api/training-types (grouped, flat, categories) - Extend activity_log: training_type_id, training_category, training_subcategory - Extend ActivityEntry model: support training type fields Frontend: - TrainingTypeSelect component (two-level dropdown) - TrainingTypeDistribution component (pie chart) - API functions: listTrainingTypes, listTrainingTypesFlat, getTrainingCategories Quick Win: Logout Button ======================== - Add LogOut icon button in app header - Confirm dialog before logout - Redirect to / after logout - Hover effect: red color on hover Not yet integrated: - TrainingTypeSelect not yet in ActivityPage form - TrainingTypeDistribution not yet in Dashboard (will be added in next commit) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
0aca5fda5d
commit
410b2ce308
8 files changed
+490
-9
No files matched your search
+35
-8
@@ -1,6 +1,6 @@
|
||||
import { useEffect } from 'react'
|
||||
import { BrowserRouter, Routes, Route, NavLink, useNavigate } from 'react-router-dom'
|
||||
import { LayoutDashboard, PlusSquare, TrendingUp, BarChart2, Settings } from 'lucide-react'
|
||||
import { LayoutDashboard, PlusSquare, TrendingUp, BarChart2, Settings, LogOut } from 'lucide-react'
|
||||
import { ProfileProvider, useProfile } from './context/ProfileContext'
|
||||
import { AuthProvider, useAuth } from './context/AuthContext'
|
||||
import { setProfileId } from './utils/api'
|
||||
@@ -50,10 +50,17 @@ function Nav() {
|
||||
}
|
||||
|
||||
function AppShell() {
|
||||
const { session, loading: authLoading, needsSetup } = useAuth()
|
||||
const { session, loading: authLoading, needsSetup, logout } = useAuth()
|
||||
const { activeProfile, loading: profileLoading } = useProfile()
|
||||
const nav = useNavigate()
|
||||
|
||||
const handleLogout = () => {
|
||||
if (confirm('Wirklich abmelden?')) {
|
||||
logout()
|
||||
window.location.href = '/'
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(()=>{
|
||||
if (session?.profile_id) {
|
||||
setProfileId(session.profile_id)
|
||||
@@ -119,12 +126,32 @@ function AppShell() {
|
||||
<div className="app-shell">
|
||||
<header className="app-header">
|
||||
<span className="app-logo">Mitai Jinkendo</span>
|
||||
<NavLink to="/settings" style={{textDecoration:'none'}}>
|
||||
{activeProfile
|
||||
? <Avatar profile={activeProfile} size={30}/>
|
||||
: <div style={{width:30,height:30,borderRadius:'50%',background:'var(--accent)'}}/>
|
||||
}
|
||||
</NavLink>
|
||||
<div style={{display:'flex', gap:12, alignItems:'center'}}>
|
||||
<button
|
||||
onClick={handleLogout}
|
||||
title="Abmelden"
|
||||
style={{
|
||||
background:'none',
|
||||
border:'none',
|
||||
cursor:'pointer',
|
||||
padding:6,
|
||||
display:'flex',
|
||||
alignItems:'center',
|
||||
color:'var(--text2)',
|
||||
transition:'color 0.15s'
|
||||
}}
|
||||
onMouseEnter={e => e.currentTarget.style.color = '#D85A30'}
|
||||
onMouseLeave={e => e.currentTarget.style.color = 'var(--text2)'}
|
||||
>
|
||||
<LogOut size={18}/>
|
||||
</button>
|
||||
<NavLink to="/settings" style={{textDecoration:'none'}}>
|
||||
{activeProfile
|
||||
? <Avatar profile={activeProfile} size={30}/>
|
||||
: <div style={{width:30,height:30,borderRadius:'50%',background:'var(--accent)'}}/>
|
||||
}
|
||||
</NavLink>
|
||||
</div>
|
||||
</header>
|
||||
<main className="app-main">
|
||||
<Routes>
|
||||
|
||||
Reference in new issue
Block a user