mirror of
https://github.com/vercel/commerce.git
synced 2025-06-07 16:56:59 +00:00
add sign up hook
This commit is contained in:
parent
5b29bf8c78
commit
daabb58fed
@ -1,5 +1,4 @@
|
||||
import { useCallback } from 'react'
|
||||
import useCustomer from '../customer/use-customer'
|
||||
import { MutationHook } from '@vercel/commerce/utils/types'
|
||||
import useSignup, { UseSignup } from '@vercel/commerce/auth/use-signup'
|
||||
|
||||
@ -7,13 +6,37 @@ export default useSignup as UseSignup<typeof handler>
|
||||
|
||||
export const handler: MutationHook<any> = {
|
||||
fetchOptions: {
|
||||
query: '',
|
||||
url: '/api/v2/shop/customers',
|
||||
method: 'POST',
|
||||
},
|
||||
async fetcher() {
|
||||
return null
|
||||
fetcher: async ({
|
||||
input: { firstName, lastName, email, password },
|
||||
options,
|
||||
fetch,
|
||||
}) => {
|
||||
await fetch({
|
||||
url: options.url,
|
||||
method: options.method,
|
||||
body: {
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
email: email,
|
||||
password: password,
|
||||
subscribedToNewsletter: false,
|
||||
},
|
||||
variables: {
|
||||
useToken: false,
|
||||
},
|
||||
})
|
||||
},
|
||||
useHook:
|
||||
({ fetch }) =>
|
||||
() =>
|
||||
() => {},
|
||||
() => {
|
||||
return useCallback(
|
||||
async function signup(input) {
|
||||
await fetch({ input })
|
||||
},
|
||||
[fetch]
|
||||
)
|
||||
},
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user