diff options
Diffstat (limited to 'frontend/src/pages/Profile.tsx')
| -rw-r--r-- | frontend/src/pages/Profile.tsx | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/frontend/src/pages/Profile.tsx b/frontend/src/pages/Profile.tsx index 5e39308..6bd4cf4 100644 --- a/frontend/src/pages/Profile.tsx +++ b/frontend/src/pages/Profile.tsx | |||
| @@ -14,7 +14,7 @@ interface ProfileProps { | |||
| 14 | profile?: UserProfile; | 14 | profile?: UserProfile; |
| 15 | token?: string; | 15 | token?: string; |
| 16 | gameData: Game[]; | 16 | gameData: Game[]; |
| 17 | onDeleteRecord: () => void; | 17 | onDeleteRecord: () => void; |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | const Profile: React.FC<ProfileProps> = ({ profile, token, gameData, onDeleteRecord }) => { | 20 | const Profile: React.FC<ProfileProps> = ({ profile, token, gameData, onDeleteRecord }) => { |
| @@ -191,7 +191,7 @@ const Profile: React.FC<ProfileProps> = ({ profile, token, gameData, onDeleteRec | |||
| 191 | 191 | ||
| 192 | <select id='select-chapter' | 192 | <select id='select-chapter' |
| 193 | onChange={() => setChapter((document.querySelector('#select-chapter') as HTMLInputElement).value)}> | 193 | onChange={() => setChapter((document.querySelector('#select-chapter') as HTMLInputElement).value)}> |
| 194 | <option value="0" key="0">All</option> | 194 | <option value="0" key="0">All Chapters</option> |
| 195 | {chapterData.chapters.filter(e => e.is_disabled === false).map((e, i) => ( | 195 | {chapterData.chapters.filter(e => e.is_disabled === false).map((e, i) => ( |
| 196 | <option value={e.id} key={i + 1}>{e.name}</option> | 196 | <option value={e.id} key={i + 1}>{e.name}</option> |
| 197 | ))}</select> | 197 | ))}</select> |
| @@ -207,10 +207,26 @@ const Profile: React.FC<ProfileProps> = ({ profile, token, gameData, onDeleteRec | |||
| 207 | <span><span>Date</span><img src={SortIcon} alt="" /></span> | 207 | <span><span>Date</span><img src={SortIcon} alt="" /></span> |
| 208 | <div id='page-number'> | 208 | <div id='page-number'> |
| 209 | <div> | 209 | <div> |
| 210 | <button onClick={() => pageNumber === 1 ? null : setPageNumber(prevPageNumber => prevPageNumber - 1)} | 210 | <button onClick={() => { |
| 211 | if (pageNumber !== 1) { | ||
| 212 | setPageNumber(prevPageNumber => prevPageNumber - 1); | ||
| 213 | const records = document.querySelectorAll(".profileboard-record"); | ||
| 214 | records.forEach((r) => { | ||
| 215 | (r as HTMLInputElement).style.height = "44px"; | ||
| 216 | }); | ||
| 217 | } | ||
| 218 | }} | ||
| 211 | ><i className='triangle' style={{ position: 'relative', left: '-5px', }}></i> </button> | 219 | ><i className='triangle' style={{ position: 'relative', left: '-5px', }}></i> </button> |
| 212 | <span>{pageNumber}/{pageMax}</span> | 220 | <span>{pageNumber}/{pageMax}</span> |
| 213 | <button onClick={() => pageNumber === pageMax ? null : setPageNumber(prevPageNumber => prevPageNumber + 1)} | 221 | <button onClick={() => { |
| 222 | if (pageNumber !== pageMax) { | ||
| 223 | setPageNumber(prevPageNumber => prevPageNumber + 1); | ||
| 224 | const records = document.querySelectorAll(".profileboard-record"); | ||
| 225 | records.forEach((r) => { | ||
| 226 | (r as HTMLInputElement).style.height = "44px"; | ||
| 227 | }); | ||
| 228 | } | ||
| 229 | }} | ||
| 214 | ><i className='triangle' style={{ position: 'relative', left: '5px', transform: 'rotate(180deg)' }}></i> </button> | 230 | ><i className='triangle' style={{ position: 'relative', left: '5px', transform: 'rotate(180deg)' }}></i> </button> |
| 215 | </div> | 231 | </div> |
| 216 | </div> | 232 | </div> |
| @@ -240,7 +256,7 @@ const Profile: React.FC<ProfileProps> = ({ profile, token, gameData, onDeleteRec | |||
| 240 | <span>{e.date.split("T")[0]}</span> | 256 | <span>{e.date.split("T")[0]}</span> |
| 241 | <span style={{ flexDirection: "row-reverse" }}> | 257 | <span style={{ flexDirection: "row-reverse" }}> |
| 242 | 258 | ||
| 243 | <button style={{marginRight: "10px"}} onClick={() => { window.alert(`Demo ID: ${e.demo_id}`) }}><img src={ThreedotIcon} alt="demo_id" /></button> | 259 | <button style={{ marginRight: "10px" }} onClick={() => { window.alert(`Demo ID: ${e.demo_id}`) }}><img src={ThreedotIcon} alt="demo_id" /></button> |
| 244 | <button onClick={() => { _delete_submission(r.map_id, e.record_id) }}><img src={DeleteIcon}></img></button> | 260 | <button onClick={() => { _delete_submission(r.map_id, e.record_id) }}><img src={DeleteIcon}></img></button> |
| 245 | <button onClick={() => window.location.href = `/api/v1/demos?uuid=${e.demo_id}`}><img src={DownloadIcon} alt="download" /></button> | 261 | <button onClick={() => window.location.href = `/api/v1/demos?uuid=${e.demo_id}`}><img src={DownloadIcon} alt="download" /></button> |
| 246 | {i === 0 && r.scores.length > 1 ? <button onClick={() => { | 262 | {i === 0 && r.scores.length > 1 ? <button onClick={() => { |
| @@ -264,7 +280,7 @@ const Profile: React.FC<ProfileProps> = ({ profile, token, gameData, onDeleteRec | |||
| 264 | let record = profile.records.find((e) => e.map_id === r.id); | 280 | let record = profile.records.find((e) => e.map_id === r.id); |
| 265 | return record === undefined ? ( | 281 | return record === undefined ? ( |
| 266 | <button className="profileboard-record" key={index} style={{ backgroundColor: "#1b1b20" }}> | 282 | <button className="profileboard-record" key={index} style={{ backgroundColor: "#1b1b20" }}> |
| 267 | <span>{r.name}</span> | 283 | <Link to={`/maps/${r.id}`}><span>{r.name}</span></Link> |
| 268 | <span style={{ display: "grid" }}>N/A</span> | 284 | <span style={{ display: "grid" }}>N/A</span> |
| 269 | <span style={{ display: "grid" }}>N/A</span> | 285 | <span style={{ display: "grid" }}>N/A</span> |
| 270 | <span>N/A</span> | 286 | <span>N/A</span> |
| @@ -277,7 +293,7 @@ const Profile: React.FC<ProfileProps> = ({ profile, token, gameData, onDeleteRec | |||
| 277 | <button className="profileboard-record" key={index}> | 293 | <button className="profileboard-record" key={index}> |
| 278 | {record.scores.map((e, i) => (<> | 294 | {record.scores.map((e, i) => (<> |
| 279 | {i !== 0 ? <hr style={{ gridColumn: "1 / span 8" }} /> : ""} | 295 | {i !== 0 ? <hr style={{ gridColumn: "1 / span 8" }} /> : ""} |
| 280 | <span>{r.name}</span> | 296 | <Link to={`/maps/${r.id}`}><span>{r.name}</span></Link> |
| 281 | <span style={{ display: "grid" }}>{record!.scores[i].score_count}</span> | 297 | <span style={{ display: "grid" }}>{record!.scores[i].score_count}</span> |
| 282 | <span style={{ display: "grid" }}>{record!.scores[i].score_count - record!.map_wr_count}</span> | 298 | <span style={{ display: "grid" }}>{record!.scores[i].score_count - record!.map_wr_count}</span> |
| 283 | <span style={{ display: "grid" }}>{ticks_to_time(record!.scores[i].score_time)}</span> | 299 | <span style={{ display: "grid" }}>{ticks_to_time(record!.scores[i].score_time)}</span> |
| @@ -287,6 +303,7 @@ const Profile: React.FC<ProfileProps> = ({ profile, token, gameData, onDeleteRec | |||
| 287 | <span style={{ flexDirection: "row-reverse" }}> | 303 | <span style={{ flexDirection: "row-reverse" }}> |
| 288 | 304 | ||
| 289 | <button onClick={() => { window.alert(`Demo ID: ${e.demo_id}`) }}><img src={ThreedotIcon} alt="demo_id" /></button> | 305 | <button onClick={() => { window.alert(`Demo ID: ${e.demo_id}`) }}><img src={ThreedotIcon} alt="demo_id" /></button> |
| 306 | <button onClick={() => { _delete_submission(r.id, e.record_id) }}><img src={DeleteIcon}></img></button> | ||
| 290 | <button onClick={() => window.location.href = `/api/v1/demos?uuid=${e.demo_id}`}><img src={DownloadIcon} alt="download" /></button> | 307 | <button onClick={() => window.location.href = `/api/v1/demos?uuid=${e.demo_id}`}><img src={DownloadIcon} alt="download" /></button> |
| 291 | {i === 0 && record!.scores.length > 1 ? <button onClick={() => { | 308 | {i === 0 && record!.scores.length > 1 ? <button onClick={() => { |
| 292 | (document.querySelectorAll(".profileboard-record")[index % 20] as HTMLInputElement).style.height === "44px" || | 309 | (document.querySelectorAll(".profileboard-record")[index % 20] as HTMLInputElement).style.height === "44px" || |