diff --git a/app/product/[handle]/page.tsx b/app/product/[handle]/page.tsx
index c73509847..6573882bb 100644
--- a/app/product/[handle]/page.tsx
+++ b/app/product/[handle]/page.tsx
@@ -2,10 +2,10 @@ import type { Metadata } from 'next';
import { notFound } from 'next/navigation';
import { Suspense } from 'react';
+import { AddToCart } from 'components/cart/add-to-cart';
import Grid from 'components/grid';
import Footer from 'components/layout/footer';
import ProductGridItems from 'components/layout/product-grid-items';
-import { AddToCart } from 'components/cart/add-to-cart';
import { Gallery } from 'components/product/gallery';
import { VariantSelector } from 'components/product/variant-selector';
import Prose from 'components/prose';
@@ -69,9 +69,8 @@ export default async function ProductPage({ params }: { params: { handle: string
availability: product.availableForSale
? 'https://schema.org/InStock'
: 'https://schema.org/OutOfStock',
- priceCurrency: product.priceRange.minVariantPrice.currencyCode,
- highPrice: product.priceRange.maxVariantPrice.amount,
- lowPrice: product.priceRange.minVariantPrice.amount
+ priceCurrency: product.priceRange.maxVariantPrice.currencyCode,
+ highPrice: product.priceRange.maxVariantPrice.amount
}
};
@@ -99,6 +98,7 @@ export default async function ProductPage({ params }: { params: { handle: string
)}
+ {/* @ts-expect-error server component */}
{product.descriptionHtml ? (
@@ -109,8 +109,10 @@ export default async function ProductPage({ params }: { params: { handle: string
+ {/* @ts-expect-error server component */}
+ {/* @ts-expect-error server component */}
diff --git a/app/search/[collection]/opengraph-image.tsx b/app/search/[collection]/opengraph-image.tsx
index 9eb9c47f7..99a8f363d 100644
--- a/app/search/[collection]/opengraph-image.tsx
+++ b/app/search/[collection]/opengraph-image.tsx
@@ -1,10 +1,10 @@
import OpengraphImage from 'components/opengraph-image';
-import { getCollection } from 'lib/shopify';
+import { getCategory } from 'lib/medusa';
export const runtime = 'edge';
export default async function Image({ params }: { params: { collection: string } }) {
- const collection = await getCollection(params.collection);
+ const collection = await getCategory(params.collection);
const title = collection?.seo?.title || collection?.title;
return await OpengraphImage({ title });
diff --git a/app/search/[collection]/page.tsx b/app/search/[collection]/page.tsx
index cb5cadbde..b7d257a6f 100644
--- a/app/search/[collection]/page.tsx
+++ b/app/search/[collection]/page.tsx
@@ -33,7 +33,11 @@ export default async function CategoryPage({
}) {
const { sort } = searchParams as { [key: string]: string };
const { sortKey, reverse } = sorting.find((item) => item.slug === sort) || defaultSort;
- const products = await getCategoryProducts({ collection: params.collection, sortKey, reverse });
+ const products = await getCategoryProducts(
+ params.collection
+ // sortKey,
+ // reverse
+ );
return (
diff --git a/components/cart/actions.ts b/components/cart/actions.ts
index 5e5f2b2ea..55e6e3ddf 100644
--- a/components/cart/actions.ts
+++ b/components/cart/actions.ts
@@ -1,6 +1,6 @@
'use server';
-import { addToCart, removeFromCart, updateCart } from 'lib/shopify';
+import { addToCart, removeFromCart, updateCart } from 'lib/medusa';
import { cookies } from 'next/headers';
export const addItem = async (variantId: string | undefined): Promise => {
@@ -10,7 +10,7 @@ export const addItem = async (variantId: string | undefined): Promise =>
return new Error('Missing cartId');
}
try {
- await removeFromCart(cartId, [lineId]);
+ await removeFromCart(cartId, lineId);
} catch (e) {
return new Error('Error removing item', { cause: e });
}
@@ -44,13 +44,10 @@ export const updateItemQuantity = async ({
return new Error('Missing cartId');
}
try {
- await updateCart(cartId, [
- {
- id: lineId,
- merchandiseId: variantId,
- quantity
- }
- ]);
+ await updateCart(cartId, {
+ lineItemId: lineId,
+ quantity
+ });
} catch (e) {
return new Error('Error updating item quantity', { cause: e });
}
diff --git a/components/cart/delete-item-button.tsx b/components/cart/delete-item-button.tsx
index 081fb7cc9..0d4777ce2 100644
--- a/components/cart/delete-item-button.tsx
+++ b/components/cart/delete-item-button.tsx
@@ -1,33 +1,16 @@
import CloseIcon from 'components/icons/close';
import LoadingDots from 'components/loading-dots';
import { useRouter } from 'next/navigation';
-import { startTransition, useState } from 'react';
-import { useCookies } from 'react-cookie';
import clsx from 'clsx';
-import { removeFromCart } from 'lib/medusa';
+import { removeItem } from 'components/cart/actions';
import type { CartItem } from 'lib/medusa/types';
+import { useTransition } from 'react';
export default function DeleteItemButton({ item }: { item: CartItem }) {
const router = useRouter();
- const [removing, setRemoving] = useState(false);
- const [cookie] = useCookies(['cartId']);
+ const [isPending, startTransition] = useTransition();
- async function handleRemove() {
- const cartId = cookie.cartId;
-
- if (!cartId) return;
-
- setRemoving(true);
-
- await removeFromCart(cartId, item.id);
-
- setRemoving(false);
-
- startTransition(() => {
- router.refresh();
- });
- }
return (