2020-06-12 18:49:43 +00:00
|
|
|
export const buildSearchParamsWithLocale = search => {
|
2020-12-12 06:38:36 +00:00
|
|
|
const locale = window.WOOT_WIDGET.$root.$i18n.locale;
|
2020-06-12 18:49:43 +00:00
|
|
|
if (search) {
|
|
|
|
search = `${search}&locale=${locale}`;
|
|
|
|
} else {
|
|
|
|
search = `?locale=${locale}`;
|
|
|
|
}
|
|
|
|
return search;
|
|
|
|
};
|
2020-08-28 12:09:46 +00:00
|
|
|
|
|
|
|
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}`;
|
|
|
|
};
|