@@ -10,39 +10,21 @@ def initialize(programme, active:)
1010
1111 def call
1212 render AppSecondaryNavigationComponent . new do |nav |
13- nav . with_item (
14- href : programme_path ( programme ) ,
15- text : "Overview" ,
16- selected : active == :overview
17- )
18-
19- nav . with_item (
20- href : programme_cohorts_path ( programme ) ,
21- text : I18n . t ( "cohorts.index.title" ) ,
22- selected : active == :cohorts
23- )
24-
25- nav . with_item (
26- href : sessions_programme_path ( programme ) ,
27- text : I18n . t ( "sessions.index.title" ) ,
28- selected : active == :sessions
29- )
30-
31- nav . with_item (
32- href : patients_programme_path ( programme ) ,
33- text : I18n . t ( "patients.index.title" ) ,
34- selected : active == :patients
35- )
36-
37- nav . with_item (
38- href : programme_vaccination_records_path ( programme ) ,
39- text : I18n . t ( "vaccination_records.index.title" ) ,
40- selected : active == :vaccination_records
41- )
13+ SECTIONS . each do |section |
14+ action = section == :overview ? :show : :index
15+
16+ nav . with_item (
17+ href : public_send ( "programme_#{ section } _path" , programme ) ,
18+ text : I18n . t ( "title" , scope : [ :programmes , section , action ] ) ,
19+ selected : active == section
20+ )
21+ end
4222 end
4323 end
4424
4525 private
4626
4727 attr_reader :programme , :active
28+
29+ SECTIONS = %i[ overview cohorts sessions patients vaccinations ] . freeze
4830end
0 commit comments