diff --git a/app/models/competition.rb b/app/models/competition.rb index f3bd7462d1..3dc5321fb6 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -2212,6 +2212,10 @@ def serializable_hash(options = nil) ) end + def competitor_count + competitors.count + end + def to_ics cal = Icalendar::Calendar.new wcif_ids = rounds.to_h { |r| [r.wcif_id, r.to_string_map] } diff --git a/app/views/competitions/show.html.erb b/app/views/competitions/show.html.erb index 9ae89d8ffb..b179fc99b5 100644 --- a/app/views/competitions/show.html.erb +++ b/app/views/competitions/show.html.erb @@ -9,7 +9,7 @@ media number_of_bookmarks date_range information on_the_spot_registration? on_the_spot_entry_fee_lowest_denomination guests_per_registration_limit_enabled? guests_per_registration_limit uses_qualification? allow_registration_without_qualification events_per_registration_limit_enabled? events_per_registration_limit guests_entry_fee_lowest_denomination all_guests_allowed? - uses_cumulative? uses_cumulative_across_rounds? uses_cutoff? uses_qualification?]} %> + uses_cumulative? uses_cumulative_across_rounds? uses_cutoff? uses_qualification? results_posted? competitor_count]} %> <%= render layout: 'nav' do %> <%= react_component("CompetitionTabs", { tabs: @competition.tabs.as_json, @@ -19,6 +19,8 @@ only: %w[wca_id unconfirmed_wca_id], methods: [], include: [], - }) + }), + winners: winners(@competition, @competition.main_event), + records: records(@competition), }) %> <% end %> diff --git a/app/webpacker/components/CompetitionTabs/GeneralInfoTab.jsx b/app/webpacker/components/CompetitionTabs/GeneralInfoTab.jsx index 928c7c8b89..9a42af1c53 100644 --- a/app/webpacker/components/CompetitionTabs/GeneralInfoTab.jsx +++ b/app/webpacker/components/CompetitionTabs/GeneralInfoTab.jsx @@ -18,9 +18,11 @@ const linkToGoogleMapsPlace = (latitude, longitude) => `https://www.google.com/m export default function GeneralInfoTab({ competition, userInfo, + records, + winners, }) { const [showRegistrationRequirements, setShowRegistrationRequirements] = useState(!competition['is_probably_over?']); - const [showHighlights, setShowHighlights] = useState(false); + const [showHighlights, setShowHighlights] = useState(true); return ( @@ -243,7 +245,7 @@ export default function GeneralInfoTab({
{I18n.t('competitions.nav.menu.competitors')}
- {competition.competitors.length} + {competition.competitor_count} )} {(competition.media.accepted ?? []).map((mediaType) => ( @@ -360,32 +362,36 @@ export default function GeneralInfoTab({ + {competition['results_posted?'] && (competition.main_event_id || records) && ( + + +
{I18n.t('competitions.competition_info.highlights')}
+
+ +
+ {showHighlights ? ( + <> + +
+ {competition.main_event_id && } +
+ {records && } +
+ + ) : ( + + )} +
+
+
+ )}
- - {competition.userCanViewResults && (competition.main_event_id || records) && ( -
-
{I18n.t('competitions.competition_info.highlights')}
-
-
- {showHighlights ? ( - <> - -
- {competition.main_event_id &&

{winners(competition, competition.mainEvent)}

} - {records &&

{records}

} -
- - ) : ( - - )} -
-
-
- )} diff --git a/app/webpacker/components/CompetitionTabs/index.jsx b/app/webpacker/components/CompetitionTabs/index.jsx index 609ed662d6..6a25edd465 100644 --- a/app/webpacker/components/CompetitionTabs/index.jsx +++ b/app/webpacker/components/CompetitionTabs/index.jsx @@ -28,10 +28,21 @@ const tabIndexFromSlug = (panes) => { }; export default function Wrapper({ - tabs, competition, wcifEvents, wcifSchedule, locale, userInfo, + tabs, competition, wcifEvents, wcifSchedule, locale, userInfo, records, winners, }) { const panes = useMemo(() => { - const p = [{ slug: 'general-info', menuItem: 'General Info', render: () => }]; + const p = [{ + slug: 'general-info', + menuItem: 'General Info', + render: () => ( + + ), + }]; if (competition['has_rounds?']) { p.push({ slug: 'competition-events',