From c43aa314a3916be3c264d0d4f94f9153151d118f Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Sun, 16 Oct 2022 19:30:29 +0200 Subject: Delete rows from admin cp --- store/warnings.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'store') diff --git a/store/warnings.js b/store/warnings.js index 65f1c92..d2983bd 100644 --- a/store/warnings.js +++ b/store/warnings.js @@ -124,6 +124,31 @@ export const actions = { commit("loadingStatus", false, { root: true }); + return res; + }, + // Delete a warning + async deleteWarning({ commit, rootGetters }, id) { + commit("loadingStatus", true, { root: true }); + let res = { status: 0, data: null }; + let api = this.$config.api; + + await fetch(`${api}/v1/warnings/${id}`, { + method: "DELETE", + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${rootGetters["auth/accessToken"]}`, + }, + }) + .then(async (response) => { + res.status = response.status; + res.data = await response.text(); + }) + .catch((e) => { + res.status = e.status; + }); + + commit("loadingStatus", false, { root: true }); + return res; }, }; -- cgit v1.2.3-18-g5258