Skip to content

refactor(admin): consolidate fetch state machines into useApiResource#41

Merged
ut42tech merged 3 commits into
feat/admin-ui-responsivefrom
refactor/admin-data-layer
Jun 2, 2026
Merged

refactor(admin): consolidate fetch state machines into useApiResource#41
ut42tech merged 3 commits into
feat/admin-ui-responsivefrom
refactor/admin-data-layer

Conversation

@ut42tech
Copy link
Copy Markdown
Owner

@ut42tech ut42tech commented Jun 2, 2026

Sub-project 1(データ層モダナイゼーション)。admin で 6 箇所に重複していた取得+状態機械を共通フックに集約する純粋リファクタ。UI・挙動は不変

リサーチ結論: PPR/cacheComponents と loading.tsx は「全クライアントフェッチ+ホスト限定クロスオリジン Cookie」の現構成には効かない(spec 参照)。高価値・低リスクなのは重複の共通化。

変更

  • @tecnova/uiuseApiResource<T>(path, {enabled})(idle/loading/ok/error+reload()、path 変化で再取得、participant-detail-sheet の cancel ガードを踏襲、読み取り専用)+ DataError / EmptyState
  • admin の 6 箇所(dashboard / participants / stats / mentors / pre-registrations / 詳細シート)を移行。インラインのエラー Alert → DataError、空ブロック → EmptyState
  • クエリ駆動ページは path にクエリを組み立て再取得、更新ボタン/ミューテーション後は reload()。ミューテーション callback は () => void 化(POST/PATCH/DELETE は従来どおり apiJson/apiFetch)。

検証

  • type-check(admin / @tecnova/ui)・Biome green。
  • Playwright: 初期ロード・reload()(更新)・検索での再取得(path 変化→一覧更新)・詳細シート・DataError(500+サーバ文言)・EmptyState を実機確認。ハイドレーション警告なし。

stacked PR

feat/admin-ui-responsive#40)の上に積んでいる。#40 をマージ後、本PRは develop へ自動リターゲットされる(マージ順: #40 → 本PR → SP2)。

🤖 Generated with Claude Code

ut42tech and others added 3 commits June 2, 2026 18:52
…ub-project plan)

Records the Next.js 16.2.4 research conclusions (PPR/cacheComponents and
server-side streaming do not fit the current all-client-fetch +
host-only cross-origin cookie architecture) and decomposes the work into
three sequenced sub-projects: (1) client data-layer consolidation,
(2) resilience + instant shell, (3) server-side data (BFF vs
cross-subdomain cookie — its own design).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Shared read-only data primitives to consolidate admin's duplicated fetch
state machines:
- useApiResource<T>(path, {enabled}) — idle|loading|ok|error + reload(),
  refetches when `path` changes (query string drives search/filter/page),
  with the cancellation guard lifted from participant-detail-sheet.
  Mutations are out of scope (read-only).
- DataError — the destructive Alert used for fetch errors.
- EmptyState — the centered "no results" placeholder (non-table).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace the duplicated {loading|ok|error} useEffect+apiJson state
machines across the dashboard, participants, stats, mentors,
pre-registrations and the participant detail sheet with the shared
useApiResource hook, and the inline error Alerts / empty blocks with
DataError / EmptyState.

- Query-param-driven pages build the path (date / search+filter+page /
  date-range) and rely on refetch-on-path-change; the refresh button and
  post-mutation callbacks call reload().
- Mutation callbacks become () => void (reload is fire-and-forget); the
  POST/PATCH/DELETE calls still use apiJson/apiFetch directly.

No UI/behavior change. Verified: load, reload, search refetch, detail
sheet, and DataError/EmptyState states all render as before.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tecnova-platform-admin Ready Ready Preview, Comment Jun 2, 2026 11:16am
tecnova-platform-checkin Ready Ready Preview, Comment Jun 2, 2026 11:16am
tecnova-platform-signage Ready Ready Preview, Comment Jun 2, 2026 11:16am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant