import React, {useEffect, useState} from 'react';
import JSOG from "jsog";
import {OpinionCard, OpinionCardContent, OpinionCardContentTime} from "../Components/Styled/OpinionCard.style";
import LoadingSpinner from "../Components/Styled/LoadingSpinner.style";
import {dateConverter} from "../Util/dateConverter";
import {findParentThread} from "../Util/findParentThread";
import {CurrentPageNav} from "../Components/Styled/Main.style";
const Home = () => {
const [latestOpinions, setLatestOpinions] = useState(null);
const [loadedLatestOpinions, setLoadedLatestOpinions] = useState(false);
const [latestThreads, setLatestThreads] = useState(null);
const [loadedLatestThreads, setLoadedLatestThreads] = useState(false);
useEffect(() => {
Promise.all([fetch(`http://192.168.1.254:8080/public/latest10opinions`),
fetch(`http://192.168.1.254:8080/public/latest10threads`)])
.then(([resOpinions, resThreads]) => Promise.all([resOpinions.json(), resThreads.json()]))
.then(([dataOpinions, dataThreads]) => {
let cyclicGraph1 = dataOpinions;
let jsogStructure1 = JSOG.encode(cyclicGraph1);
cyclicGraph1 = JSOG.decode(jsogStructure1);
setLatestOpinions(cyclicGraph1);
setLoadedLatestOpinions(true);
let cyclicGraph2 = dataThreads;
let jsogStructure2 = JSOG.encode(cyclicGraph2);
cyclicGraph2 = JSOG.decode(jsogStructure2);
setLatestThreads(cyclicGraph2);
setLoadedLatestThreads(true);
})
}, []);
return (
<>
во дискусија за{" "} {opinion.targetProfessor.professorName}
{opinion.author.username} {" "} напишал
{opinion.content}
{new Date(opinion.timePosted).setMilliseconds(0) === new Date(opinion.timeLastEdited).setMilliseconds(0) ? (во дискусија за{" "} {thread.targetSubject.subjectName}
{thread.author.username} {" "} напишал
{thread.content}
{new Date(thread.timePosted).setMilliseconds(0) === new Date(thread.timeLastEdited).setMilliseconds(0) ? (