import { useState } from "react"; import { useLocation } from "react-router-dom"; import ModalCom from "../Helpers/ModalCom"; import { Form, Formik } from "formik"; import InputCom from "../Helpers/Inputs/InputCom"; import usersService from "../../services/UsersService"; import Icons from "../Helpers/Icons"; const DEFAULT_IMAGE = require("../../assets/images/family/default.jpg"); const SuggestTask = ({ details, onClose, situation, continuePopupData }) => { const { pathname, state } = useLocation(); const [submitTask, setSubmitTask] = useState({ loading: false, msg: "", state: "", }); const [suggestedNextStep, setSuggestedNextStep] = useState("Send Task"); const switchNextStep = ({ target: value }) => { setSuggestedNextStep(value); }; const selectedImage = details?.selectedImage || DEFAULT_IMAGE; const initialValues = { title: details?.title || "", description: details?.description || "", banner: details?.banner, }; const apiCall = new usersService(); const handleSuggestedTask = async (values) => { if (!values.title && !values.description) return; try { setSubmitTask({ loading: true }); const reqData = { ...values }; const res = await apiCall.sendFamilySuggestedTasks(reqData); if (res.internal_return < 0) { setSubmitTask({ loading: false, msg: res.status, state: "bad" }); return; } setSubmitTask({ loading: false, msg: res.status, state: "success" }); setTimeout(() => { onClose(); }, 2000); } catch (error) { setSubmitTask({ loading: false, msg: error, state: "bad" }); throw new Error("Error Occurred", error); } }; const handleParentSuggestion = (values) => { if (suggestedNextStep == "Send Task") { let firstName = state?.firstname; let family_uid = state?.family_uid; continuePopupData({ ...details, firstName, family_uid }); } onClose(); }; return (

{pathname === "/manage-family" ? `${state?.firstname}'s Suggested Task` : "Suggest to Parent"}

{(props) => { return (
{/* Image Section */}
{/* ACTION SECTION */}
{/* Title */}
{/* Description */}