Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a30bd2d72c |
@@ -1,24 +1,18 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
|
||||||
import Layout from "../Partials/Layout";
|
import Layout from "../Partials/Layout";
|
||||||
import CommonHead from "../UserHeader/CommonHead";
|
import CommonHead from "../UserHeader/CommonHead";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import usersService from "../../services/UsersService";
|
|
||||||
import { handlePagingFunc } from "../Pagination/HandlePagination";
|
import { handlePagingFunc } from "../Pagination/HandlePagination";
|
||||||
import PaginatedList from "../Pagination/PaginatedList";
|
import PaginatedList from "../Pagination/PaginatedList";
|
||||||
import LoadingSpinner from "../Spinners/LoadingSpinner";
|
|
||||||
import OthersInterestedTable from "./OthersInterestedTable";
|
import OthersInterestedTable from "./OthersInterestedTable";
|
||||||
|
|
||||||
export default function ManageInterestOffer(props) {
|
export default function ManageInterestOffer(props) {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const apiCall = new usersService()
|
|
||||||
|
|
||||||
let [redirectTime, setRedirectTime] = useState(5)
|
|
||||||
|
|
||||||
let [tab, setTab] = useState("info"); //message STATE FOR SWITCHING BETWEEN TABS
|
let [tab, setTab] = useState("info"); //message STATE FOR SWITCHING BETWEEN TABS
|
||||||
|
|
||||||
let [requestStatus, setRequestStatus] = useState({loading: false, status: false, message: '', processType: ''})
|
|
||||||
|
|
||||||
const messageList = {data: [1,2,3,4,5,6]} // TO BE REMOVED AND REPLACE WITH REAL MESSAGE FROM API CALL
|
const messageList = {data: [1,2,3,4,5,6]} // TO BE REMOVED AND REPLACE WITH REAL MESSAGE FROM API CALL
|
||||||
const [currentPage, setCurrentPage] = useState(0);
|
const [currentPage, setCurrentPage] = useState(0);
|
||||||
const indexOfFirstItem = Number(currentPage);
|
const indexOfFirstItem = Number(currentPage);
|
||||||
@@ -34,36 +28,6 @@ export default function ManageInterestOffer(props) {
|
|||||||
setValue(value);
|
setValue(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
//FUNCTION TO ACCEPT/REJECT OFFER INTEREST
|
|
||||||
const interestOfferProcess = ({target:{name}}) => {
|
|
||||||
setRequestStatus(prev => ({...prev, loading: true, processType: name}))
|
|
||||||
let reqData = { // API PAYLOADS
|
|
||||||
proc: name.toUpperCase(),
|
|
||||||
client_uid : props.offerDetails?.client_uid,
|
|
||||||
offer_code : props.offerDetails?.offer_code,
|
|
||||||
offer_uid: props.offerDetails?.offer_uid,
|
|
||||||
}
|
|
||||||
apiCall.offersInterestProc(reqData).then(res => {
|
|
||||||
if(res.status != 200 || res.data.internal_return < 0){
|
|
||||||
setRequestStatus({loading: false, status: false, message: 'Unable to complete request', processType: ''})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
setInterval(() => { // SETS REDIRECT COUNT DOWN
|
|
||||||
setRedirectTime(prev => prev - 1)
|
|
||||||
}, 1000);
|
|
||||||
setRequestStatus({loading: false, status: true, message: `Offer ${name}ed`, processType: ''})
|
|
||||||
setTimeout(()=>{
|
|
||||||
navigate('/offer-interest', {replace: true})
|
|
||||||
},5000)
|
|
||||||
}).catch(err => {
|
|
||||||
setRequestStatus({loading: false, status: false, message: 'Opps! something went wrong. Try again', processType: ''})
|
|
||||||
}).finally(()=>{
|
|
||||||
setTimeout(()=>{
|
|
||||||
setRequestStatus({loading: false, status: false, message: '', processType: ''})
|
|
||||||
},5000)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
// run API to get message to replace message array above, add reload variable as dependence array
|
// run API to get message to replace message array above, add reload variable as dependence array
|
||||||
},[])
|
},[])
|
||||||
@@ -224,58 +188,19 @@ export default function ManageInterestOffer(props) {
|
|||||||
|
|
||||||
{/* BUTTON section */}
|
{/* BUTTON section */}
|
||||||
<div className="p-4 w-full min-h-full bg-sky-100 dark:bg-dark-gray col-span-1">
|
<div className="p-4 w-full min-h-full bg-sky-100 dark:bg-dark-gray col-span-1">
|
||||||
<div className="w-full h-full">
|
<div className="w-full h-full flex flex-col justify-center items-center gap-10">
|
||||||
<div className="mt-0 sm:mt-10 flex sm:flex-col justify-center items-center gap-10">
|
<button
|
||||||
{requestStatus.loading && requestStatus.processType == 'accept' ?
|
type="button"
|
||||||
<LoadingSpinner color='sky-blue' size='10' />
|
className="px-2 py-1 h-11 flex justify-center items-center btn-gradient text-base rounded-full text-white"
|
||||||
:
|
>
|
||||||
<button
|
<span className="text-white">Accept</span>
|
||||||
type="button"
|
</button>
|
||||||
name='accept'
|
<button
|
||||||
disabled={requestStatus.loading}
|
type="button"
|
||||||
onClick={interestOfferProcess}
|
className="px-2 py-1 h-11 flex justify-center items-center border-gradient text-base rounded-full text-white"
|
||||||
className="px-2 py-1 h-11 flex justify-center items-center btn-gradient text-base rounded-full text-white"
|
>
|
||||||
>
|
<span className="text-gradient">Reject</span>
|
||||||
Accept
|
</button>
|
||||||
</button>
|
|
||||||
}
|
|
||||||
|
|
||||||
{requestStatus.loading && requestStatus.processType == 'reject' ?
|
|
||||||
<LoadingSpinner color='sky-blue' size='10' />
|
|
||||||
:
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
name='reject'
|
|
||||||
disabled={requestStatus.loading}
|
|
||||||
onClick={interestOfferProcess}
|
|
||||||
className="px-2 py-1 h-11 flex justify-center items-center border-gradient text-base rounded-full text-black"
|
|
||||||
>
|
|
||||||
Reject
|
|
||||||
</button>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* ERROR DISPLAY */}
|
|
||||||
<div className="w-full">
|
|
||||||
{/* error or success display */}
|
|
||||||
{requestStatus.message != "" && requestStatus.processType != 'sendmeassge' &&
|
|
||||||
(!requestStatus.status ? (
|
|
||||||
<div
|
|
||||||
className={`relative p-4 my-4 text-[#912741] bg-[#fcd9e2] border-[#fbc6d3] mb-4 rounded-[0.475rem] text-md font-light leading-[19.5px] text-[13px]`}
|
|
||||||
>
|
|
||||||
{requestStatus.message}
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
requestStatus.status && (
|
|
||||||
<div
|
|
||||||
className={`relative p-4 my-4 text-green-700 bg-slate-200 border-slate-800 mb-4 rounded-[0.475rem] text-md font-light leading-[19.5px] text-[13px]`}
|
|
||||||
>
|
|
||||||
{`${requestStatus.message} redirecting.... ${redirectTime}sec`}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
{/* End of error or success display */}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/* END of BUTTON section */}
|
{/* END of BUTTON section */}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export default function OffersInterestTable({offerInterestList, className}) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`update-table w-full my-8 p-8 bg-white dark:bg-dark-white rounded-2xl section-shadow min-h-[520px] ${
|
className={`update-table w-full p-8 bg-white dark:bg-dark-white rounded-2xl section-shadow min-h-[520px] ${
|
||||||
className || ""
|
className || ""
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -666,18 +666,6 @@ class usersService {
|
|||||||
return this.postAuxEnd("/offersinterestlist", postData);
|
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
|
// END POINT FOR WORKER TO MARK TASK AS COMPLETED
|
||||||
workerJobAction(reqData) {
|
workerJobAction(reqData) {
|
||||||
var postData = {
|
var postData = {
|
||||||
|
|||||||
Reference in New Issue
Block a user