/**
 * User actions
 */
import * as types from './types';

export const initRequest = () => {
  return (dispatch: any) => {
    dispatch({
      type: types.INIT_REQUEST,
      payload: {}
    });
  };
};

export const loginRequest = (email: any, password: any) => ({
  type: types.LOGIN_REQUEST,
  payload: { email, password }
});

export const loginSuccess = (user: any) => ({
  type: types.LOGIN_SUCCESS,
  payload: { user }
});

export const loginFail = (message: string) => ({
  type: types.LOGIN_FAIL,
  payload: { message }
});

export const logoutRequest = () => ({
  type: types.LOGOUT_REQUEST,
  payload: {}
});

export const logoutSuccess = () => ({
  type: types.LOGOUT_SUCCESS,
  payload: {}
});

export const logoutFail = (message: string) => ({
  type: types.LOGOUT_FAIL,
  payload: { message }
});

export const registerRequest = (params: any) => ({
  type: types.REGISTER_REQUEST,
  payload: {
    params
  }
});

export const registerSuccess = (user: any) => ({
  type: types.REGISTER_SUCCESS,
  payload: { user }
});

export const registerFail = (message: string) => ({
  type: types.LOGIN_FAIL,
  payload: { message }
});

export const getProfileRequest = () => ({
  type: types.GET_PROFILE_DETAILS_REQUEST,
  payload: {}
});

export const getProfileSuccess = (profile: any) => ({
  type: types.GET_PROFILE_DETAILS_SUCCESS,
  payload: {
    profile
  }
});

export const getProfileFail = (message: string) => ({
  type: types.GET_PROFILE_DETAILS_FAIL,
  payload: { message }
});

export const updateProfileRequest = (params: any) => ({
  
  type: types.UPDATE_PROFILE_DETAILS_REQUEST,
  payload: { params }
});

export const updateProfileSuccess = () => ({
  type: types.UPDATE_PROFILE_DETAILS_SUCCESS,
  payload: {}
});

export const updateProfileFail = (message: string) => ({
  type: types.UPDATE_PROFILE_DETAILS_FAIL,
  payload: { message }
});

export const changePasswordRequest = (params: any) => ({
  type: types.CHANGE_PASSWORD_REQUEST,
  payload: { params }
});

export const changePasswordSuccess = () => ({
  type: types.CHANGE_PASSWORD_SUCCESS,
  payload: {}
});

export const changePasswordFail = (message: string) => ({
  type: types.CHANGE_PASSWORD_FAIL,
  payload: { message }
});

export const resetPasswordRequest = (params: any) => ({
  type: types.RESET_PASSWORD_REQUEST,
  payload: { params }
});

export const resetPasswordSuccess = () => ({
  type: types.RESET_PASSWORD_SUCCESS,
  payload: {}
});

export const resetPasswordFail = (message: string) => ({
  type: types.RESET_PASSWORD_FAIL,
  payload: { message }
});

export const forgotPasswordRequest = (params: any) => ({
  type: types.FORGOT_PASSWORD_REQUEST,
  payload: { params }
});

export const forgotPasswordSuccess = () => ({
  type: types.FORGOT_PASSWORD_SUCCESS,
  payload: {}
});

export const forgotPasswordFail = (message: string) => ({
  type: types.FORGOT_PASSWORD_FAIL,
  payload: { message }
});
