Skip to content

Commit

Permalink
rewards UI done
Browse files Browse the repository at this point in the history
  • Loading branch information
DonaldKLee committed Oct 27, 2024
1 parent 84c5551 commit 375e7a0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
32 changes: 15 additions & 17 deletions pages/[id]/rewards.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import setMinutes from 'date-fns/setMinutes'
import React, { useEffect, useState } from 'react'
import Button from '../../components/button'
import Card, { CardButtonContainer, CardContent, CardHeader, CardTitle } from '../../components/card'
import { DateTimePicker } from '../../components/dateTimePicker'
import Modal, { Label, ModalContent, ModalField } from '../../components/modal'

Check failure on line 6 in pages/[id]/rewards.js

View workflow job for this annotation

GitHub Actions / Linting

'Label' is defined but never used
import Page from '../../components/page'
import {
Expand Down Expand Up @@ -81,7 +80,6 @@ export default function Rewards({ id, hackathons }) {
...rewards,
[rewardEditing.rewardID]: {
...rewardEditing,
date: formatDate(rewardEditing.date, true),
},
})
setRewardEditing({})
Expand All @@ -104,7 +102,7 @@ export default function Rewards({ id, hackathons }) {
return obj
}, {})
)
setRewardConfirm({}, setAlertMsg(`Successfully deleted the following reward: \n${rewards[rewardID].title}`))
setRewardConfirm({}, setAlertMsg(`Successfully deleted the following reward: \n${rewards[rewardID].reward}`))
}

const handleInput = (property, value, reward, setState) => {
Expand All @@ -119,10 +117,10 @@ export default function Rewards({ id, hackathons }) {
<TableRow>
<TableData>{props.reward}</TableData>
<TableData>{props.blurb}</TableData>
<TableData>{props.numOfWinners}</TableData>
<TableData>{props.prizesAvailable}</TableData>
<TableData>{props.requiredPoints}</TableData>
<TableData>{props.lastmod}</TableData>
<TableData>{props.lastmodby}</TableData>
<TableData>{props.lastmodBy}</TableData>
<TableData actions>
<ActionsButtonContainer>
<Button type={VIEW} color={COLOR.TRANSPARENT} onClick={() => setRewardViewing(rewards[props.rewardID])} />
Expand Down Expand Up @@ -178,7 +176,7 @@ export default function Rewards({ id, hackathons }) {
<TableRow>
<TableHeader>Reward</TableHeader>
<TableHeader>Blurb</TableHeader>
<TableHeader>Number of Winners</TableHeader>
<TableHeader>Number of Prizes Available</TableHeader>
<TableHeader>Required Points</TableHeader>
<TableHeader>Last Modified</TableHeader>
<TableHeader>Last Modified By</TableHeader>
Expand All @@ -192,7 +190,7 @@ export default function Rewards({ id, hackathons }) {
rewardID={rewards[curr].rewardID}
reward={rewards[curr].reward}
blurb={rewards[curr].blurb}
numOfWinners={rewards[curr].numOfWinners}
prizesAvailable={rewards[curr].prizesAvailable}
requiredPoints={rewards[curr].requiredPoints}
lastmod={rewards[curr].lastmod}
lastmodBy={rewards[curr].lastmodBy}
Expand Down Expand Up @@ -252,7 +250,7 @@ export default function Rewards({ id, hackathons }) {
label="Number of prizes available"
modalAction={NEW}
onChange={reward => {
handleInput('numOfWinners', reward.target.value, newReward, setNewReward)
handleInput('prizesAvailable', reward.target.value, newReward, setNewReward)
}}
/>
<ModalField
Expand Down Expand Up @@ -283,7 +281,7 @@ export default function Rewards({ id, hackathons }) {
<ModalField label="Image URL" value={rewardViewing.imgURL} modalAction={VIEW} />
</ModalContent>
<ModalContent columns={2}>
<ModalField label="Number of prizes available" value={rewardViewing.numOfWinners} modalAction={VIEW} />
<ModalField label="Number of prizes available" value={rewardViewing.prizesAvailable} modalAction={VIEW} />
<ModalField label="Required Points" value={rewardViewing.requiredPoints} modalAction={VIEW} />
</ModalContent>
</Modal>
Expand All @@ -298,7 +296,7 @@ export default function Rewards({ id, hackathons }) {
<ModalContent columns={1}>
<ModalField
label="Reward"
value={rewardEditing.Reward}
value={rewardEditing.reward}
modalAction={EDIT}
onChange={reward => {
handleInput('reward', reward.target.value, rewardEditing, setRewardEditing)
Expand All @@ -308,7 +306,7 @@ export default function Rewards({ id, hackathons }) {
<ModalContent columns={1}>
<ModalField
label="Blurb"
value={rewardEditing.text}
value={rewardEditing.blurb}
modalAction={EDIT}
onChange={reward => {
handleInput('blurb', reward.target.value, rewardEditing, setRewardEditing)
Expand All @@ -318,7 +316,7 @@ export default function Rewards({ id, hackathons }) {
<ModalContent columns={1}>
<ModalField
label="Image Name"
value={rewardEditing.text}
value={rewardEditing.imgName}
modalAction={EDIT}
onChange={reward => {
handleInput('imgName', reward.target.value, rewardEditing, setRewardEditing)
Expand All @@ -328,7 +326,7 @@ export default function Rewards({ id, hackathons }) {
<ModalContent columns={1}>
<ModalField
label="Image URL"
value={rewardEditing.text}
value={rewardEditing.imgURL}
modalAction={EDIT}
onChange={reward => {
handleInput('imgURL', reward.target.value, rewardEditing, setRewardEditing)
Expand All @@ -338,15 +336,15 @@ export default function Rewards({ id, hackathons }) {
<ModalContent columns={2}>
<ModalField
label="Number of prizes available"
value={rewardEditing.text}
value={rewardEditing.prizesAvailable}
modalAction={EDIT}
onChange={reward => {
handleInput('numOfWinners', reward.target.value, rewardEditing, setRewardEditing)
handleInput('prizesAvailable', reward.target.value, rewardEditing, setRewardEditing)
}}
/>
<ModalField
label="Required Points"
value={rewardEditing.points}
value={rewardEditing.requiredPoints}
modalAction={EDIT}
onChange={reward => {
handleInput('requiredPoints', reward.target.value, rewardEditing, setRewardEditing)
Expand Down Expand Up @@ -375,7 +373,7 @@ export default function Rewards({ id, hackathons }) {
<ModalField label="Image URL" value={rewardConfirm.imgURL} modalAction={VIEW} />
</ModalContent>
<ModalContent columns={2}>
<ModalField label="Number of prizes available" value={rewardConfirm.numOfWinners} modalAction={VIEW} />
<ModalField label="Number of prizes available" value={rewardConfirm.prizesAvailable} modalAction={VIEW} />
<ModalField label="Required Points" value={rewardConfirm.requiredPoints} modalAction={VIEW} />
</ModalContent>
</Modal>
Expand Down
8 changes: 4 additions & 4 deletions utility/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export const getReward = (rewardID, data) => {
from: data.from || 'None', // Source or sponsor of the reward

Check failure on line 183 in utility/firebase.js

View workflow job for this annotation

GitHub Actions / Linting

Delete `······························`
imgName: data.imgName || 'None', // Image name (if applicable)

Check failure on line 184 in utility/firebase.js

View workflow job for this annotation

GitHub Actions / Linting

Delete `························`
imgURL: data.imgURL || '', // URL to the reward image

Check failure on line 185 in utility/firebase.js

View workflow job for this annotation

GitHub Actions / Linting

Delete `······························`
numOfWinners: data.numOfWinners || '0', // Number of winners for the reward
prizesAvailable: data.prizesAvailable || '0', // Number of winners for the reward

Check failure on line 186 in utility/firebase.js

View workflow job for this annotation

GitHub Actions / Linting

Delete `···················`
requiredPoints: data.requiredPoints || '0', // Points required to win the reward

Check failure on line 187 in utility/firebase.js

View workflow job for this annotation

GitHub Actions / Linting

Delete `·············`
lastmod: data.lastmod ? formatDate(data.lastmod.seconds) : formatDate(getTimestamp().seconds), // Last modified date
lastmodBy: data.lastmodBy || 'Unknown user', // Last person who modified the reward
Expand All @@ -209,7 +209,7 @@ export const addReward = async (hackathon, reward) => {
blurb: reward.blurb, // Short description of the reward
imgName: reward.imgName, // Image name (if applicable)
imgURL: reward.imgURL, // URL to the reward image
numOfWinners: reward.numOfWinners, // Number of winners for the reward
prizesAvailable: reward.prizesAvailable, // Number of prizes we have
requiredPoints: reward.requiredPoints, // Points required to win the reward
lastmod: getTimestamp(), // Timestamp of when the reward was last modified
lastmodBy: reward.lastmodBy, // User who last modified the reward
Expand All @@ -228,10 +228,10 @@ export const updateReward = async (hackathon, reward) => {
from: reward.from || 'None',
imgName: reward.imgName || 'None',
imgURL: reward.imgURL || '',
numOfWinners: reward.numOfWinners || '0',
prizesAvailable: reward.prizesAvailable || '0',
requiredPoints: reward.requiredPoints || '0',
lastmod: currDate,
lastmodBy: reward.lastModifiedBy,
lastmodBy: reward.lastmodBy,
})
}

Expand Down

0 comments on commit 375e7a0

Please sign in to comment.