feat(accounts): add admin accounts and user preferences

Remove public registration, support administrator-managed accounts, and persist personal preferences.

Refs #2 #5

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 19:54:06 +01:00
parent 1b0625f91c
commit 50bde816ed
46 changed files with 1362 additions and 256 deletions

View File

@ -0,0 +1,41 @@
import { Sun, Moon } from 'lucide-react'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import { useTheme } from '@/lib/theme'
export function Appearance() {
const { theme, setTheme } = useTheme()
return (
<Card>
<CardHeader><CardTitle>Apparence</CardTitle></CardHeader>
<CardContent>
<div className="flex items-center gap-3">
<button
aria-pressed={theme === 'light'}
onClick={() => setTheme('light')}
className={`flex items-center gap-2 px-4 py-2 rounded-md border text-sm font-medium transition-colors ${
theme === 'light'
? 'bg-primary text-primary-foreground border-primary'
: 'bg-transparent text-muted-foreground border-border hover:bg-accent hover:text-foreground'
}`}
>
<Sun className="h-4 w-4" />
Clair
</button>
<button
aria-pressed={theme === 'dark'}
onClick={() => setTheme('dark')}
className={`flex items-center gap-2 px-4 py-2 rounded-md border text-sm font-medium transition-colors ${
theme === 'dark'
? 'bg-primary text-primary-foreground border-primary'
: 'bg-transparent text-muted-foreground border-border hover:bg-accent hover:text-foreground'
}`}
>
<Moon className="h-4 w-4" />
Sombre
</button>
</div>
</CardContent>
</Card>
)
}

View File

@ -1,5 +1,6 @@
import { NavLink } from 'react-router-dom'
import { LayoutDashboard, Newspaper, Star, Settings, FileText } from 'lucide-react'
import { useAuth } from '@/lib/auth'
import { cn } from '@/lib/cn'
const items = [
@ -7,20 +8,22 @@ const items = [
{ to: '/feed', icon: Newspaper, label: 'Actus' },
{ to: '/watchlist', icon: Star, label: 'Watchlist' },
{ to: '/reports', icon: FileText, label: 'Rapports' },
{ to: '/admin', icon: Settings, label: 'Admin' },
{ to: '/preferences', icon: Settings, label: 'Mes préférences' },
]
export function MobileNav() {
const { isAdmin } = useAuth()
const visibleItems = isAdmin ? [...items, { to: '/admin', icon: Settings, label: 'Admin' }] : items
return (
<nav className="fixed bottom-0 left-0 right-0 z-50 flex border-t bg-card md:hidden shadow-sm">
{items.map(({ to, icon: Icon, label }) => (
{visibleItems.map(({ to, icon: Icon, label }) => (
<NavLink
key={to}
to={to}
end={to === '/'}
className={({ isActive }) =>
cn(
'flex flex-1 flex-col items-center gap-1 py-3 text-xs transition-colors',
'flex min-w-0 flex-1 flex-col items-center gap-1 px-1 py-3 text-center text-xs transition-colors',
isActive ? 'text-primary font-medium' : 'text-muted-foreground'
)
}

View File

@ -7,13 +7,14 @@ const navItems = [
{ to: '/', icon: LayoutDashboard, label: 'Dashboard' },
{ to: '/feed', icon: Newspaper, label: 'Actualités' },
{ to: '/watchlist', icon: Star, label: 'Watchlist' },
{ to: '/preferences', icon: Settings, label: 'Mes préférences' },
{ to: '/reports', icon: FileText, label: 'Rapports' },
]
const adminItems = [
{ to: '/admin/ai', icon: Cpu, label: 'Fournisseurs IA' },
{ to: '/admin/credentials', icon: Key, label: 'Identifiants' },
{ to: '/admin/sources', icon: Database, label: 'Sources' },
{ to: '/admin/sources', icon: Database, label: 'Sources et plafonds' },
{ to: '/admin/jobs', icon: ClipboardList, label: 'Jobs' },
{ to: '/admin/users', icon: Users, label: 'Utilisateurs' },
{ to: '/admin/schedule', icon: CalendarDays, label: 'Planning' },

View File

@ -1,7 +1,7 @@
import { forwardRef, type InputHTMLAttributes } from 'react'
import { cn } from '@/lib/cn'
export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {}
export type InputProps = InputHTMLAttributes<HTMLInputElement>
export const Input = forwardRef<HTMLInputElement, InputProps>(({ className, type, ...props }, ref) => (
<input

View File

@ -2,7 +2,7 @@ import { forwardRef, type SelectHTMLAttributes } from 'react'
import { cn } from '@/lib/cn'
import { ChevronDown } from 'lucide-react'
export interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> {}
export type SelectProps = SelectHTMLAttributes<HTMLSelectElement>
export const Select = forwardRef<HTMLSelectElement, SelectProps>(({ className, children, ...props }, ref) => (
<div className="relative">