@@ -3,24 +3,80 @@ import {
3
3
Button ,
4
4
Divider ,
5
5
Grid ,
6
+ IconButton ,
7
+ Stack ,
6
8
TextField ,
9
+ Tooltip ,
7
10
Typography ,
8
11
} from "@mui/material" ;
9
12
import { LoadingButton } from "@mui/lab" ;
13
+ import { useMemo , useState } from "react" ;
14
+ import { GroupRest } from "../../../rest/GroupRest" ;
15
+ import { Clear } from "@mui/icons-material" ;
10
16
11
17
export 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 (
14
34
< Box sx = { { pt : 5 , pb : 5 } } >
15
35
< TextField
16
36
fullWidth
17
37
label = { "Enter team name (e.g. chalk-increase-vague)" }
38
+ value = { groupInput }
39
+ onChange = { ( event ) => setGroupInput ( event . target . value ) }
18
40
/>
19
41
< 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 >
23
52
</ 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 ( ) }
24
80
</ Grid >
25
81
) ;
26
82
}
0 commit comments