Changeset 2998dc4 for reactapp/src


Ignore:
Timestamp:
07/30/22 15:39:04 (2 years ago)
Author:
unknown <mlviktor23@…>
Branches:
main
Children:
e958037
Parents:
3a44163
Message:

made OpinionTree display author info

Location:
reactapp/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • reactapp/src/App.css

    r3a44163 r2998dc4  
    22  text-align: center;
    33}
    4 
    5 .App-logo {
    6   height: 40vmin;
    7   pointer-events: none;
    8 }
    9 
    10 @media (prefers-reduced-motion: no-preference) {
    11   .App-logo {
    12     animation: App-logo-spin infinite 20s linear;
    13   }
    14 }
    15 
    16 .App-header {
    17   background-color: #282c34;
    18   min-height: 100vh;
    19   display: flex;
    20   flex-direction: column;
    21   align-items: center;
    22   justify-content: center;
    23   font-size: calc(10px + 2vmin);
    24   color: white;
    25 }
    26 
    27 .App-link {
    28   color: #61dafb;
    29 }
    30 
    31 @keyframes App-logo-spin {
    32   from {
    33     transform: rotate(0deg);
    34   }
    35   to {
    36     transform: rotate(360deg);
    37   }
    38 }
  • reactapp/src/App.js

    r3a44163 r2998dc4  
    44  return (
    55    <div>
    6       <h1>Main App Page</h1>
    7       <nav
    8         style={{
    9           borderBottom: "solid 1px",
    10           paddingBottom: "1rem",
    11         }}
    12       >
    13         <Link to="/professor">Professor</Link>
    14       </nav>
     6      <h1>profesori.mk</h1>
    157      <Outlet />
    168    </div>
  • reactapp/src/Components/OpinionTree.js

    r3a44163 r2998dc4  
    11function OpinionTree({ professor }) {
    2   function displayChildPosts(post) {
    3     if (post == null) return;
     2  var renderedOpinionIds = [];
     3  var postCount; // za da ne go pokazuva ispod postot
     4
     5  function displayChildPosts(child) {
     6    if (child == null) return;
     7    postCount = renderedOpinionIds.push(child.postId);
    48    return (
    5       <div key={post.postId}>
    6         <p>Содржина: {post.content}</p>
    7         {post.children.map((child) => displayChildPosts(child))}
     9      <div key={child.postId}>
     10        <p>{child.author.username} реплицирал</p>
     11        <p>Содржина: {child.content}</p>
     12        {child.children.map((childOfChild) => displayChildPosts(childOfChild))}
    813      </div>
    914    );
     
    1318    <div className="opinionTree">
    1419      {professor.relatedOpinions.map((opinion) => {
    15         if (opinion.hasOwnProperty("title")) {
     20        if (!renderedOpinionIds.includes(opinion.postId)) {
     21          postCount = renderedOpinionIds.push(opinion.postId);
    1622          return (
    1723            <div key={opinion.postId}>
     24              <p>{opinion.author.username} напишал</p>
    1825              <p>Наслов: {opinion.title}</p>
    1926              <p>Содржина: {opinion.content}</p>
    2027              {opinion.children.map((child) => displayChildPosts(child))}
     28              <hr />
    2129            </div>
    2230          );
  • reactapp/src/Pages/Professor.js

    r3a44163 r2998dc4  
    11import React, { useEffect, useState } from "react";
    22import { Outlet, useParams } from "react-router-dom";
     3import JSOG from "jsog";
    34import OpinionTree from "../Components/OpinionTree";
    45
     
    1516      try {
    1617        const response = await fetch(url);
    17         const json = await response.json();
    18         setProfessor(json);
     18        var cyclicGraph = await response.json();
     19        var jsogStructure = JSOG.encode(cyclicGraph); // has { '@ref': 'ID' } links instead of cycles
     20        cyclicGraph = JSOG.decode(jsogStructure);
     21        setProfessor(cyclicGraph);
    1922        setLoaded(true);
    2023      } catch (error) {
Note: See TracChangeset for help on using the changeset viewer.