Guest User

Untitled

a guest
Jan 27th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. const signUpRequest: Function = (): { type: string } => ({
  2. type: actionTypes.SIGN_UP_REQUEST
  3. })
  4.  
  5. const signUpSuccess: Function = ({ data }: { data: Object }): { type: string, payload: { data: Object } } => ({
  6. type: actionTypes.SIGN_UP_SUCCESS,
  7. payload: { data }
  8. })
  9.  
  10. const signUpFailure: Function = ({ error }: { error: Object }): { type: string, payload: { error: Object } } => ({
  11. type: actionTypes.SIGN_UP_FAILURE,
  12. payload: { error }
  13. })
  14.  
  15. export const signUp: Function = ({ username, password, email, phone }: { username: string, password: string, email: string, phone: string }): Function => async (dispatch: Function): Promise<void> => {
  16. dispatch(signUpRequest())
  17.  
  18. try {
  19. const data = await Auth.signUp(username, password, email, phone)
  20. dispatch(signUpSuccess({ data }))
  21. } catch (error) {
  22. dispatch(signUpFailure({ error }))
  23. }
  24. }
Add Comment
Please, Sign In to add comment