diff --git a/frontend/src/components/Navbar.jsx b/frontend/src/components/Navbar.jsx index c732828..2e2c03f 100644 --- a/frontend/src/components/Navbar.jsx +++ b/frontend/src/components/Navbar.jsx @@ -4,7 +4,7 @@ import AuthWidget from './AuthWidget'; import UserDisplay from './ui/UserDisplay'; import { useEffect, useRef, useState } from 'preact/hooks'; import { useSpring, animated } from '@react-spring/web'; -import { hydrateAuthFromStorage } from '../stores/authStore'; +import { hydrateAuthFromStorage, loadCurrentUser, $user, $accessToken } from '../stores/authStore'; const ITEMS = [ { id: 'dashboard', label: 'Dashboard', href: '/' }, @@ -21,8 +21,12 @@ function normalizePath(p) { } function getActiveIndex(path) { - const idx = ITEMS.findIndex((item) => item.href === path); - return idx >= 0 ? idx : 0; + // Exact match (e.g. '/' → Dashboard) + const exact = ITEMS.findIndex((item) => item.href === path); + if (exact >= 0) return exact; + // Prefix match for sub-paths (e.g. '/putni-nalozi/racuni' → Putni nalozi) + const prefix = ITEMS.findIndex((item) => item.href !== '/' && path.startsWith(item.href)); + return prefix >= 0 ? prefix : 0; } export default function Navbar({ minimal = false }) { @@ -55,6 +59,10 @@ export default function Navbar({ minimal = false }) { // Mount: izmjeri početnu poziciju bez animacije, pa uključi animaciju za buduće navigacije useEffect(() => { hydrateAuthFromStorage(); + // Učitaj korisnika ako token postoji ali $user još nije popunjen + if (!$user.get() && $accessToken.get()) { + loadCurrentUser(); + } const timer = setTimeout(() => { measureIndicator(); diff --git a/frontend/src/components/dashboard/WorkOrderInvoicesPdfPage.jsx b/frontend/src/components/dashboard/WorkOrderInvoicesPdfPage.jsx index 9c1cd74..fe54e7c 100644 --- a/frontend/src/components/dashboard/WorkOrderInvoicesPdfPage.jsx +++ b/frontend/src/components/dashboard/WorkOrderInvoicesPdfPage.jsx @@ -321,22 +321,24 @@ export default function WorkOrderInvoicesPdfPage() { {workOrder ? `Dizalica: ${workOrder.crane_label || workOrder.crane || '-'}` : 'Pregled računa prije kreiranja PDF-a.'}

- - +
+ + +