saleor: fix the session handling

This commit is contained in:
Zaiste 2021-05-12 11:40:35 +02:00
parent e0ee2580bd
commit 3b559e9853
No known key found for this signature in database
GPG Key ID: 15DF7EBC7F2FFE35
4 changed files with 21932 additions and 23763 deletions

View File

@ -18,8 +18,7 @@ const countItem = (count: number, item: LineItem) => count + item.quantity
const UserNav: FC<Props> = ({ className }) => {
const { data } = useCart()
let customer;
// const { data: customer } = useCustomer()
const { data: customer } = useCustomer()
const { toggleSidebar, closeSidebarIfPresent, openModal } = useUI()
const itemsCount = data?.lineItems.reduce(countItem, 0) ?? 0

View File

@ -1,7 +1,7 @@
import useCustomer, { UseCustomer } from '@commerce/customer/use-customer'
import { Customer } from '@commerce/types'
import { SWRHook } from '@commerce/utils/types'
import { getCustomerQuery, getCSRFToken } from '../utils'
import { getCustomerQuery } from '../utils'
export default useCustomer as UseCustomer<typeof handler>
@ -12,9 +12,9 @@ export const handler: SWRHook<Customer | null> = {
async fetcher({ options, fetch }) {
const data = await fetch<any | null>({
...options,
variables: { customerAccessToken: getCSRFToken() },
variables: {},
})
return data.customer ?? null
return data.me ?? null
},
useHook: ({ useData }) => (input) => {
return useData({

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff