mirror of
https://github.com/vercel/commerce.git
synced 2025-06-19 13:41:22 +00:00
21 lines
678 B
TypeScript
21 lines
678 B
TypeScript
import { useHook, useMutationHook } from '../utils/use-hook'
|
|
import { mutationFetcher } from '../utils/default-fetcher'
|
|
import type { HookFetcherFn, MutationHook } from '../utils/types'
|
|
import type { SignupHook } from '../types/signup'
|
|
import type { Provider } from '..'
|
|
|
|
export type UseSignup<
|
|
H extends MutationHook<SignupHook<any>> = MutationHook<SignupHook>
|
|
> = ReturnType<H['useHook']>
|
|
|
|
export const fetcher: HookFetcherFn<SignupHook> = mutationFetcher
|
|
|
|
const fn = (provider: Provider) => provider.auth?.useSignup!
|
|
|
|
const useSignup: UseSignup = (...args) => {
|
|
const hook = useHook(fn)
|
|
return useMutationHook({ fetcher, ...hook })(...args)
|
|
}
|
|
|
|
export default useSignup
|