cpLoginAction.js 1.17 KB
import axios from "axios";
import { CLEAR_ERRORS } from "../constants/cpLoginConstants";

export const finishChannelPartnerOtpLogin = async ({ mobileNumber, mahareraNumber, oneTimePassword }) => {
  // 1. invoke the api to start the login with otp process.
  const config = {
    headers: {
      "Content-Type": "application/json"
    }
  };

  return await axios.post(
    `${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/users-permissions/users/channel-partner/finish-otp-login`,
    {
      mobileNumber,
      mahareraNumber,
      oneTimePassword
    },
    config
  );
};

export const startChannelPartnerOtpLogin = async ({ mobileNumber, mahareraNumber }) => {
  // 1. invoke the api to start the login with otp process.
  const config = {
    headers: {
      "Content-Type": "application/json"
    }
  };

  const startOtpLoginResponse = await axios.post(
    `${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/users-permissions/users/channel-partner/start-otp-login`,
    {
      mobileNumber,
      mahareraNumber
    },
    config
  );

  return startOtpLoginResponse;
};

// Clear errors
export const clearErrors = () => async dispatch => {
  dispatch({
    type: CLEAR_ERRORS
  });
};