1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-03 04:25:21 +02:00

Fix accountable type references in new account flow (#395)

* Fix accountable type references in new account flow

* Add remaining references

* Refactor accountable type checking

* Refactor new account template to use account

* Refactor account create action

* Refactor account sidebar
This commit is contained in:
Josh Brown 2024-02-09 14:26:54 +00:00 committed by GitHub
parent 80f68b657c
commit f8174990ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 27 additions and 29 deletions

View file

@ -1,7 +1,7 @@
<h1 class="text-3xl font-semibold font-display"><%= t('.title')%></h1>
<%= modal do %>
<% if params[:type].blank? || Account.accountable_types.include?("Account::#{params[:type]}") == false %>
<% if @account.accountable.blank? %>
<div class="border-b border-[#141414]/2 p-4 text-gray-400">
<%= t '.select_accountable_type' %>
</div>
@ -31,7 +31,7 @@
<span>Close</span> <kbd class="bg-[#141414]/5 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.1)] p-1 rounded-md flex w-8 h-5 shrink-0 grow-0 items-center justify-center text-xs">ESC</kbd>
</div>
</div>
<% elsif params[:step] == 'method' && params[:type].present? %>
<% elsif params[:step] == 'method' && @account.accountable.present? %>
<div class="border-b border-[#141414]/2 p-4 text-gray-400 flex items-center space-x-3">
<%= link_to new_account_path, class: "flex w-8 h-8 shrink-0 grow-0 items-center justify-center rounded-lg bg-[#141414]/5" do %>
<%= lucide_icon('arrow-left', class: 'text-gray-500 w-5 h-5') %>
@ -42,9 +42,9 @@
<button hidden data-controller="hotkey" data-hotkey="k,K,ArrowUp,ArrowLeft" data-action="list-keyboard-navigation#focusPrevious">Previous</button>
<button hidden data-controller="hotkey" data-hotkey="j,J,ArrowDown,ArrowRight" data-action="list-keyboard-navigation#focusNext">Next</button>
<%= render "entry_method", type: Account::Depository.new, text: 'Enter account balance manually', icon: "keyboard" %>
<%= render "entry_method", type: Account::Depository.new, text: 'Securely link bank account with data provider (coming soon)', icon: "link-2", disabled: true %>
<%= render "entry_method", type: Account::Depository.new, text: 'Upload spreadsheet (coming soon)', icon: "sheet", disabled: true %>
<%= render "entry_method", type: @account.accountable, text: 'Enter account balance manually', icon: "keyboard" %>
<%= render "entry_method", type: @account.accountable, text: 'Securely link bank account with data provider (coming soon)', icon: "link-2", disabled: true %>
<%= render "entry_method", type: @account.accountable, text: 'Upload spreadsheet (coming soon)', icon: "sheet", disabled: true %>
</div>
<div class="border-t border-[#141414]/2 p-4 text-gray-500 text-sm flex justify-between">
<div class="flex space-x-5">
@ -64,7 +64,7 @@
<%= link_to new_account_path(step: 'method', type: params[:type]), class: "flex w-8 h-8 shrink-0 grow-0 items-center justify-center rounded-lg bg-[#141414]/5" do %>
<%= lucide_icon('arrow-left', class: 'text-gray-500 w-5 h-5') %>
<% end %>
<span>Add account</span>
<span>Add <%= @account.accountable.model_name.human.downcase %></span>
</div>
<%= form_with model: @account, url: accounts_path, scope: :account, html: { class: "space-y-4 m-5 mt-1", data: { turbo: false } } do |f| %>
@ -86,7 +86,7 @@
<div class="">
<button type="submit" class="w-full p-3 text-center text-white bg-black rounded-lg hover:bg-gray-700" title="Submit">
Add account
Add <%= @account.accountable.model_name.human.downcase %>
</button>
</div>
<% end %>