<!-- body bala logic yha pr hoga -->
<% layout('layouts/boilerplate')%>  <!--yha layouts k boiler plate ko use kiya h-->
<%- include('../partials/navbar') %>  <!--navbar ko add krne k liye-->
<%- include('../partials/flash') %>  <!--flash ko add krne k liye-->


<div class="row">
  <!-- displaying flash -->
  <!-- <%  if(msg && msg.length){ %>
  <div class="alert alert-success" role="alert">
    <strong> <%= msg %> </strong>
    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
  </div>
  <%  }  %>
          -->
            <div class="col-lg-6 mt-3">
             



                <div class="card shadow mx-auto" style="width: 18rem;">
                    <img src="<%=foundProduct.img%>" class="card-img-top" alt="...">
                    <div class="card-body">
                      
                      <h2 class="card-title"><%=foundProduct.name %></h2>
                      <h5 class="card-title"><%=foundProduct.price %></h5>
                      <p class="card-text"><%=foundProduct.desc %></p>
                      
                   
                      <% if(currentUser && currentUser.role =='seller'){ %>
                      <a href="/products/<%=foundProduct._id%>/edit" class="btn btn-sm btn-dark">Edit</a>
                     <% }  %>

                     <form method="POST" action="/user/<%=foundProduct._id%>/add" class="d-inline-block" >
                       <button class="btn btn-sm btn-secondary">Add to cart</button>
                     </form>

                      <a href="<%=foundProduct.payment_link%>" class="btn btn-sm btn-primary">Buy Product</a>
                    </div>
                  </div>      
            </div>
            <div class="col-lg-4">
                <h1 class="display-5">Leave a Review</h1>
                <form action="/products/<%=foundProduct._id%>/review" method="POST">
                  <div class="">
                    <fieldset class="starability-basic">
                      <input type="radio" id="no-rate" class="input-no-rate" name="rating" value="0" checked aria-label="No rating." />
                      <input type="radio" id="first-rate1" name="rating" value="1" />
                      <label for="first-rate1" title="Terrible">1 star</label>
                      <input type="radio" id="first-rate2" name="rating" value="2" />
                      <label for="first-rate2" title="Not good">2 stars</label>
                      <input type="radio" id="first-rate3" name="rating" value="3" />
                      <label for="first-rate3" title="Average">3 stars</label>
                      <input type="radio" id="first-rate4" name="rating" value="4" />
                      <label for="first-rate4" title="Very good">4 stars</label>
                      <input type="radio" id="first-rate5" name="rating" value="5" />
                      <label for="first-rate5" title="Amazing">5 stars</label>
                    </fieldset>
                  </div>
                  <div class="mb-3">
                    <label class="form-label" for="comment">Comment:</label>
                     <textarea class="form-control" name="comment" id=""  rows="3" id="comment"></textarea>
                  </div>

                  <button class="btn btn-sm btn-success">Add Review</button>
                </form>

                <!-- review ko show kr rhe h  -->
                <div class="my-3">

                <%  for(let review of foundProduct.reviews){  %>

                    <div class="card mt-3">
                      <p class="card-title mx-2">
                        <% if(review.createdAt){ %>
                         <%=review.createdAt.toDateString()%>
                       <% }  %>
                       </p>
                      <p class="starability-result" data-rating="<%=review.rating%>">
                        Rated:<%=review.rating%> stars
                      </p>
                      <div class="card-body">
                        <p class="card-text">Comment:<%=review.comment%></p>
                        <a href="#" class="btn btn-primary">Delete</a>
                      </div>
                      
                    </div>
               <%   }   %>
                </div>
            </div>
   
</div>
</body>
</html>

<!-- https://rzp.io/l/g0LJIwuK12 -->
