munch-ease-frontend/src/composables/useShopping.js
2025-10-18 13:01:18 +11:00

27 lines
618 B
JavaScript

import {
getCurrentShoppingList,
getShoppingList,
purchaseShoppingList,
requestMeal,
unrequestMeal,
getMyShoppingList,
saveMyShoppingList,
} from '@/api/shopping'
import { groupsToItems } from '@/components/shopping/shopping.js'
export function useShopping() {
return {
getCurrentShoppingList,
getShoppingList,
purchaseShoppingList,
requestMeal,
unrequestMeal,
getMyShoppingList,
saveMyShoppingList,
async purchaseFromGroups(groups) {
const items = groupsToItems(groups)
if (!items?.length) return null
return purchaseShoppingList(items)
},
}
}