Skip to content

Commit

Permalink
Merge pull request #38 from ugahacks/feature/presenter-form
Browse files Browse the repository at this point in the history
Feature/presenter form
  • Loading branch information
genki-aik authored Jan 18, 2023
2 parents cb38b54 + 2c0ca84 commit 89c104d
Show file tree
Hide file tree
Showing 10 changed files with 430 additions and 7 deletions.
2 changes: 1 addition & 1 deletion projects/mybyte/components/Event.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function Event(props: EventDetail) {
<Typography>{props.date}</Typography>
<Typography>{props.description}</Typography>
<Typography className="text-[#DC4141]">
{props.in_person ? "In-Person" : "Hybrid"}
{props.in_person ? "In-Person" : "Hybrid (In-Person & Virtual)"}
</Typography>
</CardBody>
</Card>
Expand Down
68 changes: 65 additions & 3 deletions projects/mybyte/context/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import {
} from "firebase/storage";

import { RegisterForm } from "../interfaces/registerForm";
import { useRouter } from "next/router";
import { ESportsRegisterForm } from "../interfaces/eSportsRegisterForm";
import { PresenterRegisterForm } from "../interfaces/presenterRegisterForm";

export interface UserType {
email: string | null;
Expand Down Expand Up @@ -73,13 +73,13 @@ export const AuthContextProvider = ({
const userRefStage = collection(db, "users-stage");
const eSportsRefStage = collection(db, "user-e-sports-details-stage");
const registerRefStage = collection(db, "user-registration-details-stage");
const workshopRefStage = collection(db, "user-workshop-details-stage");

// Prod Environment
const userRef = collection(db, "users");
const eSportsRef = collection(db, "user-e-sports-details");
const registerRef = collection(db, "user-registration-details");

const router = useRouter();
const workshopRef = collection(db, "user-workshop-details");

useEffect(() => {
const unsubscribe = onAuthStateChanged(auth, (curr_user) => {
Expand Down Expand Up @@ -184,6 +184,67 @@ export const AuthContextProvider = ({
setUserInformation(user.uid);
};

const storeWorkshopRegistrationInformation = async (
data: PresenterRegisterForm
) => {
if (data.slides.length == 0) {
await setDoc(doc(workshopRef, user.uid ? user.uid : ""), {
uid: user.uid,
firstName: data.firstName,
lastName: data.lastName,
preferredTimes: data.preferredTimes,
workshopName: data.workshopName,
workshopDetails: data.workshopDetails,
topic: data.topic,
isOnline: data.isOnline,
});
} else {
const storage = getStorage();
const file = data.slides[0];

const storageRef = ref(
storage,
"presentation_slides/" + user.uid + "/" + file.name
);

const uploadTask = uploadBytesResumable(storageRef, file);

uploadTask.on(
"state_changed",
(snapshot) => {
console.log("upload in progress");
},
(error) => {
console.log("Error uploading resume");
alert(error);
},
async () => {
await getDownloadURL(uploadTask.snapshot.ref).then((downloadURL) => {
setDoc(doc(workshopRef, user.uid ? user.uid : ""), {
uid: user.uid,
firstName: data.firstName,
lastName: data.lastName,
preferredTimes: data.preferredTimes,
workshopName: data.workshopName,
workshopDetails: data.workshopDetails,
topic: data.topic,
isOnline: data.isOnline,
slides: downloadURL,
});
});
}
);
}

// Set user status to registered for workshop hosting
await updateDoc(doc(userRef, user.uid ? user.uid : ""), {
"registered.PRESENT8": true,
});

// Update user info
setUserInformation(user.uid);
};

function getFirstAndLastNameFromGoogleName(
full_name: string | null
): [string, string] {
Expand Down Expand Up @@ -373,6 +434,7 @@ export const AuthContextProvider = ({
currEvent,
setCurrEvent,
storeESportsRegistrationInformation,
storeWorkshopRegistrationInformation,
}}
>
{loading ? null : children}
Expand Down
1 change: 1 addition & 0 deletions projects/mybyte/enums/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export enum Events {
hacks8 = "HACKS8",
make8 = "MAKE8",
e_sports_8 = "ESPORTS8",
present_8 = "PRESENT8",
}
10 changes: 10 additions & 0 deletions projects/mybyte/interfaces/presenterRegisterForm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export interface PresenterRegisterForm {
firstName: string;
lastName: string;
preferredTimes: string;
workshopName: string;
workshopDetails: string;
topic: string;
slides: FileList;
isOnline: boolean;
}
1 change: 1 addition & 0 deletions projects/mybyte/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function MyApp({ Component, pageProps }: AppProps) {
const hacks_8_bg_routes = [
"/registrationSuccess",
"/eSportsRegistrationSuccess",
"/presenterRegistrationSuccess",
];

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion projects/mybyte/pages/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Hacks8: EventDetail = {
date: "02/03/2023 - 02/05/2023",
description: "Create your own adventure! 🛫",
page: "/events/hacks-8",
in_person: true,
in_person: false,
image: "/byte_mini.png",
// Add in person attribute
};
Expand Down
Loading

0 comments on commit 89c104d

Please sign in to comment.