28 lines
618 B
JavaScript
28 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)
|
||
|
|
},
|
||
|
|
}
|
||
|
|
}
|