source: reactapp/src/Pages/UserDashboard.js@ 62b653f

main
Last change on this file since 62b653f was 6221ab6, checked in by unknown <mlviktor23@…>, 23 months ago

finished add post func. in react, fixed user dashboard details not loading upon login redirect

  • Property mode set to 100644
File size: 2.4 KB
Line 
1import React, { useEffect } from "react";
2import {
3 OpinionCard,
4 OpinionCardContent,
5 OpinionCardContentTime,
6 OpinionCardContentTitle,
7} from "../Components/Styled/OpinionCard.style";
8import {
9 UserDetailsCard,
10 UserDetailsCardContent,
11} from "../Components/Styled/UserDetails.style";
12import { dateConverter } from "../Util/dateConverter";
13
14function UserDashboard({ user, userLoaded }) {
15 useEffect(() => {
16 const timer = setTimeout(() => {
17 if (user === null) window.location.reload(false);
18 }, 3000);
19 return () => clearTimeout(timer);
20 }, []);
21
22 return userLoaded ? (
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
79export default UserDashboard;
Note: See TracBrowser for help on using the repository browser.