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;
|
2022-10-19 20:20:40 +00:00
|
|
|
const params = new URLSearchParams(search);
|
|
|
|
params.append('locale', locale);
|
|
|
|
|
|
|
|
return `?${params}`;
|
2020-06-12 18:49:43 +00:00
|
|
|
};
|
2020-08-28 12:09:46 +00:00
|
|
|
|
|
|
|
export const getLocale = (search = '') => {
|
2022-10-19 20:20:40 +00:00
|
|
|
return new URLSearchParams(search).get('locale');
|
2020-08-28 12:09:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const buildPopoutURL = ({
|
|
|
|
origin,
|
|
|
|
conversationCookie,
|
|
|
|
websiteToken,
|
|
|
|
locale,
|
|
|
|
}) => {
|
2022-10-19 20:20:40 +00:00
|
|
|
const popoutUrl = new URL('/widget', origin);
|
|
|
|
popoutUrl.searchParams.append('cw_conversation', conversationCookie);
|
|
|
|
popoutUrl.searchParams.append('website_token', websiteToken);
|
|
|
|
popoutUrl.searchParams.append('locale', locale);
|
|
|
|
|
|
|
|
return popoutUrl.toString();
|
2020-08-28 12:09:46 +00:00
|
|
|
};
|