Commit Graph

134 Commits

Author SHA1 Message Date
jesxion
a225d0f0e3 fix(projects): resolve Task 2 signoff issues in ProjectListPage
- Clear searchQuery after project creation so newly created projects
  are visible even when a search filter is active
- Disable refresh button while loading to prevent overlapping fetches
- Fix loadProjects referenced-before-declaration lint error by moving
  it to useCallback declared before useEffect; suppress
  react-hooks/set-state-in-effect for the intentional async data-fetch
  pattern (same pattern used in ProjectDetailPage)
- Add TDD tests first: 'clears search filter after creation' and
  'disables refresh button while loading'; verified failing before impl,
  passing after; all 13 tests pass with no lint errors on this file

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 18:04:32 +08:00
jesxion
38e5d63273 feat: redesign admin project overview
- Add KPI overview section (项目总览) with project count, account total, and latest project cards
- Add toolbar with search input and refresh button above the project table
- Extract 'new project' button into the overview heading for better hierarchy
- Add admin-overview, admin-kpi-grid, admin-kpi-card, admin-table-section, admin-toolbar CSS classes
- Extend Project type with optional user_count field
- Convert it.fails placeholder to passing overview test
- Fix modal test to use role-based selector (avoids duplicate text in KPI card + table)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 17:17:06 +08:00
jesxion
2640b243ea feat: add structured admin shell
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 17:14:40 +08:00
jesxion
12653235be feat: add structured admin shell
- Replace placeholder AppLayout with dark sidebar nav, semantic header/content zones
- Add CSS design tokens and shell utility classes to global.css
- Add shell-aware test expectation for 项目总览 (fails until Task 2 implements it)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-26 16:38:29 +08:00
jesxion
db0eabe3a6 feat: add project detail and account assignment ui
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 18:41:51 +08:00
jesxion
327b486e6d fix: polish admin project ui
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 18:28:24 +08:00
jesxion
7a23e81c9c feat: add platform login and project list ui
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 18:15:32 +08:00
jesxion
0d7f85c3e1 fix: trim admin scaffold
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 18:03:58 +08:00
jesxion
d1eddba8a5 feat: scaffold platform admin web app
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 17:57:04 +08:00
jesxion
bc489f1e7a feat: add platform project user management api
- Add user repository functions for project user CRUD
- Create platform-user-service for project user management
- Add GET /v1/platform/projects/:id/users endpoint
- Add POST /v1/platform/projects/:id/users endpoint
- Support project_admin and manager roles
- Validate username uniqueness and project existence
- Normalize real_name and phone inputs
- Add comprehensive test coverage (13 tests)
- Fix test isolation issue in platform-projects cleanup

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 17:40:12 +08:00
jesxion
c0b4f7f66e fix: tighten project api validation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 17:34:30 +08:00
jesxion
80d13a80c4 fix: tighten platform project api
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 17:27:09 +08:00
jesxion
c111083ce7 feat: add platform project management api
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 17:16:58 +08:00
jesxion
84dd09458f fix: harden platform login flows
- Add timing-attack mitigation by always verifying passwords against real or dummy hash
- Add comprehensive negative-path tests for platform login (wrong password, non-existent user, project user rejection, invalid body)
- Add focused middleware tests for requirePlatformAuth covering auth header validation and user type enforcement
- All 60 tests passing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 17:06:01 +08:00
jesxion
003267b281 feat: add platform admin login
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 16:53:57 +08:00
jesxion
5e03ba3593 fix: guard nullable project_id in getProjectId
After Task 1 changed AuthUser.project_id from number to number | null, getProjectId now explicitly checks for null values and throws an error for platform users attempting to access project resources.

This fix:
- Adds null check to reject platform users (project_id === null)
- Maintains type safety by ensuring return type is always number
- Includes comprehensive unit tests for all scenarios
- Preserves existing project-side behavior for valid project users

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 16:52:51 +08:00
jesxion
bcd0abaf8a fix: harden project login user type check
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 16:47:09 +08:00
jesxion
5ec5d03f57 test: assert platform login error message
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 16:37:58 +08:00
jesxion
7a7cf25e50 feat: split platform and project auth users
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 16:31:56 +08:00
jesxion
3df38e44c6 docs: add platform admin design spec
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 16:23:44 +08:00
jesxion
7718330d7d chore: remove legacy h5 static prototype
The old static HTML/CSS/JS prototype in h5/ is superseded by the
React + Ant Design Mobile app in h5-app/. Removing to avoid confusion.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 15:56:50 +08:00
jesxion
018eab2918 feat: merge Ant Design Mobile H5 app, replace legacy h5 prototype
The feature/h5-design-polish branch brings in a complete React + Ant Design
Mobile rebuild of the H5 client (in h5-app/), replacing the old static
prototype in h5/.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 15:56:38 +08:00
jesxion
b89b58108d feat(h5-app): add mock login fallback and fix apiLogin flow
- Add MOCK_ACCOUNTS with admin/123456 and worker/123456 as fallback
  when real backend is unavailable
- apiLogin tries real backend first; falls through to mock only on failure
- Supports real JWT token flow when backend (port 3201) is available

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 15:53:44 +08:00
jesxion
268d9b0394 fix: reports page mock data, date display, and severity badge mapping
- apiGetReports: use mock data instead of real API (no backend available)
- reports.html: add mock.js script include
- Fix date display: was concatenating dateStr+timeStr causing duplication
- Fix severity badge: map Chinese mock values to backend enum keys

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 15:34:36 +08:00
jesxion
2ec5c98759 chore: add github instructions, superpowers config, and hazards plan docs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 15:20:45 +08:00
jesxion
6c7143329f refactor: align log module structure
- Add LogsPage.tsx re-export alias pointing to LogListPage
- Add src/tests/log-ui-model.test.ts with 26 targeted tests for log
  UI-model and helper semantics (getLogStatusMeta, findTodayLog
  integration, format helpers, equipment labels, truncate,
  getTodayDateString, WEATHER_OPTIONS)
- Refactor LogFormPage to use ADM Form/Form.Item/Form.Header for
  section layout, ADM Input for text fields, ADM Stepper for worker
  count; remove hand-rolled FieldLabel and RequiredMark helpers

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 19:08:31 +08:00
jesxion
373a781b5b fix: align log flow semantics
- Make date field editable (initialized to today)
- Rename remark → note to match legacy h5/log.html semantics
- Add photo upload field to LogFormPage
- Move weather to optional (was incorrectly required)
- LogDetailPage: render note, photo gallery, author+created_at footer
- Weather block is now conditional (not forced)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 19:01:47 +08:00
jesxion
5257c1534c feat: port logs flow to ant mobile
- Add src/mocks/logs.ts: canonical in-memory log store (5 seed entries, addLog/getLog/getLogs)
- Add src/features/logs/types.ts: LogItem and Equipment types
- Add src/features/logs/utils.ts: formatLogDate, formatLogTime, getEquipmentLabels, findTodayLog, truncate
- Add src/features/logs/LogListPage.tsx: today card + history list + FAB, mirrors logs.html semantics
- Add src/features/logs/LogDetailPage.tsx: hero, body sections, meta grid, equipment tags
- Add src/features/logs/LogFormPage.tsx: core + extra fields, Selector for weather/equipment, mock submit
- Update src/lib/mock-logs.ts: shim re-export from mocks/logs.ts (backward compat for HomePage)
- Update src/App.tsx: wire /logs, /logs/new, /logs/:id routes; drop placeholder LogsPage import
- Update src/pages/LogsPage.tsx: forward-export to features/logs/LogListPage
- Update package.json: add preview:local script (port 8084, host 0.0.0.0)
- Add src/tests/logs-utils.test.ts: 14 tests covering all util helpers

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 18:53:09 +08:00
jesxion
74f367ef90 fix: guard hazard list state
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 18:42:17 +08:00
jesxion
d67b935882 fix: guard hazard async state
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 18:39:52 +08:00
jesxion
e0ea692e65 fix: harden hazard upload reliability
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 18:35:28 +08:00
jesxion
cb6010715d fix: correct hazard upload flow
- Fix upload-token API: backend returns { uploadUrl, objectKey } directly
  (camelCase, no ApiResponse wrapper); update UploadTokenResult interface
  and remove incorrect res.data access
- Fix confirm API: backend returns { fileId, objectKey } directly (no url,
  no ApiResponse wrapper); update ConfirmResult interface accordingly
- uploadPhoto now returns { url: blobUrl, extra: { objectKey } } so the
  ImageUploader can show a local preview while HazardReportPage submits
  the confirmed objectKey (via extra) rather than the ephemeral blob URL
- Fix geolocation: getCurrentPosition returns void, not a watch ID;
  remove the incorrect cast and clearWatch cleanup call; drop unused gpsWatchId ref

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 18:30:39 +08:00
jesxion
4bd95c4ce7 test: cover hazard severity labels
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 18:13:56 +08:00
jesxion
b379ccd415 feat: port hazards flow to ant mobile
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 18:08:57 +08:00
jesxion
1b6601068e fix: validate login session payload
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 17:59:16 +08:00
jesxion
e79eee6e15 fix: align home activity semantics
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 17:48:23 +08:00
jesxion
d7da6d1331 test: align ui model test location
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 17:33:22 +08:00
jesxion
7e7790c4af refactor: align ant mobile shell structure
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 17:27:44 +08:00
jesxion
24f0d30e46 fix: align home subtitle copy
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 17:18:09 +08:00
jesxion
d1118f7eee fix: restore shell page semantics
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 17:11:12 +08:00
jesxion
8cb468c4cf feat: port auth shell to ant mobile
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 17:02:08 +08:00
jesxion
71c437968a fix: type vite env settings
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 16:44:57 +08:00
jesxion
a994c8d076 fix: harden ant mobile scaffold config
- vite.config.ts: use loadEnv() to read VITE_BASE (base path) and
  DEV_API_TARGET (proxy target) from .env; falls back to '/' and
  http://127.0.0.1:3201 so local dev is unchanged
- App.tsx: pass basename={import.meta.env.BASE_URL} to BrowserRouter
  so router paths align with the Vite base at runtime
- global.css: change #root overflow from hidden to auto so page
  content is scrollable
- .env: document VITE_BASE, VITE_API_BASE, DEV_API_TARGET defaults
- src/config.ts: expose apiBase helper for runtime API prefix
- tsconfig.json: add vite/client types so import.meta.env is typed

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 16:42:24 +08:00
jesxion
c5508a1927 feat: scaffold ant design mobile frontend
- Vite + React 18 + TypeScript + React Router v6 + Ant Design Mobile
- /v1 proxy to http://127.0.0.1:3201 in vite.config.ts
- Placeholder routes for / and /login
- Build verified passing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 16:38:00 +08:00
jesxion
0a8e42c673 Polish H5 task lists and detail views
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 16:25:06 +08:00
jesxion
8f45c7ded5 Refine H5 home and profile composition
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 16:21:01 +08:00
jesxion
4d7e314c6b Polish H5 visual foundation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 16:15:39 +08:00
jesxion
821ea72a90 Merge branch 'feature/h5-redesign'\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> 2026-04-24 15:52:00 +08:00
jesxion
40e3435cc7 Fix redesign smoke validation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 15:49:01 +08:00
jesxion
fe2e8aa32f feat: finish H5 redesign polish
- Consolidate page-local styles into shared CSS files
- Move login, home, reports, and detail page styles to style.css
- Add shared section headers and status pills to task-ui.css
- Remove duplicate <style> blocks from HTML files
- All in-scope pages now use consistent shared styling

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 15:19:28 +08:00