Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Edwin950821/BodegaX/llms.txt

Use this file to discover all available pages before exploring further.

The Management page (/management) is BodegaX’s warehouse inventory dashboard, labelled Mi Bodega (My Warehouse) in the interface. When an admin navigates here, the page immediately fetches all products from the backend and computes a live stock total by summing every product’s stock value. The result — displayed prominently as total — tells the warehouse team exactly how many crates are currently on hand across all beer brands. Below the counter, a table breaks the total down by product, giving a brand-by-brand view of available crates. When a new shipment arrives, the Recibir button opens the RecibirCaja dialog to log the incoming stock without requiring a page reload.
The Mi Bodega page is intended for administrators. Ensure the user’s session stored in sessionStorage under the key bodegax carries role: 'admin' before navigating to /management.

Warehouse Summary Cards

Total Crates in Warehouse

The total property is initialised to 0 and incremented by each product’s stock during ngOnInit. It updates in real time after every successful stock receipt, without a page reload.

Product Inventory Table

The table iterates over productos (fetched from GET /productos/all) and renders one row per beer brand, showing producto.nombre and producto.stock.

Recibir Button

Opens the RecibirCaja dialog, passing the current productos array. After the dialog closes, the component updates the matching product’s stock in place and recalculates total.

Terminar Jornada Button

The orange Terminar Jornada button is present in the template, but its handler (terminar()) is currently an empty stub and does not open any dialog. End-of-day reporting from this page is not yet implemented.

Product Data Structure

The PUT /productos/edit endpoint — called during stock receipt and during dispatch — expects and returns the full product object. The table below documents every field:
FieldTypeDescription
uuidstringUnique identifier for the product
nombrestringBeer brand name displayed in the UI
precionumberUnit price per crate, used in sales total calculations
stocknumberCurrent crate count in the warehouse

Receiving Incoming Stock

1

Click the Recibir Button

From the Mi Bodega dashboard, click the blue Recibir button. The recibirCaja() method opens the RecibirCaja dialog and passes the current productos array as dialog data.
2

Select a Product

Inside the dialog, choose a beer brand from the product dropdown. The selection is bound to the producto property, which stores the selected product’s uuid. If no product is selected when confirming, the dialog closes with false and no changes are made.
3

Enter the Incoming Quantity

Type the number of crates being received into the quantity field, bound to the quantity property. This value is added to the product’s existing stock — it is not a replacement.
4

Confirm — Stock Update API Call

Clicking Confirmar triggers the following sequence inside RecibirCaja:
  1. The component locates the selected product via productos.find(p => p.uuid == this.producto).
  2. It sets selected.stock = selected.stock + this.quantity on the local object.
  3. It calls PUT /productos/edit with the full updated product object.
  4. On success, the dialog closes and returns the updated selected object to the Management component.
5

Real-Time Total Recalculation

The Management component’s afterClosed() subscription receives the returned product object. It finds the matching entry in this.productos by uuid and updates its stock in place. Then it resets total to 0 and re-sums all product stocks, so the dashboard reflects the new warehouse total immediately.

Initialisation Flow

When the Management component initialises (ngOnInit), it performs a single GET /productos/all request. On success, it stores the response in this.productos and loops through every product to accumulate this.total. If the request fails, the error is logged to the console and both productos and total remain at their default empty/zero values.
GET /productos/all
  └── for each product:
        this.total += product.stock
Because the stock total is recalculated client-side after each RecibirCaja dialog closes, there is no need to re-fetch all products from the API. The local productos array is treated as the source of truth for the duration of the session.

Build docs developers (and LLMs) love