| 
									
										
										
										
											2024-09-22 09:59:20 -05:00
										 |  |  | import { ref, Ref } from "@nuxtjs/composition-api"; | 
					
						
							|  |  |  | import { useData, useReadOnlyStore, useStore } from "../partials/use-store-factory"; | 
					
						
							| 
									
										
										
										
											2022-10-22 11:51:07 -08:00
										 |  |  | import { RecipeTool } from "~/lib/api/types/recipe"; | 
					
						
							| 
									
										
										
										
											2024-09-22 09:59:20 -05:00
										 |  |  | import { usePublicExploreApi, useUserApi } from "~/composables/api"; | 
					
						
							| 
									
										
										
										
											2022-06-03 20:12:32 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-22 09:59:20 -05:00
										 |  |  | const store: Ref<RecipeTool[]> = ref([]); | 
					
						
							|  |  |  | const loading = ref(false); | 
					
						
							|  |  |  | const publicLoading = ref(false); | 
					
						
							| 
									
										
										
										
											2022-06-03 20:12:32 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-22 09:59:20 -05:00
										 |  |  | export const useToolData = function () { | 
					
						
							|  |  |  |   return useData<RecipeTool>({ | 
					
						
							| 
									
										
										
										
											2022-06-03 20:12:32 -08:00
										 |  |  |     id: "", | 
					
						
							|  |  |  |     name: "", | 
					
						
							| 
									
										
										
										
											2024-09-22 09:59:20 -05:00
										 |  |  |     slug: "", | 
					
						
							| 
									
										
										
										
											2022-06-03 20:12:32 -08:00
										 |  |  |     onHand: false, | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2023-09-14 09:01:24 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-22 09:59:20 -05:00
										 |  |  | export const useToolStore = function () { | 
					
						
							| 
									
										
										
										
											2022-06-03 20:12:32 -08:00
										 |  |  |   const api = useUserApi(); | 
					
						
							| 
									
										
										
										
											2024-09-22 09:59:20 -05:00
										 |  |  |   return useStore<RecipeTool>(store, loading, api.tools); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-06-03 20:12:32 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-22 09:59:20 -05:00
										 |  |  | export const usePublicToolStore = function (groupSlug: string) { | 
					
						
							|  |  |  |   const api = usePublicExploreApi(groupSlug).explore; | 
					
						
							|  |  |  |   return useReadOnlyStore<RecipeTool>(store, publicLoading, api.tools); | 
					
						
							| 
									
										
										
										
											2022-06-03 20:12:32 -08:00
										 |  |  | } |