Improve expense views

This commit is contained in:
Andrew Tomaka 2025-06-10 22:38:28 -04:00
parent 0b5fd582e6
commit 8c7fbfa9cd
Signed by: atomaka
GPG key ID: 61209BF70A5B18BE
6 changed files with 413 additions and 93 deletions

View file

@ -1,32 +1,80 @@
<div id="<%= dom_id expense %>">
<p class="my-5">
<strong class="block font-medium mb-1">Description:</strong>
<%= expense.description %>
</p>
<div id="<%= dom_id expense %>" class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<div class="mb-6">
<h2 class="text-2xl font-semibold text-gray-900 mb-4"><%= expense.description %></h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-sm text-gray-600 mb-1">Payment Amount</p>
<p class="text-xl font-mono font-semibold text-gray-900"><%= number_to_currency(expense.payment) %></p>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-sm text-gray-600 mb-1">Monthly Amount</p>
<p class="text-xl font-mono font-semibold text-gray-900"><%= number_to_currency(expense.monthly) %></p>
</div>
</div>
</div>
<p class="my-5">
<strong class="block font-medium mb-1">Payment:</strong>
<%= expense.payment %>
</p>
<p class="my-5">
<strong class="block font-medium mb-1">Period:</strong>
<%= expense.period %>
</p>
<p class="my-5">
<strong class="block font-medium mb-1">Credit card:</strong>
<%= expense.credit_card %>
</p>
<p class="my-5">
<strong class="block font-medium mb-1">Estimated:</strong>
<%= expense.estimated %>
</p>
<div class="border-t border-gray-200 pt-4">
<p class="text-sm text-gray-600 mb-3">Details</p>
<div class="flex flex-wrap gap-2">
<span class="inline-flex items-center px-3 py-1 rounded-md text-sm font-medium bg-purple-100 text-purple-800">
<svg class="w-4 h-4 mr-1.5" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.829a1 1 0 101.415-1.415L11 9.586V6z" clip-rule="evenodd"/>
</svg>
<%= expense.period.downcase %>
</span>
<% if expense.credit_card %>
<span class="inline-flex items-center px-3 py-1 rounded-md text-sm font-medium bg-blue-100 text-blue-800">
<svg class="w-4 h-4 mr-1.5" fill="currentColor" viewBox="0 0 20 20">
<path d="M4 4a2 2 0 00-2 2v1h16V6a2 2 0 00-2-2H4z"/>
<path fill-rule="evenodd" d="M18 9H2v5a2 2 0 002 2h12a2 2 0 002-2V9zM4 13a1 1 0 011-1h1a1 1 0 110 2H5a1 1 0 01-1-1zm5-1a1 1 0 100 2h1a1 1 0 100-2H9z" clip-rule="evenodd"/>
</svg>
credit card
</span>
<% else %>
<span class="inline-flex items-center px-3 py-1 rounded-md text-sm font-medium bg-gray-100 text-gray-700">
<svg class="w-4 h-4 mr-1.5" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M4 4a2 2 0 00-2 2v4a2 2 0 002 2V6h10a2 2 0 00-2-2H4zm2 6a2 2 0 012-2h8a2 2 0 012 2v4a2 2 0 01-2 2H8a2 2 0 01-2-2v-4zm6 4a2 2 0 100-4 2 2 0 000 4z" clip-rule="evenodd"/>
</svg>
bank account
</span>
<% end %>
<% if expense.estimated %>
<span class="inline-flex items-center px-3 py-1 rounded-md text-sm font-medium bg-yellow-100 text-yellow-800">
<svg class="w-4 h-4 mr-1.5" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"/>
</svg>
estimated
</span>
<% else %>
<span class="inline-flex items-center px-3 py-1 rounded-md text-sm font-medium bg-green-100 text-green-800">
<svg class="w-4 h-4 mr-1.5" 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>
actual
</span>
<% end %>
</div>
</div>
<% if action_name != "show" %>
<%= link_to "Show this expense", expense, class: "rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
<%= link_to 'Edit this expense', edit_expense_path(expense), class: "rounded-lg py-3 ml-2 px-5 bg-gray-100 inline-block font-medium" %>
<hr class="mt-6">
<div class="mt-6 pt-6 border-t border-gray-200 flex gap-3">
<%= link_to expense, class: "inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" do %>
<svg class="w-4 h-4 mr-2" 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>
View details
<% end %>
<%= link_to edit_expense_path(expense), class: "inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" do %>
<svg class="w-4 h-4 mr-2" 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>
Edit expense
<% end %>
</div>
<% end %>
</div>

View file

@ -1,47 +1,103 @@
<%= form_with(model: expense, class: "contents") do |form| %>
<%= form_with(model: expense, class: "space-y-6") do |form| %>
<% if expense.errors.any? %>
<div id="error_explanation" class="bg-red-50 text-red-500 px-3 py-2 font-medium rounded-lg mt-3">
<h2><%= pluralize(expense.errors.count, "error") %> prohibited this expense from being saved:</h2>
<ul>
<% expense.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
<div id="error_explanation" class="bg-red-50 border border-red-200 text-red-600 px-4 py-3 rounded-lg">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-red-400" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"/>
</svg>
</div>
<div class="ml-3">
<h3 class="text-sm font-medium"><%= pluralize(expense.errors.count, "error") %> prohibited this expense from being saved:</h3>
<div class="mt-2 text-sm">
<ul class="list-disc list-inside space-y-1">
<% expense.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
</div>
</div>
</div>
<% end %>
<div class="my-5">
<%= form.label :description %>
<%= form.text_field :description, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-4 sm:p-6 lg:p-8">
<h3 class="text-lg font-medium text-gray-900 mb-6">Expense Information</h3>
<div class="grid grid-cols-1 gap-6 lg:grid-cols-2">
<div class="lg:col-span-2">
<%= form.label :description, class: "block text-sm font-medium text-gray-700" %>
<%= form.text_field :description, class: "mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500 sm:text-sm", placeholder: "e.g., Netflix subscription" %>
<p class="mt-1 text-sm text-gray-500">A brief description of the expense</p>
</div>
<div>
<%= form.label :payment, class: "block text-sm font-medium text-gray-700" %>
<div class="mt-1 relative rounded-md shadow-sm">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<span class="text-gray-500 sm:text-sm">$</span>
</div>
<%= form.text_field :payment, class: "pl-7 pr-3 py-2 block w-full border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500 sm:text-sm", placeholder: "0.00" %>
</div>
<p class="mt-1 text-sm text-gray-500">The payment amount for this billing period</p>
</div>
<div>
<%= form.label :period, class: "block text-sm font-medium text-gray-700" %>
<%=
form.select :period,
options_for_select(expense_periods, expense.period),
{},
class: "mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500 sm:text-sm"
%>
<p class="mt-1 text-sm text-gray-500">How often this expense is billed</p>
</div>
</div>
</div>
<div class="my-5">
<%= form.label :payment %>
<%= form.text_field :payment, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-4 sm:p-6 lg:p-8">
<h3 class="text-lg font-medium text-gray-900 mb-6">Payment Details</h3>
<div class="space-y-4">
<div class="flex items-center justify-between">
<div class="flex-grow">
<label for="expense_credit_card" class="text-sm font-medium text-gray-700">Credit Card Payment</label>
<p class="text-sm text-gray-500">This expense is paid by credit card</p>
</div>
<div class="flex-shrink-0 ml-4">
<%= form.check_box :credit_card, class: "toggle-checkbox sr-only" %>
<label for="expense_credit_card" class="toggle-label relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 bg-gray-200">
<span class="toggle-switch pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out translate-x-0"></span>
</label>
</div>
</div>
<div class="flex items-center justify-between">
<div class="flex-grow">
<label for="expense_estimated" class="text-sm font-medium text-gray-700">Estimated Amount</label>
<p class="text-sm text-gray-500">This amount is an estimate</p>
</div>
<div class="flex-shrink-0 ml-4">
<%= form.check_box :estimated, class: "toggle-checkbox sr-only" %>
<label for="expense_estimated" class="toggle-label relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 bg-gray-200">
<span class="toggle-switch pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out translate-x-0"></span>
</label>
</div>
</div>
</div>
</div>
<style>
.toggle-checkbox:checked + .toggle-label {
background-color: rgb(59, 130, 246);
}
.toggle-checkbox:checked + .toggle-label .toggle-switch {
transform: translateX(1.25rem);
}
</style>
<div class="my-5">
<%= form.label :period %>
<%=
form.select :period,
options_for_select(expense_periods, expense.period),
{},
class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full"
%>
</div>
<div class="my-5">
<%= form.label :credit_card %>
<%= form.check_box :credit_card, class: "block mt-2 h-5 w-5" %>
</div>
<div class="my-5">
<%= form.label :estimated %>
<%= form.check_box :estimated, class: "block mt-2 h-5 w-5" %>
</div>
<div class="inline">
<%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
<div class="flex justify-end gap-3">
<%= link_to "Cancel", expenses_path, class: "inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500" %>
<%= form.submit class: "inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 cursor-pointer" %>
</div>
<% end %>

View file

@ -1,8 +1,39 @@
<div class="mx-auto md:w-2/3 w-full">
<h1 class="font-bold text-4xl">Editing expense</h1>
<div class="mx-auto max-w-4xl px-4 py-8">
<div class="mb-8">
<nav class="flex" aria-label="Breadcrumb">
<ol class="inline-flex items-center space-x-1 md:space-x-3">
<li class="inline-flex items-center">
<%= link_to expenses_path, class: "inline-flex items-center text-sm font-medium text-gray-700 hover:text-blue-600" do %>
<svg class="w-4 h-4 mr-2" fill="currentColor" viewBox="0 0 20 20">
<path d="M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z"/>
</svg>
Expenses
<% end %>
</li>
<li>
<div class="flex items-center">
<svg class="w-6 h-6 text-gray-400" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd"/>
</svg>
<%= link_to @expense.description, @expense, class: "ml-1 text-sm font-medium text-gray-700 hover:text-blue-600 md:ml-2" %>
</div>
</li>
<li>
<div class="flex items-center">
<svg class="w-6 h-6 text-gray-400" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd"/>
</svg>
<span class="ml-1 text-sm font-medium text-gray-500 md:ml-2">Edit</span>
</div>
</li>
</ol>
</nav>
</div>
<div class="mb-8">
<h1 class="text-3xl font-bold text-gray-900">Editing expense</h1>
<p class="mt-2 text-sm text-gray-600">Update the details for this expense.</p>
</div>
<%= render "form", expense: @expense %>
<%= link_to "Show this expense", @expense, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
<%= link_to "Back to expenses", expenses_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
</div>

View file

@ -1,14 +1,130 @@
<div class="w-full">
<div class="w-full px-4 py-8">
<% if notice.present? %>
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
<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">
<h1 class="font-bold text-4xl">Expenses</h1>
<%= link_to 'New expense', new_expense_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %>
<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>
<div id="expenses" class="min-w-full">
<%= render @expenses %>
</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>

View file

@ -1,7 +1,31 @@
<div class="mx-auto md:w-2/3 w-full">
<h1 class="font-bold text-4xl">New expense</h1>
<div class="mx-auto max-w-4xl px-4 py-8">
<div class="mb-8">
<nav class="flex" aria-label="Breadcrumb">
<ol class="inline-flex items-center space-x-1 md:space-x-3">
<li class="inline-flex items-center">
<%= link_to expenses_path, class: "inline-flex items-center text-sm font-medium text-gray-700 hover:text-blue-600" do %>
<svg class="w-4 h-4 mr-2" fill="currentColor" viewBox="0 0 20 20">
<path d="M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z"/>
</svg>
Expenses
<% end %>
</li>
<li>
<div class="flex items-center">
<svg class="w-6 h-6 text-gray-400" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd"/>
</svg>
<span class="ml-1 text-sm font-medium text-gray-500 md:ml-2">New expense</span>
</div>
</li>
</ol>
</nav>
</div>
<div class="mb-8">
<h1 class="text-3xl font-bold text-gray-900">New expense</h1>
<p class="mt-2 text-sm text-gray-600">Add a new recurring expense to track your spending.</p>
</div>
<%= render "form", expense: @expense %>
<%= link_to 'Back to expenses', expenses_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
</div>

View file

@ -1,15 +1,60 @@
<div class="mx-auto md:w-2/3 w-full flex">
<div class="mx-auto">
<% if notice.present? %>
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
<% end %>
<%= render @expense %>
<%= link_to 'Edit this expense', edit_expense_path(@expense), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
<div class="inline-block ml-2">
<%= button_to 'Destroy this expense', expense_path(@expense), method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>
<div class="mx-auto max-w-4xl 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>
<%= link_to 'Back to expenses', expenses_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
<% end %>
<div class="mb-6">
<nav class="flex" aria-label="Breadcrumb">
<ol class="inline-flex items-center space-x-1 md:space-x-3">
<li class="inline-flex items-center">
<%= link_to expenses_path, class: "inline-flex items-center text-sm font-medium text-gray-700 hover:text-blue-600" do %>
<svg class="w-4 h-4 mr-2" fill="currentColor" viewBox="0 0 20 20">
<path d="M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z"/>
</svg>
Expenses
<% end %>
</li>
<li>
<div class="flex items-center">
<svg class="w-6 h-6 text-gray-400" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd"/>
</svg>
<span class="ml-1 text-sm font-medium text-gray-500 md:ml-2"><%= @expense.description %></span>
</div>
</li>
</ol>
</nav>
</div>
<%= render @expense %>
<div class="mt-8 flex flex-wrap gap-3">
<%= link_to edit_expense_path(@expense), class: "inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" do %>
<svg class="w-4 h-4 mr-2" 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>
Edit expense
<% end %>
<%= button_to expense_path(@expense), method: :delete, form: { data: { turbo_confirm: "Are you sure you want to delete this expense?" } }, class: "inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500" do %>
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
</svg>
Delete expense
<% end %>
<%= link_to expenses_path, class: "inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500" do %>
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"/>
</svg>
Back to expenses
<% end %>
</div>
</div>