Skip to content

Instantly share code, notes, and snippets.

@Jahans3
Last active January 16, 2018 01:24
Show Gist options
  • Save Jahans3/b1ea98aa0d4f33b6d734abf492e4a2b3 to your computer and use it in GitHub Desktop.
Save Jahans3/b1ea98aa0d4f33b6d734abf492e4a2b3 to your computer and use it in GitHub Desktop.
const signUpRequest: Function = (): { type: string } => ({
type: actionTypes.SIGN_UP_REQUEST
})
const signUpSuccess: Function = ({ data }: { data: Object }): { type: string, payload: { data: Object } } => ({
type: actionTypes.SIGN_UP_SUCCESS,
payload: { data }
})
const signUpFailure: Function = ({ error }: { error: Object }): { type: string, payload: { error: Object } } => ({
type: actionTypes.SIGN_UP_FAILURE,
payload: { error }
})
export const signUp: Function = ({ username, password, email, phone }: { username: string, password: string, email: string, phone: string }): Function => async (dispatch: Function): Promise<void> => {
dispatch(signUpRequest())
try {
const data = await Auth.signUp(username, password, email, phone)
dispatch(signUpSuccess({ data }))
} catch (error) {
dispatch(signUpFailure({ error }))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment