From ea259358b2b21bf08e665ab29759a1767fa0d5e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Meyer?= Date: Mon, 17 Jul 2023 09:22:11 +0200 Subject: [PATCH] feat(poc): revert and change filter --- components/layout/navbar/search.tsx | 24 ++++++++++++------------ lib/shopware/api.ts | 24 +++++++----------------- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/components/layout/navbar/search.tsx b/components/layout/navbar/search.tsx index c11aa2eff..bf4d12230 100644 --- a/components/layout/navbar/search.tsx +++ b/components/layout/navbar/search.tsx @@ -1,13 +1,13 @@ 'use client'; -// import { useRouter, useSearchParams } from 'next/navigation'; +import { useRouter, useSearchParams } from 'next/navigation'; import SearchIcon from 'components/icons/search'; -// import { createUrl } from 'lib/utils'; +import { createUrl } from 'lib/utils'; export default function Search() { - //const router = useRouter(); - //const searchParams = useSearchParams(); + const router = useRouter(); + const searchParams = useSearchParams(); function onSubmit(e: React.FormEvent) { e.preventDefault(); @@ -15,15 +15,15 @@ export default function Search() { const val = e.target as HTMLFormElement; const search = val.search as HTMLInputElement; console.log(`Search:` + search); - // const newParams = new URLSearchParams(searchParams.toString()); + const newParams = new URLSearchParams(searchParams.toString()); - // if (search.value) { - // newParams.set('q', search.value); - // } else { - // newParams.delete('q'); - // } + if (search.value) { + newParams.set('q', search.value); + } else { + newParams.delete('q'); + } - // router.push(createUrl('/search', newParams)); + router.push(createUrl('/search', newParams)); } return ( @@ -36,7 +36,7 @@ export default function Search() { name="search" placeholder="Search for products..." autoComplete="off" - // defaultValue={searchParams?.get('q') || ''} + defaultValue={searchParams?.get('q') || ''} className="w-full px-4 py-2 text-black dark:bg-black dark:text-gray-100" />
diff --git a/lib/shopware/api.ts b/lib/shopware/api.ts index b77d1227d..98f0d32ec 100644 --- a/lib/shopware/api.ts +++ b/lib/shopware/api.ts @@ -134,29 +134,19 @@ export async function requestSeoUrl( limit: number = 1 ): Promise { try { - return await apiInstance.invoke('readSeoUrl post /seo-url', { + const criteria = { page: page, limit: limit, filter: [ { - type: 'multi', - // @ts-ignore - operator: 'or', - queries: [ - { - type: 'equals', - field: 'seoPathInfo', - value: handle + '/' - }, - { - type: 'equals', - field: 'seoPathInfo', - value: handle - } - ] + type: 'contains', + field: 'seoPathInfo', + value: handle } ] - }); + }; + console.log(criteria); + return await apiInstance.invoke('readSeoUrl post /seo-url', criteria); } catch (error) { console.log(error); }