-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #516 from nwplus/hackcamp-work-around
HackCamp Whitelist Work Around
- Loading branch information
Showing
4 changed files
with
115 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react' | ||
import { Button } from '../components/Input' | ||
import { setWhitelist } from '../utility/firebase' | ||
|
||
export default () => { | ||
return ( | ||
<div> | ||
<Button | ||
color="secondary" | ||
width="flex" | ||
onClick={() => { | ||
setWhitelist() | ||
}} | ||
> | ||
Add current whitelist | ||
</Button> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = [ | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
] | ||
|
||
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) | ||
} | ||
|
||
|