diff --git a/src/components/MyActiveJobs/ActiveJobs.jsx b/src/components/MyActiveJobs/ActiveJobs.jsx index 867462b..f06110e 100644 --- a/src/components/MyActiveJobs/ActiveJobs.jsx +++ b/src/components/MyActiveJobs/ActiveJobs.jsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState, useRef, forwardRef } from "react"; +import React, { useEffect, useState, useRef } from "react"; import { useSelector } from "react-redux"; import Layout from "../Partials/Layout"; import { useNavigate } from "react-router-dom"; diff --git a/src/components/MyCoupons/CouponPopup.jsx b/src/components/MyCoupons/CouponPopup.jsx index e247a68..4c34f50 100644 --- a/src/components/MyCoupons/CouponPopup.jsx +++ b/src/components/MyCoupons/CouponPopup.jsx @@ -1,6 +1,44 @@ - +import { useMemo, useState } from "react"; +import { toast } from "react-toastify"; +import usersService from "../../services/UsersService"; const CouponPopup = ({ popUpHandler, data }) => { + const [loader, setLoader] = useState(false); + const apiCall = useMemo(() => new usersService(), []); + + const redeemCouponHandler = async () => { + setLoader(true); + + try { + const { code, coupon_id } = data; + const reqData = { code_id: Number(coupon_id), code }; + + const res = await apiCall.getCouponRedeem(reqData); + if (res.statusText === "OK") { + toast.success("Great news! Your coupon has been redeemed.", { + autoClose: 3000, + hideProgressBar: true, + }); + } + + setTimeout(() => { + popUpHandler(); + setLoader(false); + }, 3000); + throw new Response(res); + } catch (error) { + // error && + // toast.warn("An error occurred while processing your coupon.", { + // autoClose: 3000, + // hideProgressBar: true, + // }); + setLoader(false); + console.log(error); + return; + // throw new Error(error); + } + }; + return (
@@ -45,14 +83,17 @@ const CouponPopup = ({ popUpHandler, data }) => {
diff --git a/src/components/MyPendingJobs/MyPendingJobTable.jsx b/src/components/MyPendingJobs/MyPendingJobTable.jsx index d7e6a03..e807d21 100644 --- a/src/components/MyPendingJobs/MyPendingJobTable.jsx +++ b/src/components/MyPendingJobs/MyPendingJobTable.jsx @@ -1,13 +1,10 @@ import React, { useState } from "react"; import dataImage2 from "../../assets/images/data-table-user-2.png"; import PendingJobsPopout from "../jobPopout/PendingJobsPopout"; - import { handlePagingFunc } from "../Pagination/HandlePagination"; import PaginatedList from "../Pagination/PaginatedList"; export default function MyPendingJobTable({ MyJobList, className }) { - const filterCategories = ["All Categories", "Explore", "Featured"]; - const [selectedCategory, setCategory] = useState(filterCategories[0]); let [jobPopout, setJobPopout] = useState({ show: false, data: {} }); // STATE TO HOLD THE VALUE OF THE ALERT DETAILS AND DETERMINE WHEN TO SHOW const [currentPage, setCurrentPage] = useState(0); @@ -24,26 +21,28 @@ export default function MyPendingJobTable({ MyJobList, className }) { }; return ( -
- {MyJobList && MyJobList?.result_list && ( -
- - - {/**/} - {/* */} - {/* */} - {/**/} +
+ {MyJobList && MyJobList?.result_list && ( +
+
All Product.
+ + {/**/} + {/* */} + {/* */} + {/**/} - { - <> - {MyJobList && - MyJobList?.result_list && - MyJobList.result_list.length > 0 ? - currentActiveJobList.map((value, index) => ( + { + <> + {MyJobList && + MyJobList?.result_list && + MyJobList.result_list.length > 0 ? ( + currentActiveJobList.map((value, index) => { + let deliveryDate = value?.expire?.split(" ")[0]; + return ( - - Duration:{" "} - - {" "} - {value.timeline_days} day(s) +
+ + Duration:{" "} + + {" "} + {value.timeline_days} day(s) + - - - Expire:{" "} - - {" "} - {value.expire} + + Expire:{" "} + + {" "} + {deliveryDate} + - - - Send to:{" "} - - {" "} - {value.job_to} + + Send to:{" "} + + {" "} + {value.job_to} + - +
- +
- )) - : + ) + }) + ) : ( - + - } - - } - -
All Product.
- No Pending Task! - No Pending Task!
- {/* PAGINATION BUTTON */} - = - MyJobList?.result_list.length - ? true - : false + )} + } - data={MyJobList?.result_list} - start={indexOfFirstItem} - stop={indexOfLastItem} - /> - {/* END OF PAGINATION BUTTON */} -
- )} - - {/* Active Job Popout */} - {jobPopout.show && ( - { - setJobPopout({ show: false, data: {} }); - }} - situation={jobPopout.show} + + + {/* PAGINATION BUTTON */} + = + MyJobList?.result_list.length + ? true + : false + } + data={MyJobList?.result_list} + start={indexOfFirstItem} + stop={indexOfLastItem} /> - )} - {/* End of Active Job Popout */} -
+ {/* END OF PAGINATION BUTTON */} +
+ )} + + {/* Active Job Popout */} + {jobPopout.show && ( + { + setJobPopout({ show: false, data: {} }); + }} + situation={jobPopout.show} + /> + )} + {/* End of Active Job Popout */} +
); } diff --git a/src/components/MyTasks/MyJobTable.jsx b/src/components/MyTasks/MyJobTable.jsx index a7c7ed6..604c47e 100644 --- a/src/components/MyTasks/MyJobTable.jsx +++ b/src/components/MyTasks/MyJobTable.jsx @@ -85,6 +85,7 @@ export default function MyJobTable({ className, ActiveJobList }) { {Number(task?.price) * 0.01} + Duration: diff --git a/src/services/UsersService.js b/src/services/UsersService.js index 0e802d0..f820c97 100644 --- a/src/services/UsersService.js +++ b/src/services/UsersService.js @@ -455,13 +455,13 @@ class usersService { return this.postAuxEnd("/stepresetpass", reqData); } - getCouponRedeem() { + getCouponRedeem(reqData) { var postData = { uuid: localStorage.getItem("uid"), member_id: localStorage.getItem("member_id"), sessionid: localStorage.getItem("session_token"), - page: 0, - limit: 100, + action: 85020, + ...reqData }; return this.postAuxEnd("/couponredeem", postData); } diff --git a/src/views/MyPendingJobsPage.jsx b/src/views/MyPendingJobsPage.jsx index 5c1458a..9830f34 100644 --- a/src/views/MyPendingJobsPage.jsx +++ b/src/views/MyPendingJobsPage.jsx @@ -1,34 +1,32 @@ -import React, { useContext,useState, useEffect } from "react"; +import React, { useContext, useState, useEffect } from "react"; import usersService from "../services/UsersService"; -//import MyJobs from "../components/MyJobs"; -import MyActiveJobs from "../components/MyActiveJobs"; import MyPendingJobs from "../components/MyPendingJobs"; import { useSelector } from "react-redux"; export default function MyPendingJobsPage() { - let {commonHeadBanner} = useSelector(state => state.commonHeadBanner) - const [MyJobList, setMyJobList] = useState([]); - const api = new usersService(); + let { commonHeadBanner } = useSelector((state) => state.commonHeadBanner); + const [MyJobList, setMyJobList] = useState([]); + const api = new usersService(); - const getMyJobList = async () => { - try { - const res = await api.getMyPendingJobList(); - setMyJobList(res.data); - } catch (error) { - console.log("Error getting mode"); - } - }; - useEffect(() => { - getMyJobList(); - }, []); + const getMyJobList = async () => { + try { + const res = await api.getMyPendingJobList(); + setMyJobList(res.data); + } catch (error) { + console.log("Error getting mode"); + } + }; + useEffect(() => { + getMyJobList(); + }, []); - // debugger; - return ( - <> - - - ); + // debugger; + return ( + <> + + + ); }