mirror of
https://github.com/vercel/commerce.git
synced 2025-05-16 14:36:59 +00:00
type: add type to MutationHook
This commit is contained in:
parent
5d1341d012
commit
daba93efbe
@ -1,10 +1,11 @@
|
||||
import { useCallback } from 'react'
|
||||
import { MutationHook } from '@vercel/commerce/utils/types'
|
||||
import useSignup, { UseSignup } from '@vercel/commerce/auth/use-signup'
|
||||
import { SignupHook } from '@vercel/commerce/types/signup'
|
||||
|
||||
export default useSignup as UseSignup<typeof handler>
|
||||
|
||||
export const handler: MutationHook<any> = {
|
||||
export const handler: MutationHook<SignupHook> = {
|
||||
fetchOptions: {
|
||||
url: '/api/v2/shop/customers',
|
||||
method: 'POST',
|
||||
@ -14,7 +15,7 @@ export const handler: MutationHook<any> = {
|
||||
options,
|
||||
fetch,
|
||||
}) => {
|
||||
await fetch({
|
||||
const data = await fetch({
|
||||
url: options.url,
|
||||
method: options.method,
|
||||
body: {
|
||||
@ -28,13 +29,15 @@ export const handler: MutationHook<any> = {
|
||||
useToken: false,
|
||||
},
|
||||
})
|
||||
return data
|
||||
},
|
||||
useHook:
|
||||
({ fetch }) =>
|
||||
() => {
|
||||
return useCallback(
|
||||
async function signup(input) {
|
||||
await fetch({ input })
|
||||
const data = await fetch({ input })
|
||||
return data
|
||||
},
|
||||
[fetch]
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user