mirror of
https://github.com/vercel/commerce.git
synced 2025-07-25 11:11:24 +00:00
(feat): create aquilacms provider
(style): replace all bigcommerce name by aquilacms
This commit is contained in:
34
framework/aquilacms/customer/get-customer-id.ts
Normal file
34
framework/aquilacms/customer/get-customer-id.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { GetCustomerIdQuery } from '../schema'
|
||||
import { AquilacmsConfig, getConfig } from '../api'
|
||||
|
||||
export const getCustomerIdQuery = /* GraphQL */ `
|
||||
query getCustomerId {
|
||||
customer {
|
||||
entityId
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
async function getCustomerId({
|
||||
customerToken,
|
||||
config,
|
||||
}: {
|
||||
customerToken: string
|
||||
config?: AquilacmsConfig
|
||||
}): Promise<number | undefined> {
|
||||
config = getConfig(config)
|
||||
|
||||
const { data } = await config.fetch<GetCustomerIdQuery>(
|
||||
getCustomerIdQuery,
|
||||
undefined,
|
||||
{
|
||||
headers: {
|
||||
cookie: `${config.customerCookie}=${customerToken}`,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
return data?.customer?.entityId
|
||||
}
|
||||
|
||||
export default getCustomerId
|
Reference in New Issue
Block a user