feat: Add an option to edit webhook URL (#2316)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
@@ -8,6 +8,7 @@ const state = {
|
||||
fetchingList: false,
|
||||
creatingItem: false,
|
||||
deletingItem: false,
|
||||
updatingItem: false,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -36,7 +37,10 @@ export const actions = {
|
||||
commit(types.default.SET_WEBHOOK_UI_FLAG, { creatingItem: true });
|
||||
try {
|
||||
const response = await webHookAPI.create(params);
|
||||
commit(types.default.ADD_WEBHOOK, response.data.payload.webhook);
|
||||
const {
|
||||
payload: { webhook },
|
||||
} = response.data;
|
||||
commit(types.default.ADD_WEBHOOK, webhook);
|
||||
commit(types.default.SET_WEBHOOK_UI_FLAG, { creatingItem: false });
|
||||
} catch (error) {
|
||||
commit(types.default.SET_WEBHOOK_UI_FLAG, { creatingItem: false });
|
||||
@@ -44,6 +48,18 @@ export const actions = {
|
||||
}
|
||||
},
|
||||
|
||||
update: async ({ commit }, { id, ...updateObj }) => {
|
||||
commit(types.default.SET_WEBHOOK_UI_FLAG, { updatingItem: true });
|
||||
try {
|
||||
const response = await webHookAPI.update(id, updateObj);
|
||||
commit(types.default.UPDATE_WEBHOOK, response.data.payload.webhook);
|
||||
} catch (error) {
|
||||
throw new Error(error);
|
||||
} finally {
|
||||
commit(types.default.SET_WEBHOOK_UI_FLAG, { updatingItem: false });
|
||||
}
|
||||
},
|
||||
|
||||
async delete({ commit }, id) {
|
||||
commit(types.default.SET_WEBHOOK_UI_FLAG, { deletingItem: true });
|
||||
try {
|
||||
@@ -64,10 +80,10 @@ export const mutations = {
|
||||
...data,
|
||||
};
|
||||
},
|
||||
|
||||
[types.default.SET_WEBHOOK]: MutationHelpers.set,
|
||||
[types.default.ADD_WEBHOOK]: MutationHelpers.create,
|
||||
[types.default.DELETE_WEBHOOK]: MutationHelpers.destroy,
|
||||
[types.default.UPDATE_WEBHOOK]: MutationHelpers.update,
|
||||
};
|
||||
|
||||
export default {
|
||||
|
||||
Reference in New Issue
Block a user