| 
									
										
										
										
											2021-10-23 16:42:20 -08:00
										 |  |  | import { BaseCRUDAPI } from "../_base"; | 
					
						
							| 
									
										
										
										
											2022-03-17 10:30:10 -08:00
										 |  |  | import { CreateIngredientUnit, IngredientUnit } from "~/types/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
										 |  |  | } |