Products
The / page is the back office's only screen. It shows the number of products, an add form and the product table.
The interface is in French: the labels below are quoted as they appear, with a translation.
Displaying the list
| Column | Rule |
|---|---|
| Produit (product) | The name in bold, the description below it if any |
| Prix (price) | Two decimals, French comma, euro sign: 2.5 → 2,50 € |
| Stock | The raw number |
| État (status) | A badge computed from the stock (see below) |
| (action) | A Supprimer (delete) button |
The stock badge
| Stock | Badge | Colour |
|---|---|---|
0 | Rupture (out of stock) | red |
1 to 9 | Stock faible (low stock) | orange |
10 and more | En stock (in stock) | green |
The threshold of 10 is written in stockStatus(), in web/components/ProductList.js. See The product list.
The counter
Next to the title: "1 produit", "3 produits". It disappears if the API is unavailable.
Empty list, missing API
| Situation | Display |
|---|---|
| No products | "Aucun produit." (no products) |
| The API does not answer | A banner "API indisponible : …", without form or table |
Adding a product
| Field | Required | Rule in the form | Rule in the API |
|---|---|---|---|
| Nom (name) | yes | at most 120 characters | at most 120 characters |
| Prix (€) (price) | yes | number ≥ 0, step 0.01 | decimal ≥ 0, 2 decimals |
| Stock | yes | integer ≥ 0, 0 by default | integer ≥ 0 |
| Description | no | free text | free text |
The browser already blocks invalid values. But the API decides: if it refuses (code 400), the message "Ajout impossible : API responded with status 400" appears under the form. The API rules are in Products (API).
While sending, the button shows "Ajout…" and cannot be clicked again.
Deleting a product
The Supprimer button on each row deletes the product immediately, without confirmation. The page then refreshes.
No confirmation, no undo
A delete is final. There is no "Are you sure?" dialog yet. It is listed in the Limits.
The full code is explained in Adding and deleting.