mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-07 22:45:20 +02:00
Fix: Filter categories by transaction type in forms (#2082)
Changed transaction form to only display relevant categories based on transaction type (income or expense), improving usability and preventing misclassification. Created a shared transaction type tabs component for consistent navigation between expense, income, and transfer forms, providing a better user experience and reducing code duplication. Signed-off-by: Zach Gollwitzer <zach@maybe.co> Co-authored-by: Zach Gollwitzer <zach@maybe.co>
This commit is contained in:
parent
ce83418f0b
commit
71bc51ca15
10 changed files with 74 additions and 67 deletions
24
app/views/shared/_transaction_type_tabs.html.erb
Normal file
24
app/views/shared/_transaction_type_tabs.html.erb
Normal file
|
@ -0,0 +1,24 @@
|
|||
<fieldset class="bg-gray-50 rounded-lg p-1 grid grid-flow-col justify-stretch gap-x-2">
|
||||
<% active_tab = local_assigns[:active_tab] || 'expense' %>
|
||||
|
||||
<%= link_to new_transaction_path(nature: 'outflow'),
|
||||
data: { turbo_frame: :modal },
|
||||
class: "flex px-4 py-1 rounded-lg items-center space-x-2 justify-center text-sm md:text-normal text-subdued #{active_tab == 'expense' ? 'bg-container text-gray-800 shadow-sm' : 'hover:bg-container hover:text-gray-800 hover:shadow-sm'}" do %>
|
||||
<%= lucide_icon "minus-circle", class: "w-4 h-4 md:w-5 md:h-5" %>
|
||||
<%= tag.span t("shared.transaction_tabs.expense") %>
|
||||
<% end %>
|
||||
|
||||
<%= link_to new_transaction_path(nature: 'inflow'),
|
||||
data: { turbo_frame: :modal },
|
||||
class: "flex px-4 py-1 rounded-lg items-center space-x-2 justify-center text-sm md:text-normal text-subdued #{active_tab == 'income' ? 'bg-container text-gray-800 shadow-sm' : 'hover:bg-container hover:text-gray-800 hover:shadow-sm'}" do %>
|
||||
<%= lucide_icon "plus-circle", class: "w-4 h-4 md:w-5 md:h-5" %>
|
||||
<%= tag.span t("shared.transaction_tabs.income") %>
|
||||
<% end %>
|
||||
|
||||
<%= link_to new_transfer_path,
|
||||
data: { turbo_frame: :modal },
|
||||
class: "flex px-4 py-1 rounded-lg items-center space-x-2 justify-center text-sm md:text-normal text-subdued #{active_tab == 'transfer' ? 'bg-container text-gray-800 shadow-sm' : 'hover:bg-container hover:text-gray-800 hover:shadow-sm'}" do %>
|
||||
<%= lucide_icon "arrow-right-left", class: "w-4 h-4 md:w-5 md:h-5" %>
|
||||
<%= tag.span t("shared.transaction_tabs.transfer") %>
|
||||
<% end %>
|
||||
</fieldset>
|
Loading…
Add table
Add a link
Reference in a new issue