import Axios from "axios";

class usersService {
  constructor() {
    console.log("WRB Service Entry");
  }

  CreateUser(reqData) {
    localStorage.setItem("session_token", ``);
    return this.postAuxEnd("/createuser", reqData);
  }

  CompleteOauthLogin(reqData) {
    localStorage.setItem("session_token", ``);
    return this.postAuxEnd("/authlogin", reqData);
  }
  CompleteSignUp(reqData) {
    localStorage.setItem("session_token", ``);
    return this.postAuxEnd("/completesignuplink", reqData);
  }

  // FUNCTION TO GET USER CURRENT TASK DUE TIME
  getHomeDate() {
    var postData = {
      // uuid: localStorage.getItem("uid"),
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
    };
    return this.postAuxEnd("/dashdata", postData);
  }

  getRecentActivities(){
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 11202
    };
    return this.postAuxEnd("/recentactivities", postData);
  }

  logInUser(reqData) {
    localStorage.setItem("session_token", ``);
    return this.postAuxEnd("/userlogin", reqData);
  }

  authStart(reqData) {
    localStorage.setItem("session_token", ``);
    return this.postAuxEnd("/authstart", reqData);
  }

  authLogin(reqData) {
    localStorage.setItem("session_token", ``);
    return this.postAuxEnd("/authlogin", reqData);
  }

  marketJobData(reqData) {
    var postData = {
      uuid: localStorage.getItem("uuid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
    };
    return this.postAuxEnd("/getjobsdata", postData);
  }
  //
  getUserBankList(reqData) {
    var postData = {
      uuid: localStorage.getItem("uuid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
    };
    return this.postAuxEnd("/mybanklist", postData);
  }
  getUserWallets() {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
    };
    return this.postAuxEnd("/getwallets", postData);
  }
  getApiGate() {
    // localStorage.setItem("session_token", ``);
    return this.postAuxEnd("/apigate", null);
  }

  getLoadProfile() {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 0,
      limit: 100,
    };
    return this.postAuxEnd("/loadprofile", null);
  }

  getUploadedList() {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 1,
      limit: 20,
      action: 11309,
    };
    return this.postAuxEnd("/myfiles", postData);
  }

  getOffersList() {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 0,
      limit: 100,
    };
    return this.postAuxEnd("/offerslist", postData);
  }

  getPendingJob() {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 0,
      limit: 100,
    };
    return this.postAuxEnd("/pendingjob", postData);
  }

  /*
    getActiveJobList -  All available Jobs
     */
  getActiveJobList() {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 0,
      limit: 100,
    };
    return this.postAuxEnd("/getjobsdata", postData);
  }

  /*
    getMyActiveJobList  - List of jobs active under this user
     */
  // getMyActiveJobList(){
  //     var postData = {
  //         uuid: localStorage.getItem("uid"),
  //         member_id: localStorage.getItem("member_id"),
  //         sessionid: localStorage.getItem("session_token"),
  //         page:0,
  //         offset:0,
  //         limit :100
  //     };
  //     return this.postAuxEnd("/getjobsdata", postData);
  // }
  getHeroJBanners() {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 0,
      limit: 100,
    };
    return this.postAuxEnd("/homebanners", postData);
  }

  getRecentActivitiedData() {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 0,
      limit: 100,
    };
    return this.postAuxEnd("/dashrecent", postData);
  }
  getGetPendingJobs() {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 0,
      limit: 100,
    };
    return this.postAuxEnd("/getpendingjobs", postData);
  }

  getUsersCards() {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 0,
      limit: 100,
    };
    return this.postAuxEnd("/userscards", postData);
  }

  getCouponPending() {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 0,
      limit: 100,
    };
    return this.postAuxEnd("/couponpending", postData);
  }

  // API FUNCTION TO GET COUPON HISTORY
  getRecipient() {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 1,
      limit: 20,
      action: 11175,
    };
    return this.postAuxEnd("/recipients", postData);
  }

  //END POINT CALL FOR UPDATE PROFILE
  addRecipient(data) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      ...data,
    };
    return this.postAuxEnd("/addrecipient", postData);
  }

  // API FUNCTION TO GET SEND MONEY FEE
  getSendMoneyFee(amount) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      amount,
      action: 33025,
    };
    return this.postAuxEnd("/sendmoneyfee", postData);
  }

  // Start Credit for Cards
  getStartCredit(value) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 11053,
      ...value,
    };
    return this.postAuxEnd("/startcredit", postData);
  }

  // Paying using Previous Cards
  getPaidPrevCard(value) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 11056,
      ...value,
    };
    return this.postAuxEnd("/payprevcard", postData);
  }

  // Paying using New Card
  getPaidNewCard(value) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 11054,
      ...value,
    };
    return this.postAuxEnd("/paynewcard", postData);
  }

  getFamilySampleTasks() {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      limit: 30,
      offset: 0,
      action: 22027,
    };
    return this.postAuxEnd("/familysampletasks", postData);
  }

  sendFamilySuggestedTasks(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 13010,
      ...reqData,
    };
    return this.postAuxEnd("/familysuggesttasks", postData);
  }

  // Family Manage
  ManageFamily(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 22025,
      ...reqData,
    };
    return this.postAuxEnd("/familymanage", postData);
  }

  // Family Tasks
  ManageTasks(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      job_mode: "ACTIVE",
      limit: 30,
      offset: 0,
      action: 13008,
      ...reqData,
    };
    return this.postAuxEnd("/jobmanageractive", postData);
  }

  // Family Waitlist
  ManageFamilyWaitlist() {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 13010,
      limit: 30,
      offset: 0,
    };
    return this.postAuxEnd("/familywaitingtasks", postData);
  }

  ManageFamilyPending() {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 0,
      offset: 0,
      limit: 100,
    };
    return this.postAuxEnd("/jobmanageroffers", postData);
  }

  // Task for the person doing the job
  getMyActiveTaskList() {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 0,
      offset: 0,
      limit: 100,
      allstatus: 0
    };
    return this.postAuxEnd("/activetaskslist", postData);
  }
  getMyActiveJobList() {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      job_mode: "ACTIVE",
      page: 0,
      offset: 0,
      limit: 100,
    };
    return this.postAuxEnd("/jobmanageractive", postData);
  }

  getMyPastDueJobList() {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      job_mode: "PASTDUE",
      page: 0,
      offset: 0,
      limit: 100,
    };
    return this.postAuxEnd("/jobmanageractive", postData);
  }
  getMyReviewDueJobList() {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      job_mode: "REVIEW",
      page: 0,
      offset: 0,
      limit: 100,
    };
    return this.postAuxEnd("/jobmanageractive", postData);
  }

  getMyPendingJobList() {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 0,
      offset: 0,
      limit: 100,
    };
    return this.postAuxEnd("/jobmanageroffers", postData);
  }
  //
  getResourceList() {
    // jobs you have shown inteterest in
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 0,
      offset: 0,
      limit: 100,
    };
    return this.postAuxEnd("/resources", postData);
  }

  // ASK QUESTION RESOURCES
  askResourcesResult(reqData) {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 22010,
      ...reqData,
    };
    return this.postAuxEnd("/askresources", postData);
  }

  getMyWiatingJobList() {
    // jobs you have shown inteterest in
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 0,
      offset: 0,
      limit: 100,
    };
    return this.postAuxEnd("/waitinginterest", postData);
  }
  getMyJobList(reqData = {}) {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 0,
      offset: 0,
      limit: 100,
      ...reqData,
    };
    return this.postAuxEnd("/jobmanagerlist", postData);
  }
  // API FUNCTION TO GET COUPON HISTORY
  getCouponHx() {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 1,
      limit: 20,
      action: 85025,
    };
    return this.postAuxEnd("/couponhx", postData);
  }

  getPurchaseHx() {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 1,
      limit: 20,
      action: 15049,
    };
    return this.postAuxEnd("/purchasehx", postData);
  }

  // API FUNCTION TO GET PAYMENT HISTORY
  getPaymentHx() {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 1,
      limit: 20,
      action: 15046,
    };
    return this.postAuxEnd("/paymenthx", postData);
  }

  // API FUNCTION TO GET PAYMENT HISTORY
  sendMoney(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 33020,
      ...reqData,
    };
    return this.postAuxEnd("/sendmoney", postData);
  }

  //END POINT CALL FOR REFERRAL HISTORY
  getReferralHx() {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      offset: 1,
      limit: 100,
      action: 11064,
    };
    return this.postAuxEnd("/refferhx", postData);
  }

  //END POINT CALL FOR UPDATE PROFILE
  updateProfile(post) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 5031,
      ...post,
    };
    return this.postAuxEnd("/updateprofile", postData);
  }

  //END POINT CALL FOR GETTING USER PROFILE
  loadProfile(post) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
    };
    return this.postAuxEnd("/loadprofile", postData);
  }

  getFamilyList() {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 0,
      limit: 100,
    };
    return this.postAuxEnd("/familylist", postData);
  }

  getFamilyAdd() {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 0,
      limit: 100,
    };
    return this.postAuxEnd("/familyadd", postData);
  }

  getFamilyUpdate() {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 0,
      limit: 100,
    };
    return this.postAuxEnd("/familyupdate", postData);
  }

  getFamilyManage() {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      page: 0,
      limit: 100,
    };
    return this.postAuxEnd("/familymanage", postData);
  }

  // END POINT CALL FOR ACCOUNT TOP
  startTopUp(post) {
    alert("WHY ARE WE CALLING THIS ?");
    // var postData = {
    //   uid: localStorage.getItem("uid"),
    //   member_id: localStorage.getItem("member_id"),
    //   sessionid: localStorage.getItem("session_token"),
    //   action: 11062,
    //   ...post,
    // };
    // console.log("starttopup",postData);
    // return this.postAuxEnd("/starttopup", postData);
  }

  resultTopUp(post) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: Number(localStorage.getItem("member_id")),
      sessionid: localStorage.getItem("session_token"),
      action: 11061,
      ...post,
    };
    console.log("topupresult", postData);
    return this.postAuxEnd("/topupresult", postData);
  }

  //END POINT CALL FOR SENDING REFERRAL MESSAGE
  sendReferralMsg(postData) {
    var reqData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 11032,
      ...postData,
    };
    return this.postAuxEnd("/sendreferral", reqData);
  }

  StartResetPassword(reqData) {
    return this.postAuxEnd("/startresetpasword", reqData);
  }

  CompleteResetPassword(reqData) {
    return this.postAuxEnd("/stepresetpass", reqData);
  }

  getCouponRedeem(reqData) {
    var postData = {
      uuid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 85020,
      ...reqData,
    };
    return this.postAuxEnd("/couponredeem", postData);
  }

  // Country Data {GET}
  getSignupCountryData() {
    return this.postAuxEnd("/signupcountry", null);
  }

  // END POINT TO GET BANK NAME
  getCountryBank(value) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 11183,
      ...value,
    };
    return this.postAuxEnd("/countrybanks", postData);
  }

  // END POINT TO GET ACCOUNT TYPE
  getAccountTypes() {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 11177,
    };
    return this.postAuxEnd("/accounttypes", postData);
  }

  // Manage Interest
  MarketInterest(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      msg_type: "JOB",
      action: 13033,
      ...reqData,
    };
    return this.postAuxEnd("/marketinterest", postData);
  }

  MarketMessage(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      msg_type: "JOB",
      action: 13036,
      ...reqData,
    };
    return this.postAuxEnd("/marketmessage", postData);
  }

  // END POINT TO ACCEPT TERMS AND AGREEMENT
  jobManagerAgree() {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 13002,
    };
    return this.postAuxEnd("/jobmanageragree", postData);
  }

  // END POINT TO TO CREATE A JOB
  jobManagerCreateJob(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 13010,
      ...reqData,
    };
    return this.postAuxEnd("/jobmanagercreatejob", postData);
  }

  jobManagerUpdateJob(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 13010,
      ...reqData,
    };
    return this.postAuxEnd("/jobmanagerupdatejob", postData);
  }

  pendingJobExtend(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      extend_days: 7,
      action: 13041,
      ...reqData,
    };
    return this.postAuxEnd("/pendingjobextend", postData);
  }

  pendingJobSendTome(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      mode: 200,
      action: 13042,
      ...reqData,
    };
    return this.postAuxEnd("/pendingjobsendtome", postData);
  }

  // FUNCTION TO GET ACTIVE JOB MESSAGE LIST
  activeJobMesList(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      limit: 30,
      action: 14011,
      offset: 0,
      ...reqData,
    };
    return this.postAuxEnd("/activejobmsglist", postData);
  }

  // FUNCTION TO SEND ACTIVE JOB TASK MESSAGE
  sendTaskMessage(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 14010,
      ...reqData,
    };
    return this.postAuxEnd("/sendtaskmessage", postData);
  }

  // FUNCTION TO SEND FILE UPLOAD
  sendFiles(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 14010,
      ...reqData,
    };
    const formData = new FormData();
    for (let data in postData) {
      formData.append(data, postData[data]);
    }
    //  return this.postAuxEnd("/uploads", formData);

    return this.postAuxEnd("/uploads", postData);
  }

  // END POINT TO DELETE  A JOB
  deleteJob(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 13011,
      ...reqData,
    };
    return this.postAuxEnd("/jobmanagerdeletejob", postData);
  }

  verifyEmail(code) {
    const reqData = {
      verify_link: code,
      action: 11015,
    };
    return this.postAuxEnd("/verifysignuplink", reqData);
  }

  // END POINT FOR OFFER RESPONSE (i.e TO ACCEPT, REJECT, CANCEL, ETC OFFER)
  offersResponse(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 15012,
      ...reqData,
    };
    return this.postAuxEnd("/offersresponse", postData);
  }

  // END POINT FOR OFFERS INTEREST LIST
  offersInterestList() {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 13024,
      limit: 30,
      offset: 0,
    };
    return this.postAuxEnd("/offersinterestlist", postData);
  }

  // END POINT FOR PROCESSING OFFER INTEREST
  offersInterestProc(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 13034,
      ...reqData,
    };
    return this.postAuxEnd("/offersinterestproc", postData);
  }

  // END POINT FOR WORKER TO MARK TASK AS COMPLETED
  workerJobAction(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 14015,
      ...reqData,
    };
    return this.postAuxEnd("/activetaskstatus", postData);
  }

  // END POINT FOR OWNER JOB ACTION
  ownerJobAction(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 14015,
      ...reqData,
    };
    return this.postAuxEnd("/activejobstatus", postData);
  }

  // END POINT FOR OWNER JOB ACTION
  getFaq() {
    var postData = {
      sessionid: localStorage.getItem("session_token"),
    };
    return this.postAuxEnd("/faq", postData);
  }

  getMyNotifications() {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      limit: 30,
      offset: 0,
      action: 11205,
    };
    return this.postAuxEnd("/mynotifications", postData);
  }

  // END POINT TO GET LIST OF USER PREVIOUS CARDS
  payListCard() {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 11055,
    };
    return this.postAuxEnd("/paylistcard", postData);
  }

  // END POINT TO SEND OFFER INTEREST MESSAGE
  offerInterestMsg(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 13037,
      ...reqData,
    };
    return this.postAuxEnd("/offerinterestmsg", postData);
  }

  // END POINT TO GET OFFER INTEREST MESSAGE
  offerInterestListMsg(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 13037,
      ...reqData,
    };
    return this.postAuxEnd("/offerinterestlistmsg", postData);
  }

  // TO ADD FAMILY
  addFamily(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      ...reqData,
    };
    return this.postAuxEnd("/familyadd", postData);
  }

  familyListings(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      ...reqData,
    };
    return this.postAuxEnd("/familylist", postData);
  }

  // FUNCTION TO ASSIGN TASK TO FAMILY MEMBER
  assignFamilyTask(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 13025,
      ...reqData,
    };
    return this.postAuxEnd("/assigntask", postData);
  }

  // FUNCTION TO GET FAMILY SUGGEST LIST
  getFamilySuggestList() {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      limit: 30,
      offset: 0,
      action: 13010,
    };
    return this.postAuxEnd("/familysuggestlist", postData);
  }

  // FUNCTION TO CHANGE PROFILE PASSWORD
  profilePassChange(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 11005,
      ...reqData,
    };
    return this.postAuxEnd("/profilepasschange", postData);
  }

  // FUNCTION TO GET ACCOUNT SETTINGS
  getAccSettings() {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 11059,
    };
    return this.postAuxEnd("/getaccsettings", postData);
  }

  // FUNCTION TO SET ACCOUNT SETTINGS
  setAccSettings(reqdata) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 11058,
      ...reqdata,
    };
    return this.postAuxEnd("/setaccsettings", postData);
  }

  // FUNCTION TO DELETE PAY CARD
  payRemCard(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      action: 11057,
      ...reqData,
    };
    return this.postAuxEnd("/payremcard", postData);
  }

  getHomeRecent() {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      limit: 30,
      offset: 0,
      action: 11202,
    };
    return this.postAuxEnd("/recentactivities", postData);
  }
  // FUNCTION TO GET SINGLE BLOG ITEM
  getSingleBlogData(reqData) {
    var postData = {
      uid: localStorage.getItem("uid"),
      member_id: localStorage.getItem("member_id"),
      sessionid: localStorage.getItem("session_token"),
      limit: 4,
      ...reqData,
    };
    return this.postAuxEnd("/blogdata", postData);
  }


    // FUNCTION TO CANCEL TASK OR SEND REMINDER BY FAMILY MEMBER
    suggestStatus(reqData) {
      var postData = {
        uid: localStorage.getItem("uid"),
        member_id: localStorage.getItem("member_id"),
        sessionid: localStorage.getItem("session_token"),
        action: 22026,
        ...reqData,
      };
      return this.postAuxEnd("/suggeststatus", postData);
    }

  /*
    - 20:27:30.118 FLOG_MAX [757411]: 	REQ_STRING(username)
    - 20:27:30.118 FLOG_MAX [757411]: 	REQ_STRING(password)
    - 20:27:30.118 FLOG_MAX [757411]: 	REQ_STRING(sessionid)


    $endpoints = array(
        'apigate' => array('POST'),
        'generics' => array('POST'),
        'createuser' => array('POST'),
        'createmobileuser' => array('POST'),
        'completemobileuser' => array('POST'),
        'startresetpasword' => array('POST'),
        'userlogin' => array('POST'),
        'startjoblist' => array('POST'),
        'dashdata' => array('POST'),
        'getjobsdata' => array('POST'),
        'offerslist' => array('POST'),
        'activejoblist' => array('POST'),
        'loadprofile' => array('POST'),
        'account' => array('POST'),
        'message' => array('POST'),
        'pendingjob' => array('POST'),
        'paymenthx' => array('POST'),
        'getjob' => array('POST'),
        'mybanklist' => array('POST'),
        'sendmoney' => array('POST'),
        'sendinterest' => array('POST'),
        'sendmoneyfee' => array('POST'),
        'getpendingjobs' => array('POST'),
        'taskmessage' => array('POST'),
        'sendtaskmessage' => array('POST'),
        'getwallets' => array('POST'),
        'sitecontact' => array('POST'),
        'signupcountry' => array('POST'),
        'userscards' => array('POST'),
        'blogdata' =>  array('POST'),
        'blogitem' =>  array('POST'),
        'couponhx' =>  array('POST'),
        'couponpending' =>  array('POST'),
        'couponredeem' =>  array('POST'),
        'sendinterestmessage' =>  array('POST'),
        'replyinterestmessage' => array('POST')
    );

    */

  getUserReminders() {
    return this.getAuxEnd("/reminders", null);
  }
  //----------------------------------------  -----
  //----------------------------------------  -----
  // Unified call below
  //----------------------------------------  -----
  //----------------------------------------  -----
  getAuxEnd(uri, reqData) {
    const session_token = localStorage.getItem("session_token");
    let axiosConfig = {
      headers: {
        Accept: "application/json",
        "Content-Type": "application/json;charset=UTF-8",
        Authorization: `Basic ${session_token}`,
      },
    };
    const endPoint = process.env.REACT_APP_USERS_ENDPOINT + uri;
    return Axios.get(endPoint, {
      params: {
        reqData,
      },
    })
      .then((response) => {
        console.log("~~~~~~~ Toks2 GET ~~~~~~~~");
        return response;
      })
      .catch((error) => {
        if (error.response) {
          //response status is an error code
          console.log(error.response.status);
        } else if (error.request) {
          //response not received though the request was sent
          console.log(error.request);
        } else {
          //an error occurred when setting up the request
          console.log(error.message);
        }
      });
  }

  postAuxEnd(uri, reqData) {
    const endPoint = process.env.REACT_APP_USERS_ENDPOINT + uri;
    const session_token = localStorage.getItem("session_token");
    // session_token = session_token !=null ?session_token : '';
    //   'Authorization': `Basic ${(session_token !=null) ?session_token : ''}`,
    let axiosConfig = {
      headers: {
        Accept: "application/json",
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Expose-Headers": "Access-Control-Allow-Origin",
        "Access-Control-Allow-Headers":
          "Origin, X-API-KEY, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method, Access-Control-Allow-Headers, Authorization, observe, enctype, Content-Length, X-Csrf-Token",
        "Content-Type": "application/json;charset=UTF-8",
      },
    };
    //  Axios.defaults.headers.post['Content-Type'] ='application/json;charset=utf-8';
    //     Axios.defaults.headers.post['Access-Control-Allow-Origin'] = '*'; //,axiosConfig
    //     Axios.defaults.withCredentials = true;
    //debugger;
    return Axios.post(endPoint, reqData)
      .then((response) => {
        console.log(response);
        // res = response;
        console.log("~~~~~~~ Toks2 POST ~~~~~~~~");
        return response;
      })
      .catch((error) => {
        if (error.response) {
          //response status is an error code
          console.log(
            "ERROR-------------------------------------------------------"
          );
          console.log(error.response.status);
          console.log(
            "ERROR-------------------------------------------------------"
          );
        } else if (error.request) {
          //response not received though the request was sent
          console.log(
            "ERROR2-------------------------------------------------------"
          );
          console.log(error?.request);
          console.log(
            "ERROR2-------------------------------------------------------"
          );
        } else {
          //an error occurred when setting up the request
          console.log(
            "ERROR3-------------------------------------------------------"
          );
          console.log(error);
          console.log(
            "ERROR3-------------------------------------------------------"
          );
        }
      });
  }
}

export default usersService;
