import { OpinionCard, OpinionCardContent, OpinionCardContentTime, OpinionCardContentTitle, OpinionReplyCard, OpinionReplyCardContent, OpinionReplyCardContentTime, StyledFontAwesomeIcon, } from "./Styled/OpinionCard.style"; import { solid } from "@fortawesome/fontawesome-svg-core/import.macro"; import { dateConverter } from "../Util/dateConverter"; import AuthApi from "../api/AuthApi"; import { useNavigate } from "react-router-dom"; import { useContext, useState } from "react"; import { Modal, ModalContent, ModalClose, ModalHeader, ModalBody, ModalTextarea, ModalFooter, } from "../Components/Styled/Modal.style"; import axios from "../api/axios"; function OpinionTree({ professor, user, userLoaded }) { var renderedOpinionIds = []; var postCount; // za da ne go pokazuva ispod postot let navigate = useNavigate(); const { auth, setAuth } = useContext(AuthApi); let [replyModalDisplay, setReplyModalDisplay] = useState("none"); const [replyContent, setReplyContent] = useState(""); const [postForModal, setPostForModal] = useState(null); const handleLike = () => { if (auth) { return; } else { navigate("/login"); } }; const handleDislike = () => { if (auth) { return; } else { navigate("/login"); } }; const handleReply = (opinion) => { if (auth) { setReplyModalDisplay("block"); setPostForModal(opinion); } else { navigate("/login"); } }; const handleModalCloseClick = () => { setReplyModalDisplay("none"); }; const handleContentChange = (e) => { setReplyContent(e.target.value); }; const handleReplySubmit = async (e, postId) => { e.preventDefault(); const response = await axios( `http://192.168.0.19:8080/secure/professor/${professor.professorId}/replyToOpinion/${postId}`, { method: "post", data: { content: replyContent, }, withCredentials: true, } ); window.location.reload(false); //console.log(response); }; function displayChildPosts(child, parentPostAuthorUsername, replyIndent) { if (child == null) return; postCount = renderedOpinionIds.push(child.postId); return (
{child.author.username} му реплицирал на{" "} {parentPostAuthorUsername}
{child.content}
{opinion.author.username} напишал
{opinion.content}