mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
dispatch evens for CRUD operations
This commit is contained in:
parent
79daa7aef5
commit
d74b835be7
4 changed files with 9 additions and 5 deletions
|
@ -63,5 +63,7 @@ const apiReq = {
|
|||
},
|
||||
};
|
||||
|
||||
|
||||
|
||||
export { apiReq };
|
||||
export { baseURL };
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { baseURL } from "./api-utils";
|
||||
import { apiReq } from "./api-utils";
|
||||
import { store } from "../store";
|
||||
import { store } from "@/store";
|
||||
|
||||
const backupBase = baseURL + "backups/";
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { baseURL } from "./api-utils";
|
||||
import { apiReq } from "./api-utils";
|
||||
import { store } from "@/store";
|
||||
|
||||
const prefix = baseURL + "categories";
|
||||
|
||||
|
@ -20,6 +21,7 @@ export const categoryAPI = {
|
|||
},
|
||||
async delete(category) {
|
||||
let response = await apiReq.delete(categoryURLs.delete_category(category));
|
||||
store.dispatch("requestCategories");
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
|
@ -43,6 +45,7 @@ export const tagAPI = {
|
|||
},
|
||||
async delete(tag) {
|
||||
let response = await apiReq.delete(tagURLs.deleteTag(tag));
|
||||
store.dispatch("requestTags");
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
|
|
|
@ -43,6 +43,7 @@ export const recipeAPI = {
|
|||
|
||||
async create(recipeData) {
|
||||
let response = await apiReq.post(recipeURLs.create, recipeData);
|
||||
store.dispatch("requestRecentRecipes");
|
||||
return response.data;
|
||||
},
|
||||
|
||||
|
@ -62,15 +63,13 @@ export const recipeAPI = {
|
|||
},
|
||||
|
||||
async update(data) {
|
||||
const recipeSlug = data.slug;
|
||||
|
||||
let response = await apiReq.put(recipeURLs.update(recipeSlug), data);
|
||||
let response = await apiReq.put(recipeURLs.update(data.slug), data);
|
||||
store.dispatch("requestRecentRecipes");
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async delete(recipeSlug) {
|
||||
apiReq.delete(recipeURLs.delete(recipeSlug));
|
||||
await apiReq.delete(recipeURLs.delete(recipeSlug));
|
||||
store.dispatch("requestRecentRecipes");
|
||||
router.push(`/`);
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue