@@ -4,7 +4,7 @@ import { useSearchParams } from "next/navigation";
4
4
import { QueryNames } from "@/app/(sok)/_utils/QueryNames" ;
5
5
import { mediumDisplayName } from "@/app/_common/utils/utils" ;
6
6
7
- function GroupItem ( { children, color = "surface-neutral-subtle" , tag } ) {
7
+ function GroupItem ( { children, color = "surface-neutral-subtle" , tag, match } ) {
8
8
return (
9
9
< Box
10
10
background = { color }
@@ -19,8 +19,14 @@ function GroupItem({ children, color = "surface-neutral-subtle", tag }) {
19
19
{ children }
20
20
</ BodyShort >
21
21
{ tag && (
22
- < Box paddingBlock = "05" paddingInline = "1" background = "surface-neutral-subtle" >
23
- < BodyShort size = "small" textColor = "subtle" className = "monospace" >
22
+ < Box
23
+ borderColor = "border-subtle"
24
+ borderWidth = "0 0 0 1"
25
+ paddingBlock = "05"
26
+ paddingInline = "1"
27
+ background = { match ? "surface-success-subtle" : "surface-neutral-subtle" }
28
+ >
29
+ < BodyShort size = "small" textColor = "subtle" >
24
30
{ tag }
25
31
</ BodyShort >
26
32
</ Box >
@@ -30,8 +36,18 @@ function GroupItem({ children, color = "surface-neutral-subtle", tag }) {
30
36
) ;
31
37
}
32
38
39
+ function isMatch ( list , string ) {
40
+ return list . some ( ( it ) =>
41
+ string
42
+ . toLowerCase ( )
43
+ . split ( / [ , ; - ] / )
44
+ . some ( ( word ) => word === it . toLowerCase ( ) ) ,
45
+ ) ;
46
+ }
47
+
33
48
function Debug ( { ad } ) {
34
49
const searchParams = useSearchParams ( ) ;
50
+ const searchString = searchParams . getAll ( "q" ) ;
35
51
const janzzOccupations = ad . categoryList ?. filter ( ( it ) => it . categoryType === "JANZZ" ) || [ ] ;
36
52
const otherOccupationCategories = ad . categoryList ?. filter ( ( it ) => it . categoryType !== "JANZZ" ) || [ ] ;
37
53
const janzzSynonyms =
@@ -46,28 +62,32 @@ function Debug({ ad }) {
46
62
< VStack gap = "4" >
47
63
< HStack gap = "2" >
48
64
{ searchParams . has ( QueryNames . SEARCH_STRING ) && (
49
- < GroupItem color = { ad . score >= 2 ? "surface-warning -subtle" : "surface-danger-subtle" } >
65
+ < GroupItem color = { ad . score >= 2 ? "surface-success -subtle" : "surface-danger-subtle" } >
50
66
{ ad . score ?. toFixed ( 1 ) }
51
67
</ GroupItem >
52
68
) }
53
69
54
70
{ ad . medium && < GroupItem color = "surface-info-subtle" > { mediumDisplayName ( ad . medium ) } </ GroupItem > }
55
-
71
+ </ HStack >
72
+ < HStack gap = "2" align = "center" >
56
73
{ janzzOccupations . map ( ( category ) => (
57
- < GroupItem color = "surface-success-subtle " key = { category . id } >
74
+ < GroupItem tag = "janzz " key = { category . id } match = { isMatch ( searchString , category . name ) } >
58
75
{ category . name }
59
76
</ GroupItem >
60
77
) ) }
61
- </ HStack >
62
- < HStack gap = "2" align = "center" >
78
+
63
79
{ janzzSynonyms . map ( ( tag ) => (
64
- < GroupItem key = { tag . label } tag = "janzz" >
80
+ < GroupItem key = { tag . label } tag = "janzz" match = { isMatch ( searchString , tag . label ) } >
65
81
{ tag . label }
66
82
</ GroupItem >
67
83
) ) }
68
84
69
85
{ otherOccupationCategories . map ( ( category ) => (
70
- < GroupItem key = { category . id } tag = { category . categoryType ?. toLowerCase ( ) } >
86
+ < GroupItem
87
+ key = { category . id }
88
+ tag = { category . categoryType ?. toLowerCase ( ) }
89
+ match = { isMatch ( searchString , category . name ) }
90
+ >
71
91
{ category . name }
72
92
</ GroupItem >
73
93
) ) }
@@ -76,8 +96,8 @@ function Debug({ ad }) {
76
96
{ ad . properties ?. searchtagsai && Array . isArray ( ad . properties . searchtagsai ) && (
77
97
< HStack gap = "2" align = "center" >
78
98
{ ad . properties . searchtagsai . map ( ( searchTagAi ) => (
79
- < GroupItem key = { searchTagAi } tag = "ai" >
80
- { searchTagAi }
99
+ < GroupItem key = { searchTagAi } tag = "ai" match = { isMatch ( searchString , searchTagAi ) } >
100
+ { searchTagAi } { " " }
81
101
</ GroupItem >
82
102
) ) }
83
103
</ HStack >
@@ -88,7 +108,7 @@ function Debug({ ad }) {
88
108
{ ad . properties . keywords . split ( / [ , ; ] / ) . map ( ( keyword ) => {
89
109
if ( keyword === "null" ) return null ;
90
110
return (
91
- < GroupItem key = { keyword } tag = "kwrd" >
111
+ < GroupItem key = { keyword } tag = "kword" match = { isMatch ( searchString , keyword ) } >
92
112
{ keyword }
93
113
</ GroupItem >
94
114
) ;
0 commit comments