Skip to content

Commit

Permalink
Add star rating to collection item
Browse files Browse the repository at this point in the history
And fix type in collection
  • Loading branch information
Zwyx committed Jul 10, 2024
1 parent e584b99 commit 9b042d1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
18 changes: 13 additions & 5 deletions app/routes/collections.$handle.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import {json, redirect, type LoaderFunctionArgs} from '@shopify/remix-oxygen';
import {useLoaderData, Link, type MetaFunction} from '@remix-run/react';
import {
Pagination,
getPaginationVariables,
OkendoStarRating,
type WithOkendoStarRatingSnippet,
} from '@okendo/shopify-hydrogen';
import {Link, useLoaderData, type MetaFunction} from '@remix-run/react';
import {
Image,
Money,
Pagination,
getPaginationVariables,
} from '@shopify/hydrogen';
import {json, redirect, type LoaderFunctionArgs} from '@shopify/remix-oxygen';
import type {ProductItemFragment} from 'storefrontapi.generated';
import {useVariantUrl} from '~/lib/variants';

Expand Down Expand Up @@ -81,7 +85,7 @@ function ProductItem({
product,
loading,
}: {
product: ProductItemFragment;
product: ProductItemFragment & WithOkendoStarRatingSnippet;
loading?: 'eager' | 'lazy';
}) {
const variant = product.variants.nodes[0];
Expand All @@ -103,6 +107,10 @@ function ProductItem({
/>
)}
<h4>{product.title}</h4>
<OkendoStarRating
productId={product.id}
okendoStarRatingSnippet={product.okendoStarRatingSnippet}
/>
<small>
<Money data={product.priceRange.minVariantPrice} />
</small>
Expand Down
5 changes: 4 additions & 1 deletion app/routes/collections.all.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { OkendoStarRating, WithOkendoStarRatingSnippet } from '@okendo/shopify-hydrogen';
import {
OkendoStarRating,
type WithOkendoStarRatingSnippet,
} from '@okendo/shopify-hydrogen';
import {Link, useLoaderData, type MetaFunction} from '@remix-run/react';
import {
Image,
Expand Down

0 comments on commit 9b042d1

Please sign in to comment.