Last active
January 16, 2018 01:24
-
-
Save Jahans3/b1ea98aa0d4f33b6d734abf492e4a2b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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