<%= @user.is_vendor? ? "Vendor" : "Buyer" %> feedback

<% if @product %> Feedback placed on this <%=link_to 'product', product_path(@product) %> sold by <%= link_to @user.displayname, profile_path(@user) %>. <% else %> All feedback placed on <%= link_to @user.displayname, profile_path(@user) %>. <% end %>

<% if @total_count == 0 %> No feedback placed yet. <%else%>

Total feedbacks <%=@total_count%>.

<% @feedbacks.each do |feedback| %> <%# nil.try always returns nil. in_time_zone(nil) gives UTC. so when visitor not logged in they get UTC time. %> <% end %>
Placed by <% concat 'Product' if @user.is_vendor? %> Feedback Order price Date
<% if feedback.rating == 'negative' %> <%= image_tag 'sad_face1.gif', class: 'faceimage' %> <% elsif feedback.rating == 'neutral' %> <%= image_tag 'neutral_face1.gif', class: 'faceimage' %> <%else%> <%= image_tag 'happy_face1.gif', class: 'faceimage' %> <%end%> <%# A hash salt is added in which is the vendors username. This makes the buyers displayed hash different when they review different vendors. %> <%= feedback.placedby.displayname_hash(@user.username) %> <%# Don't show order title unless this is the vendors feedback page. We don't want a buyers profile to show what they bought. This partial is used on product#show so not necessary to show title there. Use title from order, not product because product title can be changed by vendor. %> <%= @user.is_vendor? ? feedback.order.title : '' %>

<%= simple_format h(feedback.feedback) %>

<% unless feedback.response.empty? %>

Response: <%= simple_format h(feedback.response) %>

<%end%>
<% unless Rails.configuration.order_age_to_hide_price_on_review && feedback.order.created_at < Time.now - Rails.configuration.order_age_to_hide_price_on_review %> <%# Unauthenticated users can view this so display prices in USD for them. %> <%= number_to_range(feedback.order.total_price_in_currency(current_user.try(:currency) || "USD"), Rails.configuration.price_ranges) %> <%= current_user.try(:currency) || "USD" %> <% end %> <%= feedback.created_at.in_time_zone(current_user.try(:timezone)).strftime('%F') %>
<%= paginate @feedbacks %> <%end%>