|
| 1 | +# StormCom UI Changelog |
| 2 | + |
| 3 | +All notable changes to this repository are documented here. This log includes prior stabilization fixes and the current dashboard/API debugging task. |
| 4 | + |
| 5 | +## 2025-11-20 |
| 6 | + |
| 7 | +### Fixed – Attributes module |
| 8 | +- Edit page params (Next.js 16 dynamic params): Updated `src/app/dashboard/attributes/[id]/page.tsx` |
| 9 | + - Change: Treat `params` as a Promise per Next.js 16. `params: Promise<{ id: string }>` and `const { id } = await params;` |
| 10 | + - Reason: Avoided runtime error "Route used `params.id`. `params` is a Promise" and eliminated undefined `id` in client. |
| 11 | +- Switched to client-side data fetch on Edit page |
| 12 | + - Added `src/components/attribute-edit-client.tsx` to fetch `/api/attributes/:id` client-side and render `AttributeForm` when ready. |
| 13 | + - Reason: Avoid Prisma usage during SSR and cookie forwarding complexity; ensures robust loading on Node runtime without Edge constraints. |
| 14 | +- API param handling fix for dynamic routes |
| 15 | + - Updated `src/app/api/attributes/[id]/route.ts` to use proper handler signature `(req, { params })` and added fallback extraction from `request.nextUrl.pathname`. |
| 16 | + - Reason: `params.id` was resolving to `undefined` in route context, causing Prisma to be called with `id: undefined` and 500s. Fallback ensures resilience. |
| 17 | +- Improved error responses for diagnostics |
| 18 | + - Enhanced GET `/api/attributes/[id]` 500 response to include `details` with the error message for faster debugging. |
| 19 | +- Attributes list/new verified end-to-end |
| 20 | + - Created attribute "Color" with values `[Red, Green, Yellow]` via UI; verified presence on list and successfully loaded on Edit page. |
| 21 | + |
| 22 | +### Prior stabilization work (from previous session) |
| 23 | +- Attribute service typing and JSON handling |
| 24 | + - File: `src/lib/services/attribute.service.ts` |
| 25 | + - Change: Explicitly typed Prisma results; ensured `values` is parsed to `string[]`; included `_count.productValues` in list/get/update responses. |
| 26 | + - Reason: Removed implicit anys and ensured API/UI get consistent typed data. |
| 27 | +- Attribute routes safety and validation |
| 28 | + - Files: `src/app/api/attributes/route.ts`, `src/app/api/attributes/[id]/route.ts` |
| 29 | + - Change: Safer `catch` blocks with `unknown` narrowing; preserved Zod `.issues` on 400 responses; conflict/not-found errors mapped to 409/404. |
| 30 | +- Product service update shape and normalization |
| 31 | + - File: `src/lib/services/product.service.ts` |
| 32 | + - Change: Stringified `images` for Prisma update input; improved `normalizeProductFields` signature (`unknown` → typed casts). |
| 33 | + - Reason: Fixed Prisma input type mismatch and avoided spreading arrays into Prisma update. |
| 34 | +- Category service typing cleanup |
| 35 | + - File: `src/lib/services/category.service.ts` |
| 36 | + - Change: Cast certain Prisma find results to `CategoryWithRelations | null` to avoid implicit anys. |
| 37 | +- Brand/Category form props alignment |
| 38 | + - Files: `src/components/brand-form-client.tsx`, `src/components/category-form-client.tsx` and calling pages |
| 39 | + - Change: Aligned prop names (`_storeId`) and used `void _storeId` to avoid unused var linting. |
| 40 | + |
| 41 | +### Known issues and follow-ups |
| 42 | +- Brands and Categories pages are UI stubs (from dashboard template) |
| 43 | + - Current: List pages show "Loading …" and New pages render forms, but no API wiring exists (`/api/brands`, `/api/categories` missing). |
| 44 | + - Action: Implement Brand/Category APIs and wire form submissions; add list/fetch handlers and tables. |
| 45 | +- Products and Orders modules need full verification |
| 46 | + - Current: Not fully exercised in this pass. |
| 47 | + - Action: Walk through creation/edit flows after API wiring; ensure Prisma models align with inputs. |
| 48 | +- Source map warnings during dev (non-blocking) |
| 49 | + - Logged: "Invalid source map" warnings from dev chunks; informational only. |
| 50 | + |
| 51 | +--- |
| 52 | + |
| 53 | +## 2025-11-19 |
| 54 | + |
| 55 | +- Attributes list/create endpoints verified functional. |
| 56 | +- Implemented `AttributeForm` and pages: list and new; validated create flow via browser automation. |
| 57 | +- General lint and types cleanup across services and route handlers. |
0 commit comments