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

Commit

Permalink
Sets chat filter on launch
Browse files Browse the repository at this point in the history
  • Loading branch information
mamikals committed Jan 18, 2024
1 parent 64c2484 commit 076bffa
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/komponenter/footer/chatbot/ChatbotWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ import { FridaIcon } from './FridaIcon';
import { BoostConfig, BoostObject } from './boost-config';

import style from './ChatbotWrapper.module.scss';
import { MenuValue } from 'utils/meny-storage-utils';
import { Locale } from 'store/reducers/language-duck';

const stateSelector = (state: AppState) => ({
chatbotParamEnabled: state.environment.PARAMS.CHATBOT,
chatbotParamVisible: state.environment.PARAMS.CHATBOT_VISIBLE,
featureToggles: state.featureToggles,
context: state.arbeidsflate.status,
env: state.environment.ENV,
language: state.language.language,
arbeidsflate: state.arbeidsflate.status,
});

const conversationCookieName = 'nav-chatbot%3Aconversation';
Expand All @@ -23,7 +27,7 @@ const boostApiUrlBaseTest = 'navtest';
const boostApiUrlBaseProduction = 'nav';

export const ChatbotWrapper = () => {
const { chatbotParamEnabled, chatbotParamVisible, env } = useSelector(stateSelector);
const { chatbotParamEnabled, chatbotParamVisible, env, language, arbeidsflate } = useSelector(stateSelector);
const [cookies, setCookie, removeCookie] = useCookies([conversationCookieName]);

// Do not mount chatbot on initial render. Prevents hydration errors
Expand Down Expand Up @@ -52,6 +56,13 @@ export const ChatbotWrapper = () => {
return;
}

let preferredFilter;
if (arbeidsflate === MenuValue.ARBEIDSGIVER) {
preferredFilter = 'arbeidsgiver';
} else {
preferredFilter = language === Locale.NYNORSK ? 'nynorsk' : 'bokmal';
}

const options: BoostConfig = {
chatPanel: {
settings: {
Expand All @@ -64,6 +75,11 @@ export const ChatbotWrapper = () => {
multiline: true,
},
},
header: {
filters: {
filterValues: preferredFilter,
},
},
},
};

Expand Down

0 comments on commit 076bffa

Please sign in to comment.