130 lines
7.3 KiB
Text
130 lines
7.3 KiB
Text
<div class="w-full px-4 py-8">
|
|
<% if notice.present? %>
|
|
<div class="mb-6">
|
|
<p class="py-3 px-4 bg-green-50 text-green-800 font-medium rounded-lg inline-flex items-center" id="notice">
|
|
<svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20">
|
|
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
|
|
</svg>
|
|
<%= notice %>
|
|
</p>
|
|
</div>
|
|
<% end %>
|
|
|
|
<div class="flex justify-between items-center mb-8">
|
|
<h1 class="font-bold text-3xl sm:text-4xl text-gray-900">Expenses</h1>
|
|
<%= link_to new_expense_path, class: "rounded-lg py-2.5 px-4 sm:py-3 sm:px-5 bg-blue-600 hover:bg-blue-700 text-white font-medium transition-colors flex items-center" do %>
|
|
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
|
|
</svg>
|
|
New expense
|
|
<% end %>
|
|
</div>
|
|
|
|
<% if @expenses.any? %>
|
|
<div class="hidden lg:block overflow-x-auto bg-white rounded-lg shadow">
|
|
<table class="min-w-full">
|
|
<thead class="bg-gray-50 border-b border-gray-200">
|
|
<tr>
|
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Description</th>
|
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Payment</th>
|
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Monthly</th>
|
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Details</th>
|
|
<th scope="col" class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="bg-white divide-y divide-gray-200">
|
|
<% @expenses.each do |expense| %>
|
|
<tr class="hover:bg-gray-50 transition-colors">
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
<div class="text-sm font-medium text-gray-900"><%= expense.description %></div>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
<span class="text-sm text-gray-900 font-mono"><%= number_to_currency(expense.payment) %></span>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
<span class="text-sm text-gray-900 font-mono"><%= number_to_currency(expense.monthly) %></span>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
<div class="flex gap-1">
|
|
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-purple-100 text-purple-800">
|
|
<%= expense.period.downcase %>
|
|
</span>
|
|
<% if expense.credit_card %>
|
|
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-800">credit card</span>
|
|
<% end %>
|
|
<% if expense.estimated %>
|
|
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-yellow-100 text-yellow-800">estimated</span>
|
|
<% end %>
|
|
</div>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
|
<%= link_to "View", expense, class: "text-blue-600 hover:text-blue-900 mr-3" %>
|
|
<%= link_to "Edit", edit_expense_path(expense), class: "text-indigo-600 hover:text-indigo-900" %>
|
|
</td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="lg:hidden space-y-4">
|
|
<% @expenses.each do |expense| %>
|
|
<div class="bg-white rounded-lg shadow p-4 hover:shadow-md transition-shadow">
|
|
<div class="flex justify-between items-start mb-3">
|
|
<h3 class="text-lg font-medium text-gray-900"><%= expense.description %></h3>
|
|
<div class="flex gap-2">
|
|
<%= link_to expense, class: "text-blue-600 hover:text-blue-800" do %>
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/>
|
|
</svg>
|
|
<% end %>
|
|
<%= link_to edit_expense_path(expense), class: "text-indigo-600 hover:text-indigo-800" do %>
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/>
|
|
</svg>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-2 mb-3">
|
|
<div>
|
|
<p class="text-xs text-gray-500">Payment</p>
|
|
<p class="text-sm font-mono font-medium"><%= number_to_currency(expense.payment) %></p>
|
|
</div>
|
|
<div>
|
|
<p class="text-xs text-gray-500">Monthly</p>
|
|
<p class="text-sm font-mono font-medium"><%= number_to_currency(expense.monthly) %></p>
|
|
</div>
|
|
</div>
|
|
<div class="flex flex-wrap gap-1">
|
|
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-purple-100 text-purple-800">
|
|
<%= expense.period.downcase %>
|
|
</span>
|
|
<% if expense.credit_card %>
|
|
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-800">credit card</span>
|
|
<% end %>
|
|
<% if expense.estimated %>
|
|
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-yellow-100 text-yellow-800">estimated</span>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
<% else %>
|
|
<div class="text-center py-12 bg-white rounded-lg shadow">
|
|
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>
|
|
</svg>
|
|
<h3 class="mt-2 text-sm font-medium text-gray-900">No expenses</h3>
|
|
<p class="mt-1 text-sm text-gray-500">Get started by creating a new expense.</p>
|
|
<div class="mt-6">
|
|
<%= link_to new_expense_path, class: "inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700" do %>
|
|
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
|
|
</svg>
|
|
New expense
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
</div>
|