Skip to content

Commit 554cc9d

Browse files
authored
Merge pull request #5797 from simpledotorg/sagar-rtsl/SIMPLEETH-27
feat(ET): Use country config for supported genders in breakdown table
2 parents 1d78501 + 6d4761f commit 554cc9d

4 files changed

Lines changed: 34 additions & 24 deletions

File tree

app/components/progress_tab/breakdown_table_component.html.erb

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,15 @@
77
<%= breakdown[:all] %>
88
</p>
99
</div>
10-
<div class="d-flex ai-center jc-space-between pb-3px bb-grey-mid mb-4px">
11-
<p class="m-0px p-0px pl-16px ta-left fw-normal fs-16px c-grey-dark">
12-
<%= t("progress_tab.genders.female") %>
13-
</p>
14-
<p class="m-0px p-0px ta-right fw-normal fs-16px c-grey-dark">
15-
<%= breakdown[:female] %>
16-
</p>
17-
</div>
18-
<div class="d-flex ai-center jc-space-between pb-3px bb-grey-mid mb-4px">
19-
<p class="m-0px p-0px pl-16px ta-left fw-normal fs-16px c-grey-dark">
20-
<%= t("progress_tab.genders.male") %>
21-
</p>
22-
<p class="m-0px p-0px ta-right fw-normal fs-16px c-grey-dark">
23-
<%= breakdown[:male] %>
24-
</p>
25-
</div>
26-
<div class="d-flex ai-center jc-space-between <% if include_bottom_border %>pb-3px bb-grey-mid<% end %> mb-4px">
27-
<p class="m-0px p-0px pl-16px ta-left fw-normal fs-16px c-grey-dark">
28-
<%= t("progress_tab.genders.transgender") %>
29-
</p>
30-
<p class="m-0px p-0px ta-right fw-normal fs-16px c-grey-dark">
31-
<%= breakdown[:transgender] %>
32-
</p>
33-
</div>
10+
<% supported_genders.each_with_index do |gender, index| %>
11+
<% is_last = index == supported_genders.size - 1 %>
12+
<div class="d-flex ai-center jc-space-between <% if !is_last || include_bottom_border %>pb-3px bb-grey-mid<% end %> mb-4px">
13+
<p class="m-0px p-0px pl-16px ta-left fw-normal fs-16px c-grey-dark">
14+
<%= t("progress_tab.genders.#{gender}") %>
15+
</p>
16+
<p class="m-0px p-0px ta-right fw-normal fs-16px c-grey-dark">
17+
<%= breakdown[gender.to_sym] %>
18+
</p>
19+
</div>
20+
<% end %>
3421
</div>

app/components/progress_tab/breakdown_table_component.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ def initialize(title:, breakdown:)
1818
def include_bottom_border
1919
title != t("progress_tab.diagnoses.hypertension_and_diabetes")
2020
end
21+
22+
def supported_genders
23+
CountryConfig.supported_genders
24+
end
2125
end

config/initializers/country_config.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ def self.country_environment_file
149149
def self.current_country?(country)
150150
CountryConfig.current[:name] == country
151151
end
152+
153+
def self.supported_genders
154+
current[:supported_genders] || %w[male female transgender]
155+
end
152156
end
153157

154158
Rails.application.config.country = CountryConfig.for(ENV.fetch("DEFAULT_COUNTRY"))

spec/initializers/country_config_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,19 @@
1111
).to eq true
1212
end
1313
end
14+
15+
describe ".supported_genders" do
16+
it "returns supported genders from the current country config" do
17+
test_genders = %w[male female]
18+
allow(CountryConfig).to receive(:current).and_return({supported_genders: test_genders})
19+
20+
expect(CountryConfig.supported_genders).to eq(test_genders)
21+
end
22+
23+
it "returns fallback genders when not configured" do
24+
allow(CountryConfig).to receive(:current).and_return({})
25+
26+
expect(CountryConfig.supported_genders).to eq(%w[male female transgender])
27+
end
28+
end
1429
end

0 commit comments

Comments
 (0)