Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1535 from navikt/removeSettingsDomain
Browse files Browse the repository at this point in the history
Include domain settings on removeCookie
  • Loading branch information
terjeofnorway authored Apr 17, 2024
2 parents 9fef135 + 870775a commit a996fd4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/komponenter/footer/chatbot/ChatbotWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,15 @@ export const ChatbotWrapper = () => {
const [scriptLoaded, setScriptLoaded] = useState<boolean>(false);
const currentFeatureToggles = useSelector(stateSelector).featureToggles;

const isLocal: boolean = env === 'localhost';
const isProduction = env === 'prod';
const boostApiUrlBase = isProduction ? boostApiUrlBaseProduction : boostApiUrlBaseTest;

const cookieSettings = {
path: '/',
domain: isLocal ? 'localhost' : '.nav.no',
};

const openBoostWindow = () => {
if (typeof boost !== 'undefined') {
boost.chatPanel.show();
Expand Down Expand Up @@ -122,22 +128,22 @@ export const ChatbotWrapper = () => {

boost.chatPanel.addEventListener('conversationIdChanged', (event: any) => {
if (!event?.detail?.conversationId) {
removeCookie(conversationCookieName);
removeCookie(conversationCookieName, cookieSettings);
return;
}
const expirationDay = new Date();
expirationDay.setHours(expirationDay.getHours() + 1);
setCookie(conversationCookieName, event.detail.conversationId, {
expires: expirationDay,
domain: isProduction ? '.nav.no' : '.dev.nav.no',
...cookieSettings,
});
});
boost.chatPanel.addEventListener('setFilterValue', function (ev: any) {
boost.chatPanel.setFilterValues(ev.detail.filterValue);
if (ev.detail.nextId) boost.chatPanel.triggerAction(ev.detail.nextId);
});
boost.chatPanel.addEventListener('chatPanelClosed', () => {
removeCookie(conversationCookieName);
removeCookie(conversationCookieName, cookieSettings);
});

if (bufferLoad) {
Expand Down

0 comments on commit a996fd4

Please sign in to comment.