diff --git a/.env.example b/.env.example index a51f9f81..5d6e98ce 100644 --- a/.env.example +++ b/.env.example @@ -7,6 +7,7 @@ SPREE_PUBLISHABLE_KEY=your_publishable_api_key # Set these to your store's default_country_iso and default_locale NEXT_PUBLIC_DEFAULT_COUNTRY=us NEXT_PUBLIC_DEFAULT_LOCALE=en +NEXT_PUBLIC_STORE_NAME=Spree Store # Google Tag Manager (leave empty to disable) GTM_ID= diff --git a/package-lock.json b/package-lock.json index e0f672c2..90b9c20c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,8 +10,8 @@ "dependencies": { "@next/third-parties": "^16.1.6", "@sentry/nextjs": "^10.38.0", - "@spree/next": "^0.6.7", - "@spree/sdk": "^0.6.7", + "@spree/next": "^0.6.8", + "@spree/sdk": "^0.6.8", "@stripe/react-stripe-js": "^5.6.0", "@stripe/stripe-js": "^8.7.0", "next": "^16", @@ -4728,20 +4728,20 @@ } }, "node_modules/@spree/next": { - "version": "0.6.7", - "resolved": "https://registry.npmjs.org/@spree/next/-/next-0.6.7.tgz", - "integrity": "sha512-3huii/iDgvt58GMlnK/zgDP8Wd98Elsf4fdLm3DdetMJNeYL9cinGTaJrG59CybN12Chac727i/F7ukqtHwvVA==", + "version": "0.6.8", + "resolved": "https://registry.npmjs.org/@spree/next/-/next-0.6.8.tgz", + "integrity": "sha512-u363RFctbXZfX//7q/FZwqgT73czkiAtneyOtEiuURvVjfgaaNLl4XJGZAPDV7qUVWuVc/O69yBYRbYprO2ghg==", "license": "MIT", "peerDependencies": { - "@spree/sdk": ">=0.6.7", + "@spree/sdk": ">=0.6.8", "next": ">=15.0.0", "react": ">=19.0.0" } }, "node_modules/@spree/sdk": { - "version": "0.6.7", - "resolved": "https://registry.npmjs.org/@spree/sdk/-/sdk-0.6.7.tgz", - "integrity": "sha512-gGrC49omgJLgtoxOYreHvw8eXLmhCtVNl1JFTJz6klMNYJX/ZkUIz7yiOIDHAaFYhsG8eQmKhFqALPYi+v5oWg==", + "version": "0.6.8", + "resolved": "https://registry.npmjs.org/@spree/sdk/-/sdk-0.6.8.tgz", + "integrity": "sha512-GDJL4KZBZg6yy7upl0PRX9pBii8hZmezpqTyQB68o/HXmfghwmRCP/uHvPfuKvwxtIRPMSG7bLKhmEUTZYZquQ==", "license": "MIT", "engines": { "node": ">=18.0.0" diff --git a/package.json b/package.json index 46f54ae3..f0bf3ee3 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ "dependencies": { "@next/third-parties": "^16.1.6", "@sentry/nextjs": "^10.38.0", - "@spree/next": "^0.6.7", - "@spree/sdk": "^0.6.7", + "@spree/next": "^0.6.8", + "@spree/sdk": "^0.6.8", "@stripe/react-stripe-js": "^5.6.0", "@stripe/stripe-js": "^8.7.0", "next": "^16", diff --git a/src/app/[country]/[locale]/(checkout)/layout.tsx b/src/app/[country]/[locale]/(checkout)/layout.tsx index b7a1ae07..2175d534 100644 --- a/src/app/[country]/[locale]/(checkout)/layout.tsx +++ b/src/app/[country]/[locale]/(checkout)/layout.tsx @@ -9,9 +9,10 @@ import { ShoppingBagIcon, } from "@/components/icons"; import { CheckoutProvider, CheckoutSummary } from "@/contexts/CheckoutContext"; -import { useStore } from "@/contexts/StoreContext"; import { extractBasePath } from "@/lib/utils/path"; +const storeName = process.env.NEXT_PUBLIC_STORE_NAME || "Spree Store"; + function CheckoutHeader() { const pathname = usePathname(); const basePath = extractBasePath(pathname); @@ -33,14 +34,12 @@ function CheckoutHeader() { } function CheckoutFooter() { - const { store } = useStore(); const currentYear = new Date().getFullYear(); return ( ); diff --git a/src/app/[country]/[locale]/(storefront)/account/gift-cards/page.tsx b/src/app/[country]/[locale]/(storefront)/account/gift-cards/page.tsx index 53dd46b4..d2127201 100644 --- a/src/app/[country]/[locale]/(storefront)/account/gift-cards/page.tsx +++ b/src/app/[country]/[locale]/(storefront)/account/gift-cards/page.tsx @@ -1,5 +1,6 @@ "use client"; +import type { StoreGiftCard } from "@spree/sdk"; import { useEffect, useState } from "react"; import { CheckIcon, @@ -9,27 +10,6 @@ import { } from "@/components/icons"; import { getGiftCards } from "@/lib/data/gift-cards"; -// Gift card type (matches SDK StoreGiftCard) -interface GiftCard { - id: string; - code: string; - state: string; - currency: string; - amount: number; - amount_used: number; - amount_authorized: number; - amount_remaining: number; - display_amount: string; - display_amount_used: string; - display_amount_remaining: string; - expires_at: string | null; - redeemed_at: string | null; - expired: boolean; - active: boolean; - created_at: string; - updated_at: string; -} - function getStateColor(state: string, expired: boolean): string { if (expired) return "bg-gray-100 text-gray-800"; switch (state) { @@ -115,9 +95,11 @@ function CopyButton({ code }: { code: string }) { ); } -function GiftCardItem({ card }: { card: GiftCard }) { +function GiftCardItem({ card }: { card: StoreGiftCard }) { const usagePercentage = - card.amount > 0 ? Math.round((card.amount_used / card.amount) * 100) : 0; + Number(card.amount) > 0 + ? Math.round((Number(card.amount_used) / Number(card.amount)) * 100) + : 0; return (
@@ -181,7 +163,7 @@ function GiftCardItem({ card }: { card: GiftCard }) { } export default function GiftCardsPage() { - const [cards, setCards] = useState([]); + const [cards, setCards] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { diff --git a/src/contexts/StoreContext.tsx b/src/contexts/StoreContext.tsx index 9beeff44..26357126 100644 --- a/src/contexts/StoreContext.tsx +++ b/src/contexts/StoreContext.tsx @@ -1,6 +1,6 @@ "use client"; -import type { StoreCountry, StoreMarket, StoreStore } from "@spree/sdk"; +import type { StoreCountry, StoreMarket } from "@spree/sdk"; import { usePathname, useRouter } from "next/navigation"; import { createContext, @@ -13,7 +13,6 @@ import { useState, } from "react"; import { getMarkets as getMarketsAction } from "@/lib/data/markets"; -import { getStore as getStoreAction } from "@/lib/data/store"; import { setStoreCookies } from "@/lib/utils/cookies"; import { getPathWithoutPrefix } from "@/lib/utils/path"; @@ -28,7 +27,6 @@ interface StoreContextValue { country: string; locale: string; currency: string; - store: StoreStore | null; countries: CountryWithMarket[]; setCountry: (country: string) => void; setLocale: (locale: string) => void; @@ -126,7 +124,6 @@ export function StoreProvider({ const [country, setCountryState] = useState(initialCountry); const [locale, setLocaleState] = useState(initialLocale); const [currency, setCurrency] = useState("USD"); - const [store, setStore] = useState(null); const [countries, setCountries] = useState([]); const [loading, setLoading] = useState(true); const pathnameRef = useRef(pathname); @@ -136,12 +133,8 @@ export function StoreProvider({ useEffect(() => { const fetchData = async () => { try { - const [storeData, marketsData] = await Promise.all([ - getStoreAction(), - getMarketsAction(), - ]); + const marketsData = await getMarketsAction(); - setStore(storeData); const enrichedCountries = buildCountriesFromMarkets(marketsData.data); setCountries(enrichedCountries); @@ -200,22 +193,12 @@ export function StoreProvider({ country, locale, currency, - store, countries, setCountry, setLocale, loading, }), - [ - country, - locale, - currency, - store, - countries, - setCountry, - setLocale, - loading, - ], + [country, locale, currency, countries, setCountry, setLocale, loading], ); return ( diff --git a/src/lib/data/index.ts b/src/lib/data/index.ts index f0ff091d..cbbf55d9 100644 --- a/src/lib/data/index.ts +++ b/src/lib/data/index.ts @@ -8,5 +8,4 @@ export * from "./credit-cards"; export * from "./customer"; export * from "./orders"; export * from "./products"; -export * from "./store"; export * from "./taxonomies"; diff --git a/src/lib/data/orders.ts b/src/lib/data/orders.ts index 2af402f2..74af3483 100644 --- a/src/lib/data/orders.ts +++ b/src/lib/data/orders.ts @@ -7,7 +7,17 @@ import { withFallback } from "./utils"; export async function getOrders(params?: OrderListParams) { return withFallback(() => listOrders(params), { data: [], - meta: { page: 1, limit: 25, count: 0, pages: 0 }, + meta: { + page: 1, + limit: 25, + count: 0, + pages: 0, + from: 0, + to: 0, + in: 0, + previous: null, + next: null, + }, }); } diff --git a/src/lib/data/store.ts b/src/lib/data/store.ts deleted file mode 100644 index 85645269..00000000 --- a/src/lib/data/store.ts +++ /dev/null @@ -1,7 +0,0 @@ -"use server"; - -import { getStore as _getStore } from "@spree/next"; - -export async function getStore() { - return _getStore(); -}