mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 15:49:39 +02:00
Consolidate and simplify account pages (#2462)
* Remove ScrollFocusable * Consolidate and simplify account pages * Lint fixes * Fix tab param initialization * Remove stale files * Remove stale route, make accountable routes clearer
This commit is contained in:
parent
3eea5a9891
commit
8c97c9d31a
41 changed files with 252 additions and 269 deletions
45
app/components/UI/account_page.rb
Normal file
45
app/components/UI/account_page.rb
Normal file
|
@ -0,0 +1,45 @@
|
|||
class UI::AccountPage < ApplicationComponent
|
||||
attr_reader :account, :chart_view, :chart_period
|
||||
|
||||
def initialize(account:, chart_view: nil, chart_period: nil, active_tab: nil)
|
||||
@account = account
|
||||
@chart_view = chart_view
|
||||
@chart_period = chart_period
|
||||
@active_tab = active_tab
|
||||
end
|
||||
|
||||
def title
|
||||
account.name
|
||||
end
|
||||
|
||||
def subtitle
|
||||
return nil unless account.property?
|
||||
|
||||
account.property.address
|
||||
end
|
||||
|
||||
def active_tab
|
||||
tabs.find { |tab| tab == @active_tab&.to_sym } || tabs.first
|
||||
end
|
||||
|
||||
def tabs
|
||||
case account.accountable_type
|
||||
when "Investment"
|
||||
[ :activity, :holdings ]
|
||||
when "Property", "Vehicle", "Loan"
|
||||
[ :activity, :overview ]
|
||||
else
|
||||
[ :activity ]
|
||||
end
|
||||
end
|
||||
|
||||
def tab_partial_name(tab)
|
||||
case tab
|
||||
when :activity
|
||||
"accounts/show/activity"
|
||||
when :holdings, :overview
|
||||
# Accountable is responsible for implementing the partial in the correct folder
|
||||
"#{account.accountable_type.downcase.pluralize}/tabs/#{tab}"
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue