Files
open-safetylog-ehs/src/App.tsx
T
jayjennings a382fa904a
CI / Lint, typecheck, test, build (push) Canceled after 0s
CI / End-to-end tests (push) Canceled after 0s
feat: initialize project structure with core components and pages
- Added shared styles for UI components in `src/components/styles.ts`.
- Created configuration constants in `src/lib/config.ts`.
- Implemented date formatting and greeting functions in `src/lib/dates.ts` and corresponding tests in `src/lib/dates.test.ts`.
- Developed incident management functions in `src/lib/incidents.ts` with tests in `src/lib/incidents.test.ts`.
- Established navigation structure in `src/lib/navigation.ts`.
- Seeded demo data for incidents and users in `src/lib/seed.ts`.
- Defined tone classes for UI elements in `src/lib/tones.ts`.
- Created type definitions for incidents and related entities in `src/lib/types.ts`.
- Set up main application entry point in `src/main.tsx`.
- Developed various pages including About, Analytics, Incidents, Locations, Overview, and Report Incident.
- Configured testing setup in `src/test/setup.ts` and TypeScript configurations.
- Integrated Vite for development and testing with appropriate plugins.
2026-10-06 10:07:57 -07:00

34 lines
1.5 KiB
TypeScript

import { useState } from 'react'
import { Navigate, Route, Routes } from 'react-router-dom'
import { AppLayout } from './components/AppLayout'
import { createIncident, isOpen } from './lib/incidents'
import { currentUser, seedIncidents } from './lib/seed'
import type { NewIncident } from './lib/types'
import { About } from './pages/About'
import { Analytics } from './pages/Analytics'
import { Incidents } from './pages/Incidents'
import { Locations } from './pages/Locations'
import { Overview } from './pages/Overview'
import { ReportIncident } from './pages/ReportIncident'
export default function App() {
// In-memory store until the backend lands (Phase 1)
const [incidents, setIncidents] = useState(seedIncidents)
const addIncident = (report: NewIncident) =>
setIncidents((current) => [createIncident(report, current, currentUser.name, new Date()), ...current])
return (
<Routes>
<Route element={<AppLayout openIncidentCount={incidents.filter(isOpen).length} />}>
<Route index element={<Overview incidents={incidents} />} />
<Route path="incidents" element={<Incidents incidents={incidents} />} />
<Route path="locations" element={<Locations />} />
<Route path="analytics" element={<Analytics />} />
<Route path="report" element={<ReportIncident onSubmit={addIncident} />} />
<Route path="about" element={<About />} />
<Route path="*" element={<Navigate to="/" replace />} />
</Route>
</Routes>
)
}