forked from crowetic/commerce
* fix update cart item * update types * update checkout * update get-page, cleanup types * revert change to incorrect file * cleanup Co-authored-by: Greg Hoskin <greghoskin@Gregs-MacBook-Pro.local>
28 lines
733 B
TypeScript
28 lines
733 B
TypeScript
import useCustomer, { UseCustomer } from '@commerce/customer/use-customer'
|
|
import { SWRHook } from '@commerce/utils/types'
|
|
import { normalizeCustomer } from '../utils/normalize'
|
|
import type { CustomerHook } from '../types/customer'
|
|
|
|
export default useCustomer as UseCustomer<typeof handler>
|
|
|
|
export const handler: SWRHook<CustomerHook> = {
|
|
fetchOptions: {
|
|
query: 'account',
|
|
method: 'get',
|
|
},
|
|
async fetcher({ options, fetch }) {
|
|
const data = await fetch<any | null>({
|
|
...options,
|
|
})
|
|
return data ? normalizeCustomer(data) : null
|
|
},
|
|
useHook: ({ useData }) => (input) => {
|
|
return useData({
|
|
swrOptions: {
|
|
revalidateOnFocus: false,
|
|
...input?.swrOptions,
|
|
},
|
|
})
|
|
},
|
|
}
|