Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"projects": {
"default": "nwplus-ubc"
"default": "nwplus-ubc",
"dev": "nwplus-ubc-dev"
},
"targets": {
"nwplus-ubc": {
Expand All @@ -9,6 +10,14 @@
"nw-admin-portal"
]
}
},
"nwplus-ubc-dev": {
"hosting": {
"admin-portal": [
"dev-nwplus-admin"
]
}
}
}
},
"etags": {}
}
27 changes: 22 additions & 5 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@
name: Deploy to Firebase Hosting on merge
'on':
push:
branches:
- main
branches: [main, dev]
workflow_dispatch:
jobs:
build_and_deploy:
runs-on: ubuntu-latest
env:
IS_PRODUCTION: ${{ endsWith(github.ref, 'main') }}
NODE_OPTIONS: --openssl-legacy-provider
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'
- name: Set up Firebase CLI
run: yarn global add firebase-tools
- name: Install and Build
run: yarn install --frozen-lockfile && yarn build
env:
Expand All @@ -28,7 +31,21 @@ jobs:
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: ${{ secrets.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET }}
SERVICE_ACCOUNT_TOKEN: ${{ secrets.SERVICE_ACCOUNT_TOKEN }}
FIREBASE_CLI_PREVIEWS: hostingchannels
- uses: FirebaseExtended/action-hosting-deploy@v0
# - name: Deploy to dev firebase project
# if: ${{ env.IS_PRODUCTION == 'false' }}
# run: firebase deploy --only hosting:admin-portal --project nwplus-ubc-dev --non-interactive --token ${{ secrets.FIREBASE_TOKEN }}
- name: Deploy to dev firebase project
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_NWPLUS_UBC_DEV }}'
projectId: nwplus-ubc-dev
target: admin-portal
channelId: live
firebaseToolsVersion: 12.9.1
- name: Deploy to prod firebase project
if: ${{ env.IS_PRODUCTION == 'true' }}
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_NWPLUS_UBC }}'
Expand Down
90 changes: 25 additions & 65 deletions pages/[id]/HackerInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,9 @@ export default function HackerInfo({ id, hackathons }) {
const [currTable, setCurrTable] = useState('Applicants')
const [unfilteredTableKeys, setUnfilteredTableKeys] = useState([])
const [filteredTableKeys, setFilteredTableKeys] = useState([])
const [groupBy, setGroupBy] = useState({
col1: '',
func: '',
col2: '',
})
const [where, setWhere] = useState({
col: '',
func: '',
val: '',
})
const [sort, setSort] = useState({
col: '',
direction: '',
})
const [groupBy, setGroupBy] = useState({ col1: '', func: '', col2: '' })
const [where, setWhere] = useState({ col: '', func: '', val: '' })
const [sort, setSort] = useState({ col: '', direction: '' })
const [filter, setFilter] = useState({})
const [calculate, setCalculate] = useState({})
const downloadLink = useRef()
Expand All @@ -129,9 +118,9 @@ export default function HackerInfo({ id, hackathons }) {

const clearFilters = () => {
setGroupBy({ col1: '', func: '', col2: '' })
setFilter({ col: '', func: '', val: '' })
setSort({ col: '', direction: '' })
setFilter({})
setSort({ col: '', direction: '' })
setWhere({ col: '', func: '', val: '' })
}

useEffect(() => {
Expand Down Expand Up @@ -204,7 +193,6 @@ export default function HackerInfo({ id, hackathons }) {
const saveWhere = () => {
const condition = {}
if (['NIS', 'NEQ'].includes(where.func)) {
// negation condition
condition.NOT = {
[where.func.substring(1)]: {
[where.col]: where.func === 'NEQ' ? Number(where.val) : where.val,
Expand All @@ -231,16 +219,13 @@ export default function HackerInfo({ id, hackathons }) {
})
}


const HackerInfoRow = ({ data }) => {
return (
<TableRow>
{filteredTableKeys.map(key => (
<TableData key={`${data}-${key}`}>{data[key]}</TableData>
))}
</TableRow>
)
}
const HackerInfoRow = ({ data }) => (
<TableRow>
{filteredTableKeys.map(key => (
<TableData key={`${data}-${key}`}>{data[key]}</TableData>
))}
</TableRow>
)

const renderTable = useMemo(
() => (
Expand Down Expand Up @@ -296,7 +281,7 @@ export default function HackerInfo({ id, hackathons }) {
</thead>
<tbody>
{filteredData.map(entry => (
<HackerInfoRow key={entry} data={entry} />
<HackerInfoRow key={JSON.stringify(entry)} data={entry} />
))}
</tbody>
</>
Expand All @@ -323,13 +308,7 @@ export default function HackerInfo({ id, hackathons }) {
))}
</TableOptionsButtons>
<ExportButton>
<Button
onClick={() => {
downloadLink.current.link.click()
}}
>
Export
</Button>
<Button onClick={() => downloadLink.current.link.click()}>Export</Button>
<CSVLink style={{ visibility: 'hidden' }} ref={downloadLink} filename="hackerinfo.csv" data={filteredData} />
</ExportButton>

Expand All @@ -344,10 +323,13 @@ export default function HackerInfo({ id, hackathons }) {
>
cmd-f 2025 Raffle
</Button>
<CSVLink style={{ visibility: 'hidden' }} ref={raffleDownloadLink} filename="cmd-f2025-raffle-emails.csv" data={raffleData} />
<CSVLink
style={{ visibility: 'hidden' }}
ref={raffleDownloadLink}
filename="cmd-f2025-raffle-emails.csv"
data={raffleData}
/>
</ExportButton>


</Buttons>
<Filters>
<FilterPills>
Expand Down Expand Up @@ -437,12 +419,7 @@ export default function HackerInfo({ id, hackathons }) {
))}
</select>
{groupBy.col1 && groupBy.func && groupBy.col2 && (
<Button
type={CHECK}
onClick={() => saveGroupBy()}
color={COLOR.TRANSPARENT}
contentColor={COLOR.DARK_GRAY}
/>
<Button type={CHECK} onClick={saveGroupBy} color={COLOR.TRANSPARENT} contentColor={COLOR.DARK_GRAY} />
)}
</Selection>
</Menu>
Expand Down Expand Up @@ -476,12 +453,7 @@ export default function HackerInfo({ id, hackathons }) {
placeholder="Value"
/>
{where.col && where.func && where.val && (
<Button
type={CHECK}
onClick={() => saveWhere()}
color={COLOR.TRANSPARENT}
contentColor={COLOR.DARK_GRAY}
/>
<Button type={CHECK} onClick={saveWhere} color={COLOR.TRANSPARENT} contentColor={COLOR.DARK_GRAY} />
)}
</Selection>
</Menu>
Expand All @@ -505,12 +477,7 @@ export default function HackerInfo({ id, hackathons }) {
<option value="DOWN">Descending</option>
</select>
{sort.col && sort.direction && (
<Button
type={CHECK}
onClick={() => saveSort()}
color={COLOR.TRANSPARENT}
contentColor={COLOR.DARK_GRAY}
/>
<Button type={CHECK} onClick={saveSort} color={COLOR.TRANSPARENT} contentColor={COLOR.DARK_GRAY} />
)}
</Selection>
</Menu>
Expand Down Expand Up @@ -554,16 +521,9 @@ export default function HackerInfo({ id, hackathons }) {
)
}

export const getStaticPaths = async () => {
return getHackathonPaths()
}
export const getStaticPaths = async () => getHackathonPaths()

export const getStaticProps = async ({ params }) => {
const hackathons = await getHackathons()
return {
props: {
hackathons,
id: params.id,
},
}
return { props: { hackathons, id: params.id } }
}
71 changes: 30 additions & 41 deletions utility/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,6 @@ export const getCSVData = async () => {
return CSV
}


// export const getRaffleNumbers = async () => {
// const apps = await db
// .collection('Hackathons')
Expand Down Expand Up @@ -789,10 +788,10 @@ export const getCSVData = async () => {
// .doc(e.eventId)
// .get()
// );

// // Wait for all dayOfDocs to resolve
// const dayOfDocs = await Promise.all(dayOfDocsPromises);

// // Calculate total points from events
// const totalPoints = dayOfDocs.reduce(
// (acc, curr) => acc + Number(curr.data()?.points ?? 0),
Expand Down Expand Up @@ -839,62 +838,51 @@ export const getRaffleWheelEmails = async () => {
.doc(HackerEvaluationHackathon)
.collection('Applicants')
.where('dayOf.checkedIn', '==', true)
.get();
.get()

// Create an array to hold all rows for the raffle entries
const raffleEntries = [];
let counter = 1; // Initialize a counter
const raffleEntries = []
let counter = 1 // Initialize a counter

// Iterate over the documents and calculate raffle entries for each user
for (const doc of apps.docs) {
const {
basicInfo: { email, legalFirstName, preferredName, legalLastName },
dayOf,
} = doc.data();
} = doc.data()

if (!dayOf?.events || !Array.isArray(dayOf.events)) continue;
if (!dayOf?.events || !Array.isArray(dayOf.events)) continue

// Determine the name to use
const displayName = (preferredName?.trim() || legalFirstName) + " " + legalLastName;
const displayName = `${preferredName?.trim() || legalFirstName} ${legalLastName}`

// Fetch event documents for each event in dayOf.events
const dayOfDocsPromises = dayOf.events.map((e) =>
db
.collection('Hackathons')
.doc(HackerEvaluationHackathon)
.collection('DayOf')
.doc(e.eventId)
.get()
);
const dayOfDocsPromises = dayOf.events.map(e =>
db.collection('Hackathons').doc(HackerEvaluationHackathon).collection('DayOf').doc(e.eventId).get()
)

const dayOfDocs = await Promise.all(dayOfDocsPromises);
const dayOfDocs = await Promise.all(dayOfDocsPromises)

// Calculate total points from events (+15 from check-in)
const totalPoints =
15 +
dayOfDocs.reduce((acc, curr) => acc + Number(curr.data()?.points ?? 0), 0);
const totalPoints = 15 + dayOfDocs.reduce((acc, curr) => acc + Number(curr.data()?.points ?? 0), 0)

// Calculate raffle entries based on total points
const totalRaffleEntries = Math.floor(totalPoints / 15);
const totalRaffleEntries = Math.floor(totalPoints / 15)

// Add the user's data multiple times based on raffle entries
for (let i = 0; i < totalRaffleEntries; i++) {
raffleEntries.push([counter, `${displayName} [${counter}]`, email]);
counter++; // Increment counter
for (let i = 0; i < totalRaffleEntries; i += 1) {
raffleEntries.push([counter, `${displayName} [${counter}]`, email])
counter += 1 // Increment counter
}
}

// Prepare CSV with "Number", "First Name + Number", and "Raffle Entries" columns
const CSV = [
['Number', 'Name + Number', 'Raffle Entries'],
...raffleEntries,
];

console.log(CSV);
const CSV = [['Number', 'Name + Number', 'Raffle Entries'], ...raffleEntries]

return CSV;
};
console.log(CSV)

return CSV
}

export const getResumeFile = async userId => {
try {
Expand Down Expand Up @@ -923,10 +911,8 @@ export const getAllResumes = async () => {
.get()

const sharableApps = apps.docs.filter(app => {
const {
termsAndConditions: { shareWithSponsors },
} = app.data()
return shareWithSponsors
const { termsAndConditions } = app.data()
return termsAndConditions?.shareWithSponsors
})

const namesAndIds = sharableApps.map(doc => {
Expand All @@ -944,13 +930,15 @@ export const getAllResumes = async () => {
return { ...info, url }
})

const APPUrls = await Promise.all(urlPromises)
const appUrls = await Promise.all(urlPromises)

const zip = new JSZip()
const zipPromises = APPUrls.map(async ({ url, name }) => {
const resume = (await fetch(url)).blob()
const zipPromises = appUrls.map(async ({ url, name }) => {
const response = await fetch(url)
const resume = await response.blob()
zip.file(`${name}.pdf`, resume, { binary: true })
})

await Promise.all(zipPromises)
const finishedZip = await zip.generateAsync({ type: 'blob' })
download(finishedZip, 'Resumes', 'application/zip')
Expand All @@ -970,7 +958,8 @@ export const updateApplicantScore = async (applicantID, newScores, oldScores, co
}
}, {})

db.collection('Hackathons')
await db
.collection('Hackathons')
.doc(HackerEvaluationHackathon)
.collection('Applicants')
.doc(applicantID)
Expand Down
Loading