mirror of
https://github.com/vercel/commerce.git
synced 2025-06-19 21:51: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 cartId = cookies[config.cartCookie]
|
||||
const customerToken = cookies[config.customerCookie]
|
||||
let checkouturl: string
|
||||
|
||||
if (!cartId) {
|
||||
res.redirect('/cart')
|
||||
return
|
||||
@ -27,8 +25,14 @@ const checkout: CheckoutEndpoint['handlers']['checkout'] = async ({
|
||||
)
|
||||
const customerId =
|
||||
customerToken && (await getCustomerId({ customerToken, config }))
|
||||
|
||||
//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 payload = {
|
||||
iss: config.storeApiClientId,
|
||||
@ -40,17 +44,15 @@ const checkout: CheckoutEndpoint['handlers']['checkout'] = async ({
|
||||
channel_id: config.storeChannelId,
|
||||
redirect_to: data.checkout_url,
|
||||
}
|
||||
let token = jwt.sign(payload, config.storeApiClientSecret, {
|
||||
let token = jwt.sign(payload, config.storeApiClientSecret!, {
|
||||
algorithm: 'HS256',
|
||||
})
|
||||
checkouturl = `${config.storeUrl}/login/token/${token}`
|
||||
} else {
|
||||
checkouturl = data.checkout_url
|
||||
}
|
||||
|
||||
if (fullCheckout) {
|
||||
res.redirect(checkouturl)
|
||||
return
|
||||
let checkouturl = `${config.storeUrl}/login/token/${token}`
|
||||
console.log('checkouturl', checkouturl)
|
||||
if (fullCheckout) {
|
||||
res.redirect(checkouturl)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: make the embedded checkout work too!
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { GetCustomerIdQuery } from '../../../../schema'
|
||||
import type { BigcommerceConfig } from '../../..'
|
||||
import type { GetCustomerIdQuery } from '../../schema'
|
||||
import type { BigcommerceConfig } from '../'
|
||||
|
||||
export const getCustomerIdQuery = /* GraphQL */ `
|
||||
query getCustomerId {
|
||||
|
1
next-env.d.ts
vendored
1
next-env.d.ts
vendored
@ -1,2 +1,3 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/types/global" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user