Updated useCustomer and core types

This commit is contained in:
Luis Alvarez
2021-05-25 10:59:22 -05:00
parent 58d782b780
commit e7980e17f5
4 changed files with 26 additions and 14 deletions

View File

@@ -1,16 +1,16 @@
import { SWRHook } from '@commerce/utils/types'
import useCustomer, { UseCustomer } from '@commerce/customer/use-customer'
import type { Customer, CustomerData } from '../api/customers'
import type { CustomerHook } from '../types/customer'
export default useCustomer as UseCustomer<typeof handler>
export const handler: SWRHook<Customer | null> = {
export const handler: SWRHook<CustomerHook> = {
fetchOptions: {
url: '/api/bigcommerce/customers',
url: '/api/customer',
method: 'GET',
},
async fetcher({ options, fetch }) {
const data = await fetch<CustomerData | null>(options)
const data = await fetch(options)
return data?.customer ?? null
},
useHook: ({ useData }) => (input) => {