@@ -3,24 +3,80 @@ import {
33 Button ,
44 Divider ,
55 Grid ,
6+ IconButton ,
7+ Stack ,
68 TextField ,
9+ Tooltip ,
710 Typography ,
811} from "@mui/material" ;
912import { LoadingButton } from "@mui/lab" ;
13+ import { useMemo , useState } from "react" ;
14+ import { GroupRest } from "../../../rest/GroupRest" ;
15+ import { Clear } from "@mui/icons-material" ;
1016
1117export function GroupManager ( props ) {
12- return (
13- < Grid item md = { 12 } xs = { 12 } >
18+ const [ loadingNewTeam , setLoadingNewTeam ] = useState ( false ) ;
19+ const [ fetchingExistingTeam , setFetchingNewTeam ] = useState ( false ) ;
20+ const [ group , setGroup ] = useState ( false ) ;
21+ const [ groupInput , setGroupInput ] = useState ( "" ) ;
22+ const groupRest = useMemo ( ( ) => new GroupRest ( ) , [ ] ) ;
23+
24+ function createNewGroup ( ) {
25+ setLoadingNewTeam ( true ) ;
26+ groupRest . createGroup ( props . eventId ) . then ( ( response ) => {
27+ setLoadingNewTeam ( false ) ;
28+ setGroup ( response . data ) ;
29+ } ) ;
30+ }
31+
32+ function renderGroupSelection ( ) {
33+ return (
1434 < Box sx = { { pt : 5 , pb : 5 } } >
1535 < TextField
1636 fullWidth
1737 label = { "Enter team name (e.g. chalk-increase-vague)" }
38+ value = { groupInput }
39+ onChange = { ( event ) => setGroupInput ( event . target . value ) }
1840 />
1941 < Divider sx = { { pt : 2 , pb : 2 } } > or </ Divider >
20- < LoadingButton variant = { "outlined" } color = { "primary" } onClick = { props . onReset } >
21- Create new Team
22- </ LoadingButton >
42+ < Box sx = { { width : "100%" , display : "flex" , justifyContent : "center" } } >
43+ < LoadingButton
44+ variant = { "outlined" }
45+ color = { "primary" }
46+ onClick = { createNewGroup }
47+ loading = { loadingNewTeam }
48+ >
49+ Create new Team
50+ </ LoadingButton >
51+ </ Box >
2352 </ Box >
53+ ) ;
54+ }
55+
56+ function renderGroup ( ) {
57+ return (
58+ < Box sx = { { pt : 5 , pb : 5 } } >
59+ < Typography gutterBottom > You are assigned to the group</ Typography >
60+ < Typography sx = { { fontWeight : 800 , pb : 3 } } variant = { "h5" } >
61+ { group . phrase }
62+ </ Typography >
63+ < Button variant = "outlined" onClick = { ( ) => setGroup ( null ) } >
64+ Reset Group
65+ </ Button >
66+
67+ < Typography sx = { { pt : 4 } } >
68+ share this name to your team members
69+ </ Typography >
70+ < Typography color = { "text.secondary" } >
71+ This is not your actual team name at the event
72+ </ Typography >
73+ </ Box >
74+ ) ;
75+ }
76+
77+ return (
78+ < Grid item md = { 12 } xs = { 12 } >
79+ { group ? renderGroup ( ) : renderGroupSelection ( ) }
2480 </ Grid >
2581 ) ;
2682}
0 commit comments