Skip to content

charging contest owner when selecting winner and fix hardcode creater…#121

Open
banh0006 wants to merge 5 commits intodevfrom
charging-on-select-winner
Open

charging contest owner when selecting winner and fix hardcode creater…#121
banh0006 wants to merge 5 commits intodevfrom
charging-on-select-winner

Conversation

@banh0006
Copy link
Copy Markdown
Collaborator

@banh0006 banh0006 commented Feb 4, 2021

  • Check user stripe id before letting they select a contest winner
  • When they select a winner, it will charge their credit card
  • Mark contest is over when contest has already had winner
  • fix hardcode createId in create contest page

@banh0006 banh0006 requested review from a user, Simeon10, bonnieli and edyhtan February 4, 2021 23:57
@banh0006 banh0006 marked this pull request as ready for review February 5, 2021 03:03
@banh0006
Copy link
Copy Markdown
Collaborator Author

banh0006 commented Feb 5, 2021

Screen Shot 2021-02-04 at 9 59 12 PM

Screen Shot 2021-02-04 at 9 59 31 PM

Screen Shot 2021-02-04 at 9 59 41 PM

import { makeStyles } from '@material-ui/core/styles'
import TabPanel from '../components/TabPanel'
import CheckoutForm from '../components/CheckoutForm'
// import CreditCardForm from '../components/CreditCardForm'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove if not needed

intentSecret = data["intent_id"]
console.log(intentSecret)
if (intentSecret != null){
let amount = contest.prize_contest
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since amount never changes, turn this into a const

console.log(intentSecret)
if (intentSecret != null){
let amount = contest.prize_contest
let currency = 'usd'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

let currency = 'usd'

createPayment(amount, currency, data => {
console.log(data.msg)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these if done using

} else {
console.log("unexpected error")
const onWinnerSubmit = async(e) => {
var intentSecret = null
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid using var as much as possible. do you need this variable to be at this level? can you call it and initilize it on line 176?


useEffect(() => {
//when payment dialog close, should fetch new data
getContestInfo(contestId)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you getting a warning that contestId needs to be part of this dependency ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, there was a warning, I just add contestId into the dependency array

import RequestError, { getContestDetails, setContestWinner } from '../apiCalls'
import RequestError, { getContestDetails, checkStripeIDExists, createPayment } from '../apiCalls'

const stripePromise = loadStripe("pk_test_51IH8tAGt0nFBLozrVPDB6mwr6yEw9QOAVWhTQK0hErAcLv7F278Dz2f3P637jEaboOp7lJbAVnZNbQTxQUoqD91z00VxrG6s3T")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to change this to a config var so that @edyhtan can replace accordingly

# Conflicts:
#	client/src/components/CreateContestForm.js
#	client/src/pages/ContestDetails.js
#	server/api/contest_handler.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants