/
index.html.erb
48 lines (47 loc) · 1.98 KB
/
index.html.erb
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
<% content_for :title, "Turbo Sortable Paginated Tables" %>
<div class="invoices">
<div class="sm:flex sm:items-center">
<div class="sm:flex-auto">
<h1 class="invoices__header">Invoices</h1>
</div>
</div>
<%= turbo_frame_tag "invoices" do %>
<div class="flow-root mt-8">
<div class="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
<div class="inline-block min-w-full py-2 align-middle sm:px-6 lg:px-8">
<div class="invoices__table--shadow">
<table class="invoices__table">
<thead class="invoices__thead">
<tr>
<%= sortable_table_header 'ID', :id, :invoices_path, class: 'invoices__row--header' %>
<%= sortable_table_header 'Amount', :amount, :invoices_path, class: 'invoices__row--header' %>
<%= sortable_table_header 'Status', :status, :invoices_path, class: 'invoices__row--header' %>
<%= sortable_table_header 'Created At', :created_at, :invoices_path, class: 'invoices__row--header' %>
</tr>
</thead>
<tbody class="invoices__tbody">
<% @invoices.each do |invoice| %>
<tr>
<td class="invoices__row invoices__row--id">
<%= invoice.id %>
</td>
<td class="invoices__row invoices__row--amount">
<%= number_to_currency(invoice.amount) %>
</td>
<td class="invoices__row invoices__row--status">
<%= status_badge(invoice.status) %>
</td>
<td class="invoices__row invoices__row--created-at">
<%= invoice.created_at.strftime('%m/%d/%Y') %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
<%= paginate @invoices %>
</div>
<% end %>
</div>