import { OpinionCard, OpinionCardContent, OpinionCardContentTime, OpinionCardContentTitle, OpinionReplyCard, OpinionReplyCardContent, OpinionReplyCardContentTime, StyledFontAwesomeIcon, } from "./OpinionCard.style"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { solid, regular, brands, } from "@fortawesome/fontawesome-svg-core/import.macro"; import { dateConverter } from "../Util/dateConverter"; function OpinionTree({ professor }) { var renderedOpinionIds = []; var postCount; // za da ne go pokazuva ispod postot function displayChildPosts(child, parentPostAuthorUsername, replyIndent) { if (child == null) return; postCount = renderedOpinionIds.push(child.postId); return (

{child.author.username} му реплицирал на{" "} {parentPostAuthorUsername}

{child.content}

{dateConverter( new Date(child.timePosted).toString().slice(4, -43) )}
{child.children.map((childOfChild) => displayChildPosts( childOfChild, child.author.username, replyIndent + 30 ) )}
); } return (
{professor.relatedOpinions.map((opinion) => { if (!renderedOpinionIds.includes(opinion.postId)) { postCount = renderedOpinionIds.push(opinion.postId); return (

{opinion.author.username} напишал

{opinion.title}

{opinion.content}

{dateConverter( new Date(opinion.timePosted).toString().slice(4, -43) )}
{opinion.children.map((child) => displayChildPosts(child, opinion.author.username, 30) )}
); } })}
); } export default OpinionTree;