Examples
Inventory editor
Built with the mantine-data-grid skill
0 products with unsaved changes
Double-click a stock, reorder, price or warehouse cell to edit. Enter or click away applies it; Escape cancels.
Build the inventory editor of a warehouse app: staff correct stock, prices and warehouse assignments directly in the table, then save all changes at once.
Data:
- about 300 generated products: SKU, name, category, warehouse (one of 4), stock, reorder level, unit price, last counted date
- a mock save function that waits 600 ms and rejects the save when a SKU it receives is locked (2 generated products are locked for an ongoing count)
Table:
- SKU and name stay visible on the left while the other columns scroll horizontally; columns can be resized
- stock, reorder level and unit price are edited in place with number fields, warehouse with a select; SKU, name and last counted date are read only
- stock and reorder level are whole numbers of 0 or more; unit price is above 0 with 2 decimals; an invalid value shows its error at the cell and is not accepted
- Enter or leaving the cell commits the edit, Escape cancels it
- changed cells are marked until they are saved or discarded; a counter shows how many products have unsaved changes
- products whose stock is at or below the reorder level are marked as low stock; the mark must stay readable on selected and edited rows
- a filter shows only low stock products, and a search finds products by SKU or name
- sortable by name, stock and unit price; numbers are right-aligned
Saving:
- "Save changes" sends only the changed products and shows a notification with the number saved; "Discard changes" restores the original values after a confirmation
- when the save is rejected, nothing is saved, the locked products are pointed out in the table and the other changes stay pending
- leaving the page with unsaved changes is not prevented, but a warning is shown next to the save button
The component is shown on a demo page that already has a title: do not add a page title or intro text.
Write tests for the component.