| 
									
										
										
										
											2022-10-22 11:51:07 -08:00
										 |  |  | import { BaseCRUDAPI } from "../base/base-clients"; | 
					
						
							|  |  |  | import { CreatePlanEntry, CreateRandomEntry, ReadPlanEntry, UpdatePlanEntry } from "~/lib/api/types/meal-plan"; | 
					
						
							| 
									
										
										
										
											2021-09-12 11:05:09 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | const prefix = "/api"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const routes = { | 
					
						
							| 
									
										
										
										
											2024-08-22 10:14:32 -05:00
										 |  |  |   mealplan: `${prefix}/households/mealplans`, | 
					
						
							|  |  |  |   random: `${prefix}/households/mealplans/random`, | 
					
						
							|  |  |  |   mealplanId: (id: string | number) => `${prefix}/households/mealplans/${id}`, | 
					
						
							| 
									
										
										
										
											2021-09-12 11:05:09 -08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-21 21:22:02 +02:00
										 |  |  | export class MealPlanAPI extends BaseCRUDAPI<CreatePlanEntry, ReadPlanEntry, UpdatePlanEntry> { | 
					
						
							| 
									
										
										
										
											2021-09-12 11:05:09 -08:00
										 |  |  |   baseRoute = routes.mealplan; | 
					
						
							|  |  |  |   itemRoute = routes.mealplanId; | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-21 21:22:02 +02:00
										 |  |  |   async setRandom(payload: CreateRandomEntry) { | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |     console.log(payload); | 
					
						
							| 
									
										
										
										
											2022-05-21 21:22:02 +02:00
										 |  |  |     return await this.requests.post<ReadPlanEntry>(routes.random, payload); | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2021-09-12 11:05:09 -08:00
										 |  |  | } |