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
4ff10864bb
commit
701c626597
@ -25,10 +25,19 @@ const checkout: CheckoutEndpoint['handlers']['checkout'] = async ({
|
||||
method: 'POST',
|
||||
}
|
||||
)
|
||||
const customerId =
|
||||
customerToken && (await getCustomerId({ customerToken, config }))
|
||||
const customerId: string =
|
||||
(customerToken && (await getCustomerId({ customerToken, config }))) ?? ''
|
||||
|
||||
console.log('customerId', customerId)
|
||||
console.log('check', customerId == 'undefined')
|
||||
|
||||
//if there is a customer create a jwt token
|
||||
if (customerId >= 0) {
|
||||
if (customerId == 'undefined') {
|
||||
if (fullCheckout) {
|
||||
res.redirect(data.checkout_url)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
const dateCreated = Math.round(new Date().getTime() / 1000)
|
||||
const payload = {
|
||||
iss: config.storeApiClientId,
|
||||
@ -40,17 +49,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
|
||||
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