fix clicks on billing types label not toggling correct radio

Currently, all the billing types radios are being assigned the
same "billingType" id, so clicking on any of the labels
always selects the monthly one. If you inspect the HTML, all the
billing type labels have 'for="billingType"' which is how the HTML
knows which input to select.

We have to keep the "name" attribute the same because that's how
the input values are linked to the billingType form field.

To fix, we explicitly assign the "id" prop for each radio so
that the <label>'s "for" attribute is tied to the correct
radio input.
This commit is contained in:
mzivil 2024-02-03 16:42:10 -05:00
parent 3328c1daa3
commit f2f39f4c22
1 changed files with 3 additions and 0 deletions

View File

@ -172,6 +172,7 @@ export default function TerritoryForm ({ sub }) {
label='100k sats/month' label='100k sats/month'
value='MONTHLY' value='MONTHLY'
name='billingType' name='billingType'
id='monthly-checkbox'
readOnly={!!sub} readOnly={!!sub}
handleChange={checked => checked && setBilling('monthly')} handleChange={checked => checked && setBilling('monthly')}
groupClassName='ms-1 mb-0' groupClassName='ms-1 mb-0'
@ -182,6 +183,7 @@ export default function TerritoryForm ({ sub }) {
label='1m sats/year' label='1m sats/year'
value='YEARLY' value='YEARLY'
name='billingType' name='billingType'
id='yearly-checkbox'
readOnly={!!sub} readOnly={!!sub}
handleChange={checked => checked && setBilling('yearly')} handleChange={checked => checked && setBilling('yearly')}
groupClassName='ms-1 mb-0' groupClassName='ms-1 mb-0'
@ -192,6 +194,7 @@ export default function TerritoryForm ({ sub }) {
label='3m sats once' label='3m sats once'
value='ONCE' value='ONCE'
name='billingType' name='billingType'
id='once-checkbox'
readOnly={!!sub} readOnly={!!sub}
handleChange={checked => checked && setBilling('once')} handleChange={checked => checked && setBilling('once')}
groupClassName='ms-1 mb-0' groupClassName='ms-1 mb-0'