How oregon-mai/oregon-frontend works
Purpose and runtime
T1 Workspace is a Vite/React TypeScript frontend for employee desk booking. It runs locally through the Vite dev server and currently uses a stub authentication flow; no backend implementation is present. Browser localStorage persists the JWT token.
Entry bootstrap and route/provider composition are in src/main.tsx; global styling begins in src/index.css.
Application shell and navigation
The authenticated workspace is organized around a shared layout that supplies the top bar, navigation sidebar, and page content area:
• src/components/Layout.tsx
• src/components/Sidebar.tsx
• src/components/Layout.module.css
The sidebar is also the floor/navigation and “today” booking summary boundary. The principal protected destination is the office map page at /map.
Authentication boundary
Authentication is modeled as a global React context holding the current user and bookings:
• src/context/AuthContext.tsx
• src/types/auth.ts
src/api/authApi.ts defines the login API boundary (POST /auth/login), while the current README-described behavior is a client-side stub accepting an email and password of at least six characters. Login UI lives in src/pages/LoginPage.tsx.
Access control is enforced at routing level by src/components/ProtectedRoute.tsx, which checks for the stored token and redirects unauthenticated users away from /map to /login.
Route and session flow
1. src/main.tsx initializes React routing and wraps routes in AuthProvider.
2. A user submits credentials on src/pages/LoginPage.tsx.
3. The login page calls src/api/authApi.ts; successful authentication updates AuthContext and stores the token in browser storage.
4. ProtectedRoute permits access to src/pages/MapPage.tsx only with an authenticated token.
5. Logout from the shared layout clears session state/token and returns the user to the public login flow.
Office map domain
The office visualization and booking domain types are separated from rendering:
• src/types/map.ts
• src/pages/MapPage.tsx
• src/components/OfficeMap/OfficeMap.tsx
MapPage composes the workspace view. OfficeMap renders desks grouped by zones and exposes desk status distinctions: available, occupied, and booked by the current user. Domain structures include desks, zones, and bookings, enabling the map to remain a presentation/selection layer rather than own authentication state.
Booking interaction flow
Selecting a bookable desk on the map feeds the booking panel:
• src/components/OfficeMap/OfficeMap.tsx
• src/components/BookingPanel/BookingPanel.tsx
• src/context/AuthContext.tsx
BookingPanel presents 15-minute reservation slots. Booking changes are maintained in AuthContext, making them available both to the map (for desk status) and sidebar/widget views (for today’s reservations). This is currently client-side shared state; no booking API or persistence service is represented in the repository.
Key boundaries and extension points
The repository separates external authentication integration (src/api/authApi.ts) from session state (src/context/AuthContext.tsx), and map domain contracts (src/types/map.ts) from visual components. A production backend can replace the auth stub and add booking/map data APIs without changing route protection or the broad page composition. The material platform dependencies are React, TypeScript, Vite, browser routing, and localStorage; no server runtime, database, or external infrastructure is included.
Main entry points: AuthContext.tsx Auth context · main.tsx App bootstrap · MapPage.tsx Map page · ProtectedRoute.tsx Protected route
Components 15
Frontend runtime
- Vite dev server · Serves the React frontend locally.
- App bootstrap · Composes routing and AuthProvider.
src/main.tsx - Global styles
src/index.css
Authentication
- Login page
src/pages/LoginPage.tsx - Auth API boundary · Currently implements the client-side login stub.
src/api/authApi.ts - Auth context · Holds current user and shared bookings.
src/context/AuthContext.tsx - Auth contracts
src/types/auth.ts - Browser localStorage · Persists the JWT token.
Protected workspace
- Protected route · Redirects unauthenticated map access to login.
src/components/ProtectedRoute.tsx - Workspace layout · Supplies top bar, sidebar, and page area.
src/components/Layout.tsx - Sidebar · Shows floor navigation and today's bookings.
src/components/Sidebar.tsx
Office booking
- Map page · Composes the desk-booking workspace at /map.
src/pages/MapPage.tsx - Office map · Renders zoned desks and their booking status.
src/components/OfficeMap/OfficeMap.tsx - Booking panel · Offers 15-minute reservation slots.
src/components/BookingPanel/BookingPanel.tsx - Map contracts · Defines desks, zones, and bookings.
src/types/map.ts
Connections 23
- Vite dev server → App bootstrap: serves
- App bootstrap → Global styles: loads
- App bootstrap → Auth context: wraps with provider
- App bootstrap → Login page: routes /login
- App bootstrap → Protected route: guards /map
- Login page → Auth API boundary: submits credentials
- Auth API boundary → Auth context: returns authenticated session
- Auth context → Browser localStorage: stores token
- Protected route → Browser localStorage: checks token
- Protected route → Map page: permits authenticated access
- Protected route → Login page: redirects when absent
- Auth context → Auth contracts: uses
- Map page → Workspace layout: renders within
- Workspace layout → Sidebar: includes
- Map page → Office map: composes
- Map page → Booking panel: composes
- Office map → Booking panel: selected desk
- Office map → Auth context: reads booking state
- Booking panel → Auth context: updates bookings
- Sidebar → Auth context: reads today's bookings
- Workspace layout → Auth context: logout clears session
- Office map → Map contracts: uses desk and zone contracts
- Map page → Map contracts: uses booking contracts