diff --git a/app/components/polls/results/question_component.html.erb b/app/components/polls/results/question_component.html.erb
new file mode 100644
index 000000000..f11a56898
--- /dev/null
+++ b/app/components/polls/results/question_component.html.erb
@@ -0,0 +1,25 @@
+
<%= question.title %>
+
+
+
+ <%- question.question_answers.each do |answer| %>
+ |
+ <% if most_voted_answer?(answer) %>
+ <%= t("polls.show.results.most_voted_answer") %>
+ <% end %>
+ <%= answer.title %>
+ |
+ <% end %>
+
+
+
+
+ <%- question.question_answers.each do |answer| %>
+ |
+ <%= answer.total_votes %>
+ (<%= answer.total_votes_percentage.round(2) %>%)
+ |
+ <% end %>
+
+
+
diff --git a/app/components/polls/results/question_component.rb b/app/components/polls/results/question_component.rb
new file mode 100644
index 000000000..f62a6b69d
--- /dev/null
+++ b/app/components/polls/results/question_component.rb
@@ -0,0 +1,15 @@
+class Polls::Results::QuestionComponent < ApplicationComponent
+ attr_reader :question
+
+ def initialize(question:)
+ @question = question
+ end
+
+ def answer_styles(answer)
+ "win" if most_voted_answer?(answer)
+ end
+
+ def most_voted_answer?(answer)
+ answer.id == question.most_voted_answer_id
+ end
+end
diff --git a/app/views/polls/results.html.erb b/app/views/polls/results.html.erb
index 745b31914..eaaaaae5b 100644
--- a/app/views/polls/results.html.erb
+++ b/app/views/polls/results.html.erb
@@ -16,34 +16,7 @@
- <%- @poll.questions.each do |question| %>
- <% most_voted_answer_id = question.most_voted_answer_id %>
-
<%= question.title %>
-
-
-
- <%- question.question_answers.each do |answer| %>
- | >
- <% if answer.id == most_voted_answer_id %>
- <%= t("polls.show.results.most_voted_answer") %>
- <% end %>
- <%= answer.title %>
- |
- <% end %>
-
-
-
-
- <%- question.question_answers.each do |answer| %>
- | >
- <%= answer.total_votes %>
- (<%= answer.total_votes_percentage.round(2) %>%)
- |
- <% end %>
-
-
-
- <% end %>
+ <%= render Polls::Results::QuestionComponent.with_collection(@poll.questions) %>