1---2name: frontend-pages3description: Create or modify React pages using MUI components, React Router, and the HATEOAS API client.4---56# Frontend Pages78## Technology Stack9- **React 19** with **TypeScript**10- **MUI (Material UI) v7** for all UI components11- **React Router v7** for client-side routing12- **Vite** as build tool1314## Page Types1516### List Pages (e.g., `PatientListPage.tsx`)17- Fetch data using `apiClient` with HATEOAS link discovery.18- Support **server-side pagination** with `TablePagination` controls.19- Support **server-side search** with a text input and search button.20- Support **sortable columns** by clicking table headers (ascending/descending toggle).21- Query parameters: `page`, `pageSize`, `search`, `sortBy`, `sortDirection`.22- Display data in MUI `Table` with `TableSortLabel` for column headers.2324### Detail Pages (e.g., `PatientDetailPage.tsx`)25- Fetch single item by ID from route params.26- Display all fields using MUI `Paper`, `Typography`, `Grid`.27- Provide navigation links (edit, delete, back to list) using HATEOAS links.2829### Form Pages (e.g., `PatientFormPage.tsx`)30- Support both Create and Edit modes (determined by presence of route param `:id`).31- Use MUI `TextField`, `Select`, etc. for form inputs.32- Submit via `apiClient.post()` or `apiClient.put()`.33- Navigate back to detail/list on success.3435### Statistics Page (`StatisticsPage.tsx`)36- Uses **recharts** library for charts.37- Chart types: `PieChart`, `BarChart`, `LineChart`.38- Fetches data from `/api/statistics/*` endpoints.39- Each chart in its own `Paper` card with title.4041### Admin Page (`AdminPage.tsx`)42- Buttons for Seed and Reset operations.43- Displays current database statistics.4445## Routing46- All routes defined in `App.tsx` under a `<Layout />` wrapper.47- Layout includes navigation bar with links to all sections.48- Pattern: `/entities`, `/entities/new`, `/entities/:id`, `/entities/:id/edit`.4950## API Client (`frontend/src/api/apiClient.ts`)51- Singleton `ApiClient` class.52- `discoverApi()` — fetches root links from `GET /api` (cached).53- `getLink(rel)` — looks up a link by relation name.54- `findLink(links, rel)` — finds a link in a given array.55- `get<T>`, `post<T>`, `put<T>`, `delete` — typed HTTP methods.56- **All navigation uses HATEOAS links** — never hard-code API URLs in pages.5758## TypeScript Types59- Located in `frontend/src/types/`.60- Must mirror backend DTOs: `patient.ts`, `doctor.ts`, `exam.ts`, `statistics.ts`, `hateoas.ts`.6162## Adding a New Page631. Create the page component in `frontend/src/pages/`.642. Add the route in `App.tsx`.653. Add navigation button in `Layout.tsx` if it's a top-level section.664. Create/update types in `frontend/src/types/` to match backend DTOs.675. Use `apiClient` for all API calls, discovering links from HATEOAS responses.