From 5e5b79ebeab61f96b38b66572c056d768867bc4b Mon Sep 17 00:00:00 2001 From: otenav Date: Fri, 11 Oct 2024 18:09:57 +0200 Subject: [PATCH] Debug highlight match --- .../(sok)/_components/searchResult/Debug.jsx | 46 +++++++++++++------ 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/src/app/(sok)/_components/searchResult/Debug.jsx b/src/app/(sok)/_components/searchResult/Debug.jsx index 972de8b94..70bf91ae6 100644 --- a/src/app/(sok)/_components/searchResult/Debug.jsx +++ b/src/app/(sok)/_components/searchResult/Debug.jsx @@ -4,7 +4,7 @@ import { useSearchParams } from "next/navigation"; import { QueryNames } from "@/app/(sok)/_utils/QueryNames"; import { mediumDisplayName } from "@/app/_common/utils/utils"; -function GroupItem({ children, color = "surface-neutral-subtle", tag }) { +function GroupItem({ children, color = "surface-neutral-subtle", tag, match }) { return ( {tag && ( - - + + {tag} @@ -30,8 +36,18 @@ function GroupItem({ children, color = "surface-neutral-subtle", tag }) { ); } +function isMatch(list, string) { + return list.some((it) => + string + .toLowerCase() + .split(/[ ,;-]/) + .some((word) => word === it.toLowerCase()), + ); +} + function Debug({ ad }) { const searchParams = useSearchParams(); + const searchString = searchParams.getAll("q"); const janzzOccupations = ad.categoryList?.filter((it) => it.categoryType === "JANZZ") || []; const otherOccupationCategories = ad.categoryList?.filter((it) => it.categoryType !== "JANZZ") || []; const janzzSynonyms = @@ -46,28 +62,32 @@ function Debug({ ad }) { {searchParams.has(QueryNames.SEARCH_STRING) && ( - = 2 ? "surface-warning-subtle" : "surface-danger-subtle"}> + = 2 ? "surface-success-subtle" : "surface-danger-subtle"}> {ad.score?.toFixed(1)} )} {ad.medium && {mediumDisplayName(ad.medium)}} - + + {janzzOccupations.map((category) => ( - + {category.name} ))} - - + {janzzSynonyms.map((tag) => ( - + {tag.label} ))} {otherOccupationCategories.map((category) => ( - + {category.name} ))} @@ -76,8 +96,8 @@ function Debug({ ad }) { {ad.properties?.searchtagsai && Array.isArray(ad.properties.searchtagsai) && ( {ad.properties.searchtagsai.map((searchTagAi) => ( - - {searchTagAi} + + {searchTagAi}{" "} ))} @@ -88,7 +108,7 @@ function Debug({ ad }) { {ad.properties.keywords.split(/[,;]/).map((keyword) => { if (keyword === "null") return null; return ( - + {keyword} );