Restructure omni services and add Chatwoot research snapshot
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import MessageAPI from '../../api/message';
|
||||
|
||||
const state = {
|
||||
uiFlags: {
|
||||
isUpdating: false,
|
||||
},
|
||||
};
|
||||
|
||||
export const getters = {
|
||||
getUIFlags: $state => $state.uiFlags,
|
||||
};
|
||||
|
||||
export const actions = {
|
||||
update: async (
|
||||
{ commit, dispatch, getters: { getUIFlags: uiFlags } },
|
||||
{ email, messageId, submittedValues }
|
||||
) => {
|
||||
if (uiFlags.isUpdating) {
|
||||
return;
|
||||
}
|
||||
commit('toggleUpdateStatus', true);
|
||||
try {
|
||||
await MessageAPI.update({
|
||||
email,
|
||||
messageId,
|
||||
values: submittedValues,
|
||||
});
|
||||
commit(
|
||||
'conversation/updateMessage',
|
||||
{
|
||||
id: messageId,
|
||||
content_attributes: {
|
||||
submitted_email: email,
|
||||
submitted_values: email ? null : submittedValues,
|
||||
},
|
||||
},
|
||||
{ root: true }
|
||||
);
|
||||
dispatch('contacts/get', {}, { root: true });
|
||||
} catch (error) {
|
||||
// Ignore error
|
||||
}
|
||||
commit('toggleUpdateStatus', false);
|
||||
},
|
||||
};
|
||||
|
||||
export const mutations = {
|
||||
toggleUpdateStatus($state, status) {
|
||||
$state.uiFlags.isUpdating = status;
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations,
|
||||
};
|
||||
Reference in New Issue
Block a user