File tree Expand file tree Collapse file tree 10 files changed +53
-312
lines changed Expand file tree Collapse file tree 10 files changed +53
-312
lines changed Original file line number Diff line number Diff line change 22import { Routes , Route } from "react-router-dom" ;
33import Home from "./pages/home" ;
44import Player from "./pages/app" ;
5- import Login from "./pages/login" ;
6- import Register from "./pages/register" ;
75import Verify from "./pages/verify" ;
86import About from "./pages/about" ;
97import 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 /> } />
Original file line number Diff line number Diff line change 1- import React from "react" ;
1+ import React , { useState } from "react" ;
22import apiClient from "../../libs/api.client" ;
3- import { useState } from "react" ;
43import { toast } from "react-toastify" ;
54
65function 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 (
Original file line number Diff line number Diff line change 1- import React from "react" ;
1+ import React , { useState } from "react" ;
22import apiClient from "../../libs/api.client" ;
3- import { useState } from "react" ;
3+ import { toast } from "react-toastify " ;
44
55function 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 >
Original file line number Diff line number Diff 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!" , {
Original file line number Diff line number Diff line change 11import { 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
64import apiClient from "../../libs/api.client" ;
75
Load Diff This file was deleted.
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments