mirror of
				https://github.com/mealie-recipes/mealie.git
				synced 2025-10-30 17:53:31 -04:00 
			
		
		
		
	refactor(frontend): ♻️ rewrite search componenets to typescript
This commit is contained in:
		| @@ -1,37 +1,35 @@ | ||||
| import {  useAsync, ref } from "@nuxtjs/composition-api"; | ||||
| import { useAsync, ref, reactive } from "@nuxtjs/composition-api"; | ||||
| import { useApiSingleton } from "~/composables/use-api"; | ||||
| import { Recipe } from "~/types/api-types/recipe"; | ||||
|  | ||||
| export const useRecipeContext = function () { | ||||
|   const api = useApiSingleton(); | ||||
|   const loading = ref(false) | ||||
|  | ||||
|   const loading = ref(false); | ||||
|  | ||||
|   function getBySlug(slug: string) { | ||||
|     loading.value = true | ||||
|     loading.value = true; | ||||
|     const recipe = useAsync(async () => { | ||||
|       const { data } = await api.recipes.getOne(slug); | ||||
|       return data; | ||||
|     }, slug); | ||||
|  | ||||
|     loading.value = false | ||||
|     loading.value = false; | ||||
|     return recipe; | ||||
|   } | ||||
|  | ||||
|   async function  deleteRecipe(slug: string) { | ||||
|     loading.value = true | ||||
|   async function deleteRecipe(slug: string) { | ||||
|     loading.value = true; | ||||
|     const { data } = await api.recipes.deleteOne(slug); | ||||
|     loading.value = false | ||||
|     loading.value = false; | ||||
|     return data; | ||||
|   } | ||||
|  | ||||
|   async function updateRecipe(slug: string, recipe: Recipe) { | ||||
|     loading.value = true | ||||
|     loading.value = true; | ||||
|     const { data } = await api.recipes.updateOne(slug, recipe); | ||||
|     loading.value = false | ||||
|     loading.value = false; | ||||
|     return data; | ||||
|   } | ||||
|  | ||||
|  | ||||
|   return {loading, getBySlug, deleteRecipe, updateRecipe} | ||||
|   return { loading, getBySlug, deleteRecipe, updateRecipe }; | ||||
| }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user