link search
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { useRouter } from '@/shared/config/i18n/navigation';
|
||||||
import formatPrice from '@/shared/lib/formatPrice';
|
import formatPrice from '@/shared/lib/formatPrice';
|
||||||
import { categories, ProductDetail } from '@/widgets/categories/lib/data';
|
import { categories, ProductDetail } from '@/widgets/categories/lib/data';
|
||||||
import { PackageOpen } from 'lucide-react';
|
import { PackageOpen } from 'lucide-react';
|
||||||
@@ -10,6 +11,7 @@ type SearchResultProps = {
|
|||||||
|
|
||||||
export const SearchResult = ({ query }: SearchResultProps) => {
|
export const SearchResult = ({ query }: SearchResultProps) => {
|
||||||
const [searchProduct, setSearchProduct] = useState<ProductDetail[]>([]);
|
const [searchProduct, setSearchProduct] = useState<ProductDetail[]>([]);
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSearchProduct(
|
setSearchProduct(
|
||||||
@@ -40,7 +42,10 @@ export const SearchResult = ({ query }: SearchResultProps) => {
|
|||||||
|
|
||||||
{searchProduct.slice(0, 5).map((product, index) => (
|
{searchProduct.slice(0, 5).map((product, index) => (
|
||||||
<Fragment key={index}>
|
<Fragment key={index}>
|
||||||
<div className="flex items-center gap-3 p-2 rounded-lg hover:bg-slate-100 cursor-pointer transition">
|
<div
|
||||||
|
className="flex items-center gap-3 p-2 rounded-lg hover:bg-slate-100 cursor-pointer transition"
|
||||||
|
onClick={() => router.push(`/product/${product.id}`)}
|
||||||
|
>
|
||||||
<Image
|
<Image
|
||||||
width={500}
|
width={500}
|
||||||
height={500}
|
height={500}
|
||||||
|
|||||||
Reference in New Issue
Block a user