1
1
import { MscrSearchResult } from '@app/common/interfaces/search.interface' ;
2
2
import { Block , RouterLink } from 'suomifi-ui-components' ;
3
- import { IconMerge , IconFileGeneric } from 'suomifi-icons' ;
4
3
import {
5
- ResultIconWrapper ,
4
+ ChipWrapper , MetadataChip ,
6
5
ResultTextWrapper ,
6
+ TypeChip
7
7
} from '@app/common/components/search-result/search-result.styles' ;
8
8
import { Schema } from '@app/common/interfaces/schema.interface' ;
9
9
import router from 'next/router' ;
@@ -24,22 +24,23 @@ export default function SearchResult({ hit }: { hit: MscrSearchResult }) {
24
24
state : result . state ,
25
25
versionLabel : result . versionLabel ,
26
26
description : result . comment ,
27
+ format : result . format ,
27
28
} ;
28
- let icon ;
29
29
let url ;
30
30
if ( result . type == 'SCHEMA' ) {
31
- icon = < IconFileGeneric /> ;
32
31
url = `/schema/${ displayResult . pid } ` ;
33
32
} else {
34
- icon = < IconMerge /> ;
35
33
url = `/crosswalk/${ displayResult . pid } ` ;
36
34
}
35
+ let chips : string [ ] = [ result . state ] ;
36
+ if ( result . format ) {
37
+ chips = chips . concat ( result . format ) ;
38
+ }
37
39
38
40
return (
39
41
< Block >
40
- < ResultIconWrapper > { icon } </ ResultIconWrapper >
41
42
< ResultTextWrapper >
42
- < Link href = { url } >
43
+ < Link href = { url } passHref >
43
44
< RouterLink onClick = { ( ) => setIsSearchActive ( false ) } >
44
45
< h4 >
45
46
{ getLanguageVersion ( {
@@ -50,19 +51,26 @@ export default function SearchResult({ hit }: { hit: MscrSearchResult }) {
50
51
</ h4 >
51
52
</ RouterLink >
52
53
</ Link >
54
+ < ChipWrapper >
55
+ { result . type == 'SCHEMA' && (
56
+ < TypeChip $isSchema > { result . type } </ TypeChip >
57
+ ) }
58
+ { result . type != 'SCHEMA' && (
59
+ < TypeChip > { result . type } </ TypeChip >
60
+ ) }
61
+ </ ChipWrapper >
53
62
< p >
54
63
{ getLanguageVersion ( {
55
64
data : displayResult . description ,
56
65
lang,
57
66
appendLocale : true ,
58
67
} ) }
59
68
</ p >
60
- { /*TODO: What exactly is supposed to be in the chips?
61
- {Object.keys(result.label).map((key) => (
62
- <ChipWrapper key={key}>
63
- <StaticChip>{result.label[key]}</StaticChip>
69
+ { chips . map ( ( chip ) => (
70
+ < ChipWrapper key = { chip } >
71
+ < MetadataChip > { chip } </ MetadataChip >
64
72
</ ChipWrapper >
65
- ))}*/ }
73
+ ) ) }
66
74
</ ResultTextWrapper >
67
75
</ Block >
68
76
) ;
0 commit comments