feat(recipe): añadida función para crear recetas en stores y services

parent 6d6069be
...@@ -21,5 +21,9 @@ export const recipeService = { ...@@ -21,5 +21,9 @@ export const recipeService = {
readDetail: async (id) => { readDetail: async (id) => {
const response = await api.get(`/recipe/${id}`); const response = await api.get(`/recipe/${id}`);
return response.data; return response.data;
},
create: async (recipeData) => {
const response = await api.post('/recipe', recipeData);
return response.data;
} }
} }
\ No newline at end of file
...@@ -52,6 +52,15 @@ export const useRecipeStore = defineStore('recipe', { ...@@ -52,6 +52,15 @@ export const useRecipeStore = defineStore('recipe', {
this.recipe = null; this.recipe = null;
throw error; throw error;
} }
},
async create(recipeData) {
try {
const newRecipe = await recipeService.create(recipeData);
this.recipe = newRecipe;
} catch (error) {
console.error('Error al crear la receta:', error);
throw error;
}
} }
} }
}); });
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment