feat(poc): revert and change filter

This commit is contained in:
Björn Meyer 2023-07-17 09:22:11 +02:00
parent 6e09bf12c4
commit ea259358b2
2 changed files with 19 additions and 29 deletions

View File

@ -1,13 +1,13 @@
'use client'; 'use client';
// import { useRouter, useSearchParams } from 'next/navigation'; import { useRouter, useSearchParams } from 'next/navigation';
import SearchIcon from 'components/icons/search'; import SearchIcon from 'components/icons/search';
// import { createUrl } from 'lib/utils'; import { createUrl } from 'lib/utils';
export default function Search() { export default function Search() {
//const router = useRouter(); const router = useRouter();
//const searchParams = useSearchParams(); const searchParams = useSearchParams();
function onSubmit(e: React.FormEvent<HTMLFormElement>) { function onSubmit(e: React.FormEvent<HTMLFormElement>) {
e.preventDefault(); e.preventDefault();
@ -15,15 +15,15 @@ export default function Search() {
const val = e.target as HTMLFormElement; const val = e.target as HTMLFormElement;
const search = val.search as HTMLInputElement; const search = val.search as HTMLInputElement;
console.log(`Search:` + search); console.log(`Search:` + search);
// const newParams = new URLSearchParams(searchParams.toString()); const newParams = new URLSearchParams(searchParams.toString());
// if (search.value) { if (search.value) {
// newParams.set('q', search.value); newParams.set('q', search.value);
// } else { } else {
// newParams.delete('q'); newParams.delete('q');
// } }
// router.push(createUrl('/search', newParams)); router.push(createUrl('/search', newParams));
} }
return ( return (
@ -36,7 +36,7 @@ export default function Search() {
name="search" name="search"
placeholder="Search for products..." placeholder="Search for products..."
autoComplete="off" 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" className="w-full px-4 py-2 text-black dark:bg-black dark:text-gray-100"
/> />
<div className="absolute right-0 top-0 mr-3 flex h-full items-center"> <div className="absolute right-0 top-0 mr-3 flex h-full items-center">

View File

@ -134,29 +134,19 @@ export async function requestSeoUrl(
limit: number = 1 limit: number = 1
): Promise<SeoURLResultSW | undefined> { ): Promise<SeoURLResultSW | undefined> {
try { try {
return await apiInstance.invoke('readSeoUrl post /seo-url', { const criteria = {
page: page, page: page,
limit: limit, limit: limit,
filter: [ filter: [
{ {
type: 'multi', type: 'contains',
// @ts-ignore
operator: 'or',
queries: [
{
type: 'equals',
field: 'seoPathInfo',
value: handle + '/'
},
{
type: 'equals',
field: 'seoPathInfo', field: 'seoPathInfo',
value: handle value: handle
} }
] ]
} };
] console.log(criteria);
}); return await apiInstance.invoke('readSeoUrl post /seo-url', criteria);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }