normalize data output in use-customer

Signed-off-by: Loan Laux <loan@outgrow.io>
This commit is contained in:
Loan Laux
2021-04-28 21:16:50 +04:00
parent ea9cfe9c02
commit 254659e7c0
7 changed files with 21 additions and 11 deletions

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 { viewerQuery } from '../utils'
import { viewerQuery, normalizeCustomer } from '../utils'
export default useCustomer as UseCustomer<typeof handler>
@@ -13,7 +13,7 @@ export const handler: SWRHook<Customer | null> = {
const data = await fetch<any | null>({
...options,
})
return data.viewer ?? null
return normalizeCustomer(data.viewer) ?? null
},
useHook: ({ useData }) => (input) => {
return useData({