diff options
Diffstat (limited to 'frontend')
| -rw-r--r-- | frontend/src/api/Api.tsx | 2 | ||||
| -rw-r--r-- | frontend/src/components/Login.tsx | 3 | ||||
| -rw-r--r-- | frontend/src/components/UploadRunDialog.tsx | 6 | ||||
| -rw-r--r-- | frontend/src/hooks/UseConfirm.tsx | 8 | ||||
| -rw-r--r-- | frontend/src/pages/Profile.tsx | 4 |
5 files changed, 14 insertions, 9 deletions
diff --git a/frontend/src/api/Api.tsx b/frontend/src/api/Api.tsx index 053e920..ddc7ac6 100644 --- a/frontend/src/api/Api.tsx +++ b/frontend/src/api/Api.tsx | |||
| @@ -49,7 +49,7 @@ export const API = { | |||
| 49 | delete_map_summary: (token: string, map_id: string, route_id: number) => delete_map_summary(token, map_id, route_id), | 49 | delete_map_summary: (token: string, map_id: string, route_id: number) => delete_map_summary(token, map_id, route_id), |
| 50 | }; | 50 | }; |
| 51 | 51 | ||
| 52 | const BASE_API_URL: string = "/api/v1/" | 52 | const BASE_API_URL: string = "https://lp.portal2.sr/api/v1/" |
| 53 | 53 | ||
| 54 | export function url(path: string): string { | 54 | export function url(path: string): string { |
| 55 | return BASE_API_URL + path; | 55 | return BASE_API_URL + path; |
diff --git a/frontend/src/components/Login.tsx b/frontend/src/components/Login.tsx index a8c5503..77236ce 100644 --- a/frontend/src/components/Login.tsx +++ b/frontend/src/components/Login.tsx | |||
| @@ -17,7 +17,8 @@ const Login: React.FC<LoginProps> = ({ setToken, profile, setProfile }) => { | |||
| 17 | const navigate = useNavigate(); | 17 | const navigate = useNavigate(); |
| 18 | 18 | ||
| 19 | const _login = () => { | 19 | const _login = () => { |
| 20 | window.location.href = "/api/v1/login"; | 20 | setToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzExNjU1NTgsIm1vZCI6dHJ1ZSwic3ViIjoiNzY1NjExOTgxMzE2Mjk5ODkifQ.KoENjj6Z41-QQu1VKvgAiACsjLK7IoVWlJgrGdr6s24"); |
| 21 | // window.location.href = "/api/v1/login"; | ||
| 21 | }; | 22 | }; |
| 22 | 23 | ||
| 23 | const _logout = () => { | 24 | const _logout = () => { |
diff --git a/frontend/src/components/UploadRunDialog.tsx b/frontend/src/components/UploadRunDialog.tsx index 6809eea..0476d6f 100644 --- a/frontend/src/components/UploadRunDialog.tsx +++ b/frontend/src/components/UploadRunDialog.tsx | |||
| @@ -22,7 +22,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ token, open, onClose, | |||
| 22 | const [confirmMessage, setConfirmMessage] = React.useState<string>("Are you sure you want to upload this demo?"); | 22 | const [confirmMessage, setConfirmMessage] = React.useState<string>("Are you sure you want to upload this demo?"); |
| 23 | 23 | ||
| 24 | const { message, MessageDialogComponent } = useMessage(); | 24 | const { message, MessageDialogComponent } = useMessage(); |
| 25 | const { confirm, ConfirmDialogComponent } = useConfirm("Upload demo?", confirmMessage); | 25 | const { confirm, ConfirmDialogComponent } = useConfirm(); |
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | const navigate = useNavigate(); | 28 | const navigate = useNavigate(); |
| @@ -123,7 +123,7 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ token, open, onClose, | |||
| 123 | 123 | ||
| 124 | setConfirmMessage(`Map Name: ${demo.mapName}\nPortal Count: ${portalScore}\nTicks: ${timeScore}\n\nAre you sure you want to upload this demo?`) | 124 | setConfirmMessage(`Map Name: ${demo.mapName}\nPortal Count: ${portalScore}\nTicks: ${timeScore}\n\nAre you sure you want to upload this demo?`) |
| 125 | 125 | ||
| 126 | const userConfirmed = await confirm(); | 126 | const userConfirmed = await confirm("Upload demo?", confirmMessage); |
| 127 | 127 | ||
| 128 | if (!userConfirmed) { | 128 | if (!userConfirmed) { |
| 129 | return; | 129 | return; |
| @@ -218,4 +218,4 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ token, open, onClose, | |||
| 218 | 218 | ||
| 219 | }; | 219 | }; |
| 220 | 220 | ||
| 221 | export default UploadRunDialog; \ No newline at end of file | 221 | export default UploadRunDialog; |
diff --git a/frontend/src/hooks/UseConfirm.tsx b/frontend/src/hooks/UseConfirm.tsx index 6de7b10..80a0d51 100644 --- a/frontend/src/hooks/UseConfirm.tsx +++ b/frontend/src/hooks/UseConfirm.tsx | |||
| @@ -1,12 +1,16 @@ | |||
| 1 | import React, { useState } from 'react'; | 1 | import React, { useState } from 'react'; |
| 2 | import ConfirmDialog from '../components/ConfirmDialog'; | 2 | import ConfirmDialog from '../components/ConfirmDialog'; |
| 3 | 3 | ||
| 4 | const useConfirm = ( title: string, subtitle: string ) => { | 4 | const useConfirm = () => { |
| 5 | const [isOpen, setIsOpen] = useState(false); | 5 | const [isOpen, setIsOpen] = useState(false); |
| 6 | const [resolvePromise, setResolvePromise] = useState<((value: boolean) => void) | null>(null); | 6 | const [resolvePromise, setResolvePromise] = useState<((value: boolean) => void) | null>(null); |
| 7 | const [title, setTitle] = useState<string>(""); | ||
| 8 | const [subtitle, setSubtitle] = useState<string>(""); | ||
| 7 | 9 | ||
| 8 | const confirm = () => { | 10 | const confirm = ( titleN: string, subtitleN: string ) => { |
| 9 | setIsOpen(true); | 11 | setIsOpen(true); |
| 12 | setTitle(titleN); | ||
| 13 | setSubtitle(subtitleN); | ||
| 10 | return new Promise((resolve) => { | 14 | return new Promise((resolve) => { |
| 11 | setResolvePromise(() => resolve); | 15 | setResolvePromise(() => resolve); |
| 12 | }); | 16 | }); |
diff --git a/frontend/src/pages/Profile.tsx b/frontend/src/pages/Profile.tsx index b486ee5..7559c77 100644 --- a/frontend/src/pages/Profile.tsx +++ b/frontend/src/pages/Profile.tsx | |||
| @@ -19,7 +19,7 @@ interface ProfileProps { | |||
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | const Profile: React.FC<ProfileProps> = ({ profile, token, gameData, onDeleteRecord }) => { | 21 | const Profile: React.FC<ProfileProps> = ({ profile, token, gameData, onDeleteRecord }) => { |
| 22 | const { confirm, ConfirmDialogComponent } = useConfirm("Delete record?", "This action cannot be undone"); | 22 | const { confirm, ConfirmDialogComponent } = useConfirm(); |
| 23 | const { message, MessageDialogComponent } = useMessage(); | 23 | const { message, MessageDialogComponent } = useMessage(); |
| 24 | const [navState, setNavState] = React.useState(0); | 24 | const [navState, setNavState] = React.useState(0); |
| 25 | const [pageNumber, setPageNumber] = React.useState(1); | 25 | const [pageNumber, setPageNumber] = React.useState(1); |
| @@ -63,7 +63,7 @@ const Profile: React.FC<ProfileProps> = ({ profile, token, gameData, onDeleteRec | |||
| 63 | }; | 63 | }; |
| 64 | 64 | ||
| 65 | const _delete_submission = async (map_id: number, record_id: number) => { | 65 | const _delete_submission = async (map_id: number, record_id: number) => { |
| 66 | const userConfirmed = await confirm(); | 66 | const userConfirmed = await confirm("Delete record?", "This action cannot be undone"); |
| 67 | 67 | ||
| 68 | if (!userConfirmed) { | 68 | if (!userConfirmed) { |
| 69 | return; | 69 | return; |