aboutsummaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'frontend')
-rw-r--r--frontend/src/App.tsx2
-rw-r--r--frontend/src/api/Maps.tsx2
-rw-r--r--frontend/src/components/UploadRunDialog.tsx32
-rw-r--r--frontend/src/css/Dialog.css14
-rw-r--r--frontend/src/css/UploadRunDialog.css5
-rw-r--r--frontend/src/hooks/UseConfirm.tsx (renamed from frontend/src/components/UseConfirm.tsx)2
-rw-r--r--frontend/src/hooks/UseMessage.tsx (renamed from frontend/src/components/UseMessage.tsx)2
-rw-r--r--frontend/src/pages/Profile.tsx4
8 files changed, 44 insertions, 19 deletions
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index 41e426c..d1d501d 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -25,6 +25,8 @@ const App: React.FC = () => {
25 const [profile, setProfile] = React.useState<UserProfile | undefined>(undefined); 25 const [profile, setProfile] = React.useState<UserProfile | undefined>(undefined);
26 const [isModerator, setIsModerator] = React.useState<boolean>(false); 26 const [isModerator, setIsModerator] = React.useState<boolean>(false);
27 27
28 const [msgIsOpen, setMsgIsOpen] = React.useState<boolean>(false);
29
28 const [games, setGames] = React.useState<Game[]>([]); 30 const [games, setGames] = React.useState<Game[]>([]);
29 31
30 const [uploadRunDialog, setUploadRunDialog] = React.useState<boolean>(false); 32 const [uploadRunDialog, setUploadRunDialog] = React.useState<boolean>(false);
diff --git a/frontend/src/api/Maps.tsx b/frontend/src/api/Maps.tsx
index 8295cf2..b6a6bad 100644
--- a/frontend/src/api/Maps.tsx
+++ b/frontend/src/api/Maps.tsx
@@ -75,7 +75,7 @@ export const delete_map_discussion = async (token: string, map_id: string, discu
75 return response.data.success; 75 return response.data.success;
76}; 76};
77 77
78export const post_record = async (token: string, run: UploadRunContent): Promise<[string]> => { 78export const post_record = async (token: string, run: UploadRunContent): Promise<string> => {
79 if (run.partner_demo && run.partner_id) { 79 if (run.partner_demo && run.partner_id) {
80 const response = await axios.postForm(url(`maps/${run.map_id}/record`), { 80 const response = await axios.postForm(url(`maps/${run.map_id}/record`), {
81 "host_demo": run.host_demo, 81 "host_demo": run.host_demo,
diff --git a/frontend/src/components/UploadRunDialog.tsx b/frontend/src/components/UploadRunDialog.tsx
index b26bbe6..f3258e8 100644
--- a/frontend/src/components/UploadRunDialog.tsx
+++ b/frontend/src/components/UploadRunDialog.tsx
@@ -7,6 +7,8 @@ import { Game } from '../types/Game';
7import { Map } from '../types/Map'; 7import { Map } from '../types/Map';
8import { API } from '../api/Api'; 8import { API } from '../api/Api';
9import { useNavigate } from 'react-router-dom'; 9import { useNavigate } from 'react-router-dom';
10import useMessage from '../hooks/UseMessage';
11import useConfirm from '../hooks/UseConfirm';
10 12
11interface UploadRunDialogProps { 13interface UploadRunDialogProps {
12 token?: string; 14 token?: string;
@@ -16,6 +18,8 @@ interface UploadRunDialogProps {
16} 18}
17 19
18const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ token, open, onClose, games }) => { 20const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ token, open, onClose, games }) => {
21 const { message, MessageDialogComponent } = useMessage();
22 const { confirm, ConfirmDialogComponent } = useConfirm("Upload demo?", "Are you sure you want to upload this demo?");
19 23
20 const navigate = useNavigate(); 24 const navigate = useNavigate();
21 25
@@ -89,18 +93,18 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ token, open, onClose,
89 if (token) { 93 if (token) {
90 if (games[selectedGameID].is_coop) { 94 if (games[selectedGameID].is_coop) {
91 if (uploadRunContent.host_demo === null) { 95 if (uploadRunContent.host_demo === null) {
92 alert("You must select a host demo to upload.") 96 message("Error", "You must select a host demo to upload.")
93 return 97 return
94 } else if (uploadRunContent.partner_demo === null) { 98 } else if (uploadRunContent.partner_demo === null) {
95 alert("You must select a partner demo to upload.") 99 message("Error", "You must select a partner demo to upload.")
96 return 100 return
97 } else if (uploadRunContent.partner_id === undefined) { 101 } else if (uploadRunContent.partner_id === undefined) {
98 alert("You must specify your partner.") 102 message("Error", "You must specify your partner.")
99 return 103 return
100 } 104 }
101 } else { 105 } else {
102 if (uploadRunContent.host_demo === null) { 106 if (uploadRunContent.host_demo === null) {
103 alert("You must select a demo to upload.") 107 message("Error", "You must select a demo to upload.")
104 return 108 return
105 } 109 }
106 } 110 }
@@ -112,17 +116,22 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ token, open, onClose,
112 }) 116 })
113 117
114 if (!scoreboard) { 118 if (!scoreboard) {
115 alert("Error while processing demo: Unable to get scoreboard result. Is this not a CM demo?") 119 message("Error", "Error while processing demo: Unable to get scoreboard result. Is this not a CM demo?")
116 return 120 return
117 } 121 }
118 const { portalScore, timeScore } = scoreboard.userMessage?.as<ScoreboardTempUpdate>() ?? {}; 122 const { portalScore, timeScore } = scoreboard.userMessage?.as<ScoreboardTempUpdate>() ?? {};
119 console.log(`Portal count: ${portalScore}. Ticks: ${timeScore}.`); 123 console.log(`Portal count: ${portalScore}. Ticks: ${timeScore}.`);
120 if (window.confirm("Are you sure you want to submit this run to LPHUB?")) { 124
121 const message = await API.post_record(token, uploadRunContent); 125 const userConfirmed = await confirm();
122 alert(message); 126
123 navigate(0); 127 if (!userConfirmed) {
124 onClose(); 128 return;
125 } 129 }
130
131 const response = await API.post_record(token, uploadRunContent);
132 message("Message", response);
133 // navigate(0);
134 onClose();
126 } 135 }
127 }; 136 };
128 137
@@ -136,6 +145,9 @@ const UploadRunDialog: React.FC<UploadRunDialogProps> = ({ token, open, onClose,
136 return ( 145 return (
137 <> 146 <>
138 <div id="upload-run-block" /> 147 <div id="upload-run-block" />
148 {MessageDialogComponent}
149 {ConfirmDialogComponent}
150
139 <div id='upload-run-menu'> 151 <div id='upload-run-menu'>
140 <div id='upload-run-menu-add'> 152 <div id='upload-run-menu-add'>
141 <div id='upload-run-route-category'> 153 <div id='upload-run-route-category'>
diff --git a/frontend/src/css/Dialog.css b/frontend/src/css/Dialog.css
index c25a755..f16425d 100644
--- a/frontend/src/css/Dialog.css
+++ b/frontend/src/css/Dialog.css
@@ -1,13 +1,15 @@
1.dimmer { 1.dimmer {
2 position: absolute; 2 position: fixed;
3 width: calc(100%); 3 width: calc(100%);
4 height: 100%; 4 height: 100%;
5 background-color: rgba(0, 0, 0, 0.5); 5 background-color: rgba(0, 0, 0, 0.5);
6 z-index: 4;
7 left: 0px;
6} 8}
7 9
8.dialog { 10.dialog {
9 position: absolute; 11 position: fixed;
10 z-index: 10000; 12 z-index: 4;
11 top: 50%; 13 top: 50%;
12 left: 50%; 14 left: 50%;
13 transform: translate(-50%, -50%); 15 transform: translate(-50%, -50%);
@@ -17,6 +19,12 @@
17 min-width: 350px; 19 min-width: 350px;
18 border: 0.1em solid #272831; 20 border: 0.1em solid #272831;
19 animation: dialog_in 0.2s cubic-bezier(0.075, 0.82, 0.165, 1.1); 21 animation: dialog_in 0.2s cubic-bezier(0.075, 0.82, 0.165, 1.1);
22 color: white;
23 font-family: BarlowSemiCondensed-Regular;
24}
25
26.dialog-header {
27 font-size: 24px;
20} 28}
21 29
22.dialog-element { 30.dialog-element {
diff --git a/frontend/src/css/UploadRunDialog.css b/frontend/src/css/UploadRunDialog.css
index e85f206..6ea9884 100644
--- a/frontend/src/css/UploadRunDialog.css
+++ b/frontend/src/css/UploadRunDialog.css
@@ -95,9 +95,12 @@ button, input {
95 transition: all 0.2s ease; 95 transition: all 0.2s ease;
96} 96}
97 97
98.upload-run-buttons-container button {
99 border-radius: 32px;
100}
101
98button:hover { 102button:hover {
99 background-color: #222538; 103 background-color: #222538;
100 border-radius: 32px;
101} 104}
102 105
103.upload-run-map-container { 106.upload-run-map-container {
diff --git a/frontend/src/components/UseConfirm.tsx b/frontend/src/hooks/UseConfirm.tsx
index 2fe0e12..6de7b10 100644
--- a/frontend/src/components/UseConfirm.tsx
+++ b/frontend/src/hooks/UseConfirm.tsx
@@ -1,5 +1,5 @@
1import React, { useState } from 'react'; 1import React, { useState } from 'react';
2import ConfirmDialog from './ConfirmDialog'; 2import ConfirmDialog from '../components/ConfirmDialog';
3 3
4const useConfirm = ( title: string, subtitle: string ) => { 4const useConfirm = ( title: string, subtitle: string ) => {
5 const [isOpen, setIsOpen] = useState(false); 5 const [isOpen, setIsOpen] = useState(false);
diff --git a/frontend/src/components/UseMessage.tsx b/frontend/src/hooks/UseMessage.tsx
index fbd3c82..249a3bf 100644
--- a/frontend/src/components/UseMessage.tsx
+++ b/frontend/src/hooks/UseMessage.tsx
@@ -1,5 +1,5 @@
1import React, { useState } from 'react'; 1import React, { useState } from 'react';
2import MessageDialog from "./MessageDialog"; 2import MessageDialog from "../components/MessageDialog";
3 3
4const useMessage = () => { 4const useMessage = () => {
5 const [isOpen, setIsOpen] = useState(false); 5 const [isOpen, setIsOpen] = useState(false);
diff --git a/frontend/src/pages/Profile.tsx b/frontend/src/pages/Profile.tsx
index bf79a65..b486ee5 100644
--- a/frontend/src/pages/Profile.tsx
+++ b/frontend/src/pages/Profile.tsx
@@ -8,8 +8,8 @@ import { Map } from '../types/Map';
8import { ticks_to_time } from '../utils/Time'; 8import { ticks_to_time } from '../utils/Time';
9import "../css/Profile.css"; 9import "../css/Profile.css";
10import { API } from '../api/Api'; 10import { API } from '../api/Api';
11import useConfirm from '../components/UseConfirm'; 11import useConfirm from '../hooks/UseConfirm';
12import useMessage from '../components/UseMessage'; 12import useMessage from '../hooks/UseMessage';
13 13
14interface ProfileProps { 14interface ProfileProps {
15 profile?: UserProfile; 15 profile?: UserProfile;