Skip to content

Commit 937e4be

Browse files
committed
Fix flash of text in account request form
1 parent 34ab219 commit 937e4be

File tree

1 file changed

+11
-31
lines changed

1 file changed

+11
-31
lines changed

app/views/account_requests/new.html.erb

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,24 @@
66
</div>
77

88
<div class="form-check">
9-
<%= radio_button_tag(:account, :bank, false, class: 'form-check-input account_type') %>
9+
<%= radio_button_tag(:account, :bank, @bank_selected, class: 'form-check-input account_type') %>
1010
<%= label_tag(:account, "I am an Essentials Bank. I do NOT distribute diapers/period supplies directly to the public, I distribute them to partner agencies who distribute them to the public.", class: 'form-check-label') %>
1111
</div>
1212
<div class="form-check">
1313
<%= radio_button_tag(:account, :partner, false, class: 'form-check-input account_type') %>
1414
<%= label_tag(:account, "I am a Partner Agency to an Essentials Bank. I distribute the diapers/period supplies that I receive from essentials banks directly to the public.", class: 'form-check-label') %>
1515
</div>
1616

17-
<% if @bank_selected %>
18-
<script type="module">
19-
$(document).ready(function() {
20-
const bankRadioButtons = $('.account_type[value="bank"]:not(:checked)');
21-
22-
if (bankRadioButtons.length > 0) {
23-
bankRadioButtons.eq(0).click();
24-
}
25-
});
26-
</script>
27-
<% else %>
28-
<script type="module">
29-
$(document).ready(function() {
30-
$('#create_bank').hide()
31-
$('#partner_info').hide()
32-
});
33-
</script>
34-
<% end %>
35-
36-
<script type="module">
37-
$('.account_type').change(function() {
38-
if (this.value === 'bank') {
39-
$('#create_bank').show()
40-
$('#partner_info').hide()
41-
} else {
42-
$('#create_bank').hide()
43-
$('#partner_info').show()
44-
}
45-
})
46-
</script>
17+
<%# Hide #partner_info and #create_bank selections unless radio button selected %>
18+
<style>
19+
#partner_info, #create_bank {
20+
display: none;
21+
}
22+
.form-check:has(#account_partner:checked)~#partner_info,
23+
.form-check:has(#account_bank:checked)~#create_bank {
24+
display: block;
25+
}
26+
</style>
4727

4828
<div class='card-text' id='partner_info'>
4929
<p class='p-2'>Are you a current partner to diaper and/or period supply banks? If so please go <a href='https://humanessentials.app/users/sign_in'>here</a> to login.</p>

0 commit comments

Comments
 (0)