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/customer-token.ts
Normal file
25
providers/saleor/utils/customer-token.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import Cookies, { CookieAttributes } from 'js-cookie'
|
||||
import * as Const from '../const'
|
||||
|
||||
export const getToken = () => Cookies.get(Const.SALEOR_TOKEN)
|
||||
export const setToken = (token?: string, options?: CookieAttributes) => {
|
||||
setCookie(Const.SALEOR_TOKEN, token, options)
|
||||
}
|
||||
|
||||
export const getCSRFToken = () => Cookies.get(Const.SALEOR_CRSF_TOKEN)
|
||||
export const setCSRFToken = (token?: string, options?: CookieAttributes) => {
|
||||
setCookie(Const.SALEOR_CRSF_TOKEN, token, options)
|
||||
}
|
||||
|
||||
export const getCheckoutToken = () => Cookies.get(Const.CHECKOUT_ID_COOKIE)
|
||||
export const setCheckoutToken = (token?: string, options?: CookieAttributes) => {
|
||||
setCookie(Const.CHECKOUT_ID_COOKIE, token, options)
|
||||
}
|
||||
|
||||
const setCookie = (name: string, token?: string, options?: CookieAttributes) => {
|
||||
if (!token) {
|
||||
Cookies.remove(name)
|
||||
} else {
|
||||
Cookies.set(name, token, options ?? { expires: 60 * 60 * 24 * 30 })
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user