diff --git a/src/components/AddJob/AddJob.jsx b/src/components/AddJob/AddJob.jsx
index 111cd86..606ab67 100644
--- a/src/components/AddJob/AddJob.jsx
+++ b/src/components/AddJob/AddJob.jsx
@@ -94,6 +94,7 @@ function AddJob({ popUpHandler, categories }) {
// FUNCTION TO HANDLE ADD JOB FORM
const handleAddJob = (values, helpers) => {
values.category = values.category?.join("@");
+ values.price = Number(values.price) * 100;
setRequestStatus({ loading: true, status: false, message: "" });
ApiCall.jobManagerCreateJob(values)
.then((res) => {
diff --git a/src/components/Cards/AvailableJobsCard.jsx b/src/components/Cards/AvailableJobsCard.jsx
index 755bc17..d5cc2d9 100644
--- a/src/components/Cards/AvailableJobsCard.jsx
+++ b/src/components/Cards/AvailableJobsCard.jsx
@@ -13,38 +13,14 @@ export default function AvailableJobsCard({
}) {
//debugger;
const [marketPopUp, setMarketPopUp] = useState({ show: false, data: {} });
- const [manageInt, setManageInt] = useState(null);
const [imageUrl, setImageUrl] = useState("");
- const navigate = useNavigate();
- const apiCall = useMemo(() => new usersService(), []);
-
- const marketInterestData = useCallback(async () => {
- let { offer_code } = datas;
- let reqData = { offer_code };
-
- try {
- const manageInt = await apiCall.MarketInterest(reqData);
- const manageIntRes = await manageInt?.data;
- setManageInt(manageIntRes);
- } catch (error) {
- throw new Error(error);
- }
- }, [apiCall, datas]);
-
let thePrice = PriceFormatter(
datas?.price * 0.01,
datas?.currency_code,
datas?.currency
);
- useEffect(() => {
- if (!datas) {
- navigate("/market", { replace: true });
- }
- marketInterestData();
- }, []);
-
useEffect(() => {
const imagePath = require(`../../assets/images/${datas.thumbnil}`); // Replace with your directory path for local images
setImageUrl(imagePath);
@@ -227,7 +203,6 @@ export default function AvailableJobsCard({
setMarketPopUp({ show: false, data: {} });
}}
situation={marketPopUp.show}
- marketInt={manageInt}
/>
)}
>
diff --git a/src/components/MarketPlace/PopUp/MarketPopUp.jsx b/src/components/MarketPlace/PopUp/MarketPopUp.jsx
index c4eb18d..3934096 100644
--- a/src/components/MarketPlace/PopUp/MarketPopUp.jsx
+++ b/src/components/MarketPlace/PopUp/MarketPopUp.jsx
@@ -1,4 +1,4 @@
-import { useCallback, useMemo, useState } from "react";
+import { useCallback, useEffect, useMemo, useState } from "react";
import ModalCom from "../../Helpers/ModalCom";
import { toast } from "react-toastify";
import usersService from "../../../services/UsersService";
@@ -6,17 +6,93 @@ import LoadingSpinner from "../../Spinners/LoadingSpinner";
import { PriceFormatter } from "../../Helpers/PriceFormatter";
const MarketPopUp = ({ details, onClose, situation, marketInt }) => {
- const [marketMsg, setMarketMsg] = useState({
- loading: false,
- data: {},
- state: undefined,
- });
- const [manageInt, setManageInt] = useState({
- loading: false,
- data: {},
- state: undefined,
- msg: "",
- });
+ const MarketCalls = (details) => {
+ const [marketMsg, setMarketMsg] = useState({
+ loading: false,
+ data: {},
+ state: undefined,
+ });
+ const [manageInt, setManageInt] = useState({
+ loading: false,
+ data: {},
+ state: undefined,
+ msg: "",
+ });
+
+ const { offer_code } = details;
+ const reqData = { offer_code };
+
+ const MarketDetail = async () => {
+ try {
+ setMarketMsg({ loading: true });
+ if (!textValue) return;
+
+ reqData.yourmessage = textValue;
+
+ const marketMessage = await apiCall.MarketMessage(reqData);
+ const marketMessageRes = marketMessage?.data;
+
+ if (marketMessageRes?.internal_return < 0) {
+ toast.warn("Something wrong happened", {
+ autoClose: 2000,
+ hideProgressBar: true,
+ });
+ onClose();
+ return;
+ }
+
+ toast.success("Message sent", {
+ autoClose: 2500,
+ hideProgressBar: true,
+ });
+
+ setMarketMsg({ data: marketMessageRes, state: true });
+ setTimeout(() => onClose(), 2000);
+ } catch (error) {
+ throw new Error(error);
+ } finally {
+ setTimeout(() => {
+ setTextValue("");
+ setMarketMsg({ loading: false });
+ }, 2000);
+ }
+ };
+
+ const ManageInterest = async () => {
+ try {
+ setManageInt({ loading: true });
+
+ const manageInt = await apiCall.MarketInterest(reqData);
+ const manageIntRes = manageInt?.data;
+
+ if (manageIntRes?.internal_return < 0) {
+ setManageInt({
+ loading: false,
+ msg: manageIntRes?.status,
+ data: manageIntRes,
+ state: false,
+ });
+ } else {
+ setManageInt({
+ loading: false,
+ msg: manageIntRes?.status,
+ data: manageIntRes,
+ state: true,
+ });
+ }
+
+ setTimeout(() => setManageInt({ msg: "" }), 3000);
+ } catch (error) {
+ throw new Error(error);
+ }
+ };
+
+ // useEffect(() => {
+ // ManageInterest();
+ // }, []);
+
+ return { MarketDetail, ManageInterest, manageInt, marketMsg };
+ };
const [textValue, setTextValue] = useState("");
@@ -26,75 +102,7 @@ const MarketPopUp = ({ details, onClose, situation, marketInt }) => {
const apiCall = useMemo(() => new usersService(), []);
- const marketCalls = useCallback(
- async (e) => {
- try {
- const nameOfCall = e?.target?.name;
- const { offer_code } = details;
- const reqData = { offer_code };
-
- if (nameOfCall === "market-message") {
- setMarketMsg({ loading: true });
- if (!textValue) return;
-
- reqData.yourmessage = textValue;
-
- const marketMessage = await apiCall.MarketMessage(reqData);
- const marketMessageRes = marketMessage?.data;
-
- if (marketMessageRes?.internal_return < 0) {
- toast.warn("Something wrong happened", {
- autoClose: 2000,
- hideProgressBar: true,
- });
- onClose();
- return;
- }
-
- toast.success("Message sent", {
- autoClose: 2500,
- hideProgressBar: true,
- });
-
- setMarketMsg({ data: marketMessageRes, state: true });
- setTimeout(() => onClose(), 2000);
- } else {
- setManageInt({ loading: true });
-
- const manageInt = await apiCall.MarketInterest(reqData);
- const manageIntRes = manageInt?.data;
-
- if (manageIntRes?.internal_return < 0) {
- setManageInt({
- loading: false,
- msg: `Error - ${manageIntRes?.status}`,
- data: manageIntRes,
- state: false,
- });
- } else {
- setManageInt({
- loading: false,
- msg: manageIntRes?.status,
- data: manageIntRes,
- state: true,
- });
- }
-
- setTimeout(() => setManageInt({ msg: "" }), 3000);
-
- return;
- }
- } catch (error) {
- throw new Error(error);
- } finally {
- setTimeout(() => {
- setTextValue("");
- setMarketMsg({ loading: false });
- }, 2000);
- }
- },
- [apiCall, details, onClose, textValue]
- );
+ let { manageInt, ManageInterest, MarketDetail, marketMsg } = MarketCalls(details);
let thePrice = PriceFormatter(
details?.price * 0.01,
@@ -103,12 +111,20 @@ const MarketPopUp = ({ details, onClose, situation, marketInt }) => {
);
// let addedIntDate = marketInt?.added?.split(" ")[0];
- let expireIntDate = marketInt?.expire?.split(" ")[0];
+ // let expireIntDate = marketInt?.expire?.split(" ")[0];
- // let cleanedText = details?.job_description.replace(/</g, '<')
- // .replace(/>/g, '>')
- // .replace(/"/g, '"')
- // .replace(/&/g, '&')
+ let cleanedText = details?.job_description
+ ?.replace(/</g, "<")
+ .replace(/>/g, ">")
+ .replace(/"/g, '"')
+ .replace(/&/g, "&");
+
+ console.log("first wait", {
+ manageInt,
+ ManageInterest,
+ MarketDetail,
+ marketMsg,
+ });
return (
Expire: {expireIntDate}
++ Expire: {details.expire} +