Skip to content

Commit

Permalink
Adding missing challenge setup code from workshop
Browse files Browse the repository at this point in the history
  • Loading branch information
thezacharytaylor committed Dec 22, 2022
1 parent 1e857cf commit 9422aa0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions components/payment-form/presets-custom-amounts.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import React, {useRef, useState} from "react"

const PresetsCustomAmounts = ({amounts}) => {
const [selectedOption, setSelectedOption] = useState(false)
const customAmtRadio = useRef(null)

const focusInCustomInput = () => {
customAmtRadio.current.checked = true
}

const handleChange = (event) => {
if (event.target.checked) {
setSelectedOption(event.target.value);
}
}
return (
<>
{amounts.map((amount, index)=> {
{amounts.map((amount, index) => {
return <label key={index}>
<input
checked={selectedOption == amount}
checked={selectedOption === amount}
id={`amt_${amount}`}
name="amounts"
onChange={(event) => handleChange(event)}
Expand All @@ -24,8 +29,10 @@ const PresetsCustomAmounts = ({amounts}) => {
})}
<label className="custom-radio-group">
<input
checked={selectedOption === 'Custom'}
id="amt_custom"
name="amounts"
onChange={(event) => handleChange(event)}
ref={customAmtRadio}
type="radio"
value="Custom"
Expand Down

0 comments on commit 9422aa0

Please sign in to comment.