feat(ui): simplify to 3-button manage layout and remove drawer grouping
Build and Push Fridger Container / Build & Push Fridger Image (push) Successful in 1m36s
Build and Push Fridger Container / Build & Push Fridger Image (push) Successful in 1m36s
This commit is contained in:
@@ -266,6 +266,66 @@ function adjustQuantity(id, { newQuantity, delta, markOpened }) {
|
||||
return getItemById(id);
|
||||
}
|
||||
|
||||
function addPacket(id, count = 1) {
|
||||
const item = getItemById(id);
|
||||
if (!item) return null;
|
||||
|
||||
const packSize = item.initial_quantity > 0 ? item.initial_quantity : 1;
|
||||
const addedAmount = packSize * count;
|
||||
const newQty = item.quantity + addedAmount;
|
||||
|
||||
const stmt = db.prepare(`
|
||||
UPDATE items SET
|
||||
quantity = ?,
|
||||
updated_at = datetime('now', 'localtime')
|
||||
WHERE id = ?
|
||||
`);
|
||||
stmt.run(newQty, id);
|
||||
|
||||
logActivity({
|
||||
item_id: id,
|
||||
item_name: item.name,
|
||||
action: 'add_packet',
|
||||
amount_change: addedAmount,
|
||||
unit: item.unit,
|
||||
note: `Added ${count} packet(s) (+${addedAmount} ${item.unit})`
|
||||
});
|
||||
|
||||
return getItemById(id);
|
||||
}
|
||||
|
||||
function removePacket(id, count = 1) {
|
||||
const item = getItemById(id);
|
||||
if (!item) return null;
|
||||
|
||||
const packSize = item.initial_quantity > 0 ? item.initial_quantity : 1;
|
||||
const removeAmount = packSize * count;
|
||||
let newQty = item.quantity - removeAmount;
|
||||
|
||||
if (newQty <= 0) {
|
||||
newQty = 0;
|
||||
}
|
||||
|
||||
const stmt = db.prepare(`
|
||||
UPDATE items SET
|
||||
quantity = ?,
|
||||
updated_at = datetime('now', 'localtime')
|
||||
WHERE id = ?
|
||||
`);
|
||||
stmt.run(newQty, id);
|
||||
|
||||
logActivity({
|
||||
item_id: id,
|
||||
item_name: item.name,
|
||||
action: 'remove_packet',
|
||||
amount_change: -removeAmount,
|
||||
unit: item.unit,
|
||||
note: `Removed ${count} packet(s) (-${removeAmount} ${item.unit})`
|
||||
});
|
||||
|
||||
return getItemById(id);
|
||||
}
|
||||
|
||||
function deleteItem(id) {
|
||||
const item = getItemById(id);
|
||||
if (!item) return false;
|
||||
@@ -347,6 +407,8 @@ module.exports = {
|
||||
createItem,
|
||||
updateItem,
|
||||
adjustQuantity,
|
||||
addPacket,
|
||||
removePacket,
|
||||
deleteItem,
|
||||
getActivityLogs,
|
||||
getStats
|
||||
|
||||
Reference in New Issue
Block a user