Skip to content

Commit 0350290

Browse files
authored
core build fixes + mobile nav fix (#478)
1 parent ac4d2bf commit 0350290

File tree

6 files changed

+44
-11
lines changed

6 files changed

+44
-11
lines changed
854 KB
Binary file not shown.

examples/core/src/app/(auth)/layout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Inter } from "next/font/google";
1+
import localFont from "next/font/local";
22
import { ReactNode } from "react";
33
import { getStoreInitialState } from "../../lib/get-store-initial-state";
44
import { Providers } from "../providers";
@@ -22,8 +22,8 @@ export const metadata = {
2222
},
2323
};
2424

25-
const inter = Inter({
26-
subsets: ["latin"],
25+
const inter = localFont({
26+
src: "../../../public/fonts/Inter-VariableFont_opsz,wght.ttf",
2727
display: "swap",
2828
variable: "--font-inter",
2929
});

examples/core/src/app/(checkout)/layout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Inter } from "next/font/google";
1+
import localFont from "next/font/local";
22
import { ReactNode } from "react";
33
import { getStoreInitialState } from "../../lib/get-store-initial-state";
44
import { Providers } from "../providers";
@@ -22,8 +22,8 @@ export const metadata = {
2222
},
2323
};
2424

25-
const inter = Inter({
26-
subsets: ["latin"],
25+
const inter = localFont({
26+
src: "../../../public/fonts/Inter-VariableFont_opsz,wght.ttf",
2727
display: "swap",
2828
variable: "--font-inter",
2929
});

examples/core/src/app/(store)/layout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ReactNode, Suspense } from "react";
2-
import { Inter } from "next/font/google";
2+
import localFont from "next/font/local";
33
import { getStoreInitialState } from "../../lib/get-store-initial-state";
44
import { Providers } from "../providers";
55
import Header from "../../components/header/Header";
@@ -30,8 +30,8 @@ export const metadata = {
3030
*/
3131
export const revalidate = 300;
3232

33-
const inter = Inter({
34-
subsets: ["latin"],
33+
const inter = localFont({
34+
src: "../../../public/fonts/Inter-VariableFont_opsz,wght.ttf",
3535
display: "swap",
3636
variable: "--font-inter",
3737
});

examples/core/src/components/header/navigation/MobileNavBar.tsx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import {
1212
} from "../../../lib/cookie-constants";
1313
import {
1414
getACart,
15+
getAllCurrencies,
16+
getByContextAllProducts,
1517
getV2AccountMembersAccountMemberId,
1618
} from "@epcc-sdk/sdks-shopper";
1719
import { Suspense } from "react";
@@ -42,6 +44,34 @@ export default async function MobileNavBar() {
4244
},
4345
});
4446

47+
// Fetch product details for each cart item to get original sale price
48+
const cartItems = cart?.data?.included?.items;
49+
const productIds = cartItems?.map(item => item.product_id).filter(Boolean);
50+
const productDetailsResponse = await getByContextAllProducts({
51+
client,
52+
query: {
53+
filter: `in(id,${productIds?.join(",")})`,
54+
}
55+
});
56+
const productDetails = productDetailsResponse.data?.data || [];
57+
58+
// Merge product details into cart items
59+
const cartItemsWithDetails = cart?.data?.included?.items?.map(item => {
60+
const productDetail = productDetails.find(pd => pd.id === item.product_id);
61+
return {
62+
...item,
63+
productDetail,
64+
};
65+
});
66+
67+
// Fetch currencies
68+
const currencies = await getAllCurrencies({
69+
client,
70+
next: {
71+
tags: [TAGS.currencies],
72+
},
73+
});
74+
4575
if (!cart.data) {
4676
console.error("No cart found");
4777
return null;
@@ -78,7 +108,10 @@ export default async function MobileNavBar() {
78108
<div className="justify-self-end">
79109
<div className="flex gap-4">
80110
<Suspense fallback={<Skeleton className="h-10 w-10" />}>
81-
{cart.data && <CartSheet cart={cart.data} />}
111+
{cart.data && <CartSheet
112+
cart={{ ...cart.data, included: { items: cartItemsWithDetails } }}
113+
currencies={currencies?.data?.data ?? []}
114+
/>}
82115
</Suspense>
83116
</div>
84117
</div>

examples/core/src/lib/group-cart-items.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function groupCartItems(items: Items) {
3737
: acc.promotion;
3838

3939
const itemDiscounts = (item as any)?.discounts || [];
40-
let itemLevelPromotion = [...acc.itemLevelPromotion];
40+
const itemLevelPromotion = [...acc.itemLevelPromotion];
4141
if (!assertCartItemType(item, "promotion_item") && itemDiscounts.length) {
4242
itemDiscounts.forEach((discount: any) => {
4343
const exists = itemLevelPromotion.some(

0 commit comments

Comments
 (0)