Add edit product media action payloads

This commit is contained in:
2026-06-03 13:08:14 +07:00
parent 84c81d4a2b
commit 6ef6dcc5e8
3 changed files with 167 additions and 16 deletions

View File

@ -2,11 +2,11 @@
Project: `ina-trading-web`
Current branch: `main`
Latest verified commit: `f090ba7`
Latest verified commit: current `HEAD` after the product edit media-action payload update
## Summary
This codebase has recent updates around auth/onboarding, help/privacy pages, dashboard search, product creation/edit/review/detail, admin review/detail, stock/price editing, seller in-review listing, backend request logging, expired-session redirects, product keyword limits, sanitized backend error display, AddProductRequest validation, and 10 MB upload limits.
This codebase has recent updates around auth/onboarding, help/privacy pages, dashboard search, product creation/edit/review/detail, admin review/detail, stock/price editing, seller in-review listing, backend request logging, expired-session redirects, product keyword limits, sanitized backend error display, AddProductRequest validation, 10 MB upload limits, and edit-product media action payloads.
Latest local verification before the newest push:
@ -26,6 +26,46 @@ Latest TypeScript verification after the validation/upload changes:
npx tsc --noEmit
```
## Latest Codex Changes After `84c81d4`
### Product edit media action payloads
Files:
- `src/app/(dashboard)/products/[productId]/edit/page.tsx`
- `src/lib/product-request-validation.ts`
Behavior:
- Edit-product now captures the original product media snapshot when the product is loaded.
- Existing product save (`PUT /api/products/:productId`) now sends media changes using backend action markers:
- `ADD`
- `UPDATE`
- `DELETE`
- `productFiles` now sends:
- deleted original files as `{ fileId, action: "DELETE" }`
- newly uploaded files as `{ fileId, action: "ADD" }`
- `productImages` now sends changed image rows with `{ imageId, sequence, action }`.
- replacing an image in an existing slot sends `UPDATE`
- removing an original image sends `DELETE`
- adding a new image sends `ADD`
- `complianceInformation` now includes an `action` when the compliance/MSDS file changes:
- no old file + new file: `ADD`
- old file + no current file: `DELETE`
- old file replaced by new file: `UPDATE`
- Draft publish/create flow still keeps the previous create payload shape so `POST /api/products/create` is not changed.
- Product payload validation now supports both old `productFiles: string[]` and new `productFiles: { fileId, action }[]` shapes.
Verification:
```bash
npx tsc --noEmit
npx eslint 'src/app/(dashboard)/products/[productId]/edit/page.tsx' src/lib/product-request-validation.ts
```
Notes:
- Targeted lint passed with no errors.
- The edit page still has existing `<img>` optimization warnings from Next.js.
- Full `npm run lint` is still blocked by pre-existing lint errors in unrelated files noted before this handoff update.
## Latest Codex Changes After `4e28ccd`
### Admin review image dedupe