mirror of
https://github.com/vercel/commerce.git
synced 2025-04-02 18:15:54 +00:00
20 lines
621 B
TypeScript
20 lines
621 B
TypeScript
import { useHook, useMutationHook } from '../utils/use-hook'
|
|
import { mutationFetcher } from '../utils/default-fetcher'
|
|
import type { MutationHook, HookFetcherFn } from '../utils/types'
|
|
import type { Provider } from '..'
|
|
|
|
export type UseLogin<
|
|
H extends MutationHook<any, any, any> = MutationHook<null, {}, {}>
|
|
> = ReturnType<H['useHook']>
|
|
|
|
export const fetcher: HookFetcherFn<null, {}> = mutationFetcher
|
|
|
|
const fn = (provider: Provider) => provider.auth?.useLogin!
|
|
|
|
const useLogin: UseLogin = (...args) => {
|
|
const hook = useHook(fn)
|
|
return useMutationHook({ fetcher, ...hook })(...args)
|
|
}
|
|
|
|
export default useLogin
|