mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 13:02:50 +00:00
f294f67ced8b09e85efb1d061651cf02c35e6cfb
Seafarer and vessel registration were filtered out of the operations step by `requiresOperatorMode !== false`, so someone registering as a seafarer or vessel owner landed on an onboarding screen that did not describe them. Both now appear, grouped apart from the company modes: declaring "I am a seafarer" is a different kind of statement from "my company forwards freight". The designer's preview was gated on the Handlebars source alone, which a canvas layout does not have until the server compiles it on save -- so the button was dead for exactly the designs the canvas exists for. Editing looked broken rather than deliberately read-only: every seeded template is PUBLISHED, and a published design is immutable because certificates were issued from it. Says so, and offers the new-version action that is the way forward. Reviewing officers saw company, capital and staff tabs on seafarer certificate applications, because PRESENTATION is keyed by the generic licence keys and the fifty-odd rank-specific CoC/CoP keys fell through to the company default. Matched by prefix instead, so a certificate configured tomorrow gets the right presentation without a code change. Seaman book and BTC are wired to the newly seeded licence types and no longer marked "soon". Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
feat(vessel-registration): implement vessel registration feature with multi-step application process
EMA Platform — Nx Monorepo Frontend
A fully scaffolded Nx monorepo housing two Vite + React 19 SPAs (Backoffice and Portal) with shared libraries for API integration, UI components, and theming.
Tech Stack
| Tool | Version |
|---|---|
| React | 19 |
| Nx | 22 |
| Vite | 7 |
| TypeScript | 5.9 |
| Redux Toolkit | 2.11 |
| Mantine | 8.3 |
| React Router | 7 |
| TanStack Query | 5 |
| React Hook Form | 7 |
| Zod | 4 |
| Tailwind CSS | 3.4 |
| Vitest | 4 |
Monorepo Structure
emaui/
├── apps/
│ ├── backoffice/ # Admin/operator SPA — port 4201
│ └── portal/ # End-user SPA — port 4200
└── libs/
├── api/ # RTK Query baseApi, session resolution, generic query/mutation hooks
├── ui/ # Shared Mantine components (ConfirmModal, ApiErrorAlert, notify)
└── shared/ # Mantine theme (emaTheme), design tokens
libs/api
base-api/— RTK QuerycreateApiinstance withprepareHeadersthat injects the Bearer token from Redux state or storage.session/—resolveTokenFromStorage()reads theauth-tokencookie first, falling back tolocalStoragefor legacy pre-migration sessions.resolveSessionContext()merges Redux state token with storage fallback.query-and-mutation/— GenericuseApiQuery/useApiMutationwrappers for one-off API calls without defining a dedicated endpoint file.
libs/ui
ConfirmModal— Reusable Mantine modal for destructive-action confirmation.ApiErrorAlert— Extracts a human-readable message from RTK Query error shapes or Error objects.notify— Thin wrapper around@mantine/notificationswith.success,.error,.info,.warninghelpers.
libs/shared
ema-theme— Mantine v8createTheme()withemaPrimary(blue) andemaSecondary(warm) color tuples, Inter font, and custom shadow scale.
Auth Flow
- User submits the login form (LoginForm / LoginPage).
- The form calls the
loginRTK Query mutation (backoffice) or a plainfetch(portal). - On success,
loginSuccessaction is dispatched → Reduxauthslice storestokenanduser;authStorage.setToken()persists the token to a cookie (both apps callconfigureAuthStorage(prefix, true)). baseApi'sprepareHeadersreads the token viaresolveSessionContext(getState())and attachesAuthorization: Bearer <token>to every RTK Query request.ProtectedRoutechecksauthStorage/the token cookie on every navigation — if absent, redirects to/login.logoutaction clears Redux state and callsauthStorage.clear()to remove all auth cookies.
Local Setup
# 1. Install dependencies
npm install
# 2. Copy environment config
cp .env.example .env
# Edit VITE_BASE_API_URL to point at your running backend
# 3. Start the backoffice (port 4201)
npm run backoffice
# 4. Start the portal (port 4200)
npm run portal
# 5. Or start both in parallel
npm run dev:all
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
VITE_BASE_API_URL |
Yes | http://localhost:3000 |
Base URL for all API requests |
VITE_ENABLE_DEVELOPER_TOOLS |
No | true |
Toggle Redux DevTools |
VITE_PAYMENT_API_URL |
Yes (portal) | — | Base URL for the payment service (portal payment feature). Can be a same-origin path if a backend proxy is later placed in front of it |
VITE_PAYMENT_SERVICE_TOKEN |
Yes (portal) | — | Sent as x-service-token on every payment request. Note: bundled VITE_* values are public in the built app, not secret |
PORTAL_PORT |
No | 4200 |
Docker host port for portal |
BACKOFFICE_PORT |
No | 4201 |
Docker host port for backoffice |
Docker
# Build and run both apps via Docker Compose
cp .env.example .env
docker compose up --build
The Dockerfile uses multi-stage builds with named targets (portal / backoffice). Each stage produces an nginx image serving the built SPA.
Adding a New Feature
-
Create the feature folder under the relevant app:
apps/backoffice/src/app/features/<feature-name>/ ├── types/ # TypeScript interfaces ├── api/ # RTK Query injectEndpoints ├── store/ # Redux slice (if local state needed) ├── hooks/ # Custom hooks wrapping store/api ├── components/ # Presentational React components └── pages/ # Route-level components -
Wire up the API endpoint in
<feature-name>/api/<feature>-api.tsusingbaseApi.injectEndpoints(...). -
Add a route in
apps/<app>/src/app/router/index.tsx(backoffice) orapps/<app>/src/app/router.tsx(portal). -
Add a sidebar entry in
AppSidebar.tsx(backoffice only) for the new route. -
If the feature needs shared UI, add components to
libs/ui/and export fromlibs/ui/src/index.ts.
Description
Languages
TypeScript
97.9%
CSS
1.3%
HTML
0.4%
Shell
0.3%