aboutsummaryrefslogtreecommitdiffstats
path: root/app/views/pdfresources/show.html.erb
blob: 525e5dd317f44b2654f2b143c450a19444b07115 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<div class="container mx-auto px-4 py-8">
  <div class="flex flex-col lg:flex-row gap-8">
    <%# Left side - Main thumbnail %>
    <div class="lg:w-1/2">
      <%= image_tag @pdfresource.thumbnails.first, 
          class: "w-full rounded-lg shadow-lg", 
          alt: @pdfresource.name %>
    </div>

    <%# Right side - Product details %>
    <div class="lg:w-1/2">
      <h1 class="text-3xl font-bold mb-4"><%= @pdfresource.name %></h1>
      
      <div class="mb-4">
        <span class="text-gray-600">Maths</span>
        <span class="float-right text-gray-600">Year 1 (5-6yrs)</span>
      </div>
      
      <div class="mb-4">
        <p class="text-gray-600">Contains <%= @pdfresource.pdfs.count %> PDF file<%= 's' if @pdfresource.pdfs.count != 1 %>.</p>
      </div>

      <div class="text-2xl font-bold mb-6">
        £<%= number_with_precision(@pdfresource.price || 0.00, precision: 2) %> 
      </div>

      <div class="mb-8">
        <h2 class="text-xl font-semibold mb-2">Product summary</h2>
        <p class="text-gray-700"><%= @pdfresource.description %></p>
      </div>

      <div class="flex gap-4">
        <%= button_to "Add to basket", '#', 
            class: "bg-blue-500 hover:bg-blue-600 text-white font-semibold py-2 px-6 rounded-lg" %>
            
        <% if Current.session.user&.is_admin %>
          <%= link_to "Edit", edit_pdfresource_path(@pdfresource), 
              class: "bg-gray-500 hover:bg-gray-600 text-white font-semibold py-2 px-6 rounded-lg" %>
              
          <%= button_to "Delete", @pdfresource,
              method: :delete,
              class: "bg-red-500 hover:bg-red-600 text-white font-semibold py-2 px-6 rounded-lg",
              data: { turbo_confirm: "Are you sure you want to delete this resource?" } %>
        <% end %>
      </div>
    </div>
  </div>

  <%# Bottom thumbnails gallery %>
  <div class="mt-8">
    <div class="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4">
      <% @pdfresource.pdf_snapshots.each do |snapshot| %>
        <%= image_tag snapshot, 
            class: "w-full rounded-lg shadow cursor-pointer hover:opacity-75 transition-opacity",
            alt: "PDF preview" %>
      <% end %>
    </div>
  </div>
</div>