Refactor profile screen layout and user preference handling
Android Release Build / build-android (push) Successful in 13m44s
Android Release Build / build-android (push) Successful in 13m44s
This commit is contained in:
@@ -138,6 +138,7 @@ export default function App() {
|
||||
onStartScan={() => setActiveTab('scan')}
|
||||
onOpenProfile={() => setActiveTab('profile')}
|
||||
onToggleItem={toggleListItem}
|
||||
onChangeItemQuantity={changeListItemQuantity}
|
||||
onUpdateItemPrice={updateListItemPrice}
|
||||
preferences={preferences}
|
||||
lastDeletedItem={lastDeletedListItem}
|
||||
@@ -269,6 +270,7 @@ export default function App() {
|
||||
? {
|
||||
...item,
|
||||
quantity: item.quantity + 1,
|
||||
checked: false,
|
||||
packageQuantityGrams: item.packageQuantityGrams ?? product.packageQuantityGrams,
|
||||
packageQuantityLabel: item.packageQuantityLabel ?? product.packageQuantityLabel,
|
||||
servingQuantityGrams: item.servingQuantityGrams ?? product.servingQuantityGrams,
|
||||
@@ -337,6 +339,17 @@ export default function App() {
|
||||
}));
|
||||
}
|
||||
|
||||
function changeListItemQuantity(itemId, change) {
|
||||
setShoppingList((current) => {
|
||||
const items = current.items.map((item) =>
|
||||
item.id === itemId
|
||||
? { ...item, quantity: Math.max(1, (item.quantity || 1) + change) }
|
||||
: item
|
||||
);
|
||||
return { ...current, items, estimatedTotal: calculateEstimatedTotal(items) };
|
||||
});
|
||||
}
|
||||
|
||||
function deleteListItem(itemId) {
|
||||
const index = shoppingList.items.findIndex((item) => item.id === itemId);
|
||||
if (index < 0) return;
|
||||
|
||||
Reference in New Issue
Block a user