Fix product preorder and warranty submit flow

This commit is contained in:
2026-05-30 10:07:54 +07:00
parent 73a0767418
commit d15bf885e2
7 changed files with 143 additions and 23 deletions

View File

@ -22,6 +22,41 @@ npx tsc --noEmit
## Latest Codex Changes After `76fb4f3`
### Product create preorder and warranty submit rules
Files:
- `src/app/(dashboard)/products/new/details/page.tsx`
- `src/app/(dashboard)/products/new/specifications/page.tsx`
- `src/app/(dashboard)/products/new/review/page.tsx`
- `src/lib/product-draft.tsx`
- `src/lib/use-product-submit.ts`
- `src/lib/product-request-validation.ts`
Behavior:
- Pre-order day placeholder is now `0`, not `14`, so an empty/unfilled value is visually obvious.
- If pre-order is checked, the Details step blocks Next unless `preOrderDay` is a valid number greater than or equal to 1.
- Warranty now has an On/Off switch in the Specifications step.
- When warranty is On:
- warranty type is required
- warranty duration must be greater than or equal to 1
- the review page shows warranty information
- submit payload sends the filled `warrantyInformation` object
- When warranty is Off:
- warranty inputs are disabled and dimmed
- the review page hides warranty information
- submit payload still sends `warrantyInformation` as an object required by the backend, with:
```json
{
"type": null,
"duration": null,
"durationType": "MONTH"
}
```
- Frontend payload validation treats the above null-valued warranty object as warranty Off, so it does not block submit with warranty type/duration errors.
- Local test server was rebuilt and restarted against `https://api-dev.inatrading.co.id` in `.env.local`; `.env.local` is not committed.
### AddProductRequest validation
Files: