diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2024-10-31 23:58:14 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2024-10-31 23:58:14 +0300 |
| commit | f5ad360d02303ce27a65e67feb8ae38f1e26742c (patch) | |
| tree | b3e5b0fde361223275b8cc91fe0ccbdbb945ed13 /frontend/src/pages/User.tsx | |
| parent | backend: remove auth check for viewing user page (diff) | |
| download | lphub-f5ad360d02303ce27a65e67feb8ae38f1e26742c.tar.gz lphub-f5ad360d02303ce27a65e67feb8ae38f1e26742c.tar.bz2 lphub-f5ad360d02303ce27a65e67feb8ae38f1e26742c.zip | |
frontend: convert all native confirm and alerts to custom hooks
Diffstat (limited to '')
| -rw-r--r-- | frontend/src/pages/User.tsx | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/frontend/src/pages/User.tsx b/frontend/src/pages/User.tsx index c1175bb..ad230bd 100644 --- a/frontend/src/pages/User.tsx +++ b/frontend/src/pages/User.tsx | |||
| @@ -8,6 +8,7 @@ import { Map } from '../types/Map'; | |||
| 8 | import { API } from '../api/Api'; | 8 | import { API } from '../api/Api'; |
| 9 | import { ticks_to_time } from '../utils/Time'; | 9 | import { ticks_to_time } from '../utils/Time'; |
| 10 | import "../css/Profile.css"; | 10 | import "../css/Profile.css"; |
| 11 | import useMessage from '../hooks/UseMessage'; | ||
| 11 | 12 | ||
| 12 | interface UserProps { | 13 | interface UserProps { |
| 13 | profile?: UserProfile; | 14 | profile?: UserProfile; |
| @@ -17,6 +18,8 @@ interface UserProps { | |||
| 17 | 18 | ||
| 18 | const User: React.FC<UserProps> = ({ token, profile, gameData }) => { | 19 | const User: React.FC<UserProps> = ({ token, profile, gameData }) => { |
| 19 | 20 | ||
| 21 | const { message, MessageDialogComponent } = useMessage(); | ||
| 22 | |||
| 20 | const [user, setUser] = React.useState<UserProfile | undefined>(undefined); | 23 | const [user, setUser] = React.useState<UserProfile | undefined>(undefined); |
| 21 | 24 | ||
| 22 | const [navState, setNavState] = React.useState(0); | 25 | const [navState, setNavState] = React.useState(0); |
| @@ -89,6 +92,7 @@ const User: React.FC<UserProps> = ({ token, profile, gameData }) => { | |||
| 89 | 92 | ||
| 90 | return ( | 93 | return ( |
| 91 | <main> | 94 | <main> |
| 95 | {MessageDialogComponent} | ||
| 92 | <section id='section1' className='profile'> | 96 | <section id='section1' className='profile'> |
| 93 | <div> | 97 | <div> |
| 94 | <img src={user.avatar_link} alt="profile-image"></img> | 98 | <img src={user.avatar_link} alt="profile-image"></img> |
| @@ -190,7 +194,7 @@ const User: React.FC<UserProps> = ({ token, profile, gameData }) => { | |||
| 190 | <span><span>Date</span><img src={SortIcon} alt="" /></span> | 194 | <span><span>Date</span><img src={SortIcon} alt="" /></span> |
| 191 | <div id='page-number'> | 195 | <div id='page-number'> |
| 192 | <div> | 196 | <div> |
| 193 | <button onClick={() => { | 197 | <button onClick={() => { |
| 194 | if (pageNumber !== 1) { | 198 | if (pageNumber !== 1) { |
| 195 | setPageNumber(prevPageNumber => prevPageNumber - 1); | 199 | setPageNumber(prevPageNumber => prevPageNumber - 1); |
| 196 | const records = document.querySelectorAll(".profileboard-record"); | 200 | const records = document.querySelectorAll(".profileboard-record"); |
| @@ -239,7 +243,7 @@ const User: React.FC<UserProps> = ({ token, profile, gameData }) => { | |||
| 239 | <span>{e.date.split("T")[0]}</span> | 243 | <span>{e.date.split("T")[0]}</span> |
| 240 | <span style={{ flexDirection: "row-reverse" }}> | 244 | <span style={{ flexDirection: "row-reverse" }}> |
| 241 | 245 | ||
| 242 | <button onClick={() => { window.alert(`Demo ID: ${e.demo_id}`) }}><img src={ThreedotIcon} alt="demo_id" /></button> | 246 | <button onClick={() => { message("Demo Information", `Demo ID: ${e.demo_id}`) }}><img src={ThreedotIcon} alt="demo_id" /></button> |
| 243 | <button onClick={() => window.location.href = `/api/v1/demos?uuid=${e.demo_id}`}><img src={DownloadIcon} alt="download" /></button> | 247 | <button onClick={() => window.location.href = `/api/v1/demos?uuid=${e.demo_id}`}><img src={DownloadIcon} alt="download" /></button> |
| 244 | {i === 0 && r.scores.length > 1 ? <button onClick={() => { | 248 | {i === 0 && r.scores.length > 1 ? <button onClick={() => { |
| 245 | (document.querySelectorAll(".profileboard-record")[index % 20] as HTMLInputElement).style.height === "44px" || | 249 | (document.querySelectorAll(".profileboard-record")[index % 20] as HTMLInputElement).style.height === "44px" || |
| @@ -284,7 +288,7 @@ const User: React.FC<UserProps> = ({ token, profile, gameData }) => { | |||
| 284 | <span>{record!.scores[i].date.split("T")[0]}</span> | 288 | <span>{record!.scores[i].date.split("T")[0]}</span> |
| 285 | <span style={{ flexDirection: "row-reverse" }}> | 289 | <span style={{ flexDirection: "row-reverse" }}> |
| 286 | 290 | ||
| 287 | <button onClick={() => { window.alert(`Demo ID: ${e.demo_id}`) }}><img src={ThreedotIcon} alt="demo_id" /></button> | 291 | <button onClick={() => { message("Demo Information", `Demo ID: ${e.demo_id}`) }}><img src={ThreedotIcon} alt="demo_id" /></button> |
| 288 | <button onClick={() => window.location.href = `/api/v1/demos?uuid=${e.demo_id}`}><img src={DownloadIcon} alt="download" /></button> | 292 | <button onClick={() => window.location.href = `/api/v1/demos?uuid=${e.demo_id}`}><img src={DownloadIcon} alt="download" /></button> |
| 289 | {i === 0 && record!.scores.length > 1 ? <button onClick={() => { | 293 | {i === 0 && record!.scores.length > 1 ? <button onClick={() => { |
| 290 | (document.querySelectorAll(".profileboard-record")[index % 20] as HTMLInputElement).style.height === "44px" || | 294 | (document.querySelectorAll(".profileboard-record")[index % 20] as HTMLInputElement).style.height === "44px" || |