From 5c5b6978a2040091333e162cef025945a1c3064e Mon Sep 17 00:00:00 2001
From: Melvin Teo <62491197+meleongg@users.noreply.github.com>
Date: Wed, 8 Nov 2023 11:30:09 -0800
Subject: [PATCH] Added Whitelist work around to add hackers to HackCamp
---
src/App.js | 48 +++++++++++++++------------
src/pages/Area51.js | 19 +++++++++++
src/utility/Constants.js | 6 ++--
src/utility/firebase.js | 70 +++++++++++++++++++++++++++++++++++++---
4 files changed, 115 insertions(+), 28 deletions(-)
create mode 100644 src/pages/Area51.js
diff --git a/src/App.js b/src/App.js
index 3644c8c2..3f858653 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,36 +1,37 @@
import React, { useEffect, useState } from 'react'
import { Redirect, Route, Switch } from 'wouter'
-import GlobalStyle from './theme/GlobalStyle'
-import ThemeProvider from './theme/ThemeProvider'
-import Navbar from './components/Navbar'
import Form from './components/ApplicationForm'
+import Navbar from './components/Navbar'
+import Page from './components/Page'
import {
- NotFound,
- Login,
+ Application,
+ ApplicationConfirmation,
+ ApplicationForm,
+ ApplicationReview,
Charcuterie,
- Home,
+ DiscordBot,
Faq,
- Sponsors,
+ Gallery,
GettingStarted,
- Schedule,
+ Home,
Judging,
JudgingAdmin,
JudgingView,
- DiscordBot,
- Submission,
+ Login,
+ NotFound,
ProjectView,
- ApplicationForm,
- ApplicationReview,
- ApplicationConfirmation,
- Application,
- Gallery,
+ Schedule,
+ Sponsors,
+ Submission,
} from './pages'
-import Page from './components/Page'
-import { db, getLivesiteDoc } from './utility/firebase'
-import { APPLICATION_STATUS, DB_COLLECTION, DB_HACKATHON, IS_DEVICE_IOS } from './utility/Constants'
-import notifications from './utility/notifications'
+import Area51 from './pages/Area51'
+import GlobalStyle from './theme/GlobalStyle'
+import ThemeProvider from './theme/ThemeProvider'
import { AuthProvider, getRedirectUrl, useAuth } from './utility/Auth'
+import { APPLICATION_STATUS, DB_COLLECTION, DB_HACKATHON, IS_DEVICE_IOS } from './utility/Constants'
import { HackerApplicationProvider, useHackerApplication } from './utility/HackerApplicationContext'
+import { db, getLivesiteDoc } from './utility/firebase'
+import notifications from './utility/notifications'
// only notify user if announcement was created within last 5 secs
const notifyUser = announcement => {
@@ -67,7 +68,11 @@ const AuthPageRoute = ({ path, children }) => {
}
return (
- {user?.status === APPLICATION_STATUS.accepted ? {children} : }
+ {user?.status === APPLICATION_STATUS.accepted ? (
+ {children}
+ ) : (
+
+ )}
)
}
@@ -255,6 +260,9 @@ function App() {
+
+
+
diff --git a/src/pages/Area51.js b/src/pages/Area51.js
new file mode 100644
index 00000000..9ed5be62
--- /dev/null
+++ b/src/pages/Area51.js
@@ -0,0 +1,19 @@
+import React from 'react'
+import { Button } from '../components/Input'
+import { setWhitelist } from '../utility/firebase'
+
+export default () => {
+ return (
+
+
+
+ )
+}
diff --git a/src/utility/Constants.js b/src/utility/Constants.js
index a5cdaf0f..a6dc655c 100644
--- a/src/utility/Constants.js
+++ b/src/utility/Constants.js
@@ -1,15 +1,15 @@
export const DB_COLLECTION = 'Hackathons'
// CHANGE: firebase collection name for this hackathon
-export const DB_HACKATHON = 'nwHacks2024'
+export const DB_HACKATHON = 'HackCamp2023'
export const DAYOF_COLLECTION = 'DayOf'
export const FAQ_COLLECTION = 'FAQ'
export const NOTIFICATION_SETTINGS_CACHE_KEY = 'livesiteNotificationSettings'
export const IS_DEVICE_IOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream
export const copyText = Object.freeze({
// CHANGE: name of hackathon to be displayed on login splash
- hackathonName: 'nwHacks 2024',
- hackathonNameShort: 'nwHacks',
+ hackathonName: 'HackCamp 2023',
+ hackathonNameShort: 'HackCamp',
})
export const PROJECTS_TO_JUDGE_COUNT = 4
diff --git a/src/utility/firebase.js b/src/utility/firebase.js
index b8ddf517..7d26337f 100644
--- a/src/utility/firebase.js
+++ b/src/utility/firebase.js
@@ -1,14 +1,14 @@
+import 'firebase/analytics'
import firebase from 'firebase/app'
import 'firebase/firestore'
-import 'firebase/analytics'
import 'firebase/storage'
import {
- HACKER_APPLICATION_TEMPLATE,
- REDIRECT_STATUS,
- DB_COLLECTION,
+ ANALYTICS_EVENTS,
APPLICATION_STATUS,
+ DB_COLLECTION,
DB_HACKATHON,
- ANALYTICS_EVENTS,
+ HACKER_APPLICATION_TEMPLATE,
+ REDIRECT_STATUS,
} from '../utility/Constants'
if (!firebase.apps.length) {
@@ -42,6 +42,49 @@ export const getLivesiteDoc = callback => {
})
}
+// -----------------------------------------------------
+// TODO: Delete temporary code that whitelists users that have RSVP'd (all the commented bars)
+export const setWhitelist = async () => {
+ let batch = db.batch()
+
+ let whitelistedArr = [
+ 'mthteo@gmail.com',
+ 'melvin@nwplus.io',
+ 'dev-test@nwplus.io',
+ 'portaltest432@gmail.com',
+ ]
+
+ for (let i = 0; i < whitelistedArr.length; i++) {
+ batch.set(
+ db.collection(DB_COLLECTION).doc(DB_HACKATHON).collection('Whitelist').doc(whitelistedArr[i]),
+ {}
+ )
+ }
+
+ batch.commit().then(() => {
+ alert('uploaded successfully')
+ })
+}
+// -----------------------------------------------------
+
+// -----------------------------------------------------
+export const getWhitelisted = async () => {
+ // db.collection('Hackathons').doc('HackCamp2023').collection('Whitelist')
+ const whitelisted = []
+ await db
+ .collection(DB_COLLECTION)
+ .doc(DB_HACKATHON)
+ .collection('Whitelist')
+ .get()
+ .then(querySnapshot => {
+ querySnapshot.forEach(doc => {
+ whitelisted.push(doc.id)
+ })
+ })
+ return whitelisted
+}
+// -----------------------------------------------------
+
const createNewApplication = async user => {
analytics.logEvent(ANALYTICS_EVENTS.signup, { userId: user.uid })
const userId = {
@@ -82,6 +125,23 @@ const createNewApplication = async user => {
...judging,
}
+ // -----------------------------------------------------
+ // If not whitelisted, no
+ const whitelisted = await getWhitelisted()
+ if (whitelisted.includes(user.email)) {
+ // good to go
+ newApplication = {
+ ...newApplication,
+ status: {
+ applicationStatus: 'acceptedAndAttending',
+ responded: true,
+ attending: true,
+ },
+ }
+ // else, the default application template will block them from submissions -> redirect to "Applications for this hackathon are closed"
+ }
+ // -----------------------------------------------------
+
await applicantsRef.doc(user.uid).set(newApplication)
}