2022-10-22 11:51:07 -08:00
|
|
|
import { BaseCRUDAPI } from "../base/base-clients";
|
|
|
|
import { CreateIngredientUnit, IngredientUnit } from "~/lib/api/types/recipe";
|
2021-08-22 15:23:45 -08:00
|
|
|
|
|
|
|
const prefix = "/api";
|
|
|
|
|
|
|
|
const routes = {
|
|
|
|
unit: `${prefix}/units`,
|
|
|
|
unitsUnit: (tag: string) => `${prefix}/units/${tag}`,
|
2022-04-09 19:57:49 -08:00
|
|
|
merge: `${prefix}/units/merge`,
|
2021-08-22 15:23:45 -08:00
|
|
|
};
|
|
|
|
|
2022-05-21 21:22:02 +02:00
|
|
|
export class UnitAPI extends BaseCRUDAPI<CreateIngredientUnit, IngredientUnit> {
|
2021-08-22 15:23:45 -08:00
|
|
|
baseRoute: string = routes.unit;
|
|
|
|
itemRoute = routes.unitsUnit;
|
2022-04-09 19:57:49 -08:00
|
|
|
|
|
|
|
merge(fromId: string, toId: string) {
|
|
|
|
// @ts-ignore TODO: fix this
|
|
|
|
return this.requests.put<IngredientUnit>(routes.merge, { fromUnit: fromId, toUnit: toId });
|
|
|
|
}
|
2021-08-22 15:23:45 -08:00
|
|
|
}
|