I'll add a complete authentication layer (login screen, session persistence, protected app shell, and working sign-out) while keeping every existing feature and page exactly as they are. Starting with the auth context.
Now the Login page — a split-screen screen matching the design system (Abhaya Libre headings, sage palette, glass effects, ripple button).
Now updating the App shell: wrap in the auth provider, show a branded splash while restoring the session, gate the workspace behind login, and keep all existing routing/features untouched.
Now wiring the Navbar to the authenticated user (dynamic name/initials) and making "Sign out" actually end the session.
Now making the "Sign out" menu item call logout:
All auth wiring is complete. Let me verify the build.
Authentication is now live, with every existing feature untouched. Here's what was added:
Authentication Layer
src/lib/auth.tsx — Auth context
AuthProvider + useAuth hook managing the session
- Two demo accounts: [EMAIL_ADDRESS_5] / demo1234
(Finance Lead) and [EMAIL_ADDRESS_6] / demo1234 (Accountant)
- Session persisted in
localStorage (remember me) or sessionStorage, restored on reload
- Simulated network delay on sign-in; invalid credentials raise a clear error
logout() clears the session from both stores
src/pages/Login.tsx — Sign-in screen
- Split-screen: dark charcoal brand panel (ambient blurred glows, gradient hairline, headline in Abhaya Libre, feature list, stats strip) on the left; form on the right — fully matching the existing design system
- Email + password fields with icons, show/hide password toggle, remember-me, "forgot password" link
- Ripple sign-in button with loading spinner, inline error/status alerts
- Click-to-fill demo account cards and (decorative) SSO buttons
- Fully responsive: brand panel collapses on mobile
src/App.tsx — Auth gate
- Branded pulsing splash while the persisted session is restored
- Routes to Login when unauthenticated, Workspace when authenticated
- The entire existing shell (Sidebar, Navbar, Footer, all 10 pages, hash routing, theme toggle) is unchanged inside
Workspace
src/components/Navbar.tsx
- Profile badge now shows the signed-in user's real initials, name, and role (no longer hardcoded)
- Sign out in the profile menu now actually ends the session and returns you to the login screen
Flow: open the app → splash → login (demo creds shown on the card) → full billing workspace → sign out via the profile menu. All existing features — dashboard, invoices, create-invoice, products, categories, customers, payments, stock, reports — remain exactly as they were.
Files built: src/lib/auth.tsx, src/pages/Login.tsx, src/App.tsx, src/components/Navbar.tsx