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 { apiReq };
|
||||||
export { baseURL };
|
export { baseURL };
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { baseURL } from "./api-utils";
|
import { baseURL } from "./api-utils";
|
||||||
import { apiReq } from "./api-utils";
|
import { apiReq } from "./api-utils";
|
||||||
import { store } from "../store";
|
import { store } from "@/store";
|
||||||
|
|
||||||
const backupBase = baseURL + "backups/";
|
const backupBase = baseURL + "backups/";
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { baseURL } from "./api-utils";
|
import { baseURL } from "./api-utils";
|
||||||
import { apiReq } from "./api-utils";
|
import { apiReq } from "./api-utils";
|
||||||
|
import { store } from "@/store";
|
||||||
|
|
||||||
const prefix = baseURL + "categories";
|
const prefix = baseURL + "categories";
|
||||||
|
|
||||||
|
@ -20,6 +21,7 @@ export const categoryAPI = {
|
||||||
},
|
},
|
||||||
async delete(category) {
|
async delete(category) {
|
||||||
let response = await apiReq.delete(categoryURLs.delete_category(category));
|
let response = await apiReq.delete(categoryURLs.delete_category(category));
|
||||||
|
store.dispatch("requestCategories");
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -43,6 +45,7 @@ export const tagAPI = {
|
||||||
},
|
},
|
||||||
async delete(tag) {
|
async delete(tag) {
|
||||||
let response = await apiReq.delete(tagURLs.deleteTag(tag));
|
let response = await apiReq.delete(tagURLs.deleteTag(tag));
|
||||||
|
store.dispatch("requestTags");
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,6 +43,7 @@ export const recipeAPI = {
|
||||||
|
|
||||||
async create(recipeData) {
|
async create(recipeData) {
|
||||||
let response = await apiReq.post(recipeURLs.create, recipeData);
|
let response = await apiReq.post(recipeURLs.create, recipeData);
|
||||||
|
store.dispatch("requestRecentRecipes");
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -62,15 +63,13 @@ export const recipeAPI = {
|
||||||
},
|
},
|
||||||
|
|
||||||
async update(data) {
|
async update(data) {
|
||||||
const recipeSlug = data.slug;
|
let response = await apiReq.put(recipeURLs.update(data.slug), data);
|
||||||
|
|
||||||
let response = await apiReq.put(recipeURLs.update(recipeSlug), data);
|
|
||||||
store.dispatch("requestRecentRecipes");
|
store.dispatch("requestRecentRecipes");
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
async delete(recipeSlug) {
|
async delete(recipeSlug) {
|
||||||
apiReq.delete(recipeURLs.delete(recipeSlug));
|
await apiReq.delete(recipeURLs.delete(recipeSlug));
|
||||||
store.dispatch("requestRecentRecipes");
|
store.dispatch("requestRecentRecipes");
|
||||||
router.push(`/`);
|
router.push(`/`);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue