add customer token and id to localstorage

This commit is contained in:
DuvCharles 2022-12-14 14:54:15 +01:00 committed by Hadrien Lucas
parent b01b327357
commit ad634950a8
2 changed files with 14 additions and 4 deletions

View File

@ -1,5 +1,4 @@
export const API_URL = process.env.NEXT_PUBLIC_SYLIUS_API_URL
//export const API_CHANNEL = process.env.NEXT_PUBLIC_SALEOR_CHANNEL
//export const CHECKOUT_ID_COOKIE = 'saleor.CheckoutID'
//export const SALEOR_TOKEN = 'saleor.Token'
//export const SALEOR_CRSF_TOKEN = 'saleor.CSRFToken'
export const SYLIUS_CUSTOMER_TOKEN = 'sylius_customerToken'
export const SYLIUS_CUSTOMER_ID = 'sylius_customerId'

View File

@ -0,0 +1,11 @@
import { SYLIUS_CUSTOMER_ID } from '../../const'
export const getCustomerId = () => localStorage.getItem(SYLIUS_CUSTOMER_ID)
export const setCustomerId = (id: string | null) => {
if (!id) {
localStorage.removeItem(SYLIUS_CUSTOMER_ID)
} else {
localStorage.setItem(SYLIUS_CUSTOMER_ID, id)
}
}