feat: Add a popout option on webwidget (#1174)

* feat: Add a popout option on webwidget
This commit is contained in:
Pranav Raj S 2020-08-28 17:39:46 +05:30 committed by GitHub
parent ce13efd273
commit 45cd949c40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 347 additions and 127 deletions

View file

@ -1,4 +1,5 @@
import Vue from 'vue';
export const buildSearchParamsWithLocale = search => {
const locale = Vue.config.lang;
if (search) {
@ -8,3 +9,23 @@ export const buildSearchParamsWithLocale = search => {
}
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}`;
};