Skip to content

Commit f36f301

Browse files
Merge dev into main (#315)
* did it work? * pls fix * key that does not even exist removed * a test * another test * test test * woah * test * adding tools * node upgrade * openssl bug fix? * finally lol * lets try to fix no permissions * avoid preview link * specified target * added my branch back * feat: add manual workflow button * chore: fix linter errors * Update firebase-hosting-merge.yml (remove node v18 mandate) * fix: linter formatting * fix: remove unary operator --------- Co-authored-by: byronwang93 <[email protected]>
1 parent b04322d commit f36f301

File tree

4 files changed

+88
-113
lines changed

4 files changed

+88
-113
lines changed

.firebaserc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"projects": {
3-
"default": "nwplus-ubc"
3+
"default": "nwplus-ubc",
4+
"dev": "nwplus-ubc-dev"
45
},
56
"targets": {
67
"nwplus-ubc": {
@@ -9,6 +10,14 @@
910
"nw-admin-portal"
1011
]
1112
}
13+
},
14+
"nwplus-ubc-dev": {
15+
"hosting": {
16+
"admin-portal": [
17+
"dev-nwplus-admin"
18+
]
19+
}
1220
}
13-
}
21+
},
22+
"etags": {}
1423
}

.github/workflows/firebase-hosting-merge.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@
44
name: Deploy to Firebase Hosting on merge
55
'on':
66
push:
7-
branches:
8-
- main
7+
branches: [main, dev]
8+
workflow_dispatch:
99
jobs:
1010
build_and_deploy:
1111
runs-on: ubuntu-latest
12+
env:
13+
IS_PRODUCTION: ${{ endsWith(github.ref, 'main') }}
14+
NODE_OPTIONS: --openssl-legacy-provider
1215
steps:
1316
- uses: actions/checkout@v3
1417
- name: Use Node.js
1518
uses: actions/setup-node@v3
16-
with:
17-
node-version: '16.x'
19+
- name: Set up Firebase CLI
20+
run: yarn global add firebase-tools
1821
- name: Install and Build
1922
run: yarn install --frozen-lockfile && yarn build
2023
env:
@@ -28,7 +31,21 @@ jobs:
2831
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: ${{ secrets.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET }}
2932
SERVICE_ACCOUNT_TOKEN: ${{ secrets.SERVICE_ACCOUNT_TOKEN }}
3033
FIREBASE_CLI_PREVIEWS: hostingchannels
31-
- uses: FirebaseExtended/action-hosting-deploy@v0
34+
# - name: Deploy to dev firebase project
35+
# if: ${{ env.IS_PRODUCTION == 'false' }}
36+
# run: firebase deploy --only hosting:admin-portal --project nwplus-ubc-dev --non-interactive --token ${{ secrets.FIREBASE_TOKEN }}
37+
- name: Deploy to dev firebase project
38+
uses: FirebaseExtended/action-hosting-deploy@v0
39+
with:
40+
repoToken: '${{ secrets.GITHUB_TOKEN }}'
41+
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_NWPLUS_UBC_DEV }}'
42+
projectId: nwplus-ubc-dev
43+
target: admin-portal
44+
channelId: live
45+
firebaseToolsVersion: 12.9.1
46+
- name: Deploy to prod firebase project
47+
if: ${{ env.IS_PRODUCTION == 'true' }}
48+
uses: FirebaseExtended/action-hosting-deploy@v0
3249
with:
3350
repoToken: '${{ secrets.GITHUB_TOKEN }}'
3451
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_NWPLUS_UBC }}'

pages/[id]/HackerInfo.js

Lines changed: 25 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,9 @@ export default function HackerInfo({ id, hackathons }) {
106106
const [currTable, setCurrTable] = useState('Applicants')
107107
const [unfilteredTableKeys, setUnfilteredTableKeys] = useState([])
108108
const [filteredTableKeys, setFilteredTableKeys] = useState([])
109-
const [groupBy, setGroupBy] = useState({
110-
col1: '',
111-
func: '',
112-
col2: '',
113-
})
114-
const [where, setWhere] = useState({
115-
col: '',
116-
func: '',
117-
val: '',
118-
})
119-
const [sort, setSort] = useState({
120-
col: '',
121-
direction: '',
122-
})
109+
const [groupBy, setGroupBy] = useState({ col1: '', func: '', col2: '' })
110+
const [where, setWhere] = useState({ col: '', func: '', val: '' })
111+
const [sort, setSort] = useState({ col: '', direction: '' })
123112
const [filter, setFilter] = useState({})
124113
const [calculate, setCalculate] = useState({})
125114
const downloadLink = useRef()
@@ -129,9 +118,9 @@ export default function HackerInfo({ id, hackathons }) {
129118

130119
const clearFilters = () => {
131120
setGroupBy({ col1: '', func: '', col2: '' })
132-
setFilter({ col: '', func: '', val: '' })
133-
setSort({ col: '', direction: '' })
134121
setFilter({})
122+
setSort({ col: '', direction: '' })
123+
setWhere({ col: '', func: '', val: '' })
135124
}
136125

137126
useEffect(() => {
@@ -204,7 +193,6 @@ export default function HackerInfo({ id, hackathons }) {
204193
const saveWhere = () => {
205194
const condition = {}
206195
if (['NIS', 'NEQ'].includes(where.func)) {
207-
// negation condition
208196
condition.NOT = {
209197
[where.func.substring(1)]: {
210198
[where.col]: where.func === 'NEQ' ? Number(where.val) : where.val,
@@ -231,16 +219,13 @@ export default function HackerInfo({ id, hackathons }) {
231219
})
232220
}
233221

234-
235-
const HackerInfoRow = ({ data }) => {
236-
return (
237-
<TableRow>
238-
{filteredTableKeys.map(key => (
239-
<TableData key={`${data}-${key}`}>{data[key]}</TableData>
240-
))}
241-
</TableRow>
242-
)
243-
}
222+
const HackerInfoRow = ({ data }) => (
223+
<TableRow>
224+
{filteredTableKeys.map(key => (
225+
<TableData key={`${data}-${key}`}>{data[key]}</TableData>
226+
))}
227+
</TableRow>
228+
)
244229

245230
const renderTable = useMemo(
246231
() => (
@@ -296,7 +281,7 @@ export default function HackerInfo({ id, hackathons }) {
296281
</thead>
297282
<tbody>
298283
{filteredData.map(entry => (
299-
<HackerInfoRow key={entry} data={entry} />
284+
<HackerInfoRow key={JSON.stringify(entry)} data={entry} />
300285
))}
301286
</tbody>
302287
</>
@@ -323,13 +308,7 @@ export default function HackerInfo({ id, hackathons }) {
323308
))}
324309
</TableOptionsButtons>
325310
<ExportButton>
326-
<Button
327-
onClick={() => {
328-
downloadLink.current.link.click()
329-
}}
330-
>
331-
Export
332-
</Button>
311+
<Button onClick={() => downloadLink.current.link.click()}>Export</Button>
333312
<CSVLink style={{ visibility: 'hidden' }} ref={downloadLink} filename="hackerinfo.csv" data={filteredData} />
334313
</ExportButton>
335314

@@ -344,10 +323,13 @@ export default function HackerInfo({ id, hackathons }) {
344323
>
345324
cmd-f 2025 Raffle
346325
</Button>
347-
<CSVLink style={{ visibility: 'hidden' }} ref={raffleDownloadLink} filename="cmd-f2025-raffle-emails.csv" data={raffleData} />
326+
<CSVLink
327+
style={{ visibility: 'hidden' }}
328+
ref={raffleDownloadLink}
329+
filename="cmd-f2025-raffle-emails.csv"
330+
data={raffleData}
331+
/>
348332
</ExportButton>
349-
350-
351333
</Buttons>
352334
<Filters>
353335
<FilterPills>
@@ -437,12 +419,7 @@ export default function HackerInfo({ id, hackathons }) {
437419
))}
438420
</select>
439421
{groupBy.col1 && groupBy.func && groupBy.col2 && (
440-
<Button
441-
type={CHECK}
442-
onClick={() => saveGroupBy()}
443-
color={COLOR.TRANSPARENT}
444-
contentColor={COLOR.DARK_GRAY}
445-
/>
422+
<Button type={CHECK} onClick={saveGroupBy} color={COLOR.TRANSPARENT} contentColor={COLOR.DARK_GRAY} />
446423
)}
447424
</Selection>
448425
</Menu>
@@ -476,12 +453,7 @@ export default function HackerInfo({ id, hackathons }) {
476453
placeholder="Value"
477454
/>
478455
{where.col && where.func && where.val && (
479-
<Button
480-
type={CHECK}
481-
onClick={() => saveWhere()}
482-
color={COLOR.TRANSPARENT}
483-
contentColor={COLOR.DARK_GRAY}
484-
/>
456+
<Button type={CHECK} onClick={saveWhere} color={COLOR.TRANSPARENT} contentColor={COLOR.DARK_GRAY} />
485457
)}
486458
</Selection>
487459
</Menu>
@@ -505,12 +477,7 @@ export default function HackerInfo({ id, hackathons }) {
505477
<option value="DOWN">Descending</option>
506478
</select>
507479
{sort.col && sort.direction && (
508-
<Button
509-
type={CHECK}
510-
onClick={() => saveSort()}
511-
color={COLOR.TRANSPARENT}
512-
contentColor={COLOR.DARK_GRAY}
513-
/>
480+
<Button type={CHECK} onClick={saveSort} color={COLOR.TRANSPARENT} contentColor={COLOR.DARK_GRAY} />
514481
)}
515482
</Selection>
516483
</Menu>
@@ -554,16 +521,9 @@ export default function HackerInfo({ id, hackathons }) {
554521
)
555522
}
556523

557-
export const getStaticPaths = async () => {
558-
return getHackathonPaths()
559-
}
524+
export const getStaticPaths = async () => getHackathonPaths()
560525

561526
export const getStaticProps = async ({ params }) => {
562527
const hackathons = await getHackathons()
563-
return {
564-
props: {
565-
hackathons,
566-
id: params.id,
567-
},
568-
}
528+
return { props: { hackathons, id: params.id } }
569529
}

utility/firebase.js

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,6 @@ export const getCSVData = async () => {
754754
return CSV
755755
}
756756

757-
758757
// export const getRaffleNumbers = async () => {
759758
// const apps = await db
760759
// .collection('Hackathons')
@@ -789,10 +788,10 @@ export const getCSVData = async () => {
789788
// .doc(e.eventId)
790789
// .get()
791790
// );
792-
791+
793792
// // Wait for all dayOfDocs to resolve
794793
// const dayOfDocs = await Promise.all(dayOfDocsPromises);
795-
794+
796795
// // Calculate total points from events
797796
// const totalPoints = dayOfDocs.reduce(
798797
// (acc, curr) => acc + Number(curr.data()?.points ?? 0),
@@ -839,62 +838,51 @@ export const getRaffleWheelEmails = async () => {
839838
.doc(HackerEvaluationHackathon)
840839
.collection('Applicants')
841840
.where('dayOf.checkedIn', '==', true)
842-
.get();
841+
.get()
843842

844843
// Create an array to hold all rows for the raffle entries
845-
const raffleEntries = [];
846-
let counter = 1; // Initialize a counter
844+
const raffleEntries = []
845+
let counter = 1 // Initialize a counter
847846

848847
// Iterate over the documents and calculate raffle entries for each user
849848
for (const doc of apps.docs) {
850849
const {
851850
basicInfo: { email, legalFirstName, preferredName, legalLastName },
852851
dayOf,
853-
} = doc.data();
852+
} = doc.data()
854853

855-
if (!dayOf?.events || !Array.isArray(dayOf.events)) continue;
854+
if (!dayOf?.events || !Array.isArray(dayOf.events)) continue
856855

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

860859
// Fetch event documents for each event in dayOf.events
861-
const dayOfDocsPromises = dayOf.events.map((e) =>
862-
db
863-
.collection('Hackathons')
864-
.doc(HackerEvaluationHackathon)
865-
.collection('DayOf')
866-
.doc(e.eventId)
867-
.get()
868-
);
860+
const dayOfDocsPromises = dayOf.events.map(e =>
861+
db.collection('Hackathons').doc(HackerEvaluationHackathon).collection('DayOf').doc(e.eventId).get()
862+
)
869863

870-
const dayOfDocs = await Promise.all(dayOfDocsPromises);
864+
const dayOfDocs = await Promise.all(dayOfDocsPromises)
871865

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

877869
// Calculate raffle entries based on total points
878-
const totalRaffleEntries = Math.floor(totalPoints / 15);
870+
const totalRaffleEntries = Math.floor(totalPoints / 15)
879871

880872
// Add the user's data multiple times based on raffle entries
881-
for (let i = 0; i < totalRaffleEntries; i++) {
882-
raffleEntries.push([counter, `${displayName} [${counter}]`, email]);
883-
counter++; // Increment counter
873+
for (let i = 0; i < totalRaffleEntries; i += 1) {
874+
raffleEntries.push([counter, `${displayName} [${counter}]`, email])
875+
counter += 1 // Increment counter
884876
}
885877
}
886878

887879
// Prepare CSV with "Number", "First Name + Number", and "Raffle Entries" columns
888-
const CSV = [
889-
['Number', 'Name + Number', 'Raffle Entries'],
890-
...raffleEntries,
891-
];
892-
893-
console.log(CSV);
880+
const CSV = [['Number', 'Name + Number', 'Raffle Entries'], ...raffleEntries]
894881

895-
return CSV;
896-
};
882+
console.log(CSV)
897883

884+
return CSV
885+
}
898886

899887
export const getResumeFile = async userId => {
900888
try {
@@ -923,10 +911,8 @@ export const getAllResumes = async () => {
923911
.get()
924912

925913
const sharableApps = apps.docs.filter(app => {
926-
const {
927-
termsAndConditions: { shareWithSponsors },
928-
} = app.data()
929-
return shareWithSponsors
914+
const { termsAndConditions } = app.data()
915+
return termsAndConditions?.shareWithSponsors
930916
})
931917

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

947-
const APPUrls = await Promise.all(urlPromises)
933+
const appUrls = await Promise.all(urlPromises)
948934

949935
const zip = new JSZip()
950-
const zipPromises = APPUrls.map(async ({ url, name }) => {
951-
const resume = (await fetch(url)).blob()
936+
const zipPromises = appUrls.map(async ({ url, name }) => {
937+
const response = await fetch(url)
938+
const resume = await response.blob()
952939
zip.file(`${name}.pdf`, resume, { binary: true })
953940
})
941+
954942
await Promise.all(zipPromises)
955943
const finishedZip = await zip.generateAsync({ type: 'blob' })
956944
download(finishedZip, 'Resumes', 'application/zip')
@@ -970,7 +958,8 @@ export const updateApplicantScore = async (applicantID, newScores, oldScores, co
970958
}
971959
}, {})
972960

973-
db.collection('Hackathons')
961+
await db
962+
.collection('Hackathons')
974963
.doc(HackerEvaluationHackathon)
975964
.collection('Applicants')
976965
.doc(applicantID)

0 commit comments

Comments
 (0)