mirror of
https://github.com/vercel/commerce.git
synced 2025-06-20 06:01:21 +00:00
fix typescript errors
This commit is contained in:
parent
1182ef523d
commit
5799915c0b
@ -13,8 +13,6 @@ const checkout: CheckoutEndpoint['handlers']['checkout'] = async ({
|
|||||||
const { cookies } = req
|
const { cookies } = req
|
||||||
const cartId = cookies[config.cartCookie]
|
const cartId = cookies[config.cartCookie]
|
||||||
const customerToken = cookies[config.customerCookie]
|
const customerToken = cookies[config.customerCookie]
|
||||||
let checkouturl: string
|
|
||||||
|
|
||||||
if (!cartId) {
|
if (!cartId) {
|
||||||
res.redirect('/cart')
|
res.redirect('/cart')
|
||||||
return
|
return
|
||||||
@ -27,8 +25,14 @@ const checkout: CheckoutEndpoint['handlers']['checkout'] = async ({
|
|||||||
)
|
)
|
||||||
const customerId =
|
const customerId =
|
||||||
customerToken && (await getCustomerId({ customerToken, config }))
|
customerToken && (await getCustomerId({ customerToken, config }))
|
||||||
|
|
||||||
//if there is a customer create a jwt token
|
//if there is a customer create a jwt token
|
||||||
if (customerId >= 0) {
|
if (!customerId) {
|
||||||
|
if (fullCheckout) {
|
||||||
|
res.redirect(data.checkout_url)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
const dateCreated = Math.round(new Date().getTime() / 1000)
|
const dateCreated = Math.round(new Date().getTime() / 1000)
|
||||||
const payload = {
|
const payload = {
|
||||||
iss: config.storeApiClientId,
|
iss: config.storeApiClientId,
|
||||||
@ -40,18 +44,16 @@ const checkout: CheckoutEndpoint['handlers']['checkout'] = async ({
|
|||||||
channel_id: config.storeChannelId,
|
channel_id: config.storeChannelId,
|
||||||
redirect_to: data.checkout_url,
|
redirect_to: data.checkout_url,
|
||||||
}
|
}
|
||||||
let token = jwt.sign(payload, config.storeApiClientSecret, {
|
let token = jwt.sign(payload, config.storeApiClientSecret!, {
|
||||||
algorithm: 'HS256',
|
algorithm: 'HS256',
|
||||||
})
|
})
|
||||||
checkouturl = `${config.storeUrl}/login/token/${token}`
|
let checkouturl = `${config.storeUrl}/login/token/${token}`
|
||||||
} else {
|
console.log('checkouturl', checkouturl)
|
||||||
checkouturl = data.checkout_url
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fullCheckout) {
|
if (fullCheckout) {
|
||||||
res.redirect(checkouturl)
|
res.redirect(checkouturl)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: make the embedded checkout work too!
|
// TODO: make the embedded checkout work too!
|
||||||
const html = `
|
const html = `
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { GetCustomerIdQuery } from '../../../../schema'
|
import type { GetCustomerIdQuery } from '../../schema'
|
||||||
import type { BigcommerceConfig } from '../../..'
|
import type { BigcommerceConfig } from '../'
|
||||||
|
|
||||||
export const getCustomerIdQuery = /* GraphQL */ `
|
export const getCustomerIdQuery = /* GraphQL */ `
|
||||||
query getCustomerId {
|
query getCustomerId {
|
||||||
|
1
next-env.d.ts
vendored
1
next-env.d.ts
vendored
@ -1,2 +1,3 @@
|
|||||||
/// <reference types="next" />
|
/// <reference types="next" />
|
||||||
/// <reference types="next/types/global" />
|
/// <reference types="next/types/global" />
|
||||||
|
/// <reference types="next/image-types/global" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user