source: reactapp/src/Components/OpinionTree.js@ ad40ec0

main
Last change on this file since ad40ec0 was ad40ec0, checked in by Viktor <mlviktor23@…>, 2 years ago

styled professor page

  • Property mode set to 100644
File size: 3.6 KB
Line 
1import {
2 OpinionCard,
3 OpinionCardContent,
4 OpinionCardContentTime,
5 OpinionCardContentTitle,
6 OpinionReplyCard,
7 OpinionReplyCardContent,
8 OpinionReplyCardContentTime,
9 StyledFontAwesomeIcon,
10} from "./OpinionCard.style";
11import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
12import {
13 solid,
14 regular,
15 brands,
16} from "@fortawesome/fontawesome-svg-core/import.macro";
17import { dateConverter } from "../Util/dateConverter";
18
19function OpinionTree({ professor }) {
20 var renderedOpinionIds = [];
21 var postCount; // za da ne go pokazuva ispod postot
22
23 function displayChildPosts(child, parentPostAuthorUsername, replyIndent) {
24 if (child == null) return;
25 postCount = renderedOpinionIds.push(child.postId);
26 return (
27 <div key={child.postId}>
28 <OpinionReplyCard indent={replyIndent + "px"}>
29 <OpinionReplyCardContent>
30 <p>
31 <a href="#">{child.author.username}</a> му реплицирал на{" "}
32 {parentPostAuthorUsername}
33 </p>
34 <p>{child.content}</p>
35 <OpinionReplyCardContentTime>
36 {dateConverter(
37 new Date(child.timePosted).toString().slice(4, -43)
38 )}
39 </OpinionReplyCardContentTime>
40 <StyledFontAwesomeIcon
41 icon={solid("thumbs-up")}
42 right={50 + "px"}
43 color="greenyellow"
44 />
45 <StyledFontAwesomeIcon
46 icon={solid("thumbs-down")}
47 right={10 + "px"}
48 color="indianred"
49 />
50 <StyledFontAwesomeIcon
51 icon={solid("reply")}
52 right={90 + "px"}
53 color="black"
54 />
55 </OpinionReplyCardContent>
56 {child.children.map((childOfChild) =>
57 displayChildPosts(
58 childOfChild,
59 child.author.username,
60 replyIndent + 30
61 )
62 )}
63 </OpinionReplyCard>
64 </div>
65 );
66 }
67
68 return (
69 <div className="opinionTree">
70 {professor.relatedOpinions.map((opinion) => {
71 if (!renderedOpinionIds.includes(opinion.postId)) {
72 postCount = renderedOpinionIds.push(opinion.postId);
73 return (
74 <div key={opinion.postId}>
75 <OpinionCard>
76 <OpinionCardContent>
77 <p>
78 <a href="#">{opinion.author.username}</a> напишал
79 </p>
80 <OpinionCardContentTitle>
81 {opinion.title}
82 </OpinionCardContentTitle>
83 <p>{opinion.content}</p>
84 <OpinionCardContentTime>
85 {dateConverter(
86 new Date(opinion.timePosted).toString().slice(4, -43)
87 )}
88 </OpinionCardContentTime>
89 <StyledFontAwesomeIcon
90 icon={solid("thumbs-up")}
91 right={50 + "px"}
92 color="greenyellow"
93 />
94 <StyledFontAwesomeIcon
95 icon={solid("thumbs-down")}
96 right={10 + "px"}
97 color="indianred"
98 />
99 <StyledFontAwesomeIcon
100 icon={solid("reply")}
101 right={90 + "px"}
102 color="black"
103 />
104 </OpinionCardContent>
105 {opinion.children.map((child) =>
106 displayChildPosts(child, opinion.author.username, 30)
107 )}
108 </OpinionCard>
109 </div>
110 );
111 }
112 })}
113 </div>
114 );
115}
116
117export default OpinionTree;
Note: See TracBrowser for help on using the repository browser.