chore: 🤖 update ENDPOINT env in cart

This commit is contained in:
Bolaji 2022-05-13 08:33:44 +01:00
parent 614369a74b
commit 8840bb7b21
No known key found for this signature in database
GPG Key ID: 00342E72694643BB
5 changed files with 7 additions and 8 deletions

View File

@ -1,6 +1,6 @@
import type { CheckoutEndpoint } from '.'
import { Orders } from '@commercelayer/sdk'
import getCredentials from '../../utils/getCredentials'
import { Order } from '@commercelayer/sdk'
const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({
req,
@ -18,7 +18,7 @@ const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({
const { ENDPOINT } = getCredentials()
if (orderId && accessToken) {
const clOrder = await Orders.withCredentials({ ENDPOINT, accessToken })
const clOrder = await Order.withCredentials({ endpoint, accessToken })
.includes('lineItems')
.find(orderId as string, { rawResponse: true })
const checkoutUrl = clOrder.data.attributes.checkout_url

View File

@ -15,8 +15,8 @@ export const handler: MutationHook<any> = {
},
async fetcher({ input }) {
const localOrderId = localStorage.getItem('CL_ORDER_ID')
const { accessToken, endpoint } = getCredentials()
const organization = getOrganizationSlug(endpoint).organization
const { accessToken, ENDPOINT } = getCredentials()
const organization = getOrganizationSlug(ENDPOINT).organization
const sdk = CLSdk({
accessToken,
organization,

View File

@ -16,7 +16,7 @@ export const handler: SWRHook<any> = {
async fetcher() {
const id = localStorage.getItem('CL_ORDER_ID') || ''
const credentials = getCredentials()
const organization = getOrganizationSlug(credentials.endpoint).organization
const organization = getOrganizationSlug(credentials.ENDPOINT).organization
const sdk = CLSdk({
accessToken: credentials.accessToken,
organization,
@ -57,7 +57,6 @@ export const handler: SWRHook<any> = {
({ useData }) =>
() => {
const response = useData()
console.log('response', response)
return useMemo(
() =>
Object.create(response, {

View File

@ -17,7 +17,7 @@ export const handler: MutationHook<any> = {
async fetcher({ input: { id } }) {
const credentials = getCredentials()
const orderId = localStorage.getItem('CL_ORDER_ID')
const organization = getOrganizationSlug(credentials.endpoint).organization
const organization = getOrganizationSlug(credentials.ENDPOINT).organization
const sdk = CLSdk({
accessToken: credentials.accessToken,
organization,

View File

@ -17,7 +17,7 @@ export const handler: MutationHook<any> = {
},
async fetcher({ input: { item, quantity } }) {
const credentials = getCredentials()
const organization = getOrganizationSlug(credentials.endpoint).organization
const organization = getOrganizationSlug(credentials.ENDPOINT).organization
const sdk = CLSdk({
accessToken: credentials.accessToken,
organization,