(config: UseSignUpConfig = {})
| 28 | } |
| 29 | |
| 30 | export function useSignUp(config: UseSignUpConfig = {}): UseSignUpResponse { |
| 31 | const client = useClient() |
| 32 | const [state, setState] = useState<UseSignUpState>(initialState) |
| 33 | |
| 34 | const execute = useCallback( |
| 35 | async (credentials: UserCredentials, options?: UseSignUpOptions) => { |
| 36 | setState({ ...initialState, fetching: true }) |
| 37 | const { error, session, user } = await client.auth.signUp( |
| 38 | credentials, |
| 39 | options ?? config.options, |
| 40 | ) |
| 41 | const res = { error, session, user } |
| 42 | setState({ ...res, fetching: false }) |
| 43 | return res |
| 44 | }, |
| 45 | [client, config], |
| 46 | ) |
| 47 | |
| 48 | return [state, execute] |
| 49 | } |
no test coverage detected