mirror of
https://github.com/vercel/commerce.git
synced 2025-06-20 06:01:21 +00:00
saleor: fix the session handling
This commit is contained in:
parent
e0ee2580bd
commit
3b559e9853
@ -18,8 +18,7 @@ const countItem = (count: number, item: LineItem) => count + item.quantity
|
|||||||
|
|
||||||
const UserNav: FC<Props> = ({ className }) => {
|
const UserNav: FC<Props> = ({ className }) => {
|
||||||
const { data } = useCart()
|
const { data } = useCart()
|
||||||
let customer;
|
const { data: customer } = useCustomer()
|
||||||
// const { data: customer } = useCustomer()
|
|
||||||
const { toggleSidebar, closeSidebarIfPresent, openModal } = useUI()
|
const { toggleSidebar, closeSidebarIfPresent, openModal } = useUI()
|
||||||
const itemsCount = data?.lineItems.reduce(countItem, 0) ?? 0
|
const itemsCount = data?.lineItems.reduce(countItem, 0) ?? 0
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import useCustomer, { UseCustomer } from '@commerce/customer/use-customer'
|
import useCustomer, { UseCustomer } from '@commerce/customer/use-customer'
|
||||||
import { Customer } from '@commerce/types'
|
import { Customer } from '@commerce/types'
|
||||||
import { SWRHook } from '@commerce/utils/types'
|
import { SWRHook } from '@commerce/utils/types'
|
||||||
import { getCustomerQuery, getCSRFToken } from '../utils'
|
import { getCustomerQuery } from '../utils'
|
||||||
|
|
||||||
export default useCustomer as UseCustomer<typeof handler>
|
export default useCustomer as UseCustomer<typeof handler>
|
||||||
|
|
||||||
@ -12,9 +12,9 @@ export const handler: SWRHook<Customer | null> = {
|
|||||||
async fetcher({ options, fetch }) {
|
async fetcher({ options, fetch }) {
|
||||||
const data = await fetch<any | null>({
|
const data = await fetch<any | null>({
|
||||||
...options,
|
...options,
|
||||||
variables: { customerAccessToken: getCSRFToken() },
|
variables: {},
|
||||||
})
|
})
|
||||||
return data.customer ?? null
|
return data.me ?? null
|
||||||
},
|
},
|
||||||
useHook: ({ useData }) => (input) => {
|
useHook: ({ useData }) => (input) => {
|
||||||
return useData({
|
return useData({
|
||||||
|
17251
framework/saleor/schema.d.ts
vendored
17251
framework/saleor/schema.d.ts
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user