Skip to content

Commit 2208f84

Browse files
committed
int: UI integration
1 parent e64bb7a commit 2208f84

File tree

10 files changed

+53
-312
lines changed

10 files changed

+53
-312
lines changed

apps/web/src/App.jsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import { Routes, Route } from "react-router-dom";
33
import Home from "./pages/home";
44
import Player from "./pages/app";
5-
import Login from "./pages/login";
6-
import Register from "./pages/register";
75
import Verify from "./pages/verify";
86
import About from "./pages/about";
97
import Leaderboard from "./pages/leaderboard";
@@ -17,8 +15,6 @@ const App = () => {
1715
<Route path='/about' element={<About />} />
1816
<Route path='/app' element={<Player />} />
1917
<Route path='/news' element={<News />} />
20-
<Route path='/login' element={<Login />} />
21-
<Route path='/register' element={<Register />} />
2218
<Route path='/verify' element={<Verify />} />
2319
<Route path='/leaderboard' element={<Leaderboard />} />
2420
<Route path='/whoami' element={<WhoAmI />} />

apps/web/src/components/cards/create-team-card.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import React from "react";
1+
import React, { useState } from "react";
22
import apiClient from "../../libs/api.client";
3-
import { useState } from "react";
43
import { toast } from "react-toastify";
54

65
function CreateTeamCard() {
@@ -10,14 +9,29 @@ function CreateTeamCard() {
109
async function submitData(evt) {
1110
evt.preventDefault();
1211
try {
13-
const res = await apiClient.post("/team", {
12+
await apiClient.post("/team", {
1413
team_name: teamName,
1514
join_code: teamCode,
15+
}, {
16+
headers: {
17+
"Content-Type": "application/json",
18+
Authorization: `Bearer ${localStorage.getItem("token")}`,
19+
},
1620
});
17-
window.location.href = "/whoami";
21+
toast.success("Team created successfully");
22+
23+
await apiClient.post("/team/join",{
24+
join_code: teamCode,
25+
}, {
26+
headers: {
27+
"Content-Type": "application/json",
28+
Authorization: `Bearer ${localStorage.getItem("token")}`,
29+
},
30+
});
31+
32+
toast.success("Team joined successfully");
1833
} catch (err) {
19-
console.error("errr");
20-
toast.error("Error creating team");
34+
toast.error(err.response.data.message || "Error creating team");
2135
}
2236
}
2337
return (

apps/web/src/components/cards/join-team-card.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
1-
import React from "react";
1+
import React, { useState } from "react";
22
import apiClient from "../../libs/api.client";
3-
import { useState } from "react";
3+
import { toast } from "react-toastify";
44

55
function JoinTeamCard() {
66
const [teamCode, setTeamCode] = useState("");
7+
8+
async function submitData(evt) {
9+
evt.preventDefault();
10+
try {
11+
const { data } = await apiClient.post("/team/join", {
12+
join_code: teamCode,
13+
}, {
14+
headers: {
15+
"Content-Type": "application/json",
16+
Authorization: `Bearer ${localStorage.getItem("token")}`,
17+
},
18+
});
19+
console.log(data);
20+
toast.success("Team joined successfully");
21+
window.location.href = "/whoami";
22+
} catch (err) {
23+
toast.error("Error creating team");
24+
}
25+
}
726

827
return (
928
<div className="signup-card login-card">
1029
<h2>Join a Team</h2>
11-
<form onSubmit={() => {}}>
30+
<form onSubmit={submitData}>
1231
<div className="form-control">
1332
<div className="form-el-container">
1433
<label htmlFor="team_code">Team Code</label>

apps/web/src/components/cards/login-card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const LoginCard = () => {
3737
draggable: true,
3838
});
3939
setTimeout(() => {
40-
window.location.href = "/app";
40+
window.location.href = "/";
4141
}, 3000);
4242
} else {
4343
toast.error("Login Failed!", {

apps/web/src/components/cards/register-card.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { useState } from "react";
2-
import { ToastContainer, toast } from "react-toastify";
3-
import { Link } from "react-router-dom";
4-
2+
import { toast } from "react-toastify";
53

64
import apiClient from "../../libs/api.client";
75

apps/web/src/pages/login.jsx

Lines changed: 0 additions & 127 deletions
This file was deleted.

apps/web/src/pages/news.jsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ function News() {
55
return (
66
<>
77
<Navbar pageTitle={"News"} />
8-
{/* <div className='about-elements'>
9-
<h2>News</h2>
10-
<div className='action-card'>
11-
<a href='https://www.youtube.com/watch?v=9Pzj7Aj25lw'>
12-
How to use the scoreboard
13-
</a>
14-
</div>
15-
</div> */}
168
</>
179
);
1810
}

0 commit comments

Comments
 (0)