mirror of
https://github.com/vercel/commerce.git
synced 2025-06-08 01:06:59 +00:00
chore: 🤖 update ENDPOINT env in cart
This commit is contained in:
parent
614369a74b
commit
8840bb7b21
@ -1,6 +1,6 @@
|
|||||||
import type { CheckoutEndpoint } from '.'
|
import type { CheckoutEndpoint } from '.'
|
||||||
import { Orders } from '@commercelayer/sdk'
|
|
||||||
import getCredentials from '../../utils/getCredentials'
|
import getCredentials from '../../utils/getCredentials'
|
||||||
|
import { Order } from '@commercelayer/sdk'
|
||||||
|
|
||||||
const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({
|
const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({
|
||||||
req,
|
req,
|
||||||
@ -18,7 +18,7 @@ const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({
|
|||||||
|
|
||||||
const { ENDPOINT } = getCredentials()
|
const { ENDPOINT } = getCredentials()
|
||||||
if (orderId && accessToken) {
|
if (orderId && accessToken) {
|
||||||
const clOrder = await Orders.withCredentials({ ENDPOINT, accessToken })
|
const clOrder = await Order.withCredentials({ endpoint, accessToken })
|
||||||
.includes('lineItems')
|
.includes('lineItems')
|
||||||
.find(orderId as string, { rawResponse: true })
|
.find(orderId as string, { rawResponse: true })
|
||||||
const checkoutUrl = clOrder.data.attributes.checkout_url
|
const checkoutUrl = clOrder.data.attributes.checkout_url
|
||||||
|
@ -15,8 +15,8 @@ export const handler: MutationHook<any> = {
|
|||||||
},
|
},
|
||||||
async fetcher({ input }) {
|
async fetcher({ input }) {
|
||||||
const localOrderId = localStorage.getItem('CL_ORDER_ID')
|
const localOrderId = localStorage.getItem('CL_ORDER_ID')
|
||||||
const { accessToken, endpoint } = getCredentials()
|
const { accessToken, ENDPOINT } = getCredentials()
|
||||||
const organization = getOrganizationSlug(endpoint).organization
|
const organization = getOrganizationSlug(ENDPOINT).organization
|
||||||
const sdk = CLSdk({
|
const sdk = CLSdk({
|
||||||
accessToken,
|
accessToken,
|
||||||
organization,
|
organization,
|
||||||
|
@ -16,7 +16,7 @@ export const handler: SWRHook<any> = {
|
|||||||
async fetcher() {
|
async fetcher() {
|
||||||
const id = localStorage.getItem('CL_ORDER_ID') || ''
|
const id = localStorage.getItem('CL_ORDER_ID') || ''
|
||||||
const credentials = getCredentials()
|
const credentials = getCredentials()
|
||||||
const organization = getOrganizationSlug(credentials.endpoint).organization
|
const organization = getOrganizationSlug(credentials.ENDPOINT).organization
|
||||||
const sdk = CLSdk({
|
const sdk = CLSdk({
|
||||||
accessToken: credentials.accessToken,
|
accessToken: credentials.accessToken,
|
||||||
organization,
|
organization,
|
||||||
@ -57,7 +57,6 @@ export const handler: SWRHook<any> = {
|
|||||||
({ useData }) =>
|
({ useData }) =>
|
||||||
() => {
|
() => {
|
||||||
const response = useData()
|
const response = useData()
|
||||||
console.log('response', response)
|
|
||||||
return useMemo(
|
return useMemo(
|
||||||
() =>
|
() =>
|
||||||
Object.create(response, {
|
Object.create(response, {
|
||||||
|
@ -17,7 +17,7 @@ export const handler: MutationHook<any> = {
|
|||||||
async fetcher({ input: { id } }) {
|
async fetcher({ input: { id } }) {
|
||||||
const credentials = getCredentials()
|
const credentials = getCredentials()
|
||||||
const orderId = localStorage.getItem('CL_ORDER_ID')
|
const orderId = localStorage.getItem('CL_ORDER_ID')
|
||||||
const organization = getOrganizationSlug(credentials.endpoint).organization
|
const organization = getOrganizationSlug(credentials.ENDPOINT).organization
|
||||||
const sdk = CLSdk({
|
const sdk = CLSdk({
|
||||||
accessToken: credentials.accessToken,
|
accessToken: credentials.accessToken,
|
||||||
organization,
|
organization,
|
||||||
|
@ -17,7 +17,7 @@ export const handler: MutationHook<any> = {
|
|||||||
},
|
},
|
||||||
async fetcher({ input: { item, quantity } }) {
|
async fetcher({ input: { item, quantity } }) {
|
||||||
const credentials = getCredentials()
|
const credentials = getCredentials()
|
||||||
const organization = getOrganizationSlug(credentials.endpoint).organization
|
const organization = getOrganizationSlug(credentials.ENDPOINT).organization
|
||||||
const sdk = CLSdk({
|
const sdk = CLSdk({
|
||||||
accessToken: credentials.accessToken,
|
accessToken: credentials.accessToken,
|
||||||
organization,
|
organization,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user