mega-plant/components/ClockBottomNav.tsx
David 29a035a4f2 Clock app: vehicle-QR diesel book-out with meter photo; user access levels
- Scanning a vehicle QR (its register code, e.g. TLB04) books diesel from the main
  tank; litres, optional odometer and a required meter photo (stored protected,
  viewable from the Booked out table)
- Settings: users are Full or Clock-app-only; clock-only users are confined to /clock
- Clock app: tapped tab highlights at once plus a loading screen; remove the
  "scanned on this device" list

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-22 12:25:15 +02:00

32 lines
1.6 KiB
TypeScript

'use client';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import { useEffect, useState } from 'react';
import { ClipboardList, Droplets, Users } from 'lucide-react';
const TABS = [
{ href: '/clock', label: 'Employees', Icon: Users },
{ href: '/clock/stock', label: 'Oil & Diesel', Icon: Droplets },
{ href: '/clock/job-cards', label: 'Job cards', Icon: ClipboardList },
];
/** Mobile-app style tab bar. Hidden on the sign-in / password screens. */
export function ClockBottomNav() {
const path = usePathname();
// Highlight the tapped tab at once: the next page takes a moment to load and an
// unchanged bar reads as "the tap did not register".
const [tapped, setTapped] = useState<string | null>(null);
useEffect(() => setTapped(null), [path]);
if (path.startsWith('/clock/login') || path.startsWith('/clock/change-password')) return null;
return <nav aria-label="Plant app" className="fixed inset-x-0 bottom-0 z-40 border-t border-border bg-surface pb-[env(safe-area-inset-bottom)]">
<ul className="mx-auto max-w-3xl grid grid-cols-3">
{TABS.map(({ href, label, Icon }) => {
const here = tapped ?? path;
const active = href === '/clock' ? here === '/clock' : here.startsWith(href);
return <li key={href}><Link href={href} onClick={() => setTapped(href)} aria-current={active ? 'page' : undefined}
className={`flex min-h-[56px] flex-col items-center justify-center gap-0.5 text-xs font-medium ${active ? 'text-[#30638E]' : 'text-text-muted'}`}>
<Icon size={22} strokeWidth={active ? 2.4 : 1.8}/>{label}</Link></li>;
})}
</ul>
</nav>;
}