andela/workdey

View on GitHub
app/views/notifications/index.html.erb

Summary

Maintainability
Test Coverage
<main>
  <section class="notifications container">
    <div class="row">
      <div class="col s12">
        <h3>Notifications</h3>
      </div>

      <% if @notifications.present? && current_user.artisan?  %>
      <div class="notification-feed col s6">
        <% @notifications.each do |object| %>
          <%= show_notifications(object) %>
        <% end %>
      </div>

      <div class="full_notification_message col s6 center-align card-panel">
      </div>

      <% elsif @notifications.present? && current_user.user_type == "tasker" %>
        <div class="notification-feed col s8">

          <% @notifications.each do |object| %>
            <div class="viewed feed">
              <img src="<%= object.sender.image_url %>" alt="" />
              <p class="title"> <%= object.message %> </p>
              <%if object.notifiable_type == 'Quote'%>
              <a href="#quote_modal" onclick="quote_object(<%= object.sender.to_json %>,<%=object.notifiable.to_json%>, <%= object.id %>)" class="btn info_btn modal-trigger"> view quote</a>
              <%end%>

            </div>

            <div id="quote_modal" class="modal info_modal">
                <div class="modal-content">
                  <h4>Quote Information</h4>
                  <p class="artisan_name">Name: <span id="name"></span></p>
                  <h3 class="">Quote: <span id="quote"></span></h3>

                  <div id= "information">
                    <h5>Details</h5>
                    <p class="artisan_phone">Phone: <span id="phone"></span></p>
                    <p class="artisan_email">Email: <span id="email"></span></p>
                    <a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">Close</a>
                  </div>

                  <button id='quote_accept' class="btn teal modal-action" onclick="quotation('accepted', <%=object.notifiable.id%>)">Accept</button>
                  <button id='quote_reject' class="btn modal-action modal-close" onclick="quotation('rejected', <%=object.notifiable.id%>)">Reject</button>
                </div>
              </div>
              <% end %>
        </div>


      <% else  %>
        <div class="col s6 full_notification_message center-align card-panel">
          <p>No new notifications available</p>
          <% 4.times do %>
            <i class="material-icons">highlight_off</i>
          <% end %>
        </div>
      <% end  %>
    </div>
  </section>
</main>