ef850eda0f
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
94 lines
2.4 KiB
JavaScript
94 lines
2.4 KiB
JavaScript
import {
|
|
SET_BUBBLE_VISIBILITY,
|
|
SET_REFERRER_HOST,
|
|
SET_WIDGET_APP_CONFIG,
|
|
SET_WIDGET_COLOR,
|
|
TOGGLE_WIDGET_OPEN,
|
|
} from '../types';
|
|
|
|
const state = {
|
|
hideMessageBubble: false,
|
|
isCampaignViewClicked: false,
|
|
isWebWidgetTriggered: false,
|
|
isWidgetOpen: false,
|
|
position: 'right',
|
|
referrerHost: '',
|
|
showPopoutButton: false,
|
|
widgetColor: '',
|
|
widgetStyle: 'standard',
|
|
darkMode: 'light',
|
|
};
|
|
|
|
export const getters = {
|
|
getAppConfig: $state => $state,
|
|
isRightAligned: $state => $state.position === 'right',
|
|
getHideMessageBubble: $state => $state.hideMessageBubble,
|
|
getIsWidgetOpen: $state => $state.isWidgetOpen,
|
|
getWidgetColor: $state => $state.widgetColor,
|
|
getReferrerHost: $state => $state.referrerHost,
|
|
isWidgetStyleFlat: $state => $state.widgetStyle === 'flat',
|
|
darkMode: $state => $state.darkMode,
|
|
};
|
|
|
|
export const actions = {
|
|
setAppConfig(
|
|
{ commit },
|
|
{
|
|
showPopoutButton,
|
|
position,
|
|
hideMessageBubble,
|
|
widgetStyle = 'rounded',
|
|
darkMode = 'light',
|
|
}
|
|
) {
|
|
commit(SET_WIDGET_APP_CONFIG, {
|
|
hideMessageBubble: !!hideMessageBubble,
|
|
position: position || 'right',
|
|
showPopoutButton: !!showPopoutButton,
|
|
widgetStyle,
|
|
darkMode,
|
|
});
|
|
},
|
|
toggleWidgetOpen({ commit }, isWidgetOpen) {
|
|
commit(TOGGLE_WIDGET_OPEN, isWidgetOpen);
|
|
},
|
|
setWidgetColor({ commit }, widgetColor) {
|
|
commit(SET_WIDGET_COLOR, widgetColor);
|
|
},
|
|
setReferrerHost({ commit }, referrerHost) {
|
|
commit(SET_REFERRER_HOST, referrerHost);
|
|
},
|
|
setBubbleVisibility({ commit }, hideMessageBubble) {
|
|
commit(SET_BUBBLE_VISIBILITY, hideMessageBubble);
|
|
},
|
|
};
|
|
|
|
export const mutations = {
|
|
[SET_WIDGET_APP_CONFIG]($state, data) {
|
|
$state.showPopoutButton = data.showPopoutButton;
|
|
$state.position = data.position;
|
|
$state.hideMessageBubble = data.hideMessageBubble;
|
|
$state.widgetStyle = data.widgetStyle;
|
|
$state.darkMode = data.darkMode;
|
|
},
|
|
[TOGGLE_WIDGET_OPEN]($state, isWidgetOpen) {
|
|
$state.isWidgetOpen = isWidgetOpen;
|
|
},
|
|
[SET_WIDGET_COLOR]($state, widgetColor) {
|
|
$state.widgetColor = widgetColor;
|
|
},
|
|
[SET_REFERRER_HOST]($state, referrerHost) {
|
|
$state.referrerHost = referrerHost;
|
|
},
|
|
[SET_BUBBLE_VISIBILITY]($state, hideMessageBubble) {
|
|
$state.hideMessageBubble = hideMessageBubble;
|
|
},
|
|
};
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state,
|
|
getters,
|
|
actions,
|
|
mutations,
|
|
};
|