Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to storefront to always pass region id, cleanup #338

Merged
merged 4 commits into from
Jul 2, 2024
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.template
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ NEXT_PUBLIC_STRIPE_KEY=
NEXT_PUBLIC_PAYPAL_CLIENT_ID=

# Your MeiliSearch / Algolia keys. See – https://docs.medusajs.com/add-plugins/meilisearch or https://docs.medusajs.com/add-plugins/algolia
NEXT_PUBLIC_FEATURE_SEARCH_ENABLED=false
NEXT_PUBLIC_SEARCH_APP_ID=
NEXT_PUBLIC_SEARCH_ENDPOINT=http://127.0.0.1:7700
NEXT_PUBLIC_SEARCH_API_KEY=
Expand Down
2 changes: 0 additions & 2 deletions netlify.toml

This file was deleted.

8 changes: 2 additions & 6 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
const { withStoreConfig } = require("./store-config")
const store = require("./store.config.json")

/**
* @type {import('next').NextConfig}
*/
const nextConfig = withStoreConfig({
features: store.features,
const nextConfig = {
reactStrictMode: true,
images: {
remotePatterns: [
Expand All @@ -27,7 +23,7 @@ const nextConfig = withStoreConfig({
},
],
},
})
}

console.log("next.config.js", JSON.stringify(module.exports, null, 2))

Expand Down
13 changes: 4 additions & 9 deletions src/app/[countryCode]/(checkout)/checkout/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import CheckoutForm from "@modules/checkout/templates/checkout-form"
import CheckoutSummary from "@modules/checkout/templates/checkout-summary"
import { enrichLineItems, retrieveCart } from "@lib/data/cart"
import { HttpTypes } from "@medusajs/types"
import { getCustomer } from "@lib/data/customer"

export const metadata: Metadata = {
title: "Checkout",
Expand All @@ -18,10 +19,7 @@ const fetchCart = async () => {
}

if (cart?.items?.length) {
const enrichedItems = await enrichLineItems(
cart?.items,
cart?.currency_code
)
const enrichedItems = await enrichLineItems(cart?.items, cart?.region_id!)
cart.items = enrichedItems as HttpTypes.StoreCartLineItem[]
}

Expand All @@ -30,15 +28,12 @@ const fetchCart = async () => {

export default async function Checkout() {
const cart = await fetchCart()

if (!cart) {
return notFound()
}
const customer = await getCustomer()

return (
<div className="grid grid-cols-1 small:grid-cols-[1fr_416px] content-container gap-x-40 py-12">
<Wrapper cart={cart}>
<CheckoutForm />
<CheckoutForm cart={cart} customer={customer} />
</Wrapper>
<CheckoutSummary cart={cart} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function getOrder(id: string) {
return
}

const enrichedItems = await enrichLineItems(order.items, order.currency_code)
const enrichedItems = await enrichLineItems(order.items, order.region_id!)

return {
...order,
Expand Down
5 changes: 1 addition & 4 deletions src/app/[countryCode]/(main)/cart/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ const fetchCart = async () => {
}

if (cart?.items?.length) {
const enrichedItems = await enrichLineItems(
cart?.items,
cart?.currency_code
)
const enrichedItems = await enrichLineItems(cart?.items, cart?.region_id!)
cart.items = enrichedItems as HttpTypes.StoreCartLineItem[]
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/[countryCode]/(main)/order/confirmed/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function getOrder(id: string) {
return
}

const enrichedItems = await enrichLineItems(order.items, order.currency_code)
const enrichedItems = await enrichLineItems(order.items, order.region_id!)

return {
...order,
Expand Down
Loading
Loading