Add status after setUser
This commit is contained in:
parent
db6629d5fa
commit
2ca92ab90c
2 changed files with 14 additions and 1 deletions
|
@ -95,6 +95,7 @@ export default {
|
|||
isCreating: 'conversation/getIsCreating',
|
||||
activeCampaign: 'campaign/getActiveCampaign',
|
||||
currentUser: 'contacts/getCurrentUser',
|
||||
setUserTriggerStatus: 'contacts/getSetUserTriggerStatus',
|
||||
}),
|
||||
textColor() {
|
||||
return getContrastingTextColor(this.widgetColor);
|
||||
|
@ -124,6 +125,9 @@ export default {
|
|||
) {
|
||||
return false;
|
||||
}
|
||||
if (this.setUserTriggerStatus && field.name === 'fullName') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
},
|
||||
|
|
|
@ -4,9 +4,11 @@ import { SET_USER_ERROR } from '../../constants/errorTypes';
|
|||
import { setHeader } from '../../helpers/axios';
|
||||
const state = {
|
||||
currentUser: {},
|
||||
isSetUserTriggered: false,
|
||||
};
|
||||
|
||||
const SET_CURRENT_USER = 'SET_CURRENT_USER';
|
||||
const TRIGGER_SET_USER = 'TRIGGER_SET_USER';
|
||||
const parseErrorData = error =>
|
||||
error && error.response && error.response.data ? error.response.data : error;
|
||||
export const updateWidgetAuthToken = widgetAuthToken => {
|
||||
|
@ -23,6 +25,9 @@ export const getters = {
|
|||
getCurrentUser(_state) {
|
||||
return _state.currentUser;
|
||||
},
|
||||
getSetUserTriggerStatus(_state) {
|
||||
return _state.isSetUserTriggered;
|
||||
},
|
||||
};
|
||||
|
||||
export const actions = {
|
||||
|
@ -42,7 +47,7 @@ export const actions = {
|
|||
// Ignore error
|
||||
}
|
||||
},
|
||||
setUser: async ({ dispatch }, { identifier, user: userObject }) => {
|
||||
setUser: async ({ dispatch, commit }, { identifier, user: userObject }) => {
|
||||
try {
|
||||
const {
|
||||
email,
|
||||
|
@ -75,6 +80,7 @@ export const actions = {
|
|||
const {
|
||||
data: { widget_auth_token: widgetAuthToken },
|
||||
} = await ContactsAPI.setUser(identifier, user);
|
||||
commit(TRIGGER_SET_USER);
|
||||
updateWidgetAuthToken(widgetAuthToken);
|
||||
dispatch('get');
|
||||
if (identifierHash || widgetAuthToken) {
|
||||
|
@ -108,6 +114,9 @@ export const mutations = {
|
|||
const { currentUser } = $state;
|
||||
$state.currentUser = { ...currentUser, ...user };
|
||||
},
|
||||
[TRIGGER_SET_USER]($state) {
|
||||
$state.isSetUserTriggered = true;
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
|
|
Loading…
Reference in a new issue