Chatwoot/app/javascript/widget/helpers/urlParamsHelper.js
Muhsin Keloth f9bd447912
chore: Upgrade vue-i18n to 8.x (#1383)
Co-authored-by: Pranav Raj S <pranav@thoughtwoot.com>
2020-12-12 12:08:36 +05:30

29 lines
761 B
JavaScript

export const buildSearchParamsWithLocale = search => {
const locale = window.WOOT_WIDGET.$root.$i18n.locale;
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}`;
};