feat(commerce-backend): panel simplificado de inventario en Medusa Admin
Nueva pestana "Inventario" en el sidebar del Admin (src/admin/routes/ inventario), pensada para un usuario no tecnico: una fila por producto (catalogo real confirmado 1 variante por producto), switch para activar seguimiento de stock, input de cantidad que guarda solo, badge de stock bajo (<=5 unidades) y activacion/desactivacion en bloque por seleccion. No reemplaza la vista nativa de Inventory de Medusa, es un atajo. Backend: src/api/admin/inventory-panel/route.ts + workflow propio src/workflows/attach-inventory-item-to-variant.ts para vincular un InventoryItem nuevo a una variante existente (Medusa no lo hace solo al togglear manage_inventory en un producto ya creado -- confirmado en vivo contra un producto [DEMO] antes de escribir el codigo). Nombres de campos y workflows verificados contra los .d.ts reales instalados en el pod (no solo contra la documentacion, que no cubre bien este flujo de vincular inventario a una variante existente).
This commit is contained in:
1 parent
cd8d2edd8f
commit
22f97ee12e
4 files changed
+376
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import { createWorkflow, WorkflowResponse } from "@medusajs/framework/workflows-sdk";
|
||||
import { attachInventoryItemToVariants } from "@medusajs/medusa/core-flows";
|
||||
|
||||
// attachInventoryItemToVariants es un step suelto (no un workflow
|
||||
// exportado) -- confirmado leyendo el .js real instalado
|
||||
// (@medusajs/core-flows/dist/inventory/steps/attach-inventory-items.js):
|
||||
// internamente resuelve ContainerRegistrationKeys.LINK y crea el link
|
||||
// Product<->Inventory. El campo "tag" del input es el variant_id (nombre
|
||||
// generico del step, no documentado con ese detalle).
|
||||
type Input = { inventoryItemId: string; variantId: string };
|
||||
|
||||
export const attachInventoryItemToVariantWorkflow = createWorkflow(
|
||||
"attach-inventory-item-to-variant",
|
||||
(input: Input) => {
|
||||
return new WorkflowResponse(
|
||||
attachInventoryItemToVariants([
|
||||
{ inventoryItemId: input.inventoryItemId, tag: input.variantId },
|
||||
]),
|
||||
);
|
||||
},
|
||||
);
|
||||
Reference in new issue
Block a user