Chatwoot/app/javascript/widget/helpers/urlParamsHelper.js
Pranav Raj S 45cd949c40
feat: Add a popout option on webwidget (#1174)
* feat: Add a popout option on webwidget
2020-08-28 17:39:46 +05:30

31 lines
763 B
JavaScript

import Vue from 'vue';
export const buildSearchParamsWithLocale = search => {
const locale = Vue.config.lang;
if (search) {
search = `${search}&locale=${locale}`;
} else {
search = `?locale=${locale}`;
}
return search;
};
export const getLocale = (search = '') => {
const searchParamKeyValuePairs = search.split('&');
return searchParamKeyValuePairs.reduce((acc, keyValuePair) => {
const [key, value] = keyValuePair.split('=');
if (key === 'locale') {
return value;
}
return acc;
}, undefined);
};
export const buildPopoutURL = ({
origin,
conversationCookie,
websiteToken,
locale,
}) => {
return `${origin}/widget?cw_conversation=${conversationCookie}&website_token=${websiteToken}&locale=${locale}`;
};