1
0
mirror of https://github.com/vercel/commerce.git synced 2025-03-28 08:15:54 +00:00
2021-04-25 16:34:29 -05:00

22 lines
522 B
TypeScript

import Cookies, { CookieAttributes } from 'js-cookie'
import { SWELL_COOKIE_EXPIRE, SWELL_CUSTOMER_TOKEN_COOKIE } from '../const'
export const getCustomerToken = () => Cookies.get(SWELL_CUSTOMER_TOKEN_COOKIE)
export const setCustomerToken = (
token: string | null,
options?: CookieAttributes
) => {
if (!token) {
Cookies.remove(SWELL_CUSTOMER_TOKEN_COOKIE)
} else {
Cookies.set(
SWELL_CUSTOMER_TOKEN_COOKIE,
token,
options ?? {
expires: SWELL_COOKIE_EXPIRE,
}
)
}
}