Add product request validation and upload limits

This commit is contained in:
2026-05-29 17:35:15 +07:00
parent 76fb4f342d
commit f090ba7bc2
12 changed files with 367 additions and 26 deletions

View File

@ -2,11 +2,11 @@
Project: `ina-trading-web`
Current branch: `main`
Latest verified commit: `aa406f5`
Latest verified commit: `9b4e5d7`
## 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, and sanitized backend error display.
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.
The latest build was verified successfully with:
@ -14,13 +14,62 @@ The latest build was verified successfully with:
npm run build
```
Latest TypeScript verification after `aa406f5`:
Latest TypeScript verification after the validation/upload changes:
```bash
npx tsc --noEmit
```
## Latest Codex Changes After `aa406f5`
## Latest Codex Changes After `76fb4f3`
### AddProductRequest validation
Files:
- `src/lib/product-request-validation.ts`
- `src/lib/use-product-submit.ts`
- `src/app/(dashboard)/products/[productId]/edit/page.tsx`
- `src/app/(dashboard)/products/new/details/page.tsx`
- `src/app/(dashboard)/products/new/pricing/page.tsx`
- `src/app/(dashboard)/products/new/specifications/page.tsx`
- `src/lib/product-draft.tsx`
Behavior:
- Added a shared validator for create/edit product payloads before requests are sent to backend.
- Validates the backend `AddProductRequest` limits for:
- basic product fields
- image/file IDs
- keywords max 3 and features max 5
- model fields, currencies, SKU, package fields
- numeric weight/dimension/package fields max 9 digits plus 1 decimal
- warehouse IDs max 50 and stock minimal 1
- measurement fields, measurement warehouses, and measurement stock
- product/category information param name/value limits
- compliance information limits
- warranty type max 50 and duration minimal 1 when warranty is filled
- Existing wizard drafts normalize keywords to max 3 and features to max 5.
- Create-product UI now shows visible validation-limit panels on:
- Details
- Pricing
- Specifications
- Relevant inputs also received direct hints/limits such as max product name length, keyword/feature limits, pre-order minimum, warranty minimum, and upload limit text.
### Upload file size limit
Files:
- `src/lib/upload-limits.ts`
- `src/app/api/upload/route.ts`
- `src/components/upload-field.tsx`
- `src/app/(dashboard)/products/new/specifications/page.tsx`
- `src/app/(dashboard)/products/[productId]/edit/page.tsx`
- `src/app/(onboarding)/onboarding/business/page.tsx`
Behavior:
- Uploads are limited to 10 MB per file.
- Client-side checks reject oversized files before upload in shared upload fields, product create/edit document uploads, and onboarding legal document upload.
- Server-side `/api/upload` rejects oversized files with HTTP `413` and a safe `responseDesc`.
- User-facing helper text now mentions the 10 MB limit for document uploads.
## Previous Codex Changes After `aa406f5`
### Backend URL