2021-10-23 16:42:20 -08:00
|
|
|
import { BaseCRUDAPI } from "../_base";
|
2022-02-13 12:23:42 -09:00
|
|
|
import { CreateIngredientFood, IngredientFood } from "~/types/api-types/recipe";
|
2021-08-22 15:23:45 -08:00
|
|
|
|
|
|
|
const prefix = "/api";
|
|
|
|
|
|
|
|
const routes = {
|
|
|
|
food: `${prefix}/foods`,
|
|
|
|
foodsFood: (tag: string) => `${prefix}/foods/${tag}`,
|
2022-04-09 19:08:48 -08:00
|
|
|
merge: `${prefix}/foods/merge`,
|
2021-08-22 15:23:45 -08:00
|
|
|
};
|
|
|
|
|
2022-05-21 21:22:02 +02:00
|
|
|
export class FoodAPI extends BaseCRUDAPI<CreateIngredientFood, IngredientFood> {
|
2021-08-22 15:23:45 -08:00
|
|
|
baseRoute: string = routes.food;
|
|
|
|
itemRoute = routes.foodsFood;
|
2022-04-09 19:08:48 -08:00
|
|
|
|
|
|
|
merge(fromId: string, toId: string) {
|
|
|
|
// @ts-ignore TODO: fix this
|
|
|
|
return this.requests.put<IngredientFood>(routes.merge, { fromFood: fromId, toFood: toId });
|
|
|
|
}
|
2021-08-22 15:23:45 -08:00
|
|
|
}
|