1
1
import React from 'react' ;
2
- import { BodyShort , Button , Detail , Heading , Loader } from '@navikt/ds-react' ;
2
+ import { Button , Detail , Heading , Loader } from '@navikt/ds-react' ;
3
3
import { SearchResponse } from 'shared/types' ;
4
4
import { SearchResultItem } from './SearchResultItem/SearchResultItem' ;
5
5
@@ -14,6 +14,24 @@ type SearchResultProps = {
14
14
export const SearchResult = ( { isLoading, searchResult, closeSearchResult } : SearchResultProps ) => {
15
15
const { hits, query, total, hasMore } = searchResult ;
16
16
17
+ const orderedHits = [ ...hits ] . sort ( ( a , b ) => {
18
+ const orderedTypes = [
19
+ 'no.nav.navno:content-page-with-sidemenus' ,
20
+ 'no.nav.navno:situation-page' ,
21
+ 'no.nav.navno:themed-article-page' ,
22
+ 'no.nav.navno:guide-page' ,
23
+ 'no.nav.navno:current-topic-page' ,
24
+ 'no.nav.navno:main-article' ,
25
+ 'no.nav.navno:internal-link' ,
26
+ 'no.nav.navno:external-link' ,
27
+ ] ;
28
+
29
+ const indexA = orderedTypes . indexOf ( a . type ) ;
30
+ const indexB = orderedTypes . indexOf ( b . type ) ;
31
+
32
+ return indexA - indexB ;
33
+ } ) ;
34
+
17
35
return (
18
36
< div >
19
37
{ isLoading ? (
@@ -32,7 +50,7 @@ export const SearchResult = ({ isLoading, searchResult, closeSearchResult }: Sea
32
50
Lukk
33
51
</ Button >
34
52
</ div >
35
- { hits . map ( ( hit ) => (
53
+ { orderedHits . map ( ( hit ) => (
36
54
< SearchResultItem hit = { hit } key = { hit . _id + hit . layerLocale } />
37
55
) ) }
38
56
{ hasMore && (
0 commit comments