import React, { useCallback, useMemo, useState } from "react"; import ModalCom from "../../Helpers/ModalCom"; import { toast } from "react-toastify"; import { Form, Formik } from "formik"; import usersService from "../../../services/UsersService"; import LoadingSpinner from "../../Spinners/LoadingSpinner"; const MarketPopUp = ({ details, onClose, situation, marketInt }) => { const [marketMsg, setMarketMsg] = useState({ loading: false, data: {}, state: undefined, }); const [textValue, setTextValue] = useState(""); const handleInputChange = ({ target: { value } }) => { setTextValue(value); }; const apiCall = useMemo(() => new usersService(), []); const marketCalls = useCallback( async (e) => { let nameOfCall = e?.target?.name; let { offer_code } = details; let reqData = { offer_code }; try { if (nameOfCall === "market-message") { // To manage the manage msg data setMarketMsg({ loading: true }); reqData = { yourmessage: textValue, ...reqData }; const marketMessage = await apiCall.MarketMessage(reqData); const marketMessageRes = await marketMessage?.data; if (marketMessageRes?.internal_return < 0) { setMarketMsg({ loading: false }); toast.warn("Something wrong happened", { autoClose: 2000, hideProgressBar: true, }); onClose(); return; } toast.success("Message sent", { autoClose: 2500, hideProgressBar: true, }); // To manage the manage msg data setMarketMsg({ data: marketMessageRes, state: true }); } } catch (error) { throw new Error(error); } finally { setTimeout(() => { onClose(); setTextValue(""); setMarketMsg({ loading: false }); }, 2000); } }, [apiCall, details, onClose, setMarketMsg, textValue] ); // let addedIntDate = marketInt?.added?.split(" ")[0]; let expireIntDate = marketInt?.expire?.split(" ")[0]; return ( // className="job-popup"

{details.offer_code}

{`Timeline: ${details.timeline_days} day(s) -- `} {`Budget: ${details.price} naira`}

{/* INPUT SECTION */} {[ { name: "Title", content: details.title }, { name: "Description", content: details.description }, { name: "Detail", content: details.job_description, danger: true, }, ].map(({ name, content, danger }, idx) => (
{danger ? (

) : (

{content !== "Detail" ? content : null}

)}
))}