Skip to content

Commit

Permalink
Add Dota 2 registration
Browse files Browse the repository at this point in the history
  • Loading branch information
muffledMitosis committed Nov 12, 2020
1 parent cc30f43 commit 7538077
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Frostbyte from "./views/frostbyte";
import 'bootstrap/dist/css/bootstrap.min.css';
import ValorantRegProcess from "./views/valorantRegProcess";
import MinecraftRegProcess from "./views/minecraftRegProcess";
import DotaRegProcess from "./views/dotaRegProcess";

function App() {
return (
Expand Down Expand Up @@ -79,6 +80,9 @@ function App() {
<Route exact path="/registration/minecraft">
<MinecraftRegProcess />
</Route>
<Route exact path="/registration/dota">
<DotaRegProcess />
</Route>

<Route exact path="/programwiz">
<Programwiz />
Expand Down
4 changes: 3 additions & 1 deletion src/utils/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const FR_LOGO = "https://firebasestorage.googleapis.com/v0/b/btui-2020.appspot.c

const VAL_REG_LOGO = "https://firebasestorage.googleapis.com/v0/b/btui-2020.appspot.com/o/assets%2Ffrostbyte%2FvalorantLogo.png?alt=media&token=dfc15429-b5b0-48ae-a34b-2f54924925dd";
const MC_REG_LOGO = "https://firebasestorage.googleapis.com/v0/b/btui-2020.appspot.com/o/assets%2Ffrostbyte%2FminecraftLogo.png?alt=media&token=cab41bac-cbdc-4bd7-a5ae-5fc93262214e";
const DT_REG_LOG = "https://firebasestorage.googleapis.com/v0/b/btui-2020.appspot.com/o/assets%2Ffrostbyte%2FdotaLogo.png?alt=media&token=61a412f0-f5b8-40a3-b7de-e56e5aa98509"

const U_BTUI_LOGO = "https://firebasestorage.googleapis.com/v0/b/btui-2020.appspot.com/o/assets%2Funified_btui_logo.png?alt=media&token=595d827d-f3fd-4c6a-b095-b5bebf693dcb";

Expand Down Expand Up @@ -49,5 +50,6 @@ export {
FR_LOGO,

VAL_REG_LOGO,
MC_REG_LOGO
MC_REG_LOGO,
DT_REG_LOG
}
174 changes: 174 additions & 0 deletions src/views/dotaRegProcess.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
import './sReg.css';

import React from 'react';
import ReactDOM from 'react-dom';
import {useState, useEffect} from 'react';

import { useForm } from "react-hook-form";

import {DT_REG_LOG} from '../utils/consts';

import {db} from '../utils/firebase';

function DotaRegProcess() {
// const [parts, setParts] = useState(4);

document.getElementsByTagName("BODY")[0].style["background"] = "linear-gradient(#141e30, #243b55)";

const [progress, setProgress] = useState(1);
const [parts, setParts] = useState(6);

const [thePeeps, setThePeeps] = useState([]);
const [peepIDs, setThePeepIDs] = useState([]);

const [schoolInfo, setSchoolInfo] = useState([]);

const [initialStyles, setInitialStyles] = useState("setBlock");
const [participantStyles, setParticipantStyles] = useState("setNone");
const [formSpaceShow, setFormSpaceShow] = useState("setBlock");
const [finalSpaceShow, setfinalSpaceShow] = useState("setNone");
const [congratsSpaceShow, setCongratsSpaceShow] = useState("setNone");

const { register, handleSubmit, watch, errors } = useForm();
const individials = useForm();

const onSubmit = data => {
// setParts(Number(data["parts"]) + 1);
setProgress(pastProg => pastProg+1);
setInitialStyles("setNone");
setParticipantStyles("setBlock");
setSchoolInfo(data);
console.log(data);
};


const participantOnSubmit = data => {
setProgress(pastProg => pastProg+1);
console.log(data);
setThePeeps(preP => [...preP, data]);
if((progress) >= parts)
{
console.log(thePeeps);

setParticipantStyles("setNone");
setFormSpaceShow("setNone");
setfinalSpaceShow("setBlock");
}
}

const yesButtonClick = ()=>{
// TODO: Show Loading icon instead of button
console.log(schoolInfo);
console.log(thePeeps);
let baseRef = db.collection('users').doc('frostbyte').collection('games').doc('dota').collection('teamsRegistered');
baseRef.add({
"teamName": schoolInfo["teamName"],
"teamContact": schoolInfo["contact"],
"email": String(schoolInfo["email"])
}).then((docRef)=>{
console.log("Done Writing team data to db");

thePeeps.forEach(person =>{
baseRef.doc(docRef.id).collection('teamMembers').add({
"firstName": person["fName"],
"lastName": person["lName"],
"email": person["email"],
"mcUserName": person["dtUserName"],
"nic": person["nic"]
}).then(personRef=>{
baseRef.doc(docRef.id).collection('teamMembers').doc(personRef.id).update({"uid": (personRef.id + "_FRB")}).then(()=>{
console.log("write complete");
setThePeepIDs(preIDs => [...preIDs, {name: (`${person["fName"]} ${person["lName"]}`),id: (personRef.id + "_FRB")}]);
}).catch(e=>console.log(e));
}).catch(e=>console.log(e));
});

console.log("participant write complete");
// TODO: Hide progress wheel
// GOT CONGRATS PAGE (show them their ids)
setfinalSpaceShow("setNone");
setCongratsSpaceShow("setBlock");
}).catch(e=>console.log(e));
}

let elem = (
<div className="bigOneLol">
<div className="login-box">
<div className="imgCont"><img src={DT_REG_LOG}/></div>
<div className={"FormSpace " + formSpaceShow}>
<form className={"initialInfoDiv " + initialStyles} onSubmit={handleSubmit(onSubmit)}>
<div >
<div className="user-box">
<input type="text" name="teamName" ref={register({ required: true })} />
<label>Team Name</label>
</div>
<div className="user-box">
<input type="email" name="email" ref={register({ required: true })} />
<label>Team Email Address</label>
</div>
<div className="user-box">
<input type="tel" name="contact" maxLength="10" minLength="10" ref={register({ required: true })} />
<label>Team Contact Number</label>
</div>
</div>
<div><p className="warningPSTD">* Please Input valid email addresses since BTUI access codes will be
emailed to you, of without you will not be able to access the events of BTUI</p>
</div>
<div className="ProgressDiv"><p>{progress} of {parts}</p><button>Next</button></div>
</form>


<form className={"participantInfoDiv " + participantStyles} onSubmit={individials.handleSubmit(participantOnSubmit)}>
<div >
<div className="user-box">
<input type="text" name="fName" ref={individials.register({ required: true })} />
<label>First Name</label>
</div>
<div className="user-box">
<input type="text" name="lName" ref={individials.register({ required: true })} />
<label>Last Name</label>
</div>
<div className="user-box">
<input type="email" name="email" ref={individials.register({ required: true })} />
<label>Email Address</label>
</div>
<div className="user-box">
<input type="text" name="dtUserName" ref={individials.register({ required: true })} />
<label>In Game Username</label>
</div>
<div className="user-box">
<input type="text" name="nic" ref={individials.register()} />
<label>NIC Number</label>
</div>
</div>
<div><p className="warningPSTD">* Please Input valid email addresses since BTUI access codes will be
emailed to you, of without you will not be able to access the events of BTUI</p>
</div>
<div className="ProgressDiv"><p>{progress} of {parts}</p><button>Next</button></div>
</form>
</div>
<div className={"FinalSpace " + finalSpaceShow}>
<p>
Cool, The Registration process is almost complete. Is the following information accurate?
</p>
<h4>Team Members</h4>
<ul>{thePeeps.map(peep => <li>{peep["fName"] + " " + peep["lName"]}</li>)}</ul>
<div className="ProgressDiv"><button onClick={yesButtonClick}>Y E S</button><button onClick={()=>window.location.href="/registration/valorant"}>N O</button></div>
</div>
<div className={"CongratsSpace " + congratsSpaceShow}>
<p>Congrats! You've successfully registered for Minecraft</p>
<h5>Access Codes for each team member</h5>
<ul>{peepIDs.map(peep=><li><p>{peep["name"]}</p><p className="uidStyleText">{peep["id"]}</p></li>)}</ul>
<p className="accesscodeWarning">* Keep these access codes with you at all times and do not share these with anyone, you'll be needing this to access certain parts of the BTUI website</p>
<hr />
<p>Join the BTUI Discord Server, where we'll be posting regular updates of Talk sessions, competitoins and other related events</p>
<div className="sRegDiscrodServerJoinButtonDiv"><button className="sRegDiscrodServerJoinButton" onClick={()=>{window.location.href="https://discord.gg/d8ZZdhHEDk"}}>J O I N</button></div>
</div>
</div>
</div>
);

return elem;
}

export default DotaRegProcess;
2 changes: 1 addition & 1 deletion src/views/frostbyte.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function Frostbyte() {
</div>
<div className="reg_div_fr">
<div onClick={()=>{window.location.href = "/registration/valorant"}} className="GameRegCard gameRegValorant"><h2>Valorant</h2></div>
<div onClick={()=>{console.log("Dota 2 Click")}} className="GameRegCard gameRegDT"><h2>Dota 2</h2></div>
<div onClick={()=>{window.location.href = "/registration/dota"}} className="GameRegCard gameRegDT"><h2>Dota 2</h2></div>
<div onClick={()=>{window.location.href = "/registration/minecraft"}} className="GameRegCard gameRegMC"><h2>Minecraft</h2></div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/views/valorantRegProcess.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function ValorantRegProcess() {
<label>Riot ID</label>
</div>
<div className="user-box">
<input type="text" name="nic" ref={individials.register({ required: true })} />
<input type="text" name="nic" ref={individials.register()} />
<label>NIC Number</label>
</div>
</div>
Expand Down

0 comments on commit 7538077

Please sign in to comment.