diff --git a/components/search/no-result.tsx b/components/search/no-result.tsx
new file mode 100644
index 000000000..36577978a
--- /dev/null
+++ b/components/search/no-result.tsx
@@ -0,0 +1,50 @@
+'use client';
+
+import { ReactNode } from 'react';
+import { ClearRefinements, useInstantSearch } from 'react-instantsearch';
+
+import { useTranslations } from 'next-intl';
+
+interface NoResultsProps {
+ children: ReactNode;
+ fallback: ReactNode;
+}
+
+export function NoResultsBoundary({ children, fallback }: NoResultsProps) {
+ const { results } = useInstantSearch();
+
+ // The `__isArtificial` flag makes sure not to display the No Results message
+ // when no hits have been returned.
+ if (!results.__isArtificial && results.nbHits === 0) {
+ return (
+ <>
+ {fallback}
+
{children}
+ >
+ );
+ }
+
+ return children;
+}
+
+export function NoResults() {
+ const t = useTranslations('search');
+ const { indexUiState } = useInstantSearch();
+
+ return (
+
+
+ {t('noResults')} {indexUiState.query}
.
+
+
+
+ );
+}
diff --git a/components/search/search-result.tsx b/components/search/search-result.tsx
new file mode 100644
index 000000000..54d037d73
--- /dev/null
+++ b/components/search/search-result.tsx
@@ -0,0 +1,52 @@
+'use client';
+
+import Text from '@/components/ui/text/text';
+import { cn } from '@/lib/utils';
+import { useTranslations } from 'next-intl';
+import Link from 'next/link';
+import { Configure, Highlight, InfiniteHits } from 'react-instantsearch';
+
+export default function SearchResult() {
+ const t = useTranslations('search');
+
+ const Hit = (props: any) => {
+ const { hit } = props;
+ const { handle, price } = props.hit;
+
+ return (
+
+
+
+
+ Brand
+
+
+
+
+
{price} SEK
+
+
+ );
+ };
+
+ return (
+ <>
+
+
+ >
+ );
+}
diff --git a/components/search/search-root.tsx b/components/search/search-root.tsx
new file mode 100644
index 000000000..4a568d367
--- /dev/null
+++ b/components/search/search-root.tsx
@@ -0,0 +1,21 @@
+import algoliasearch from 'algoliasearch/lite';
+import { InstantSearch } from 'react-instantsearch';
+
+const searchClient = algoliasearch(
+ `${process.env.NEXT_PUBLIC_ALGOLIA_APPLICATION_ID}`,
+ `${process.env.NEXT_PUBLIC_ALGOLIA_SEARCH_ONLY_API_KEY}`
+);
+
+interface SearchRootProps {
+ children: JSX.Element | JSX.Element[];
+}
+
+export default function SearchRoot({ children }: SearchRootProps) {
+ return (
+ <>
+
+ {children}
+
+ >
+ );
+}
diff --git a/components/search/search.tsx b/components/search/search.tsx
index 1ff779908..b882823e9 100644
--- a/components/search/search.tsx
+++ b/components/search/search.tsx
@@ -1,43 +1,48 @@
-import algoliasearch from 'algoliasearch/lite';
-// import { useLocale } from 'next-intl';
+'use client';
+
import Text from '@/components/ui/text';
-import { Highlight, Hits, InstantSearch, SearchBox } from 'react-instantsearch';
-const searchClient = algoliasearch(
- `${process.env.NEXT_PUBLIC_ALGOLIA_APPLICATION_ID}`,
- `${process.env.NEXT_PUBLIC_ALGOLIA_SEARCH_ONLY_API_KEY}`
-);
+import { cn } from 'lib/utils';
+import { useTranslations } from 'next-intl';
+import SearchRoot from './search-root';
+
+import { SearchBox } from 'react-instantsearch';
+
+import { ReactNode } from 'react';
+import { NoResults, NoResultsBoundary } from './no-result';
+
+interface SearchProps {
+ title?: string;
+ placeholder?: string;
+ className?: string;
+ children: ReactNode;
+ isCategory?: boolean;
+}
+
+export default function Search({ title, placeholder, children, isCategory = false }: SearchProps) {
+ const t = useTranslations('search');
+
+ console.log(isCategory);
-export default function Search() {
- // const locale = useLocale();
- // Hit.
- function Hit(props: any) {
- return (
-
-
-
-
-
- Brand
-
-
-
-
-
{props.hit.price} SEK
-
-
-
- );
- }
return (
-
-
- {/* Widgets */}
+
+ {/* Search top */}
+
+ {title && (
+
+ {title}
+
+ )}
+
+
- {/* */}
-
-
-
-
+
}>{children}
+
);
}
diff --git a/messages/en.json b/messages/en.json
index a4f7706fa..fa6d6beae 100644
--- a/messages/en.json
+++ b/messages/en.json
@@ -22,6 +22,9 @@
"submitTitle": "Submit your search query",
"clearTitle": "Clear your search query",
"resetTitle": "Reset your search query",
+ "noResults": "No results for",
+ "showMore": "Show more results",
+ "searchCategory": "Search in category",
"seo": {
"title": "Search",
"description": "Search for product or category"
diff --git a/messages/sv.json b/messages/sv.json
index 4728f3112..d381b2ddd 100644
--- a/messages/sv.json
+++ b/messages/sv.json
@@ -22,6 +22,9 @@
"submitTitle": "Skicka din sökfråga",
"clearTitle": "Rensa din sökfråga",
"resetTitle": "Återställ din sökfråga",
+ "noResults": "Inga resultat för",
+ "showMore": "Visa fler resultat",
+ "searchCategory": "Sök i kategori",
"seo": {
"title": "Sök",
"description": "Sök efter produkt eller kategori"