Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 12 additions & 25 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { useEffect, useMemo, useState } from 'react'
import { NavLink, Outlet, useLocation, useNavigate } from 'react-router'
import { Wallet, BarChart3, LayoutDashboard, CreditCard, Settings as SettingsIcon, LineChart, Eye, EyeOff, RefreshCw, Plus, Sun, Moon, MoreHorizontal, Search } from 'lucide-react'
import { Wallet, BarChart3, LayoutDashboard, CreditCard, Settings as SettingsIcon, LineChart, Eye, EyeOff, RefreshCw, Plus, MoreHorizontal, Search } from 'lucide-react'
import { getMasterCurrency, getStoredMenuVisibility, loadNavigationSettings } from './components/settings-module/settings.storage'
import { MENU_VISIBILITY_EVENT, type MenuKey } from './components/settings-module/constants'
import { useTheme } from './context/ThemeContext'
import { TransactionList } from './components/dashboard-module/TransactionList'
import { Modal } from './components/common/modal'
import { usePrivacy } from './context/PrivacyContext'
Expand Down Expand Up @@ -33,7 +32,6 @@ function App() {
const [visibleMenus, setVisibleMenus] = useState<Record<MenuKey, boolean>>(getStoredMenuVisibility)
const [navigationReady, setNavigationReady] = useState(false)
const { privacyMode, togglePrivacyMode } = usePrivacy()
const { colorMode, setColorMode } = useTheme()
const [moreOpen, setMoreOpen] = useState(false)
const [searchOpen, setSearchOpen] = useState(false)
const hasUnfinishedChanges = useHasUnsavedChanges()
Expand Down Expand Up @@ -135,11 +133,7 @@ function App() {
document.addEventListener('keydown', keyDown)
return () => document.removeEventListener('keydown', keyDown)
}, [canCompose, searchOpen, hasUnfinishedChanges])
const themeControl = <button type="button" onClick={() => setColorMode(colorMode === 'dark' ? 'light' : 'dark')}
className="finance-nav-item w-full" aria-label={colorMode === 'dark' ? 'Switch to light mode' : 'Switch to dark mode'}>
{colorMode === 'dark' ? <Sun className="h-4 w-4" /> : <Moon className="h-4 w-4" />}<span>{colorMode === 'dark' ? 'Light mode' : 'Dark mode'}</span>
</button>
const privacyControl = <button type="button" onClick={togglePrivacyMode} className="finance-icon-button"
const privacyControl = <button type="button" onClick={togglePrivacyMode} className="finance-header-button"
aria-label={privacyMode === 'hidden' ? 'Show values' : 'Hide values'} title={privacyMode === 'hidden' ? 'Show values' : 'Hide values'} aria-pressed={privacyMode === 'hidden'}>
{privacyMode === 'hidden' ? <EyeOff className="h-4 w-4" /> : <Eye className="h-4 w-4" />}
</button>
Expand All @@ -148,13 +142,13 @@ function App() {
<aside className="finance-sidebar fixed inset-y-0 left-0 z-40 hidden flex-col border-r border-border bg-card px-3.5 py-5 lg:flex overflow-hidden">
<div className="mb-5 flex shrink-0 items-center gap-2">
<NavLink to="/dashboard" className="flex min-w-0 flex-1 items-center gap-2.5 px-1.5" aria-label="Finance home">
<span className="flex h-8 w-8 items-center justify-center rounded-[9px] bg-primary text-primary-foreground"><Wallet className="h-[17px] w-[17px]" /></span>
<span><span className="block text-[15px] font-semibold">Finance</span><span className="block text-[11px] text-muted-foreground">Self-hosted</span></span>
<span className="flex h-8 w-8 items-center justify-center rounded-[9px] bg-primary-fill text-primary-foreground"><Wallet className="h-[17px] w-[17px]" /></span>
<span><span className="block text-[15px] font-semibold">Finance</span><span className="block text-xs text-muted-foreground">Self-hosted</span></span>
</NavLink>
{privacyControl}
</div>
<button type="button" onClick={() => setSearchOpen(true)} aria-label="Search everything" aria-keyshortcuts="Meta+K Control+K" className="mb-5 flex h-10 shrink-0 cursor-pointer items-center gap-2 rounded-[10px] border border-border bg-background px-3 text-xs text-muted-foreground hover:bg-secondary hover:text-foreground">
<Search className="h-4 w-4 shrink-0" /><span className="flex-1 text-left">Search everything…</span><kbd aria-hidden="true" className="rounded border border-border px-1 text-[10px]">{searchShortcut}</kbd>
<Search className="h-4 w-4 shrink-0" /><span className="flex-1 text-left">Search everything…</span><kbd aria-hidden="true" className="rounded border border-border px-1 text-xs tracking-wide">{searchShortcut}</kbd>
</button>
<nav aria-label="Main navigation" className="shrink-0 space-y-0.5">
{availableNav.filter(item => item.key !== 'accounts').map(item => <NavLink key={item.key} to={`/${item.key}`} end className="finance-nav-item">{item.icon}<span>{item.label}</span></NavLink>)}
Expand All @@ -163,19 +157,15 @@ function App() {
status={dataStatus.accounts} valuationLoading={dataStatus.exchangeRates.loading || dataStatus.investment.loading} />}
<div className="mt-auto shrink-0 space-y-0.5 border-t border-border pt-3">
<NavLink to="/settings" end className="finance-nav-item"><SettingsIcon className="h-4 w-4" />Settings</NavLink>
{themeControl}
<p className="pt-1.5 text-center text-[11px] text-muted-foreground">v{APP_VERSION}</p>
<p className="pt-1.5 text-center text-xs text-muted-foreground">v{APP_VERSION}</p>
</div>
</aside>
<div className="finance-main pb-24 lg:pb-0">
<header className="finance-mobile-header sticky top-0 z-40 flex items-center gap-2 border-b border-border bg-canvas/95 px-4 py-3 backdrop-blur-lg">
<header className="finance-mobile-header finance-material sticky top-0 z-40 flex items-center gap-1 px-4 py-2.5">
<div className="min-w-0 flex-1"><p className="text-xs text-muted-foreground">Finance</p><h1 className="text-[22px] font-semibold tracking-tight">{title}</h1></div>
{privacyControl}
<button type="button" className="finance-icon-button" aria-label="Search everything" onClick={() => setSearchOpen(true)}><Search className="h-4 w-4" /></button>
{view !== 'dashboard' && <button type="button" className="finance-icon-button" aria-label={colorMode === 'dark' ? 'Switch to light mode' : 'Switch to dark mode'} onClick={() => setColorMode(colorMode === 'dark' ? 'light' : 'dark')}>
{colorMode === 'dark' ? <Sun className="h-4 w-4" /> : <Moon className="h-4 w-4" />}
</button>}
{view !== 'dashboard' && <NavLink to="/settings" aria-label="Settings" className="finance-icon-button"><SettingsIcon className="h-4 w-4" /></NavLink>}
<button type="button" className="finance-header-button" aria-label="Search everything" onClick={() => setSearchOpen(true)}><Search className="h-5 w-5" /></button>
<button type="button" onClick={newTransaction} disabled={!canCompose} aria-label="New transaction" title="New transaction" className="finance-header-button finance-header-button-primary"><span><Plus className="h-5 w-5" /></span></button>
</header>
<main id="main-content" className="mx-auto w-full max-w-[1280px] px-4 py-4 sm:px-6 lg:px-8 lg:py-6">
{view !== 'dashboard' && view !== 'investments' && view !== 'settings' && <div className="mb-5 hidden items-center justify-between lg:flex"><h1 className="text-2xl font-semibold tracking-tight">{title}</h1></div>}
Expand All @@ -187,19 +177,16 @@ function App() {
</div>
</main>
</div>
<nav aria-label="Mobile navigation" className="fixed inset-x-0 bottom-0 z-50 border-t border-border bg-card/95 px-2 pt-2 backdrop-blur-xl lg:hidden" style={{ paddingBottom: 'max(8px, env(safe-area-inset-bottom))' }}>
<nav aria-label="Mobile navigation" className="finance-material finance-tab-bar fixed inset-x-0 bottom-0 z-50 px-2 pt-1.5 lg:hidden" style={{ paddingBottom: 'max(8px, env(safe-area-inset-bottom))' }}>
<div className="flex items-center justify-around gap-1">
{primaryMobileNav.slice(0, 2).map(item => <NavLink key={item.key} to={`/${item.key}`} end className={`flex min-w-0 flex-1 flex-col items-center gap-1 rounded-lg px-1 py-2 text-[10px] font-medium ${view === item.key ? 'text-primary' : 'text-muted-foreground'}`}>{item.icon}<span>{item.label}</span></NavLink>)}
<button type="button" onClick={newTransaction} disabled={!canCompose} aria-label="New transaction" className="flex h-11 w-11 shrink-0 items-center justify-center rounded-[14px] bg-primary text-primary-foreground shadow-lg shadow-primary/20 disabled:opacity-50"><Plus className="h-5 w-5" /></button>
{primaryMobileNav.slice(2).map(item => <NavLink key={item.key} to={`/${item.key}`} end className={`flex min-w-0 flex-1 flex-col items-center gap-1 rounded-lg px-1 py-2 text-[10px] font-medium ${view === item.key ? 'text-primary' : 'text-muted-foreground'}`}>{item.icon}<span>{item.label}</span></NavLink>)}
<button type="button" onClick={() => setMoreOpen(true)} aria-expanded={moreOpen} className={`flex min-w-0 flex-1 flex-col items-center gap-1 rounded-lg px-1 py-2 text-[10px] font-medium ${view === 'settings' || moreNav.some(item => item.key === view) ? 'text-primary' : 'text-muted-foreground'}`}><MoreHorizontal className="h-4 w-4" /><span>More</span></button>
{primaryMobileNav.map(item => <NavLink key={item.key} to={`/${item.key}`} end className={`finance-tab ${view === item.key ? 'text-primary' : 'text-muted-foreground'}`}>{item.icon}<span>{item.label}</span></NavLink>)}
<button type="button" onClick={() => setMoreOpen(true)} aria-expanded={moreOpen} className={`finance-tab ${view === 'settings' || moreNav.some(item => item.key === view) ? 'text-primary' : 'text-muted-foreground'}`}><MoreHorizontal /><span>More</span></button>
</div>
</nav>
<Modal isOpen={moreOpen} onClose={() => setMoreOpen(false)} title="More">
<nav aria-label="More navigation" className="space-y-1">
{moreNav.map(item => <NavLink key={item.key} to={`/${item.key}`} end onClick={() => setMoreOpen(false)} className="finance-nav-item">{item.icon}<span>{item.label}</span></NavLink>)}
<NavLink to="/settings" onClick={() => setMoreOpen(false)} className="finance-nav-item"><SettingsIcon className="h-4 w-4" />Settings</NavLink>
{view === 'dashboard' && themeControl}
</nav>
</Modal>
<SearchPalette isOpen={searchOpen} onClose={() => setSearchOpen(false)} finance={finance} canCompose={canCompose} hasUnfinishedChanges={hasUnfinishedChanges} onNewTransaction={newTransaction}
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/ApiSession.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function ApiSession({ children }: { children: ReactNode }) {
<p className="mt-2 text-sm text-muted-foreground">Your session may have expired, or the API is unavailable. Sign in with Cloudflare, then retry.</p>
{ready && <p className="mt-2 text-sm text-muted-foreground">Sign in in another tab to keep your unsaved changes here.</p>}
<div className="mt-4 flex flex-wrap items-center gap-3">
{API_AUTH_MODE === 'private' && <a href={getApiLoginUrl()} target={ready ? '_blank' : undefined} rel="noopener noreferrer" className="inline-flex min-h-10 items-center rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground">Sign in</a>}
{API_AUTH_MODE === 'private' && <a href={getApiLoginUrl()} target={ready ? '_blank' : undefined} rel="noopener noreferrer" className="inline-flex min-h-10 items-center rounded-lg bg-primary-fill px-4 py-2 text-sm font-medium text-primary-foreground">Sign in</a>}
<Button variant="outline" onClick={retry} disabled={checking}>{checking ? 'Checking…' : 'Retry connection'}</Button>
</div>
</div>
Expand Down
9 changes: 5 additions & 4 deletions client/src/components/analytics-module/AICashOutlookChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useCalendarAxis } from '../common/calendar-axis'
import { addDays, format, isLastDayOfMonth, startOfDay, subMonths } from 'date-fns'
import { usePrivacy } from '../../context/PrivacyContext'
import type { Account, FinancialOutlookHistoricalCashPoint, FinancialOutlookSnapshot, Transaction } from './types'
import { formatNumber } from '../../lib/format'

type AICashOutlookChartProps = {
snapshot: FinancialOutlookSnapshot | null
Expand Down Expand Up @@ -53,7 +54,7 @@ function dailyPath(points: CashPathPoint[]) {

function amount(value: number, hidden: boolean) {
if (hidden) return '••••••'
return `${value.toLocaleString('hu-HU', { maximumFractionDigits: 0 })} HUF`
return `${formatNumber(value, { maximumFractionDigits: 0 })} HUF`
}

function dateFromHistory(date: string) {
Expand Down Expand Up @@ -192,7 +193,7 @@ export function AICashOutlookChart({ snapshot, transactions, accounts, convertTo
<div className="flex flex-wrap items-center justify-between gap-3">
<h3 className="w-full text-sm font-semibold sm:w-auto">Cash history &amp; forecast</h3>
<div className="flex flex-1 flex-wrap items-center gap-3 text-xs text-muted-foreground sm:ml-2">
<span className="flex items-center gap-1.5"><span aria-hidden="true" className="h-0.5 w-3.5 bg-primary" />Actual</span>
<span className="flex items-center gap-1.5"><span aria-hidden="true" className="h-0.5 w-3.5 bg-primary-fill" />Actual</span>
<span className="flex items-center gap-1.5"><span aria-hidden="true" className="w-3.5 border-t-2 border-dashed border-forecast" />AI forecast</span>
<span className="flex items-center gap-1.5"><span aria-hidden="true" className="h-2.5 w-3.5 rounded-sm bg-forecast/20" />Possible range</span>
</div>
Expand All @@ -219,8 +220,8 @@ export function AICashOutlookChart({ snapshot, transactions, accounts, convertTo
</linearGradient>
</defs>
<CartesianGrid vertical={false} stroke="hsl(var(--border))" />
<XAxis dataKey="timestamp" type="number" scale="time" domain={['dataMin', 'dataMax']} {...axisProps} stroke="hsl(var(--muted-foreground))" fontSize={10} tickLine={false} axisLine={false} />
<YAxis stroke="hsl(var(--muted-foreground))" fontSize={10} tickLine={false} axisLine={false} domain={yDomain} width={50} tickFormatter={value => hidden ? '••••' : Math.abs(value) >= 1_000_000 ? `${(value / 1_000_000).toFixed(1)}M` : `${Math.round(value / 1_000)}K`} />
<XAxis dataKey="timestamp" type="number" scale="time" domain={['dataMin', 'dataMax']} {...axisProps} stroke="hsl(var(--muted-foreground))" fontSize={11} tickLine={false} axisLine={false} />
<YAxis stroke="hsl(var(--muted-foreground))" fontSize={11} tickLine={false} axisLine={false} domain={yDomain} width={50} tickFormatter={value => hidden ? '••••' : Math.abs(value) >= 1_000_000 ? `${(value / 1_000_000).toFixed(1)}M` : `${Math.round(value / 1_000)}K`} />
<Tooltip content={({ active, payload }) => {
const point = payload?.[0]?.payload as ChartPoint | undefined
if (!active || !point) return null
Expand Down
Loading
Loading