1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-09 15:35:22 +02:00

Add nice formatting for subtypes on account list

This commit is contained in:
hatz 2025-04-21 10:46:50 -05:00
parent a7dfafc907
commit d1eef076f0
No known key found for this signature in database
2 changed files with 23 additions and 1 deletions

View file

@ -3,4 +3,26 @@ module AccountsHelper
content = capture(&block)
render "accounts/summary_card", title: title, content: content
end
# Format account subtype to be more friendly
def format_account_subtype(subtype)
return nil if subtype.nil?
# Mapping of special cases
special_cases = {
"ira" => "IRA",
"401k" => "401(k)",
"hsa" => "HSA",
}
# Convert to title case
subtype_string = subtype.titleize
special_cases.each do |key, value|
# Use word boundaries to ensure we're replacing whole words
subtype_string = subtype_string.gsub(/\b#{key}\b/i, value)
end
subtype_string
end
end

View file

@ -24,7 +24,7 @@
<div class="min-w-0 grow">
<%= tag.p account.name, class: "text-sm text-primary font-medium mb-0.5 truncate" %>
<%= tag.p account.subtype&.humanize.presence || account_group.name, class: "text-sm text-secondary truncate" %>
<%= tag.p format_account_subtype(account.subtype).presence || account_group.name, class: "text-sm text-secondary truncate" %>
</div>
<div class="ml-auto text-right grow h-10">