Skip to content

Commit

Permalink
Only display guest field in Register form if guests enabled (#10317)
Browse files Browse the repository at this point in the history
* only display guest field if guests enabled

* oopsie
  • Loading branch information
dunkOnIT authored Nov 25, 2024
1 parent 8d8a65c commit b4c85e4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/models/competition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1865,7 +1865,7 @@ def to_competition_info
base_entry_fee_lowest_denomination currency_code allow_registration_edits allow_registration_self_delete_after_acceptance
allow_registration_without_qualification refund_policy_percent use_wca_registration guests_per_registration_limit venue contact
force_comment_in_registration use_wca_registration external_registration_page guests_entry_fee_lowest_denomination guest_entry_status
information events_per_registration_limit],
information events_per_registration_limit guests_enabled],
methods: %w[url website short_name city venue_address venue_details latitude_degrees longitude_degrees country_iso2 event_ids registration_currently_open?
main_event_id number_of_bookmarks using_payment_integrations? uses_qualification? uses_cutoff? competition_series_ids registration_full? registration_version],
include: %w[delegates organizers],
Expand Down
30 changes: 16 additions & 14 deletions app/webpacker/components/RegistrationsV2/Register/CompetingStep.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,20 +337,22 @@ export default function CompetingStep({
error={competitionInfo.force_comment_in_registration && comment.trim().length === 0 && i18n.t('registrations.errors.cannot_register_without_comment')}
/>
</Form.Field>
<Form.Field>
<label>{i18n.t('activerecord.attributes.registration.guests')}</label>
<Form.Input
id="guest-dropdown"
type="number"
value={guests}
onChange={(event, data) => {
setGuests(Number.parseInt(data.value, 10));
}}
min="0"
max={competitionInfo.guests_per_registration_limit ?? 99}
error={Number.isInteger(competitionInfo.guests_per_registration_limit) && guests > competitionInfo.guests_per_registration_limit && i18n.t('competitions.competition_info.guest_limit', { count: competitionInfo.guests_per_registration_limit })}
/>
</Form.Field>
{competitionInfo.guests_enabled && (
<Form.Field>
<label>{i18n.t('activerecord.attributes.registration.guests')}</label>
<Form.Input
id="guest-dropdown"
type="number"
value={guests}
onChange={(event, data) => {
setGuests(Number.parseInt(data.value, 10));
}}
min="0"
max={competitionInfo.guests_per_registration_limit ?? 99}
error={Number.isInteger(competitionInfo.guests_per_registration_limit) && guests > competitionInfo.guests_per_registration_limit && i18n.t('competitions.competition_info.guest_limit', { count: competitionInfo.guests_per_registration_limit })}
/>
</Form.Field>
)}
{isRegistered ? (
<ButtonGroup widths={2}>
{shouldShowUpdateButton && (
Expand Down

0 comments on commit b4c85e4

Please sign in to comment.