Skip to content

Commit ab04425

Browse files
authored
fix: update SDK methods used in memberships example (#467)
* fix: update SDK methods used in memberships example * fix: image support
1 parent 8a15224 commit ab04425

31 files changed

+109
-85
lines changed

examples/memberships/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"dependencies": {
1818
"@epcc-sdk/sdks-nextjs": "workspace:*",
19-
"@epcc-sdk/sdks-shopper": "workspace:*",
19+
"@epcc-sdk/sdks-shopper": "^0.0.42",
2020
"@headlessui/react": "^2.2.0",
2121
"@heroicons/react": "^2.2.0",
2222
"@hookform/resolvers": "^4.1.3",

examples/memberships/pnpm-lock.yaml

Lines changed: 24 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/memberships/src/app/(checkout)/checkout/AccountCheckout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ import {
1010
ResponseCurrency,
1111
} from "@epcc-sdk/sdks-shopper";
1212
import { createElasticPathClient } from "../../../lib/create-elastic-path-client";
13-
import { getCart } from "@epcc-sdk/sdks-shopper";
13+
import { getACart } from "@epcc-sdk/sdks-shopper";
1414
import { TAGS } from "../../../lib/constants";
1515
import { AccountCheckoutForm } from "./AccoutCheckoutForm";
1616

1717
export async function AccountCheckout({
1818
cart,
1919
currencies,
2020
}: {
21-
cart: NonNullable<Awaited<ReturnType<typeof getCart>>["data"]>;
21+
cart: NonNullable<Awaited<ReturnType<typeof getACart>>["data"]>;
2222
currencies: ResponseCurrency[];
2323
}) {
2424
const client = createElasticPathClient();

examples/memberships/src/app/(checkout)/checkout/AccoutCheckoutForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import * as React from "react";
1111
import {
1212
AccountAddressResponse,
1313
AccountMemberResponse,
14-
getCart,
14+
getACart,
1515
ResponseCurrency,
1616
} from "@epcc-sdk/sdks-shopper";
1717
import { AccountDisplay } from "./AccountDisplay";
@@ -23,7 +23,7 @@ export function AccountCheckoutForm({
2323
currencies,
2424
cart,
2525
}: {
26-
cart: NonNullable<Awaited<ReturnType<typeof getCart>>["data"]>;
26+
cart: NonNullable<Awaited<ReturnType<typeof getACart>>["data"]>;
2727
account: AccountMemberResponse;
2828
addresses: Array<AccountAddressResponse>;
2929
currencies: ResponseCurrency[];

examples/memberships/src/app/(checkout)/checkout/CheckoutSidebar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ import { useWatch } from "react-hook-form";
1717
import { EP_CURRENCY_CODE } from "../../../lib/resolve-ep-currency-code";
1818
import { formatCurrency } from "../../../lib/format-currency";
1919
import { LoadingDots } from "../../../components/LoadingDots";
20-
import { getCart, ResponseCurrency } from "@epcc-sdk/sdks-shopper";
20+
import { getACart, ResponseCurrency } from "@epcc-sdk/sdks-shopper";
2121
import { ItemSidebarHideable } from "../../../components/checkout-sidebar/ItemSidebarHideable";
2222
import { groupCartItems } from "../../../lib/group-cart-items";
2323

2424
export function CheckoutSidebar({
2525
cart,
2626
currencies,
2727
}: {
28-
cart: NonNullable<Awaited<ReturnType<typeof getCart>>["data"]>;
28+
cart: NonNullable<Awaited<ReturnType<typeof getACart>>["data"]>;
2929
currencies: ResponseCurrency[];
3030
}) {
3131
const shippingMethod = useWatch({ name: "shippingMethod" });

examples/memberships/src/app/(checkout)/checkout/CheckoutViews.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ReactNode, useEffect } from "react";
44
import { OrderConfirmation } from "./OrderConfirmation";
55
import { useOrderConfirmation } from "./OrderConfirmationProvider";
66
import { useRouter } from "next/navigation";
7-
import { getCart, ResponseCurrency } from "@epcc-sdk/sdks-shopper";
7+
import { getACart, ResponseCurrency } from "@epcc-sdk/sdks-shopper";
88

99
export function CheckoutViews({
1010
children,
@@ -13,7 +13,7 @@ export function CheckoutViews({
1313
}: {
1414
children: ReactNode;
1515
currencies: ResponseCurrency[];
16-
cartResponse: NonNullable<Awaited<ReturnType<typeof getCart>>["data"]>;
16+
cartResponse: NonNullable<Awaited<ReturnType<typeof getACart>>["data"]>;
1717
}) {
1818
const confirmationData = useOrderConfirmation();
1919
const router = useRouter();

examples/memberships/src/app/(checkout)/checkout/GuestCheckout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import { SubmitCheckoutButton } from "./SubmitCheckoutButton";
1010
import { Separator } from "../../../components/separator/Separator";
1111
import * as React from "react";
1212
import { CheckoutSidebar } from "./CheckoutSidebar";
13-
import { getCart, ResponseCurrency } from "@epcc-sdk/sdks-shopper";
13+
import { getACart, ResponseCurrency } from "@epcc-sdk/sdks-shopper";
1414
import { GuestCheckoutProvider } from "./checkout-provider";
1515

1616
export function GuestCheckout({
1717
cart,
1818
currencies,
1919
}: {
20-
cart: Awaited<ReturnType<typeof getCart>>["data"];
20+
cart: Awaited<ReturnType<typeof getACart>>["data"];
2121
currencies: ResponseCurrency[];
2222
}) {
2323
const hasSubscription =

examples/memberships/src/app/(checkout)/checkout/actions.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ import {
1414
deleteAllCartItems,
1515
TransactionResponse,
1616
OrderResponse,
17-
CartItemsObjectResponse,
17+
CartItemResponse,
1818
BillingAddress,
1919
ShippingAddress,
2020
ElasticPathFile,
2121
getByContextAllProducts,
22-
getCart,
22+
getACart,
2323
Product,
2424
postV2AccountMembersTokens,
2525
} from "@epcc-sdk/sdks-shopper";
@@ -43,7 +43,7 @@ export type PaymentCompleteResponse = {
4343
products: Array<Product>;
4444
mainImageMap: Record<string, ElasticPathFile>;
4545
payment: TransactionResponse;
46-
cart: Array<CartItemsObjectResponse>;
46+
cart: Array<CartItemResponse>;
4747
};
4848

4949
export async function paymentComplete(
@@ -232,7 +232,7 @@ export async function paymentComplete(
232232
* Get main images
233233
*/
234234

235-
const cartResponse = await getCart({
235+
const cartResponse = await getACart({
236236
client,
237237
path: {
238238
cartID: cartId,
@@ -250,7 +250,7 @@ export async function paymentComplete(
250250
client,
251251
query: {
252252
filter: `in(id,${productIds})`,
253-
include: ["main_images"],
253+
include: ["main_image"],
254254
},
255255
});
256256

examples/memberships/src/app/(checkout)/checkout/checkout-provider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import {
1212
import { zodResolver } from "@hookform/resolvers/zod";
1313
import { Form } from "../../../components/form/Form";
1414
import { ShippingMethod, staticDeliveryMethods } from "./useShippingMethod";
15-
import { getCart } from "@epcc-sdk/sdks-shopper";
15+
import { getACart } from "@epcc-sdk/sdks-shopper";
1616
import { paymentComplete } from "./actions";
1717
import { useSetOrderConfirmation } from "./OrderConfirmationProvider";
1818

1919
type CheckoutContext = {
20-
cart?: NonNullable<Awaited<ReturnType<typeof getCart>>["data"]>;
20+
cart?: NonNullable<Awaited<ReturnType<typeof getACart>>["data"]>;
2121
completePayment: (data: CheckoutForm) => Promise<void>;
2222
isCompleting: boolean;
2323
shippingMethods: {

examples/memberships/src/app/(checkout)/checkout/extract-cart-item-media.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
CartItemsObjectResponse,
2+
CartItemResponse,
33
ElasticPathFile,
44
Product,
55
} from "@epcc-sdk/sdks-shopper";
@@ -9,7 +9,7 @@ export function extractCartItemMedia({
99
products,
1010
mainImages,
1111
}: {
12-
items: Array<CartItemsObjectResponse>;
12+
items: Array<CartItemResponse>;
1313
products: Array<Product>;
1414
mainImages: Array<ElasticPathFile>;
1515
}) {

0 commit comments

Comments
 (0)