88 Typography ,
99} from "@mui/material" ;
1010import { LoadingButton } from "@mui/lab" ;
11- import { useEffect , useMemo , useState } from "react" ;
11+ import { useEffect , useMemo , useState } from "react" ;
1212import { GroupRest } from "../../../rest/GroupRest" ;
1313
1414export function GroupManager ( props ) {
@@ -17,21 +17,27 @@ export function GroupManager(props) {
1717 const [ group , setGroup ] = useState ( false ) ;
1818 const [ groupInput , setGroupInput ] = useState ( "" ) ;
1919 const [ groupInputError , setGroupInputError ] = useState ( false ) ;
20+ const [ groupName , setGroupName ] = useState ( "" ) ;
2021 const groupRest = useMemo ( ( ) => new GroupRest ( ) , [ ] ) ;
2122
22-
2323 function createNewGroup ( ) {
2424 setLoadingNewTeam ( true ) ;
25- setGroupInputError ( false )
26- groupRest . createGroup ( props . eventId ) . then ( ( response ) => {
27- setLoadingNewTeam ( false ) ;
28- setGroup ( response . data ) ;
29- } ) ;
25+ setGroupInputError ( false ) ;
26+ groupRest
27+ . createGroup ( props . eventId , groupName )
28+ . then ( ( response ) => {
29+ setLoadingNewTeam ( false ) ;
30+ setGroup ( response . data ) ;
31+ } )
32+ . catch ( ( err ) => {
33+ console . error ( err ) ;
34+ setLoadingNewTeam ( false ) ;
35+ } ) ;
3036 }
3137
3238 function getGroup ( ) {
3339 setFetchingExistingTeam ( true ) ;
34- setGroupInputError ( false )
40+ setGroupInputError ( false ) ;
3541 groupRest
3642 . getGroup ( props . eventId , groupInput )
3743 . then ( ( response ) => {
@@ -45,17 +51,17 @@ export function GroupManager(props) {
4551 } ) ;
4652 }
4753
48- useEffect ( ( ) => {
49- props . onGroupChange ( group )
50- } , [ group ] ) ;
54+ useEffect ( ( ) => {
55+ props . onGroupChange ( group ) ;
56+ } , [ group ] ) ;
5157
5258 function renderGroupSelection ( ) {
5359 return (
5460 < Box sx = { { pt : 5 , pb : 5 } } >
5561 < Stack direction = "row" spacing = { 2 } >
5662 < TextField
5763 fullWidth
58- label = { "Enter team name (e.g. chalk-increase-vague)" }
64+ label = { "Enter team identification (e.g. chalk-increase-vague)" }
5965 value = { groupInput }
6066 onChange = { ( event ) => setGroupInput ( event . target . value ) }
6167 error = { groupInputError }
@@ -72,26 +78,47 @@ export function GroupManager(props) {
7278 Join
7379 </ LoadingButton >
7480 </ Stack >
81+ < Typography variant = { "body2" } color = { "text.disabled" } pt = { 1 } >
82+ Identifier given by the group creator
83+ </ Typography >
7584 < Divider sx = { { pt : 2 , pb : 2 } } > or </ Divider >
76- < Box sx = { { width : "100%" , display : "flex" , justifyContent : "center" } } >
85+ < Stack direction = "row" spacing = { 2 } >
86+ < TextField
87+ fullWidth
88+ label = { "Enter team name (e.g. Carbon Coders)" }
89+ value = { groupName }
90+ onChange = { ( event ) => setGroupName ( event . target . value ) }
91+ disabled = { fetchingExistingTeam }
92+ />
7793 < LoadingButton
94+ sx = { { flexWrap : "nowrap" } }
95+ width = { "100px" }
7896 variant = { "outlined" }
7997 color = { "primary" }
8098 onClick = { createNewGroup }
8199 loading = { loadingNewTeam }
82- disabled = { fetchingExistingTeam }
100+ disabled = {
101+ fetchingExistingTeam ||
102+ groupName . length < 3 ||
103+ groupName . length > 30
104+ }
83105 >
84- Create new Team
106+ Create
85107 </ LoadingButton >
86- </ Box >
108+ </ Stack >
109+ < Typography variant = { "body2" } color = { "text.disabled" } pt = { 1 } >
110+ This will be your team name at the event
111+ </ Typography >
87112 </ Box >
88113 ) ;
89114 }
90115
91116 function renderGroup ( ) {
92117 return (
93118 < Box sx = { { pt : 5 , pb : 5 } } >
94- < Typography gutterBottom > You are assigned to the group</ Typography >
119+ < Typography gutterBottom >
120+ You are assigned to the group with identifier
121+ </ Typography >
95122 < Typography sx = { { fontWeight : 800 , pb : 3 } } variant = { "h5" } >
96123 { group . phrase }
97124 </ Typography >
@@ -100,7 +127,7 @@ export function GroupManager(props) {
100127 </ Button >
101128
102129 < Typography sx = { { pt : 4 } } >
103- share this name to your team members
130+ share this identifier to your team members
104131 </ Typography >
105132 < Typography color = { "text.secondary" } >
106133 This is not your actual team name at the event
0 commit comments