mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
23 lines
503 B
TypeScript
23 lines
503 B
TypeScript
import { ActiveCustomerQuery } from '@framework/schema'
|
|
import { gql } from 'graphql-request'
|
|
import gglFetcher from 'src/utils/gglFetcher'
|
|
import useSWR from 'swr'
|
|
|
|
const query = gql`
|
|
query activeCustomer {
|
|
activeCustomer {
|
|
id
|
|
firstName
|
|
lastName
|
|
emailAddress
|
|
}
|
|
}
|
|
`
|
|
|
|
const useActiveCustomer = () => {
|
|
const { data, ...rest } = useSWR<ActiveCustomerQuery>([query], gglFetcher)
|
|
return { customer: data?.activeCustomer, ...rest }
|
|
}
|
|
|
|
export default useActiveCustomer
|