import { DateTime } from 'luxon'; import { MENU_TYPE_URL } from '../constants'; import { getRequest, processResponse, processRejection, } from '../helpers'; import { ShoppingList } from '../types/types'; export const getLunchMenu = async ({ year, month, day }: DateTime): Promise => { const url = MENU_TYPE_URL + `lunch/${year}/${month}/${day}/`; return await getRequest(url) .then((response) => { return processResponse(response); }) .catch((error) => { return processRejection(error); }); }; export const getBreakfastMenu = async ({ year, month, day }: DateTime): Promise => { const url = MENU_TYPE_URL + `breakfast/${year}/${month}/${day}/`; return await getRequest(url) .then((response) => { return processResponse(response); }) .catch((error) => { return processRejection(error); }); }; export const getShoppingList = async (date: DateTime): Promise => { const breakfast = await getBreakfastMenu(date) ?? []; const lunch = await getLunchMenu(date) ?? []; return [...breakfast, ...lunch]; };