1.8 KiB
1.8 KiB
Task 10: Обработка ошибок и неаутентифицированного состояния в UI
Assigned to: Antigravity (Implementation Orchestrator)
Priority: LOW (UX & Error Handling)
Date: 2026-08-21
Base SHA: 3feb0d5834910bb804621edf11d3f98a07e23cbd
Scope
- Implement a unified pure helper function for parsing error messages from API responses:
- Supports structured
{ success: false, error: { message, code, details } }, legacy stringdata.error, HTTP status fallbacks, and fallback defaults. - Comprehensive unit test suite in
tests/ui-error-parser.test.ts.
- Supports structured
- Fix all UI call sites (
src/app/giveaways/new/page.tsx,src/app/giveaways/[id]/page.tsx,src/app/page.tsx):- Replace direct string casting/alert calls with error banners/state and the unified helper.
- Eliminate
[object Object]displays across 400, 401, 403, 404, 409, 429 errors.
- Fix wizard silent death without authentication:
- In
handleFetchPost(new/page.tsx), checkcreateRes.ok, extract structured error, set error state, and do NOT proceed to step 2 ifcreatedGiveawayIdis null.
- In
- Dashboard and Auth states:
- Distinguish empty list (
giveaways.length === 0when authenticated) from 401 unauthenticated state. - In
src/components/auth/AuthButton.tsx, append?redirectTarget=${encodeURIComponent(pathname)}usingusePathname()so users are seamlessly redirected back after VK ID login.
- Distinguish empty list (
- Replace
alert()calls insrc/app/giveaways/new/page.tsxwith inline error banners. - Verify via full test gate (
npm test,npx prisma generate,npx tsc --noEmit,npm run lint,npm run build,npm audit --omit=dev) and document manual UI verification steps in reportagents/antigravity/done/TASK-2026-08-21-10-ui-error-handling.md.