diff options
| -rw-r--r-- | frontend/src/App.js | 4 | ||||
| -rw-r--r-- | frontend/src/components/login.js | 16 | ||||
| -rw-r--r-- | frontend/src/components/pages/profile.css | 238 | ||||
| -rw-r--r-- | frontend/src/components/pages/profile.js | 382 | ||||
| -rw-r--r-- | frontend/src/components/pages/summary.css | 14 | ||||
| -rw-r--r-- | frontend/src/components/pages/summary.js | 7 | ||||
| -rw-r--r-- | frontend/src/components/sidebar.js | 19 | ||||
| -rw-r--r-- | frontend/src/imgs/14.png | bin | 0 -> 1363 bytes | |||
| -rw-r--r-- | frontend/src/imgs/15.png | bin | 0 -> 2988 bytes | |||
| -rw-r--r-- | frontend/src/imgs/16.png | bin | 0 -> 3078 bytes | |||
| -rw-r--r-- | frontend/src/imgs/17.png | bin | 0 -> 4943 bytes | |||
| -rw-r--r-- | frontend/src/imgs/18.png | bin | 0 -> 2434 bytes | |||
| -rw-r--r-- | frontend/src/imgs/19.png | bin | 0 -> 1266 bytes |
13 files changed, 653 insertions, 27 deletions
diff --git a/frontend/src/App.js b/frontend/src/App.js index d75636f..93652e6 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js | |||
| @@ -6,6 +6,7 @@ import Main from "./components/main.js" | |||
| 6 | import "./App.css"; | 6 | import "./App.css"; |
| 7 | 7 | ||
| 8 | import Summary from "./components/pages/summary.js" | 8 | import Summary from "./components/pages/summary.js" |
| 9 | import Profile from "./components/pages/profile.js" | ||
| 9 | import About from './components/pages/about.js'; | 10 | import About from './components/pages/about.js'; |
| 10 | 11 | ||
| 11 | 12 | ||
| @@ -30,7 +31,8 @@ export default function App() { | |||
| 30 | <Route path="/leaderboards" element={<Main text="Leaderboards"/>}></Route> | 31 | <Route path="/leaderboards" element={<Main text="Leaderboards"/>}></Route> |
| 31 | <Route path="/discussions" element={<Main text="Discussion"/>}></Route> | 32 | <Route path="/discussions" element={<Main text="Discussion"/>}></Route> |
| 32 | <Route path="/scorelog" element={<Main text="Score logs"/>}></Route> | 33 | <Route path="/scorelog" element={<Main text="Score logs"/>}></Route> |
| 33 | <Route path="/profile" element={<Main text="Profile"/>}></Route> | 34 | <Route path="/profile" element={<Profile token={token}/>}></Route> |
| 35 | <Route path="/users/*" element={<Profile/>}></Route> | ||
| 34 | <Route path="/rules" element={<Main text="Rules"/>}></Route> | 36 | <Route path="/rules" element={<Main text="Rules"/>}></Route> |
| 35 | <Route path="/about" element={<About/>}></Route> | 37 | <Route path="/about" element={<About/>}></Route> |
| 36 | <Route path="/maps/*" element={<Summary token={token} mod={mod}/>}></Route> | 38 | <Route path="/maps/*" element={<Summary token={token} mod={mod}/>}></Route> |
diff --git a/frontend/src/components/login.js b/frontend/src/components/login.js index 204007f..2b735cb 100644 --- a/frontend/src/components/login.js +++ b/frontend/src/components/login.js | |||
| @@ -8,7 +8,7 @@ import img3 from "../imgs/11.png" | |||
| 8 | 8 | ||
| 9 | 9 | ||
| 10 | export default function Login(prop) { | 10 | export default function Login(prop) { |
| 11 | const {token,setToken} = prop | 11 | const {setToken,profile,setProfile} = prop |
| 12 | function login() { | 12 | function login() { |
| 13 | window.location.href="https://lp.ardapektezol.com/api/v1/login" | 13 | window.location.href="https://lp.ardapektezol.com/api/v1/login" |
| 14 | } | 14 | } |
| @@ -16,26 +16,16 @@ function logout() { | |||
| 16 | setIsLoggedIn(false) | 16 | setIsLoggedIn(false) |
| 17 | setProfile(null) | 17 | setProfile(null) |
| 18 | setToken(null) | 18 | setToken(null) |
| 19 | fetch(`/api/v1/token`,{'method':'DELETE'}) | 19 | fetch(`https://lp.ardapektezol.com/api/v1/token`,{'method':'DELETE'}) |
| 20 | .then(r=>window.location.href="/") | 20 | .then(r=>window.location.href="/") |
| 21 | } | 21 | } |
| 22 | const [isLoggedIn, setIsLoggedIn] = React.useState(false); | 22 | const [isLoggedIn, setIsLoggedIn] = React.useState(false); |
| 23 | React.useEffect(() => { | 23 | React.useEffect(() => { |
| 24 | fetch(`/api/v1/token`) | 24 | fetch(`https://lp.ardapektezol.com/api/v1/token`) |
| 25 | .then(r => r.json()) | 25 | .then(r => r.json()) |
| 26 | .then(d => setToken(d.data.token)) | 26 | .then(d => setToken(d.data.token)) |
| 27 | }, []); | 27 | }, []); |
| 28 | 28 | ||
| 29 | const [profile, setProfile] = React.useState(null); | ||
| 30 | React.useEffect(() => { | ||
| 31 | fetch(`/api/v1/profile`,{ | ||
| 32 | headers: { | ||
| 33 | 'Content-Type': 'application/json', | ||
| 34 | Authorization: token | ||
| 35 | }}) | ||
| 36 | .then(r => r.json()) | ||
| 37 | .then(d => setProfile(d.data)) | ||
| 38 | }, [token]); | ||
| 39 | 29 | ||
| 40 | React.useEffect(() => { | 30 | React.useEffect(() => { |
| 41 | if(profile!==null){setIsLoggedIn(true)} | 31 | if(profile!==null){setIsLoggedIn(true)} |
diff --git a/frontend/src/components/pages/profile.css b/frontend/src/components/pages/profile.css new file mode 100644 index 0000000..677fa9b --- /dev/null +++ b/frontend/src/components/pages/profile.css | |||
| @@ -0,0 +1,238 @@ | |||
| 1 | #section1.profile{ | ||
| 2 | margin: 20px; | ||
| 3 | background: linear-gradient(0deg, #202232 50%, #2b2e46 50%); | ||
| 4 | border-radius: 24px; | ||
| 5 | height: 200px; | ||
| 6 | |||
| 7 | display: grid; | ||
| 8 | grid-template-columns: 250px 1fr; | ||
| 9 | |||
| 10 | } | ||
| 11 | #section1.profile>div:first-child{ | ||
| 12 | overflow: hidden; | ||
| 13 | border-radius: 100%; | ||
| 14 | display: grid; | ||
| 15 | |||
| 16 | place-items: center; | ||
| 17 | |||
| 18 | margin: 8px 33px 8px 33px; | ||
| 19 | scale: 0.9; | ||
| 20 | grid-row: 1 / 3; | ||
| 21 | |||
| 22 | |||
| 23 | } | ||
| 24 | #profile-image>img{ | ||
| 25 | border-radius: 100%; | ||
| 26 | transition: filter 0.3s; | ||
| 27 | cursor: pointer; | ||
| 28 | } | ||
| 29 | |||
| 30 | #profile-image>span{ | ||
| 31 | z-index: 1; | ||
| 32 | position: absolute; | ||
| 33 | opacity: 0; | ||
| 34 | color:white; | ||
| 35 | transition: opacity 0.3s; | ||
| 36 | cursor: pointer; | ||
| 37 | } | ||
| 38 | |||
| 39 | #profile-image:hover > img{filter: blur(5px) brightness(60%);z-index: 1;} | ||
| 40 | #profile-image:hover > span{opacity: 1;} | ||
| 41 | |||
| 42 | #profile-top{ | ||
| 43 | height: 100px; | ||
| 44 | display: grid; | ||
| 45 | grid-template-columns: 80% 20%; | ||
| 46 | } | ||
| 47 | #profile-top>div:nth-child(1)>div>img{ | ||
| 48 | margin: 12px; | ||
| 49 | border-radius: 10px; | ||
| 50 | } | ||
| 51 | |||
| 52 | #profile-top>div:nth-child(1){ | ||
| 53 | display: flex; | ||
| 54 | place-items: center; | ||
| 55 | font-size: 50px; | ||
| 56 | font-weight: bold; | ||
| 57 | color: white; | ||
| 58 | } | ||
| 59 | #profile-top>div:nth-child(1)>div{ | ||
| 60 | display: flex; | ||
| 61 | height: 60px; | ||
| 62 | } | ||
| 63 | span.titles{ | ||
| 64 | margin: 12px 12px 12px 0; | ||
| 65 | |||
| 66 | font-size: 18px; | ||
| 67 | font-weight: 100; | ||
| 68 | |||
| 69 | padding: 6px 20px 0px 20px; | ||
| 70 | border-radius: 10px; | ||
| 71 | } | ||
| 72 | |||
| 73 | #profile-top>div:nth-child(2){ | ||
| 74 | display: flex; | ||
| 75 | flex-direction: row-reverse; | ||
| 76 | align-items: center; | ||
| 77 | padding-right: 10px; | ||
| 78 | } | ||
| 79 | #profile-top>div:nth-child(2)>a>img{ | ||
| 80 | height: 50px; | ||
| 81 | padding: 0 5px 0 5px; | ||
| 82 | scale: 0.9; | ||
| 83 | filter: brightness(200%); | ||
| 84 | |||
| 85 | } | ||
| 86 | |||
| 87 | |||
| 88 | #profile-bottom{ | ||
| 89 | height: 100px; | ||
| 90 | display: grid; | ||
| 91 | grid-template-columns: 1fr 1fr 1fr; | ||
| 92 | } | ||
| 93 | #profile-bottom>div{ | ||
| 94 | margin: 12px; | ||
| 95 | background-color: #2b2e46; | ||
| 96 | border-radius: 20px; | ||
| 97 | display: grid; | ||
| 98 | place-items: center; | ||
| 99 | grid-template-rows: 40% 50%; | ||
| 100 | } | ||
| 101 | #profile-bottom>div>span:nth-child(1){ | ||
| 102 | color: inherit; | ||
| 103 | font-size: 18px; | ||
| 104 | } | ||
| 105 | #profile-bottom>div>span:nth-child(2){ | ||
| 106 | color: white; | ||
| 107 | font-size: 40px; | ||
| 108 | } | ||
| 109 | #profile-bottom>div>span:nth-child(2)>span{ | ||
| 110 | color: white; | ||
| 111 | font-size: 20px; | ||
| 112 | } | ||
| 113 | /* #section1.profile>div>div{outline: red 1px dashed;} */ | ||
| 114 | |||
| 115 | |||
| 116 | #section2.profile{ | ||
| 117 | margin: 20px; | ||
| 118 | height: 60px; | ||
| 119 | display: grid; | ||
| 120 | grid-template-columns: 1fr 1fr; | ||
| 121 | } | ||
| 122 | #section2.profile>button{ | ||
| 123 | display: flex; | ||
| 124 | justify-content: center; | ||
| 125 | align-items: center; | ||
| 126 | |||
| 127 | background-color: #2b2e46; | ||
| 128 | border: 0; | ||
| 129 | color: inherit; | ||
| 130 | font-family: inherit; | ||
| 131 | font-size: 24px; | ||
| 132 | cursor: pointer; | ||
| 133 | |||
| 134 | transition: background-color .1s; | ||
| 135 | } | ||
| 136 | #section2.profile>button:nth-child(1){border-radius: 24px 0 0 24px;} | ||
| 137 | #section2.profile>button:nth-child(2){border-radius: 0 24px 24px 0;} | ||
| 138 | |||
| 139 | #section3.profile1>hr{border: 1px solid #2b2e46;margin: 8px 20px 0px 20px;} | ||
| 140 | #section3.profile1{ | ||
| 141 | margin: 20px; | ||
| 142 | display: block; | ||
| 143 | |||
| 144 | background-color: #202232; | ||
| 145 | border-radius: 24px; | ||
| 146 | } | ||
| 147 | |||
| 148 | #profileboard-nav{ | ||
| 149 | display: grid; | ||
| 150 | grid-template-columns: 1fr 1fr; | ||
| 151 | } | ||
| 152 | |||
| 153 | #profileboard-nav>select{ | ||
| 154 | |||
| 155 | /* appearance: none; */ | ||
| 156 | margin: 10px 20px 20px 20px; | ||
| 157 | height: 50px; | ||
| 158 | |||
| 159 | border-radius: 24px; | ||
| 160 | text-align: center; | ||
| 161 | |||
| 162 | color: inherit; | ||
| 163 | font-family: inherit; | ||
| 164 | font-size: 24px; | ||
| 165 | border: 0; | ||
| 166 | |||
| 167 | background-color: #2b2e46; | ||
| 168 | } | ||
| 169 | |||
| 170 | |||
| 171 | #profileboard-top>span>img{height: 20px;scale: .8;} | ||
| 172 | #profileboard-top>span>img,#profileboard-top>span>span{cursor: pointer;} | ||
| 173 | #profileboard-top{ | ||
| 174 | height: 34px; | ||
| 175 | display: grid; | ||
| 176 | font-size: 20px; | ||
| 177 | padding-left: 60px; | ||
| 178 | margin: 0 20px; | ||
| 179 | grid-template-columns: 15% 15% 5% 15% 5% 15% 15% 15%; | ||
| 180 | } | ||
| 181 | |||
| 182 | #profileboard-top>span{ | ||
| 183 | display: flex; | ||
| 184 | place-items: flex-end; | ||
| 185 | } | ||
| 186 | |||
| 187 | #profileboard-records{ | ||
| 188 | padding-bottom: 10px; | ||
| 189 | } | ||
| 190 | |||
| 191 | .profileboard-record{ | ||
| 192 | width: calc(100% - 40px); | ||
| 193 | margin: 10px 20px 0px 20px; | ||
| 194 | height: 44px; | ||
| 195 | |||
| 196 | border-radius: 20px; | ||
| 197 | padding: 0 0 0 60px; | ||
| 198 | font-size: 20px; | ||
| 199 | |||
| 200 | color: inherit; | ||
| 201 | font-family: inherit; | ||
| 202 | border: 0; | ||
| 203 | transition: background-color .1s; | ||
| 204 | background-color: #2b2e46; | ||
| 205 | display: grid; | ||
| 206 | grid-template-columns: 15% 15% 5% 15% 5% 15% 15% 15%; | ||
| 207 | overflow: hidden; | ||
| 208 | |||
| 209 | transition: height .2s | ||
| 210 | } | ||
| 211 | |||
| 212 | /* this right here should be illegal */ | ||
| 213 | .profileboard-record>span:nth-child(-n+8){filter: brightness(100%);} | ||
| 214 | .profileboard-record>span{ | ||
| 215 | display: flex; | ||
| 216 | place-items: flex-end; | ||
| 217 | filter: brightness(65%); | ||
| 218 | } | ||
| 219 | |||
| 220 | .profileboard-record>hr{ | ||
| 221 | margin: 0 0 0 -60px; | ||
| 222 | border: 0; | ||
| 223 | height: 2px; | ||
| 224 | background-color: #202232; | ||
| 225 | } | ||
| 226 | |||
| 227 | .profileboard-record>span:nth-child(4){display: grid;} | ||
| 228 | .profileboard-record>span{ | ||
| 229 | |||
| 230 | display: flex; | ||
| 231 | place-items: center; | ||
| 232 | height: 44px; | ||
| 233 | } | ||
| 234 | .profileboard-record>span>button{ | ||
| 235 | background-color: #0000; | ||
| 236 | border: 0; | ||
| 237 | cursor: pointer; | ||
| 238 | } | ||
diff --git a/frontend/src/components/pages/profile.js b/frontend/src/components/pages/profile.js new file mode 100644 index 0000000..aa28546 --- /dev/null +++ b/frontend/src/components/pages/profile.js | |||
| @@ -0,0 +1,382 @@ | |||
| 1 | import React from 'react'; | ||
| 2 | import { useLocation } from "react-router-dom"; | ||
| 3 | |||
| 4 | import img4 from "../../imgs/4.png" | ||
| 5 | import img5 from "../../imgs/5.png" | ||
| 6 | import img12 from "../../imgs/12.png" | ||
| 7 | import img13 from "../../imgs/13.png" | ||
| 8 | import img14 from "../../imgs/14.png" | ||
| 9 | import img15 from "../../imgs/15.png" | ||
| 10 | import img16 from "../../imgs/16.png" | ||
| 11 | import img17 from "../../imgs/17.png" | ||
| 12 | import img18 from "../../imgs/18.png" | ||
| 13 | import img19 from "../../imgs/19.png" | ||
| 14 | import "./profile.css"; | ||
| 15 | |||
| 16 | export default function Profile(props) { | ||
| 17 | const {token} = props | ||
| 18 | |||
| 19 | |||
| 20 | const location = useLocation() | ||
| 21 | |||
| 22 | |||
| 23 | const [profileData, setProfileData] = React.useState(null) | ||
| 24 | React.useEffect(()=>{ | ||
| 25 | setProfileData(null) | ||
| 26 | setChapterData(null) | ||
| 27 | setMaps(null) | ||
| 28 | setPageNumber(1) | ||
| 29 | |||
| 30 | if(location.pathname==="/profile"){ | ||
| 31 | fetch(`https://lp.ardapektezol.com/api/v1/${location.pathname}`,{ | ||
| 32 | headers: { | ||
| 33 | 'Authorization': token | ||
| 34 | }}) | ||
| 35 | .then(r=>r.json()) | ||
| 36 | .then(d=>{ | ||
| 37 | setProfileData(d.data) | ||
| 38 | setPageMax(Math.ceil(d.data.records.length/20)) | ||
| 39 | }) | ||
| 40 | }else{ | ||
| 41 | fetch(`https://lp.ardapektezol.com/api/v1/${location.pathname}`) | ||
| 42 | .then(r=>r.json()) | ||
| 43 | .then(d=>{ | ||
| 44 | setProfileData(d.data) | ||
| 45 | setPageMax(Math.ceil(d.data.records.length/20)) | ||
| 46 | }) | ||
| 47 | } | ||
| 48 | },[location.pathname]) | ||
| 49 | |||
| 50 | |||
| 51 | |||
| 52 | const [game,setGame] = React.useState(0) | ||
| 53 | const [gameData,setGameData] = React.useState(null) | ||
| 54 | const [chapter,setChapter] = React.useState("0") | ||
| 55 | const [chapterData,setChapterData] = React.useState(null) | ||
| 56 | const [maps,setMaps] = React.useState(null) | ||
| 57 | |||
| 58 | React.useEffect(()=>{ | ||
| 59 | fetch("https://lp.ardapektezol.com/api/v1/games") | ||
| 60 | .then(r=>r.json()) | ||
| 61 | .then(d=>{ | ||
| 62 | setGameData(d.data) | ||
| 63 | setGame(0) | ||
| 64 | }) | ||
| 65 | |||
| 66 | },[location]) | ||
| 67 | |||
| 68 | React.useEffect(()=>{ | ||
| 69 | if(game!==null && game!= 0){ | ||
| 70 | fetch(`https://lp.ardapektezol.com/api/v1/games/${game}`) | ||
| 71 | .then(r=>r.json()) | ||
| 72 | .then(d=>{ | ||
| 73 | setChapterData(d.data) | ||
| 74 | setChapter("0") | ||
| 75 | document.querySelector('#select-chapter').value=0 | ||
| 76 | }) | ||
| 77 | |||
| 78 | } else if (game!==null && game==0 && profileData!== null){ | ||
| 79 | setPageMax(Math.ceil(profileData.records.length/20)) | ||
| 80 | setPageNumber(1) | ||
| 81 | } | ||
| 82 | |||
| 83 | },[game,location]) | ||
| 84 | |||
| 85 | React.useEffect(()=>{ | ||
| 86 | if(chapter!==null){ | ||
| 87 | if(chapter==0){ | ||
| 88 | setMaps(null) | ||
| 89 | fetch(`https://lp.ardapektezol.com/api/v1/games/${game}/maps`) | ||
| 90 | .then(r=>r.json()) | ||
| 91 | .then(d=>{ | ||
| 92 | setMaps(d.data.maps); | ||
| 93 | setPageMax(Math.ceil(d.data.maps.length/20)) | ||
| 94 | setPageNumber(1) | ||
| 95 | }) | ||
| 96 | }else{ | ||
| 97 | setMaps(null) | ||
| 98 | fetch(`https://lp.ardapektezol.com/api/v1/chapters/${chapter}`) | ||
| 99 | .then(r=>r.json()) | ||
| 100 | .then(d=>{ | ||
| 101 | setMaps(d.data.maps); | ||
| 102 | setPageMax(Math.ceil(d.data.maps.length/20)) | ||
| 103 | setPageNumber(1) | ||
| 104 | }) | ||
| 105 | |||
| 106 | } | ||
| 107 | } | ||
| 108 | },[chapter,chapterData]) | ||
| 109 | |||
| 110 | |||
| 111 | |||
| 112 | const [pageNumber, setPageNumber] = React.useState(1); | ||
| 113 | const [pageMax, setPageMax] = React.useState(0); | ||
| 114 | const [navState, setNavState] = React.useState(0); // eslint-disable-next-line | ||
| 115 | React.useEffect(() => {NavClick();}, [[],navState]); | ||
| 116 | function NavClick() { | ||
| 117 | if(profileData!==null){ | ||
| 118 | const btn = document.querySelectorAll("#section2 button"); | ||
| 119 | btn.forEach((e) => {e.style.backgroundColor = "#2b2e46"}); | ||
| 120 | btn[navState].style.backgroundColor = "#202232"; | ||
| 121 | |||
| 122 | document.querySelectorAll("section").forEach((e,i)=>i>=2?e.style.display="none":"") | ||
| 123 | if(navState === 0){document.querySelectorAll(".profile1").forEach((e) => {e.style.display = "block"});} | ||
| 124 | if(navState === 1){document.querySelectorAll(".profile2").forEach((e) => {e.style.display = "block"});} | ||
| 125 | } | ||
| 126 | } | ||
| 127 | function UpdateProfile(){ | ||
| 128 | fetch(`/api/v1/profile`,{ | ||
| 129 | method: 'POST', | ||
| 130 | headers: {Authorization: token} | ||
| 131 | }).then(r=>window.location.reload()) | ||
| 132 | } | ||
| 133 | |||
| 134 | function TimeAgo(date) { | ||
| 135 | const seconds = Math.floor((new Date() - date) / 1000); | ||
| 136 | |||
| 137 | let interval = Math.floor(seconds / 31536000); | ||
| 138 | if (interval > 1) {return interval + ' years ago';} | ||
| 139 | |||
| 140 | interval = Math.floor(seconds / 2592000); | ||
| 141 | if (interval > 1) {return interval + ' months ago';} | ||
| 142 | |||
| 143 | interval = Math.floor(seconds / 86400); | ||
| 144 | if (interval > 1) {return interval + ' days ago';} | ||
| 145 | |||
| 146 | interval = Math.floor(seconds / 3600); | ||
| 147 | if (interval > 1) {return interval + ' hours ago';} | ||
| 148 | |||
| 149 | interval = Math.floor(seconds / 60); | ||
| 150 | if (interval > 1) {return interval + ' minutes ago';} | ||
| 151 | |||
| 152 | if(seconds < 10) return 'just now'; | ||
| 153 | |||
| 154 | return Math.floor(seconds) + ' seconds ago'; | ||
| 155 | }; | ||
| 156 | |||
| 157 | function TicksToTime(ticks) { | ||
| 158 | |||
| 159 | let seconds = Math.floor(ticks/60) | ||
| 160 | let minutes = Math.floor(seconds/60) | ||
| 161 | let hours = Math.floor(minutes/60) | ||
| 162 | |||
| 163 | let milliseconds = Math.floor((ticks%60)*1000/60) | ||
| 164 | seconds = seconds % 60; | ||
| 165 | minutes = minutes % 60; | ||
| 166 | |||
| 167 | return `${hours===0?"":hours+":"}${minutes===0?"":hours>0?minutes.toString().padStart(2, '0')+":":(minutes+":")}${minutes>0?seconds.toString().padStart(2, '0'):seconds}.${milliseconds.toString().padStart(3, '0')} (${ticks})`; | ||
| 168 | } | ||
| 169 | |||
| 170 | |||
| 171 | if(profileData!==null){ | ||
| 172 | return ( | ||
| 173 | <main> | ||
| 174 | <section id='section1' className='profile'> | ||
| 175 | |||
| 176 | {profileData.profile?( | ||
| 177 | <div id='profile-image' onClick={()=>UpdateProfile()}> | ||
| 178 | <img src={profileData.avatar_link} alt=""></img> | ||
| 179 | <span>Refresh</span> | ||
| 180 | </div> | ||
| 181 | ):( | ||
| 182 | <div> | ||
| 183 | <img src={profileData.avatar_link} alt=""></img> | ||
| 184 | </div> | ||
| 185 | )} | ||
| 186 | |||
| 187 | <div id='profile-top'> | ||
| 188 | <div> | ||
| 189 | <div>{profileData.user_name}</div> | ||
| 190 | <div> | ||
| 191 | {profileData.country_code==="XX"?"":<img src={`https://flagcdn.com/w80/${profileData.country_code.toLowerCase()}.jpg`} alt={profileData.country_code} />} | ||
| 192 | </div> | ||
| 193 | <div> | ||
| 194 | {profileData.titles.map(e=>( | ||
| 195 | <span className="titles" style={{backgroundColor:`#${e.color}`}}> | ||
| 196 | {e.name} | ||
| 197 | </span> | ||
| 198 | ))} | ||
| 199 | </div> | ||
| 200 | </div> | ||
| 201 | <div> | ||
| 202 | {profileData.links.p2sr==="-"?"":<a href={profileData.links.p2sr}><img src={img17} alt="Steam" /></a>} | ||
| 203 | {profileData.links.p2sr==="-"?"":<a href={profileData.links.p2sr}><img src={img15} alt="Twitch" /></a>} | ||
| 204 | {profileData.links.p2sr==="-"?"":<a href={profileData.links.p2sr}><img src={img16} alt="Youtube" /></a>} | ||
| 205 | {profileData.links.p2sr==="-"?"":<a href={profileData.links.p2sr}><img src={img4} alt="P2SR" style={{padding:"0"}} /></a>} | ||
| 206 | </div> | ||
| 207 | |||
| 208 | </div> | ||
| 209 | <div id='profile-bottom'> | ||
| 210 | <div> | ||
| 211 | <span>Overall</span> | ||
| 212 | <span>{profileData.rankings.overall.rank===0?"N/A ":"#"+profileData.rankings.overall.rank+" "} | ||
| 213 | <span>({profileData.rankings.overall.completion_count}/{profileData.rankings.overall.completion_total})</span> | ||
| 214 | </span> | ||
| 215 | </div> | ||
| 216 | <div> | ||
| 217 | <span>Singleplayer</span> | ||
| 218 | <span>{profileData.rankings.singleplayer.rank===0?"N/A ":"#"+profileData.rankings.singleplayer.rank+" "} | ||
| 219 | <span>({profileData.rankings.singleplayer.completion_count}/{profileData.rankings.singleplayer.completion_total})</span> | ||
| 220 | </span> | ||
| 221 | </div> | ||
| 222 | <div> | ||
| 223 | <span>Cooperative</span> | ||
| 224 | <span>{profileData.rankings.cooperative.rank===0?"N/A":"#"+profileData.rankings.cooperative.rank+" "} | ||
| 225 | <span>({profileData.rankings.cooperative.completion_count}/{profileData.rankings.cooperative.completion_total})</span> | ||
| 226 | </span> | ||
| 227 | </div> | ||
| 228 | </div> | ||
| 229 | </section> | ||
| 230 | |||
| 231 | |||
| 232 | <section id='section2' className='profile'> | ||
| 233 | <button onClick={()=>setNavState(0)}><img src={img5} alt="" /> Player Records</button> | ||
| 234 | <button onClick={()=>setNavState(1)}><img src={img14} alt="" /> Statistics</button> | ||
| 235 | </section> | ||
| 236 | |||
| 237 | |||
| 238 | |||
| 239 | |||
| 240 | |||
| 241 | <section id='section3' className='profile1'> | ||
| 242 | <div id='profileboard-nav'> | ||
| 243 | {gameData===null?<select>error</select>: | ||
| 244 | |||
| 245 | <select id='select-game' | ||
| 246 | onChange={()=>setGame(document.querySelector('#select-game').value)}> | ||
| 247 | <option value={0} key={0}>All Scores</option> | ||
| 248 | {gameData.map((e,i)=>( | ||
| 249 | <option value={e.id} key={i+1}>{e.name}</option> | ||
| 250 | ))}</select> | ||
| 251 | } | ||
| 252 | |||
| 253 | {game==0? | ||
| 254 | <select disabled> | ||
| 255 | <option>All Scores</option> | ||
| 256 | </select> | ||
| 257 | :chapterData===null?<select></select>: | ||
| 258 | |||
| 259 | <select id='select-chapter' | ||
| 260 | onChange={()=>setChapter(document.querySelector('#select-chapter').value)}> | ||
| 261 | <option value="0" key="0">All</option> | ||
| 262 | {chapterData.chapters.filter(e=>e.is_disabled===false).map((e,i)=>( | ||
| 263 | <option value={e.id} key={i+1}>{e.name}</option> | ||
| 264 | ))}</select> | ||
| 265 | } | ||
| 266 | </div> | ||
| 267 | <div id='profileboard-top'> | ||
| 268 | <span><span>Map Name</span><img src={img19} alt="" /></span> | ||
| 269 | <span style={{justifyContent:'center'}}><span>Portals</span><img src={img19} alt="" /></span> | ||
| 270 | <span style={{justifyContent:'center'}}><span>WRΔ </span><img src={img19} alt="" /></span> | ||
| 271 | <span style={{justifyContent:'center'}}><span>Time</span><img src={img19} alt="" /></span> | ||
| 272 | <span> </span> | ||
| 273 | <span><span>Rank</span><img src={img19} alt="" /></span> | ||
| 274 | <span><span>Date</span><img src={img19} alt="" /></span> | ||
| 275 | <div id='page-number'> | ||
| 276 | <div> | ||
| 277 | <button onClick={() => pageNumber === 1 ? null : setPageNumber(prevPageNumber => prevPageNumber - 1)} | ||
| 278 | ><i className='triangle' style={{position:'relative',left:'-5px',}}></i> </button> | ||
| 279 | <span>{pageNumber}/{pageMax}</span> | ||
| 280 | <button onClick={() => pageNumber === pageMax? null : setPageNumber(prevPageNumber => prevPageNumber + 1)} | ||
| 281 | ><i className='triangle' style={{position:'relative',left:'5px',transform:'rotate(180deg)'}}></i> </button> | ||
| 282 | </div> | ||
| 283 | </div> | ||
| 284 | </div> | ||
| 285 | <hr/> | ||
| 286 | <div id='profileboard-records'> | ||
| 287 | |||
| 288 | {console.log(profileData)} | ||
| 289 | {game == 0 && profileData !== null | ||
| 290 | ? ( | ||
| 291 | |||
| 292 | profileData.records.sort((a,b)=>a.map_id - b.map_id) | ||
| 293 | .map((r, index) => ( | ||
| 294 | |||
| 295 | Math.ceil((index+1)/20)===pageNumber ? ( | ||
| 296 | <button className="profileboard-record" key={index}> | ||
| 297 | {r.scores.map((e,i)=>(<> | ||
| 298 | {i!==0?<hr style={{gridColumn:"1 / span 8"}}/>:""} | ||
| 299 | |||
| 300 | <span>{r.map_name}</span> | ||
| 301 | |||
| 302 | <span style={{ display: "grid" }}>{e.score_count}</span> | ||
| 303 | |||
| 304 | <span style={{ display: "grid" }}>{e.score_count-r.map_wr_count}</span> | ||
| 305 | <span style={{ display: "grid" }}>{TicksToTime(e.score_time)}</span> | ||
| 306 | <span> </span> | ||
| 307 | {i===0?<span>#{r.placement}</span>:<span> </span>} | ||
| 308 | <span>{e.date.split("T")[0]}</span> | ||
| 309 | <span style={{ flexDirection: "row-reverse" }}> | ||
| 310 | |||
| 311 | <button onClick={()=>{window.alert(`Demo ID: ${e.demo_id}`)}}><img src={img13} alt="demo_id" /></button> | ||
| 312 | <button onClick={()=>window.location.href=`https://lp.ardapektezol.com/api/v1/demos?uuid=${e.demo_id}`}><img src={img12} alt="download" /></button> | ||
| 313 | {i===0&&r.scores.length>1?<button onClick={()=> | ||
| 314 | { | ||
| 315 | document.querySelectorAll(".profileboard-record")[index%20].style.height==="44px"|| | ||
| 316 | document.querySelectorAll(".profileboard-record")[index%20].style.height===""? | ||
| 317 | document.querySelectorAll(".profileboard-record")[index%20].style.height=`${r.scores.length*46}px`: | ||
| 318 | document.querySelectorAll(".profileboard-record")[index%20].style.height="44px" | ||
| 319 | } | ||
| 320 | }><img src={img18} alt="history" /></button>:""} | ||
| 321 | |||
| 322 | </span> | ||
| 323 | </>))} | ||
| 324 | |||
| 325 | </button> | ||
| 326 | ) : "" | ||
| 327 | ))) : maps !== null ? | ||
| 328 | |||
| 329 | maps.filter(e=>e.is_disabled===false).sort((a,b)=>a.id - b.id) | ||
| 330 | .map((r, index) => { | ||
| 331 | if(Math.ceil((index+1)/20)===pageNumber){ | ||
| 332 | let record = profileData.records.find((e) => e.map_id === r.id); | ||
| 333 | return record === undefined ? ( | ||
| 334 | <button className="profileboard-record" key={index} style={{backgroundColor:"#1b1b20"}}> | ||
| 335 | <span>{r.name}</span> | ||
| 336 | <span style={{ display: "grid" }}>N/A</span> | ||
| 337 | <span style={{ display: "grid" }}>N/A</span> | ||
| 338 | <span>N/A</span> | ||
| 339 | <span> </span> | ||
| 340 | <span>N/A</span> | ||
| 341 | <span>N/A</span> | ||
| 342 | <span style={{ flexDirection: "row-reverse" }}></span> | ||
| 343 | </button> | ||
| 344 | ) : ( | ||
| 345 | <button className="profileboard-record" key={index}> | ||
| 346 | {record.scores.map((e,i)=>(<> | ||
| 347 | {i!==0?<hr style={{gridColumn:"1 / span 8"}}/>:""} | ||
| 348 | <span>{r.name}</span> | ||
| 349 | <span style={{ display: "grid" }}>{record.scores[i].score_count}</span> | ||
| 350 | <span style={{ display: "grid" }}>{record.scores[i].score_count-record.map_wr_count}</span> | ||
| 351 | <span>{TicksToTime(record.scores[i].score_time)}</span> | ||
| 352 | <span> </span> | ||
| 353 | {i===0?<span>#{record.placement}</span>:<span> </span>} | ||
| 354 | <span>{record.scores[i].date.split("T")[0]}</span> | ||
| 355 | <span style={{ flexDirection: "row-reverse" }}> | ||
| 356 | |||
| 357 | <button onClick={()=>{window.alert(`Demo ID: ${e.demo_id}`)}}><img src={img13} alt="demo_id" /></button> | ||
| 358 | <button onClick={()=>window.location.href=`https://lp.ardapektezol.com/api/v1/demos?uuid=${e.demo_id}`}><img src={img12} alt="download" /></button> | ||
| 359 | {i===0&&record.scores.length>1?<button onClick={()=> | ||
| 360 | { | ||
| 361 | document.querySelectorAll(".profileboard-record")[index%20].style.height==="44px"|| | ||
| 362 | document.querySelectorAll(".profileboard-record")[index%20].style.height===""? | ||
| 363 | document.querySelectorAll(".profileboard-record")[index%20].style.height=`${record.scores.length*46}px`: | ||
| 364 | document.querySelectorAll(".profileboard-record")[index%20].style.height="44px" | ||
| 365 | } | ||
| 366 | }><img src={img18} alt="history" /></button>:""} | ||
| 367 | |||
| 368 | </span> | ||
| 369 | </>))} | ||
| 370 | </button> | ||
| 371 | |||
| 372 | ) | ||
| 373 | }else{return null} | ||
| 374 | }):(<>{console.warn(maps)}</>)} | ||
| 375 | </div> | ||
| 376 | </section> | ||
| 377 | |||
| 378 | </main> | ||
| 379 | )} | ||
| 380 | } | ||
| 381 | |||
| 382 | |||
diff --git a/frontend/src/components/pages/summary.css b/frontend/src/components/pages/summary.css index 51f8515..47c3f4b 100644 --- a/frontend/src/components/pages/summary.css +++ b/frontend/src/components/pages/summary.css | |||
| @@ -463,11 +463,11 @@ text-align: center; | |||
| 463 | 463 | ||
| 464 | /* such responsive, very mobile */ | 464 | /* such responsive, very mobile */ |
| 465 | @media screen and (max-width: 1480px) { | 465 | @media screen and (max-width: 1480px) { |
| 466 | #section3{grid-template-columns: auto;} | 466 | #section3.summary1{grid-template-columns: auto;} |
| 467 | #category{min-width: 608px;} | 467 | #category{min-width: 608px;} |
| 468 | #history{min-width: 608px;} | 468 | #history{min-width: 608px;} |
| 469 | #description{min-width: 608px;} | 469 | #description{min-width: 608px;} |
| 470 | #section4{min-width: 588px;} | 470 | #section4.summary1{min-width: 588px;} |
| 471 | 471 | ||
| 472 | #description>iframe{ | 472 | #description>iframe{ |
| 473 | padding: 0 0 0 calc(50% - 304px); | 473 | padding: 0 0 0 calc(50% - 304px); |
| @@ -476,19 +476,19 @@ text-align: center; | |||
| 476 | align-items: center; | 476 | align-items: center; |
| 477 | } | 477 | } |
| 478 | 478 | ||
| 479 | #section1{ | 479 | #section1.summary1{ |
| 480 | grid-template-columns: auto; | 480 | grid-template-columns: auto; |
| 481 | place-items: center; | 481 | place-items: center; |
| 482 | text-align: center; | 482 | text-align: center; |
| 483 | 483 | ||
| 484 | } | 484 | } |
| 485 | 485 | ||
| 486 | #section2{ | 486 | #section2.summary1{ |
| 487 | grid-template-columns: auto; | 487 | grid-template-columns: auto; |
| 488 | width: 450px; | 488 | width: 450px; |
| 489 | margin: 40px auto 0 auto; | 489 | margin: 40px auto 0 auto; |
| 490 | } | 490 | } |
| 491 | #section2>.nav-button:nth-child(1){border-radius: 30px 30px 0 0;} | 491 | #section2.summary1>.nav-button:nth-child(1){border-radius: 30px 30px 0 0;} |
| 492 | #section2>.nav-button:nth-child(2){border-radius: 0;} | 492 | #section2.summary1>.nav-button:nth-child(2){border-radius: 0;} |
| 493 | #section2>.nav-button:nth-child(3){border-radius: 0 0 30px 30px;} | 493 | #section2.summary1>.nav-button:nth-child(3){border-radius: 0 0 30px 30px;} |
| 494 | } \ No newline at end of file | 494 | } \ No newline at end of file |
diff --git a/frontend/src/components/pages/summary.js b/frontend/src/components/pages/summary.js index c03d7b9..7c72c48 100644 --- a/frontend/src/components/pages/summary.js +++ b/frontend/src/components/pages/summary.js | |||
| @@ -20,6 +20,7 @@ const fakedata={} //for debug | |||
| 20 | //fetching data | 20 | //fetching data |
| 21 | const [data, setData] = React.useState(null); | 21 | const [data, setData] = React.useState(null); |
| 22 | React.useEffect(() => { | 22 | React.useEffect(() => { |
| 23 | setData(null) | ||
| 23 | fetch(`https://lp.ardapektezol.com/api/v1/maps/${location.pathname.split('/')[2]}/summary`) | 24 | fetch(`https://lp.ardapektezol.com/api/v1/maps/${location.pathname.split('/')[2]}/summary`) |
| 24 | .then(r => r.json()) | 25 | .then(r => r.json()) |
| 25 | .then(d => { | 26 | .then(d => { |
| @@ -37,7 +38,7 @@ const fakedata={} //for debug | |||
| 37 | .then(r => r.json()) | 38 | .then(r => r.json()) |
| 38 | .then(d => setLbData(d)) | 39 | .then(d => setLbData(d)) |
| 39 | // eslint-disable-next-line | 40 | // eslint-disable-next-line |
| 40 | }, [pageNumber]); | 41 | }, [pageNumber,location.pathname]); |
| 41 | 42 | ||
| 42 | 43 | ||
| 43 | 44 | ||
| @@ -247,7 +248,7 @@ return ( | |||
| 247 | <img src={data.map.image} alt="" /> | 248 | <img src={data.map.image} alt="" /> |
| 248 | </div> | 249 | </div> |
| 249 | <main> | 250 | <main> |
| 250 | <section id='section1'> | 251 | <section id='section1' className='summary1'> |
| 251 | <div> | 252 | <div> |
| 252 | <button className='nav-button'><i className='triangle'></i><span>{data.map.game_name}</span></button> | 253 | <button className='nav-button'><i className='triangle'></i><span>{data.map.game_name}</span></button> |
| 253 | <button className='nav-button'><i className='triangle'></i><span>{data.map.chapter_name}</span></button> | 254 | <button className='nav-button'><i className='triangle'></i><span>{data.map.chapter_name}</span></button> |
| @@ -257,7 +258,7 @@ return ( | |||
| 257 | 258 | ||
| 258 | </section> | 259 | </section> |
| 259 | 260 | ||
| 260 | <section id='section2'> | 261 | <section id='section2' className='summary1'> |
| 261 | <button className='nav-button' onClick={()=>setNavState(0)}><img src={img4} alt="" /><span>Summary</span></button> | 262 | <button className='nav-button' onClick={()=>setNavState(0)}><img src={img4} alt="" /><span>Summary</span></button> |
| 262 | <button className='nav-button' onClick={()=>setNavState(1)}><img src={img5} alt="" /><span>Leaderboards</span></button> | 263 | <button className='nav-button' onClick={()=>setNavState(1)}><img src={img5} alt="" /><span>Leaderboards</span></button> |
| 263 | <button className='nav-button' onClick={()=>setNavState(2)}><img src={img6} alt="" /><span>Discussions</span></button> | 264 | <button className='nav-button' onClick={()=>setNavState(2)}><img src={img6} alt="" /><span>Discussions</span></button> |
diff --git a/frontend/src/components/sidebar.js b/frontend/src/components/sidebar.js index d9b8012..e587c3c 100644 --- a/frontend/src/components/sidebar.js +++ b/frontend/src/components/sidebar.js | |||
| @@ -17,6 +17,17 @@ import Login from "./login.js" | |||
| 17 | 17 | ||
| 18 | export default function Sidebar(prop) { | 18 | export default function Sidebar(prop) { |
| 19 | const {token,setToken} = prop | 19 | const {token,setToken} = prop |
| 20 | const [profile, setProfile] = React.useState(null); | ||
| 21 | React.useEffect(() => { | ||
| 22 | fetch(`https://lp.ardapektezol.com/api/v1/profile`,{ | ||
| 23 | headers: { | ||
| 24 | 'Content-Type': 'application/json', | ||
| 25 | Authorization: token | ||
| 26 | }}) | ||
| 27 | .then(r => r.json()) | ||
| 28 | .then(d => setProfile(d.data)) | ||
| 29 | }, [token]); | ||
| 30 | |||
| 20 | 31 | ||
| 21 | // Locks search button for 300ms before it can be clicked again, prevents spam | 32 | // Locks search button for 300ms before it can be clicked again, prevents spam |
| 22 | const [isLocked, setIsLocked] = React.useState(false); | 33 | const [isLocked, setIsLocked] = React.useState(false); |
| @@ -147,7 +158,7 @@ return ( | |||
| 147 | <div id='sidebar-bottomlist'> | 158 | <div id='sidebar-bottomlist'> |
| 148 | <span></span> | 159 | <span></span> |
| 149 | 160 | ||
| 150 | <Login token={token} setToken={setToken}/> | 161 | <Login setToken={setToken} profile={profile} setProfile={setProfile}/> |
| 151 | 162 | ||
| 152 | <Link to="/rules" tabIndex={-1}> | 163 | <Link to="/rules" tabIndex={-1}> |
| 153 | <button className='sidebar-button'><img src={img8} alt="" /><span>Leaderboard Rules</span></button> | 164 | <button className='sidebar-button'><img src={img8} alt="" /><span>Leaderboard Rules</span></button> |
| @@ -172,11 +183,13 @@ return ( | |||
| 172 | )):""} | 183 | )):""} |
| 173 | {searchData!==null?searchData.players.map((q,index)=> | 184 | {searchData!==null?searchData.players.map((q,index)=> |
| 174 | ( | 185 | ( |
| 175 | <Link className='search-player' key={index}> | 186 | <Link to={ |
| 187 | q.steam_id===profile.steam_id?`/profile`: | ||
| 188 | `/users/${q.steam_id}` | ||
| 189 | } className='search-player' key={index}> | ||
| 176 | <img src={q.avatar_link} alt='pfp'></img> | 190 | <img src={q.avatar_link} alt='pfp'></img> |
| 177 | <span style={{fontSize:`${36 - q.user_name.length * 0.8}px`}}>{q.user_name}</span> | 191 | <span style={{fontSize:`${36 - q.user_name.length * 0.8}px`}}>{q.user_name}</span> |
| 178 | </Link> | 192 | </Link> |
| 179 | |||
| 180 | )):""} | 193 | )):""} |
| 181 | 194 | ||
| 182 | </div> | 195 | </div> |
diff --git a/frontend/src/imgs/14.png b/frontend/src/imgs/14.png new file mode 100644 index 0000000..7be6359 --- /dev/null +++ b/frontend/src/imgs/14.png | |||
| Binary files differ | |||
diff --git a/frontend/src/imgs/15.png b/frontend/src/imgs/15.png new file mode 100644 index 0000000..e5ae8aa --- /dev/null +++ b/frontend/src/imgs/15.png | |||
| Binary files differ | |||
diff --git a/frontend/src/imgs/16.png b/frontend/src/imgs/16.png new file mode 100644 index 0000000..bf3ae0c --- /dev/null +++ b/frontend/src/imgs/16.png | |||
| Binary files differ | |||
diff --git a/frontend/src/imgs/17.png b/frontend/src/imgs/17.png new file mode 100644 index 0000000..85e39f0 --- /dev/null +++ b/frontend/src/imgs/17.png | |||
| Binary files differ | |||
diff --git a/frontend/src/imgs/18.png b/frontend/src/imgs/18.png new file mode 100644 index 0000000..048cda9 --- /dev/null +++ b/frontend/src/imgs/18.png | |||
| Binary files differ | |||
diff --git a/frontend/src/imgs/19.png b/frontend/src/imgs/19.png new file mode 100644 index 0000000..0d97d16 --- /dev/null +++ b/frontend/src/imgs/19.png | |||
| Binary files differ | |||