Files
InaTrading-Portal/HANDOFF.md

5.7 KiB

Handoff

Project: ina-trading-web Current branch: main Latest verified commit: b266047

Summary

This codebase has recent updates around product creation, edit, review, detail, admin review, stock/price editing, and backend request logging.

The latest build was verified successfully with:

npm run build

Recent Commits

  • e9a0cd0 Update product review, measurement, and backend logging flows
  • b266047 Fix TypeScript build errors in product detail and admin review

Main Changes

1. Backend proxy logging

Files:

  • src/lib/backend-fetch-logger.ts
  • src/instrumentation.ts
  • .env.local uses DEBUG_BACKEND_PROXY=true locally

Behavior:

  • Logs server-side fetch requests to backend
  • Logs request method, URL, headers, body preview
  • Logs response status, duration, headers, body preview
  • Redacts authorization header

Use this when tracing frontend-to-backend failures in local dev.

2. Product measurement mode on add product

Files:

  • src/app/(dashboard)/products/new/pricing/page.tsx
  • src/lib/use-product-submit.ts
  • src/app/(dashboard)/products/new/review/page.tsx

Behavior:

  • Each model has a Product Measurement switch
  • When enabled:
    • nested measurements are shown
    • model-level price, currency, weight, dimensions, promotion, packaging, and warehouse stock are disabled
    • at least 1 measurement row is required
  • Submit payload uses model.hasMeasurements
  • When measurement mode is active, model-level numeric fields are zeroed and model warehouses are omitted

3. Product measurement mode on edit product

File:

  • src/app/(dashboard)/products/[productId]/edit/page.tsx

Behavior:

  • Matches add-product measurement behavior
  • Uses explicit hasMeasurements state instead of guessing from array length
  • Disables model-level fields when measurement mode is on

4. Seller product review page improvements

File:

  • src/app/(dashboard)/products/new/review/page.tsx

Behavior:

  • Review now renders actual product thumbnails using backend file URLs
  • Previously it only showed image indicators, which was confusing
  • Review also reflects measurement-based pricing correctly

5. Product list page improvements

File:

  • src/app/(dashboard)/products/page.tsx

Behavior:

  • Edit stock/price modal supports:
    • choosing model
    • choosing measurement if present
    • choosing warehouse
  • Warehouse labels use warehouse names from master warehouse API, not raw UUIDs
  • Product row status badges now show explicit state like active, draft, review, unpublished, deleted, rejected

6. Product detail page improvements

File:

  • src/app/(dashboard)/products/[productId]/detail/page.tsx

Behavior:

  • Main category now resolves even when backend omits subCategory.category.name
  • Warehouse display now uses warehouse master names instead of UUID slices
  • TypeScript nullability issue for category resolution was fixed here

7. Admin review page improvements

File:

  • src/app/admin/review/[productId]/page.tsx

Behavior:

  • Review supports model + measurement structures
  • New product review and compare review now handle measurement-driven price/weight/dimension/promo/stock
  • Compare view highlights updated sections using backend compare response and isUpdate
  • Product images are rendered using main image + gallery images
  • TypeScript issue around row.field nullability was fixed here

8. Sidebar submenu reliability

Files:

  • src/components/product-submenu-nav.tsx
  • src/components/admin-product-submenu-nav.tsx

Behavior:

  • Click behavior was hardened because submenu items were sometimes not navigating
  • Navigation is explicit via router.push(...)

Translation Files Touched

  • src/lib/translations/id.ts
  • src/lib/translations/en.ts

These include labels added for statuses and stock/price modal UI.

Important Findings

Admin review image issue

For at least one reviewed product, backend review payload returned:

  • image: null
  • imageId: null
  • productImages: []

In that case frontend cannot render images. If an image is missing in review, verify backend review payload before debugging frontend.

Edit product empty main image behavior

In edit product submit flow, empty imageId is currently sent as undefined, which means the field is omitted from JSON payload, not sent as null and not sent as empty string.

If backend requires explicit image removal via null, this behavior will need to be changed.

Local Dev Notes

Run local dev:

npm run dev

Build verification:

npm run build

Dev Server Update Guide

Based on current deployment notes, dev server update flow is:

sudo -iu inadev
cd ~/apps/ina-trading-web
git pull origin main
npm ci
npm run build
pm2 restart ina-trading-dev
pm2 save
sudo -iu inadev pm2 status

Optional logs:

sudo -iu inadev pm2 logs ina-trading-dev --lines 100

Suggested Next Checks

  • Verify whether backend expects null when main image is intentionally removed during edit
  • Verify seller and admin review payload consistency for image fields
  • Verify warehouse master API always contains all warehouse IDs referenced in product payloads
  • If submenu click issue still appears, inspect layout overlays with browser tooling
  • Consider adding field-level compare highlighting, not only section-level highlighting, in admin review compare page

Files Most Likely To Be Relevant Next

  • src/app/(dashboard)/products/new/pricing/page.tsx
  • src/app/(dashboard)/products/[productId]/edit/page.tsx
  • src/app/(dashboard)/products/new/review/page.tsx
  • src/app/(dashboard)/products/[productId]/detail/page.tsx
  • src/app/(dashboard)/products/page.tsx
  • src/app/admin/review/[productId]/page.tsx
  • src/lib/use-product-submit.ts
  • src/lib/backend-fetch-logger.ts