import React, { useContext, useState, useEffect } from "react";
import usersService from "../services/UsersService";
import MyPendingJobs from "../components/MyPendingJobs";
import { useSelector } from "react-redux";

export default function MyPendingJobsPage() {
  let { commonHeadBanner } = useSelector((state) => state.commonHeadBanner);
  let { pendingListTable } = useSelector((state) => state.tableReload);

  const [MyJobList, setMyJobList] = useState({loading: true, data: []});
  const api = new usersService();

  const getMyJobList = async () => {
    setMyJobList({loading: true, data: []});
    try {
      const res = await api.getMyPendingJobList();
      setMyJobList({loading: false, data: res.data});
    } catch (error) {
      setMyJobList({loading: false, data: []});
      console.log("Error getting mode");
    }
  };
  
  useEffect(() => {
    getMyJobList();
  }, [pendingListTable]);

  // debugger;
  return (
    <>
      <MyPendingJobs
        MyJobList={MyJobList}
        commonHeadData={commonHeadBanner.result_list}
      />
    </>
  );
}
