[6221ab6] | 1 | import React, { useEffect } from "react";
|
---|
[702ca77] | 2 | import {
|
---|
| 3 | OpinionCard,
|
---|
| 4 | OpinionCardContent,
|
---|
| 5 | OpinionCardContentTime,
|
---|
| 6 | OpinionCardContentTitle,
|
---|
| 7 | } from "../Components/Styled/OpinionCard.style";
|
---|
| 8 | import {
|
---|
| 9 | UserDetailsCard,
|
---|
| 10 | UserDetailsCardContent,
|
---|
| 11 | } from "../Components/Styled/UserDetails.style";
|
---|
| 12 | import { dateConverter } from "../Util/dateConverter";
|
---|
| 13 |
|
---|
[6221ab6] | 14 | function UserDashboard({ user, userLoaded }) {
|
---|
[702ca77] | 15 | useEffect(() => {
|
---|
[6221ab6] | 16 | const timer = setTimeout(() => {
|
---|
| 17 | if (user === null) window.location.reload(false);
|
---|
| 18 | }, 3000);
|
---|
| 19 | return () => clearTimeout(timer);
|
---|
[702ca77] | 20 | }, []);
|
---|
| 21 |
|
---|
[6221ab6] | 22 | return userLoaded ? (
|
---|
[702ca77] | 23 | <>
|
---|
| 24 | <h3>Кориснички податоци:</h3>
|
---|
| 25 | <UserDetailsCard>
|
---|
| 26 | <UserDetailsCardContent>
|
---|
| 27 | <b>Име:</b> {user.fullName}{" "}
|
---|
| 28 | <i style={{ fontSize: 14, color: "#0066cc" }}>
|
---|
| 29 | (<u>промени</u>)
|
---|
| 30 | </i>
|
---|
| 31 | </UserDetailsCardContent>
|
---|
| 32 | <UserDetailsCardContent>
|
---|
| 33 | <b>Корисничко име:</b> {user.username}{" "}
|
---|
| 34 | <i style={{ fontSize: 14, color: "#0066cc" }}>
|
---|
| 35 | (<u>промени</u>)
|
---|
| 36 | </i>
|
---|
| 37 | </UserDetailsCardContent>
|
---|
| 38 | <UserDetailsCardContent>
|
---|
| 39 | <b>E-mail:</b> {user.email}
|
---|
| 40 | </UserDetailsCardContent>
|
---|
| 41 | <UserDetailsCardContent>
|
---|
| 42 | <b>Карма:</b> {user.karma}
|
---|
| 43 | </UserDetailsCardContent>
|
---|
| 44 | </UserDetailsCard>
|
---|
| 45 | {user.authoredPosts.length > 0 ? (
|
---|
| 46 | <h3 style={{ marginBottom: "10px" }}>Ваши мислења:</h3>
|
---|
| 47 | ) : (
|
---|
| 48 | <h3>Немате објавени мислења</h3>
|
---|
| 49 | )}
|
---|
| 50 | {user.authoredPosts.map((post) => {
|
---|
| 51 | return (
|
---|
| 52 | <div key={post.postId}>
|
---|
| 53 | <OpinionCard>
|
---|
| 54 | <OpinionCardContent>
|
---|
| 55 | <p>
|
---|
| 56 | Во дискусија за{" "}
|
---|
| 57 | <a href={"/professor/" + post.targetProfessor.professorId}>
|
---|
| 58 | {post.targetProfessor.professorName}
|
---|
| 59 | </a>
|
---|
| 60 | </p>
|
---|
| 61 | <OpinionCardContentTitle>{post.title}</OpinionCardContentTitle>
|
---|
| 62 | <p>{post.content}</p>
|
---|
| 63 | <OpinionCardContentTime>
|
---|
| 64 | {dateConverter(
|
---|
| 65 | new Date(post.timePosted).toString().slice(4, -43)
|
---|
| 66 | )}
|
---|
| 67 | </OpinionCardContentTime>
|
---|
| 68 | </OpinionCardContent>
|
---|
| 69 | </OpinionCard>
|
---|
| 70 | </div>
|
---|
| 71 | );
|
---|
| 72 | })}
|
---|
| 73 | </>
|
---|
| 74 | ) : (
|
---|
| 75 | <>се вчитува...</>
|
---|
| 76 | );
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | export default UserDashboard;
|
---|