Login, Sign Up, Log Out, and checkout & customer association

This commit is contained in:
cond0r
2021-02-05 10:31:04 +02:00
parent 612392aaba
commit dde09c5105
21 changed files with 276 additions and 43 deletions

View File

@@ -0,0 +1,24 @@
import { getConfig, ShopifyConfig } from '@framework/api'
import getCustomerIdQuery from '@framework/utils/queries/get-customer-id-query'
import Cookies from 'js-cookie'
async function getCustomerId({
customerToken: customerAccesToken,
config,
}: {
customerToken: string
config?: ShopifyConfig
}): Promise<number | undefined> {
config = getConfig(config)
const { data } = await config.fetch(getCustomerIdQuery, {
variables: {
customerAccesToken:
customerAccesToken || Cookies.get(config.customerCookie),
},
})
return data?.customer?.id
}
export default getCustomerId