Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added waiver checkboxes to Status Changer #289

Merged
merged 4 commits into from
Dec 26, 2024
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
52 changes: 51 additions & 1 deletion pages/status.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from 'react'
import styled from 'styled-components'
import Page from '../components/page'
import { getHackathons, getApplicants, updateApplicantStatus } from '../utility/firebase'
import { getHackathons, getApplicants, updateApplicantStatus, updateWaiver } from '../utility/firebase'
import Button from '../components/button'
import Checkbox from '../components/checkbox'

Expand Down Expand Up @@ -59,6 +59,11 @@ export default function Status({ hackathons }) {
const [statusSelected, setStatusSelected] = useState('')
const [success, setSuccess] = useState('')
const [error, setError] = useState('')
const [releaseLiabilityStatus, setreleaseLiabilityStatus] = useState(false)
const [covidWaiverStatus, setCovidWaiverStatus] = useState(false)
const [mediaConsentStatus, setMediaConsentStatus] = useState(false)
const [safewalkSelectStatus, setsafewalkSelectStatus] = useState('safewalkNo')
const [mentorshipSelectStatus, setMentorshipSelectStatus] = useState('nwMentorshipNo')

const validateInputs = () => {
if (!emails) {
Expand Down Expand Up @@ -104,6 +109,13 @@ export default function Status({ hackathons }) {

for (const userId of filteredApplicants) {
await updateApplicantStatus(userId, statusSelected, hackathonSelected)
if (statusSelected === 'acceptedAndAttending') {
await updateWaiver(userId, 'releaseLiabilityCheck', releaseLiabilityStatus, hackathonSelected)
await updateWaiver(userId, 'covidWaiverCheck', covidWaiverStatus, hackathonSelected)
await updateWaiver(userId, 'mediaConsentCheck', mediaConsentStatus, hackathonSelected)
await updateWaiver(userId, 'safewalkSelect', safewalkSelectStatus, hackathonSelected)
await updateWaiver(userId, 'nwMentorshipSelect', mentorshipSelectStatus, hackathonSelected)
}
}

if (filteredApplicants.length > 0) {
Expand Down Expand Up @@ -151,6 +163,44 @@ export default function Status({ hackathons }) {
</option>
))}
</select>
{statusSelected === 'acceptedAndAttending' && (
<>
{[
{
label: 'Release of Liability Waiver',
checked: releaseLiabilityStatus,
onClick: () => setreleaseLiabilityStatus(!releaseLiabilityStatus),
},
{
label: 'Covid Waiver',
checked: covidWaiverStatus,
onClick: () => setCovidWaiverStatus(!covidWaiverStatus),
},
{
label: 'Media Consent',
checked: mediaConsentStatus,
onClick: () => setMediaConsentStatus(!mediaConsentStatus),
},
{
label: 'Safewalk',
checked: safewalkSelectStatus === 'safewalkYes',
onClick: () => setsafewalkSelectStatus(prev => (prev === 'safewalkYes' ? 'safewalkNo' : 'safewalkYes')),
},
{
label: 'nwMentorship',
checked: mentorshipSelectStatus === 'nwMentorshipYes',
onClick: () =>
setMentorshipSelectStatus(prev =>
prev === 'nwMentorshipYes' ? 'nwMentorshipNo' : 'nwMentorshipYes'
),
},
].map(({ label, checked, onClick }) => (
<div key={label}>
<Checkbox label={label} checked={checked} onClick={onClick} />
</div>
))}
</>
)}
<ButtonContainer>
<Button hoverBackgroundColor="#EB5757" onClick={handleUpdate}>
Update
Expand Down
11 changes: 11 additions & 0 deletions utility/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -952,3 +952,14 @@ export const getSpecificHackerAppQuestionOptions = async (category, formInput) =
}

// hacker application questions specific end

export const updateWaiver = async (userId, waiver, status, hackathon) => {
return db
.collection('Hackathons')
.doc(hackathon || HackerEvaluationHackathon)
.collection('Applicants')
.doc(userId)
.update({
[`basicInfo.${waiver}`]: status,
})
}
Loading