source: reactapp/src/Pages/PublicUserProfile.js@ 9bf1f8d

main
Last change on this file since 9bf1f8d was 9bf1f8d, checked in by viktor <viktor@…>, 22 months ago

prefinal

  • Property mode set to 100644
File size: 2.1 KB
Line 
1import React, {useEffect, useState} from 'react';
2import {UserDetailsCard, UserDetailsCardContent} from "../Components/Styled/UserDetails.style";
3import {useParams} from "react-router-dom";
4import JSOG from "jsog";
5import LoadingSpinner from "../Components/Styled/LoadingSpinner.style";
6
7const PublicUserProfile = () => {
8 let params = useParams();
9
10 const [publicProfile, setPublicProfile] = useState(null);
11 const [loadedPublicProfile, setLoadedPublicProfile] = useState(false);
12
13 useEffect(() => {
14 const fetchPublicProfile = async () => {
15 const resp = await fetch(`http://192.168.1.254:8080/public/user/${params.userId}`)
16 let cyclicGraph = await resp.json();
17 let jsogStructure = JSOG.encode(cyclicGraph);
18 cyclicGraph = JSOG.decode(jsogStructure);
19 setPublicProfile(cyclicGraph);
20 setLoadedPublicProfile(true);
21 }
22 fetchPublicProfile();
23 },
24 []
25 )
26
27 return <>
28 {loadedPublicProfile ?
29 (<>
30 <h3>Кориснички податоци за корисник #{publicProfile.id}:</h3>
31 <UserDetailsCard>
32 {publicProfile.fullName && (
33 <UserDetailsCardContent>
34 <b>Име:</b> {publicProfile.fullName}{" "}
35 </UserDetailsCardContent>
36 )}
37 <UserDetailsCardContent>
38 <b>Корисничко име:</b> {publicProfile.username}{" "}
39 </UserDetailsCardContent>
40 <UserDetailsCardContent>
41 <b>E-mail:</b> {publicProfile.email}
42 </UserDetailsCardContent>
43 <UserDetailsCardContent>
44 <b>Карма:</b>{" "}
45 <span style={{color: publicProfile.karma < 0 ? "indianred" : "green"}}>
46 {publicProfile.karma}
47 </span>
48 </UserDetailsCardContent>
49 </UserDetailsCard>
50 </>)
51 :
52 <LoadingSpinner/>
53 }
54 </>
55};
56
57export default PublicUserProfile;
Note: See TracBrowser for help on using the repository browser.