Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Quote NEXT_PUBLIC_STORE_NAME to avoid parsing inconsistencies.

This value contains spaces and is already flagged by dotenv-linter; quoting it avoids tool/parser ambiguity.

🔧 Suggested fix
-NEXT_PUBLIC_STORE_NAME=Spree Store
+NEXT_PUBLIC_STORE_NAME="Spree Store"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
NEXT_PUBLIC_STORE_NAME=Spree Store
NEXT_PUBLIC_STORE_NAME="Spree Store"
🧰 Tools
🪛 dotenv-linter (4.0.0)

[warning] 10-10: [ValueWithoutQuotes] This value needs to be surrounded in quotes

(ValueWithoutQuotes)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.env.example at line 10, Wrap the NEXT_PUBLIC_STORE_NAME value in quotes in
the .env.example to prevent parsing issues with dotenv-like tools; update the
line containing NEXT_PUBLIC_STORE_NAME to use quoted value (e.g.,
NEXT_PUBLIC_STORE_NAME="Spree Store") so spaces are preserved and dotenv-linter
no longer flags it.


# Google Tag Manager (leave empty to disable)
GTM_ID=
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 3 additions & 4 deletions src/app/[country]/[locale]/(checkout)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -33,14 +34,12 @@ function CheckoutHeader() {
}

function CheckoutFooter() {
const { store } = useStore();
const currentYear = new Date().getFullYear();

return (
<footer className="py-4 text-sm text-gray-500 border-t border-gray-200 mt-auto">
<p>
&copy; {currentYear} {store?.name || "Spree Store"}. All rights
reserved.
&copy; {currentYear} {storeName}. All rights reserved.
</p>
</footer>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import type { StoreGiftCard } from "@spree/sdk";
import { useEffect, useState } from "react";
import {
CheckIcon,
Expand All @@ -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) {
Expand Down Expand Up @@ -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 (
<div className="bg-white rounded-xl border border-gray-200 p-6">
Expand Down Expand Up @@ -181,7 +163,7 @@ function GiftCardItem({ card }: { card: GiftCard }) {
}

export default function GiftCardsPage() {
const [cards, setCards] = useState<GiftCard[]>([]);
const [cards, setCards] = useState<StoreGiftCard[]>([]);
const [loading, setLoading] = useState(true);

useEffect(() => {
Expand Down
23 changes: 3 additions & 20 deletions src/contexts/StoreContext.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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";

Expand All @@ -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;
Expand Down Expand Up @@ -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<StoreStore | null>(null);
const [countries, setCountries] = useState<CountryWithMarket[]>([]);
const [loading, setLoading] = useState(true);
const pathnameRef = useRef(pathname);
Expand All @@ -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);

Expand Down Expand Up @@ -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 (
Expand Down
1 change: 0 additions & 1 deletion src/lib/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ export * from "./credit-cards";
export * from "./customer";
export * from "./orders";
export * from "./products";
export * from "./store";
export * from "./taxonomies";
12 changes: 11 additions & 1 deletion src/lib/data/orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
});
}

Expand Down
7 changes: 0 additions & 7 deletions src/lib/data/store.ts

This file was deleted.