Skip to content

Commit 4e3a1d9

Browse files
committed
Adds group generation
1 parent b8ca957 commit 4e3a1d9

File tree

3 files changed

+63
-7
lines changed

3 files changed

+63
-7
lines changed

src/components/Registration/GroupManager/GroupManager.jsx

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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";
912
import { LoadingButton } from "@mui/lab";
13+
import { useMemo, useState } from "react";
14+
import { GroupRest } from "../../../rest/GroupRest";
15+
import { Clear } from "@mui/icons-material";
1016

1117
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 (
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
}

src/components/Registration/Registration.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ const steps = [
224224
},
225225
{
226226
label: "Team members",
227-
children: <GroupManager />,
227+
children: <GroupManager eventId={"02fc811b-1e67-402e-ac62-3f376cf33b6b"} />,
228228
},
229229
{
230230
label: "Confirmation",

src/rest/GroupRest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { AbstractRest } from "./AbstractRest";
33

44
export class GroupRest extends AbstractRest {
55
createGroup(signUpFormId) {
6-
return axios.post(this.baseUrl + "/group", signUpFormId);
6+
return axios.post(this.baseUrl + "/group", { event: { id: signUpFormId } });
77
}
88

99
getGroup(eventId, groupName) {

0 commit comments

Comments
 (0)