mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
rename folder
This commit is contained in:
25
providers/saleor/utils/checkout-create.ts
Normal file
25
providers/saleor/utils/checkout-create.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import Cookies from 'js-cookie'
|
||||
|
||||
import * as mutation from './mutations'
|
||||
import { CheckoutCreate } from '../schema'
|
||||
import { CHECKOUT_ID_COOKIE } from '@framework/const'
|
||||
|
||||
export const checkoutCreate = async (fetch: any): Promise<CheckoutCreate> => {
|
||||
const data = await fetch({ query: mutation.CheckoutCreate })
|
||||
const checkout = data.checkoutCreate?.checkout
|
||||
const checkoutId = checkout?.id
|
||||
const checkoutToken = checkout?.token
|
||||
|
||||
const value = `${checkoutId}:${checkoutToken}`
|
||||
|
||||
if (checkoutId) {
|
||||
const options = {
|
||||
expires: 60 * 60 * 24 * 30,
|
||||
}
|
||||
Cookies.set(CHECKOUT_ID_COOKIE, value, options)
|
||||
}
|
||||
|
||||
return checkout
|
||||
}
|
||||
|
||||
export default checkoutCreate
|
Reference in New Issue
Block a user