mirror of
https://github.com/System-End/site.git
synced 2026-04-19 20:55:09 +00:00
Merge branch 'main' of github.com:hackclub/site
This commit is contained in:
commit
3c0a47c9b9
5 changed files with 37 additions and 21 deletions
|
|
@ -14,7 +14,8 @@ const CohortCard = ({
|
|||
imageLink = '',
|
||||
personal = false,
|
||||
color = '#09AFB4',
|
||||
textColor = '#000000'
|
||||
textColor = '#000000',
|
||||
inRunning = null
|
||||
}) => {
|
||||
const [isHovered, setIsHovered] = useState(false)
|
||||
const [isDeleted, setIsDeleted] = useState(false)
|
||||
|
|
@ -61,7 +62,8 @@ const CohortCard = ({
|
|||
<>
|
||||
<div
|
||||
sx={{
|
||||
backgroundColor: color
|
||||
backgroundColor: color,
|
||||
filter: (inRunning === null || inRunning) ? 'grayscale(0%)' : 'grayscale(50%) contrast(0.5)',
|
||||
}}
|
||||
className={styles.card}
|
||||
onMouseEnter={() => setIsHovered(true)}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,10 @@ export default async function handler(req, res) {
|
|||
})
|
||||
|
||||
const projects = await airtable.read({
|
||||
filterByFormula: `AND({User} = '${user.fields['Name']}', NOT({deleted}))`
|
||||
filterByFormula: `AND(
|
||||
{User} = '${user.fields['Name']}',
|
||||
NOT({deleted})
|
||||
)`
|
||||
})
|
||||
|
||||
const results = projects.map(p => ({
|
||||
|
|
|
|||
|
|
@ -42,18 +42,27 @@ export default async function handler(req, res) {
|
|||
return res.status(401).json(user)
|
||||
}
|
||||
|
||||
const results = projects.map(p => ({
|
||||
id: p.id,
|
||||
title: p.fields['Name'] || '',
|
||||
desc: p.fields['Description'] || '',
|
||||
slackLink: p.fields['Slack Link'] || '',
|
||||
codeLink: p.fields['Code Link'] || '',
|
||||
slackLink: p.fields['Slack Link'] || '',
|
||||
playLink: p.fields['Play Link'] || '',
|
||||
imageLink: p.fields['ScreenshotLink'] || '',
|
||||
user: user.fields['Name'],
|
||||
color: p.fields['color'] || '',
|
||||
textColor: p.fields['textColor'] || ''
|
||||
}))
|
||||
const hasVoted = user.fields['Voted']
|
||||
|
||||
const results = projects.map(p => {
|
||||
const result = {
|
||||
id: p.id,
|
||||
title: p.fields['Name'] || '',
|
||||
desc: p.fields['Description'] || '',
|
||||
slackLink: p.fields['Slack Link'] || '',
|
||||
codeLink: p.fields['Code Link'] || '',
|
||||
slackLink: p.fields['Slack Link'] || '',
|
||||
playLink: p.fields['Play Link'] || '',
|
||||
imageLink: p.fields['ScreenshotLink'] || '',
|
||||
user: user.fields['Name'],
|
||||
color: p.fields['color'] || '',
|
||||
textColor: p.fields['textColor'] || '',
|
||||
}
|
||||
|
||||
if (hasVoted) {
|
||||
result.inRunning = !(Boolean(p.fields['Lost Cohorts']))
|
||||
}
|
||||
return result
|
||||
})
|
||||
return res.status(200).json({ projects: results, name: user.fields['Name'] })
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,21 +54,21 @@ export default async function handler(req, res) {
|
|||
const project = overall[i]
|
||||
const points = pointsDistribution[i]
|
||||
|
||||
votesToCreate.push(addVote(project, points, user.id, 'Overall'))
|
||||
votesToCreate.push(addVote(project, points, user.id, user.fields?.['Cohorts']?.[0], 'Overall'))
|
||||
}
|
||||
|
||||
for (let i = 0; i < technical.length; i++) {
|
||||
const project = technical[i]
|
||||
const points = pointsDistribution[i]
|
||||
|
||||
votesToCreate.push(addVote(project, points, user.id, 'Technical'))
|
||||
votesToCreate.push(addVote(project, points, user.id, user.fields?.['Cohorts']?.[0], 'Technical'))
|
||||
}
|
||||
|
||||
for (let i = 0; i < creative.length; i++) {
|
||||
const project = creative[i]
|
||||
const points = pointsDistribution[i]
|
||||
|
||||
votesToCreate.push(addVote(project, points, user.id, 'Creative'))
|
||||
votesToCreate.push(addVote(project, points, user.id, user.fields?.['Cohorts']?.[0], 'Creative'))
|
||||
}
|
||||
|
||||
await Promise.all([
|
||||
|
|
@ -85,13 +85,14 @@ export default async function handler(req, res) {
|
|||
}
|
||||
}
|
||||
|
||||
const addVote = (projectId, points, userID, type) => {
|
||||
const addVote = (projectId, points, userID, type, cohortID) => {
|
||||
return {
|
||||
fields: {
|
||||
Points: parseInt(points, 10),
|
||||
Voter: [userID],
|
||||
Showcase: [projectId],
|
||||
Type: type
|
||||
Cohort: [cohortID],
|
||||
Type: type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ const ProjectGallery = ({ projects, loadProjects, submissionClose }) => {
|
|||
reload={loadProjects}
|
||||
color={project.color}
|
||||
textColor={project.textColor}
|
||||
inRunning={project.inRunning}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue