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

Commit 3efed05

Browse files
authored
Merge pull request #1532 from navikt/nytt-sok
Nytt sok
2 parents adf7467 + 5c20a3a commit 3efed05

File tree

8 files changed

+26
-7
lines changed

8 files changed

+26
-7
lines changed

Diff for: .env

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
ENV=localhost
22
XP_BASE_URL=https://www.nav.no
3+
SEARCH_URL=https://navno-search-api.intern.nav.no
34
APP_BASE_URL=http://localhost:8088
45
APP_BASE_PATH=/dekoratoren
56
API_XP_SERVICES_URL=https://www.nav.no/_/service

Diff for: .nais/vars/prod.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ ingresses:
66
outboundHosts:
77
- www.nav.no
88
- navno-unleash-api.nav.cloud.nais.io
9+
- navno-search-api.intern.nav.no
910
env:
1011
- name: ENV
1112
value: prod
1213
- name: XP_BASE_URL
1314
value: https://www.nav.no
15+
- name: SEARCH_URL
16+
value: https://navno-search-api.intern.nav.no
1417
- name: APP_BASE_URL
1518
value: https://www.nav.no
1619
- name: APP_BASE_PATH

Diff for: src/komponenter/header/header-regular/common/sok/Sok.tsx

+14-3
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,20 @@ interface Props {
2525

2626
const MAX_HITS_TO_DISPLAY = 5;
2727

28+
const validAudiences: ReadonlySet<string> = new Set(['privatperson', 'arbeidsgiver', 'samarbeidspartner']);
29+
2830
const stateSelector = (state: AppState) => ({
2931
environment: state.environment,
3032
language: state.language.language,
33+
audience: state.arbeidsflate.status,
3134
});
3235

3336
const setSubmitTrackerCookie = () => {
3437
Cookies.set('nav-search-use', Date.now().toString(), { expires: 30, domain: '.nav.no' });
3538
};
3639

3740
const Sok = (props: Props) => {
38-
const { environment, language } = useSelector(stateSelector);
41+
const { environment, language, audience } = useSelector(stateSelector);
3942
const [loading, setLoading] = useState<boolean>(false);
4043
const [result, setResult] = useState<Sokeresultat | undefined>();
4144
const [error, setError] = useState<string | undefined>();
@@ -106,6 +109,8 @@ const Sok = (props: Props) => {
106109
setLoading(true);
107110
fetchSearchDebounced({
108111
value,
112+
audience,
113+
language,
109114
environment,
110115
setLoading,
111116
setError,
@@ -117,6 +122,7 @@ const Sok = (props: Props) => {
117122
}}
118123
className={klassenavn}
119124
language={language}
125+
audience={audience}
120126
writtenInput={searchInput}
121127
onReset={onReset}
122128
id={props.id}
@@ -144,14 +150,16 @@ const Sok = (props: Props) => {
144150
/* Abstraction for debounce */
145151
interface FetchResult {
146152
value: string;
153+
audience: string;
154+
language: Locale;
147155
environment: Environment;
148156
setLoading: (value: boolean) => void;
149157
setError: (value?: string) => void;
150158
setResult: (value?: any) => void;
151159
}
152160

153161
const fetchSearch = (props: FetchResult) => {
154-
const { environment, value } = props;
162+
const { environment, value, audience, language } = props;
155163
const { setLoading, setError, setResult } = props;
156164
const { APP_URL } = environment;
157165
const url = `${APP_URL}/api/sok`;
@@ -164,7 +172,10 @@ const fetchSearch = (props: FetchResult) => {
164172
label: value,
165173
action: 'søk-dynamisk',
166174
});
167-
fetch(`${url}?ord=${encodeURIComponent(value)}`)
175+
176+
const facet = validAudiences.has(audience) ? audience : 'privatperson';
177+
178+
fetch(`${url}?ord=${encodeURIComponent(value)}&f=${facet}&preferredLanguage=${language}`)
168179
.then((response) => {
169180
if (response.ok) {
170181
return response;

Diff for: src/komponenter/header/header-regular/common/sok/sok-innhold/SokInput.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ type Props = {
99
className: string;
1010
writtenInput: string;
1111
language: Locale;
12+
audience: string;
1213
onChange: (value: string) => void;
1314
onReset: () => void;
1415
id: string;
1516
};
1617
export const SokInput = (props: Props) => {
17-
const { className, writtenInput, language, onChange, onReset, id } = props;
18+
const { className, writtenInput, language, audience, onChange, onReset, id } = props;
1819
// Only set the input value in the browser, to prevent execution-order
1920
// dependent SSR warnings under certain circumstances
2021
const inputValue = verifyWindowObj() ? writtenInput || '' : undefined;
@@ -28,7 +29,7 @@ export const SokInput = (props: Props) => {
2829
className={className}
2930
value={inputValue}
3031
type="text"
31-
label={finnTekst('sok-knapp-sokefelt', language)}
32+
label={finnTekst('sok-knapp-sokefelt', language, audience)}
3233
autoComplete="off"
3334
/>
3435
<SokKnapper writtenInput={writtenInput} onReset={onReset} id={id} />

Diff for: src/server/api-handlers/sok.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { RequestHandler } from 'express';
22

3-
const sokServiceUrl = `${process.env.API_XP_SERVICES_URL}/navno.nav.no.search/search2/sok`;
3+
const sokServiceUrl = `${process.env.SEARCH_URL}/content/decorator-search`;
44

55
export const getSokHandler: RequestHandler = (req, res) => {
66
const queryString = new URL(req.url, process.env.APP_BASE_URL).search;

Diff for: src/server/utils.ts

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export const clientEnv = ({ req }: Props): Environment => {
2828
return {
2929
ENV: process.env.ENV as string,
3030
XP_BASE_URL: process.env.XP_BASE_URL as string,
31+
SEARCH_URL: process.env.SEARCH_URL as string,
3132
APP_URL: appUrl as string,
3233
APP_BASE_URL: process.env.APP_BASE_URL as string,
3334
APP_BASE_PATH: process.env.APP_BASE_PATH as string,

Diff for: src/store/reducers/environment-duck.ts

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Breadcrumb } from 'komponenter/header/common/brodsmulesti/Brodsmulesti'
66
export interface Environment {
77
ENV: string;
88
XP_BASE_URL: string;
9+
SEARCH_URL: string;
910
APP_URL: string;
1011
APP_BASE_URL: string;
1112
APP_BASE_PATH: string;
@@ -57,6 +58,7 @@ export interface Cookies {
5758
export const initialState: Environment = {
5859
ENV: '',
5960
XP_BASE_URL: '',
61+
SEARCH_URL: '',
6062
APP_URL: '',
6163
APP_BASE_URL: '',
6264
APP_BASE_PATH: '',

Diff for: src/tekster/ledetekster.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export const ledetekster = {
119119
'sok-reset': 'Tøm',
120120
'sok-reset-en': 'Reset',
121121
'sok-reset-se': 'Tøm',
122-
'sok-knapp-sokefelt': 'Søk på nav.no',
122+
'sok-knapp-sokefelt': (input: string) => `Søk i innhold for ${input}`,
123123
'sok-knapp-sokefelt-en': 'Search nav.no',
124124
'sok-knapp-sokefelt-se': 'Oza nav.no',
125125
'sok-input-label': 'Søk',

0 commit comments

Comments
 (0)