Skip to content

Commit

Permalink
Update product-list.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
alexprudhomme committed Nov 11, 2024
1 parent 3116039 commit 18efa1f
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@ import {useCart, useProductList} from '@/lib/commerce-engine';
import {addToCart} from '@/utils/cart';
import {Product} from '@coveo/headless-react/ssr-commerce';
import Image from 'next/image';
import {useRouter} from 'next/navigation';

export default function ProductList() {
const {state, methods} = useProductList();
const {methods: cartMethods} = useCart();

const router = useRouter();

const onProductClick = (product: Product) => {
methods?.interactiveProduct({options: {product}}).select();
router.push(
`/products/${product.ec_product_id}?name=${product.ec_name}&price=${product.ec_price}`
);
};

return (
<ul>
{state.products.map((product) => (
Expand Down

0 comments on commit 18efa1f

Please sign in to comment.