Pc / tel
deploy / deploy (push) Successful in 35s

This commit is contained in:
Romain committed 2026-10-04 17:10:56 +02:00
1 parent c82b7894a5
commit 1eed66e1c4
31 files changed
+556 -72

No files matched your search

+4 -43
View File
@@ -1,48 +1,22 @@
import Avatar from './social/Avatar'
import { useSocial } from './social/SocialProvider'
import { locale, t } from '../i18n'
import { CloudOff, KeyRound, Loader2, LogOut, RefreshCw, UserRound } from 'lucide-react'
import { useEffect, useState, type FormEvent } from 'react'
import { t } from '../i18n'
import { KeyRound, Loader2, LogOut, UserRound } from 'lucide-react'
import { useState, type FormEvent } from 'react'
import { PASSWORD_MIN, updatePassword } from '../lib/cloud/auth'
import { cx } from '../lib/utils'
import type { AccountApi } from '../store'
import ConfirmDialog from './ConfirmDialog'
import { SectionTitle } from './ui'
function ago(iso?: string): string {
if (!iso) return t('time.never')
const s = Math.max(0, (Date.now() - new Date(iso).getTime()) / 1000)
if (s < 60) return t('time.justNow')
if (s < 3600) return t('time.minutesAgo', { n: Math.floor(s / 60) })
if (s < 86400) return t('time.hoursAgo', { n: Math.floor(s / 3600) })
return t('time.onDate', { date: new Date(iso).toLocaleDateString(locale(), { day: 'numeric', month: 'short' }) })
}
/** Réglages → Mon compte : état de la synchro, mot de passe, déconnexion. */
/** Réglages → Mon compte : mot de passe, déconnexion. La synchro tourne en arrière-plan. */
export default function AccountSection({ account, onMessage }: { account: AccountApi; onMessage: (kind: 'ok' | 'error', text: string) => void }) {
const { sync } = account
const social = useSocial()
const [, tick] = useState(0)
const [pwOpen, setPwOpen] = useState(false)
const [pw, setPw] = useState('')
const [busy, setBusy] = useState<'pw' | 'logout' | 'import' | null>(null)
const [confirmLogout, setConfirmLogout] = useState(false)
// Rafraîchit « il y a x min »
useEffect(() => {
const timer = setInterval(() => tick((n) => n + 1), 30_000)
return () => clearInterval(timer)
}, [])
const statusText =
sync.state === 'syncing'
? t('account.syncing')
: sync.state === 'offline'
? t('account.offline')
: sync.state === 'error'
? t('account.syncError')
: t('account.synced', { when: ago(sync.lastSyncAt) })
const changePassword = async (e: FormEvent) => {
e.preventDefault()
setBusy('pw')
@@ -90,20 +64,7 @@ export default function AccountSection({ account, onMessage }: { account: Accoun
</span>
<span className="min-w-0 flex-1">
<span className="block truncate font-medium">{account.email}</span>
<span className={cx('mt-0.5 flex items-center gap-1.5 text-xs', sync.state === 'error' ? 'text-accent' : 'text-ink-3')}>
{sync.state === 'offline' && <CloudOff size={12} />}
{statusText}
{sync.pending > 0 && sync.state !== 'syncing' && ` · ${t('account.pending', { count: sync.pending })}`}
</span>
</span>
<button
onClick={() => account.syncNow()}
disabled={sync.state === 'syncing'}
className="grid size-10 shrink-0 place-items-center rounded-full border border-line text-ink-2"
aria-label={t('account.syncNow')}
>
{sync.state === 'syncing' ? <Loader2 size={17} className="animate-spin" /> : <RefreshCw size={17} />}
</button>
</div>
<button
+1 -1
View File
@@ -38,7 +38,7 @@ export default function BottomNav({ current, onChange, onAdd }: Props) {
}
return (
<nav className="safe-bottom fixed inset-x-0 bottom-0 z-30 border-t border-line bg-bg/95 backdrop-blur-md">
<nav className="safe-bottom fixed inset-x-0 bottom-0 z-30 border-t border-line bg-bg/95 backdrop-blur-md lg:hidden">
<div className="mx-auto flex max-w-2xl items-center px-2">
{ITEMS.slice(0, 2).map(button)}
<div className="flex flex-1 justify-center">
+55
View File
@@ -0,0 +1,55 @@
import { type Tab } from './BottomNav'
import { t } from '../i18n'
import { BarChart3, Home, LibraryBig, Plus, Settings } from 'lucide-react'
import { cx } from '../lib/utils'
const ITEMS: { tab: Tab; readonly label: string; Icon: typeof Home }[] = [
{ tab: 'home', get label() { return t('nav.home') }, Icon: Home },
{ tab: 'catalog', get label() { return t('nav.catalog') }, Icon: LibraryBig },
{ tab: 'stats', get label() { return t('nav.stats') }, Icon: BarChart3 },
{ tab: 'settings', get label() { return t('nav.settings') }, Icon: Settings },
]
interface Props {
current: Tab
onChange: (tab: Tab) => void
onAdd: () => void
}
export default function SideNav({ current, onChange, onAdd }: Props) {
return (
<nav className="fixed inset-y-0 start-0 z-30 hidden w-60 flex-col border-e border-line bg-bg px-4 py-6 lg:flex">
<h1 className="px-2 text-2xl font-bold">
Azuu<span className="text-accent">Cine</span>
</h1>
<button
onClick={onAdd}
className="mt-6 flex w-full items-center justify-center gap-2 rounded-full bg-accent-fill px-4 py-2.5 text-sm font-semibold text-on-accent transition active:scale-95"
>
<Plus size={18} strokeWidth={2.2} />
{t('nav.addTitle')}
</button>
<div className="mt-6 flex flex-col gap-1">
{ITEMS.map(({ tab, label, Icon }) => {
const active = current === tab
return (
<button
key={tab}
onClick={() => onChange(tab)}
aria-current={active ? 'page' : undefined}
className={cx(
'flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-sm font-medium transition-colors',
active ? 'bg-surface-2 text-ink' : 'text-ink-3 hover:text-ink',
)}
>
<Icon size={20} strokeWidth={active ? 2.2 : 1.6} />
{label}
</button>
)
})}
</div>
</nav>
)
}