2022-01-12 10:55:27 +00:00
|
|
|
import {
|
|
|
|
SET_REFERRER_HOST,
|
|
|
|
SET_WIDGET_APP_CONFIG,
|
|
|
|
SET_WIDGET_COLOR,
|
|
|
|
TOGGLE_WIDGET_OPEN,
|
|
|
|
} from '../types';
|
2019-11-25 18:40:27 +00:00
|
|
|
|
|
|
|
const state = {
|
2022-01-12 10:55:27 +00:00
|
|
|
hideMessageBubble: false,
|
|
|
|
isCampaignViewClicked: false,
|
2022-02-25 10:48:18 +00:00
|
|
|
isWebWidgetTriggered: false,
|
2022-01-12 10:55:27 +00:00
|
|
|
isWidgetOpen: false,
|
2022-02-25 10:48:18 +00:00
|
|
|
position: 'right',
|
2021-11-22 09:35:29 +00:00
|
|
|
referrerHost: '',
|
2022-02-25 10:48:18 +00:00
|
|
|
showPopoutButton: false,
|
|
|
|
widgetColor: '',
|
|
|
|
widgetStyle: 'standard',
|
2019-11-25 18:40:27 +00:00
|
|
|
};
|
|
|
|
|
2021-11-22 09:35:29 +00:00
|
|
|
export const getters = {
|
2022-01-12 10:55:27 +00:00
|
|
|
getAppConfig: $state => $state,
|
|
|
|
isRightAligned: $state => $state.position === 'right',
|
|
|
|
getHideMessageBubble: $state => $state.hideMessageBubble,
|
|
|
|
getIsWidgetOpen: $state => $state.isWidgetOpen,
|
2019-11-25 18:40:27 +00:00
|
|
|
getWidgetColor: $state => $state.widgetColor,
|
2021-11-22 09:35:29 +00:00
|
|
|
getReferrerHost: $state => $state.referrerHost,
|
2022-02-25 10:48:18 +00:00
|
|
|
isWidgetStyleFlat: $state => $state.widgetStyle === 'flat',
|
2019-11-25 18:40:27 +00:00
|
|
|
};
|
|
|
|
|
2021-11-22 09:35:29 +00:00
|
|
|
export const actions = {
|
2022-02-25 10:48:18 +00:00
|
|
|
setAppConfig(
|
|
|
|
{ commit },
|
|
|
|
{ showPopoutButton, position, hideMessageBubble, widgetStyle = 'rounded' }
|
|
|
|
) {
|
2022-01-12 10:55:27 +00:00
|
|
|
commit(SET_WIDGET_APP_CONFIG, {
|
|
|
|
hideMessageBubble: !!hideMessageBubble,
|
2022-02-25 10:48:18 +00:00
|
|
|
position: position || 'right',
|
|
|
|
showPopoutButton: !!showPopoutButton,
|
|
|
|
widgetStyle,
|
2022-01-12 10:55:27 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
toggleWidgetOpen({ commit }, isWidgetOpen) {
|
|
|
|
commit(TOGGLE_WIDGET_OPEN, isWidgetOpen);
|
|
|
|
},
|
|
|
|
setWidgetColor({ commit }, widgetColor) {
|
|
|
|
commit(SET_WIDGET_COLOR, widgetColor);
|
2019-11-25 18:40:27 +00:00
|
|
|
},
|
2021-11-22 09:35:29 +00:00
|
|
|
setReferrerHost({ commit }, referrerHost) {
|
|
|
|
commit(SET_REFERRER_HOST, referrerHost);
|
|
|
|
},
|
2019-11-25 18:40:27 +00:00
|
|
|
};
|
|
|
|
|
2021-11-22 09:35:29 +00:00
|
|
|
export const mutations = {
|
2022-01-12 10:55:27 +00:00
|
|
|
[SET_WIDGET_APP_CONFIG]($state, data) {
|
|
|
|
$state.showPopoutButton = data.showPopoutButton;
|
|
|
|
$state.position = data.position;
|
|
|
|
$state.hideMessageBubble = data.hideMessageBubble;
|
2022-02-25 10:48:18 +00:00
|
|
|
$state.widgetStyle = data.widgetStyle;
|
2022-01-12 10:55:27 +00:00
|
|
|
},
|
|
|
|
[TOGGLE_WIDGET_OPEN]($state, isWidgetOpen) {
|
|
|
|
$state.isWidgetOpen = isWidgetOpen;
|
|
|
|
},
|
|
|
|
[SET_WIDGET_COLOR]($state, widgetColor) {
|
|
|
|
$state.widgetColor = widgetColor;
|
2019-11-25 18:40:27 +00:00
|
|
|
},
|
2021-11-22 09:35:29 +00:00
|
|
|
[SET_REFERRER_HOST]($state, referrerHost) {
|
|
|
|
$state.referrerHost = referrerHost;
|
|
|
|
},
|
2019-11-25 18:40:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default {
|
|
|
|
namespaced: true,
|
|
|
|
state,
|
|
|
|
getters,
|
|
|
|
actions,
|
|
|
|
mutations,
|
|
|
|
};
|