-
-
Notifications
You must be signed in to change notification settings - Fork 543
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0d3741
commit ec97290
Showing
18 changed files
with
242 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
"use server" | ||
|
||
import { sdk } from "@lib/config" | ||
import { cache } from "react" | ||
import { HttpTypes } from "@medusajs/types" | ||
import { getAuthHeaders, getCacheOptions } from "./cookies" | ||
|
||
export const listCartShippingMethods = async (cartId: string) => { | ||
const headers = { | ||
...(await getAuthHeaders()), | ||
} | ||
|
||
const next = { | ||
...(await getCacheOptions("fulfillment")), | ||
} | ||
|
||
// Shipping actions | ||
export const listCartShippingMethods = cache(async function (cartId: string) { | ||
return sdk.store.fulfillment | ||
.listCartOptions({ cart_id: cartId }, { next: { tags: ["shipping"] } }) | ||
return sdk.client | ||
.fetch<HttpTypes.StoreShippingOptionListResponse>( | ||
`/store/shipping-options`, | ||
{ | ||
method: "GET", | ||
query: { cart_id: cartId }, | ||
headers, | ||
next, | ||
} | ||
) | ||
.then(({ shipping_options }) => shipping_options) | ||
.catch(() => { | ||
return null | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
"use server" | ||
import { cookies } from "next/headers" | ||
import { cookies as nextCookies } from "next/headers" | ||
import { redirect } from "next/navigation" | ||
|
||
export async function resetOnboardingState(orderId: string) { | ||
(await cookies()).set("_medusa_onboarding", "false", { maxAge: -1 }) | ||
const cookies = await nextCookies() | ||
cookies.set("_medusa_onboarding", "false", { maxAge: -1 }) | ||
redirect(`http://localhost:7001/a/orders/${orderId}`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,30 @@ | ||
"use server" | ||
|
||
import { sdk } from "@lib/config" | ||
import { cache } from "react" | ||
|
||
// Shipping actions | ||
export const listCartPaymentMethods = cache(async function (regionId: string) { | ||
return sdk.store.payment | ||
.listPaymentProviders( | ||
{ region_id: regionId }, | ||
{ next: { tags: ["payment_providers"] } } | ||
import { getAuthHeaders, getCacheOptions } from "./cookies" | ||
import { HttpTypes } from "@medusajs/types" | ||
|
||
export const listCartPaymentMethods = async (regionId: string) => { | ||
const headers = { | ||
...(await getAuthHeaders()), | ||
} | ||
|
||
const next = { | ||
...(await getCacheOptions("payment_providers")), | ||
} | ||
|
||
return sdk.client | ||
.fetch<HttpTypes.StorePaymentProviderListResponse>( | ||
`/store/payment-providers`, | ||
{ | ||
method: "GET", | ||
query: { region_id: regionId }, | ||
headers, | ||
next, | ||
} | ||
) | ||
.then(({ payment_providers }) => payment_providers) | ||
.catch(() => { | ||
return null | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.