Management: add new inventory item modal on stok page #28

Open
opened 2026-07-25 14:27:58 +00:00 by yuris · 0 comments
Owner

Problem

There is no UI to create inventory items. The only write entry point is the stock adjustment modal. Staff must use the API or SQL to add new products, which is not practical for day-to-day catalog management.

Target

  • apps/management/app/(dashboard)/stok/page.tsx
  • New file: apps/management/app/(dashboard)/stok/add-inventory-modal.tsx

Change

  • Add an AddInventoryModal client component (add-inventory-modal.tsx) that opens a FormDialog with fields:
    • Nama barang (required) — text input.
    • Tipe — select: Part / Consumable / Accessory (default Part).
    • Harga beli — number input (IDR, integer).
    • Harga jual — number input (IDR, integer).
    • Stok awal — number input (integer, default 0).
    • Slug — optional text input.
    • Deskripsi — optional textarea.
    • Gambar — optional list of URL inputs with add/remove.
    • Tampilkan di toko — checkbox; disabled when slug is empty.
  • On submit, call createInventory server action; on success close dialog, call router.refresh(), toast success; on error toast the error message.
  • Mount the trigger button in page.tsx alongside the existing AdjustmentModal in the page action prop — use an Add01Icon trigger button consistent with the pattern in other pages (e.g. pelanggan, order).

Patterns to follow

  • AdjustmentModal for component shape.
  • FormDialog, FormField, FormInput, FormSelect from @/components/ui/form-field.
  • createInventory from @/lib/inventory/actions.

Acceptance

  • Button opens dialog; all fields render; submit calls createInventory.
  • Duplicate name from the server action surfaces as a toast error.
  • is_published: true without slug is disabled in the UI.
  • tsc --noEmit and biome check pass.
  • No changes to files outside stok/.
## Problem There is no UI to create inventory items. The only write entry point is the stock adjustment modal. Staff must use the API or SQL to add new products, which is not practical for day-to-day catalog management. ## Target - `apps/management/app/(dashboard)/stok/page.tsx` - New file: `apps/management/app/(dashboard)/stok/add-inventory-modal.tsx` ## Change - Add an `AddInventoryModal` client component (`add-inventory-modal.tsx`) that opens a `FormDialog` with fields: - **Nama barang** (required) — text input. - **Tipe** — select: Part / Consumable / Accessory (default Part). - **Harga beli** — number input (IDR, integer). - **Harga jual** — number input (IDR, integer). - **Stok awal** — number input (integer, default 0). - **Slug** — optional text input. - **Deskripsi** — optional textarea. - **Gambar** — optional list of URL inputs with add/remove. - **Tampilkan di toko** — checkbox; disabled when slug is empty. - On submit, call `createInventory` server action; on success close dialog, call `router.refresh()`, toast success; on error toast the error message. - Mount the trigger button in `page.tsx` alongside the existing `AdjustmentModal` in the page `action` prop — use an `Add01Icon` trigger button consistent with the pattern in other pages (e.g. pelanggan, order). ## Patterns to follow - `AdjustmentModal` for component shape. - `FormDialog`, `FormField`, `FormInput`, `FormSelect` from `@/components/ui/form-field`. - `createInventory` from `@/lib/inventory/actions`. ## Acceptance - Button opens dialog; all fields render; submit calls `createInventory`. - Duplicate name from the server action surfaces as a toast error. - `is_published: true` without slug is disabled in the UI. - `tsc --noEmit` and `biome check` pass. - No changes to files outside `stok/`.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
yuris/garage#28
No description provided.