diff --git a/app/models/account.rb b/app/models/account.rb index 63bfe8d3..f42ef47b 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -3,12 +3,5 @@ class Account < ApplicationRecord delegated_type :accountable, types: %w[ Account::Credit Account::Depository Account::Investment Account::Loan Account::OtherAsset Account::OtherLiability Account::Property Account::Vehicle], dependent: :destroy - delegate :icon, :type_name, :color, to: :accountable - - # Class method to get a representative instance of each accountable type - def self.accountable_type_instances - accountable_types.map do |type| - type.constantize.new - end - end + delegate :type_name, to: :accountable end diff --git a/app/models/account/credit.rb b/app/models/account/credit.rb index 8dbdc745..fc3733ec 100644 --- a/app/models/account/credit.rb +++ b/app/models/account/credit.rb @@ -1,18 +1,7 @@ class Account::Credit < ApplicationRecord include Accountable - def icon - "icon-credit-card.svg" - end - def type_name "Credit Card" end - - def color - { - background: "bg-[#E6F6FA]", - text: "text-[#189FC7]" - } - end end diff --git a/app/models/account/depository.rb b/app/models/account/depository.rb index 5f4c9fd6..d40e58d3 100644 --- a/app/models/account/depository.rb +++ b/app/models/account/depository.rb @@ -1,18 +1,7 @@ class Account::Depository < ApplicationRecord include Accountable - def icon - "icon-bank-accounts.svg" - end - def type_name "Bank Accounts" end - - def color - { - background: "bg-[#EAF4FF]", - text: "text-[#3492FB]" - } - end end diff --git a/app/models/account/investment.rb b/app/models/account/investment.rb index ae3da945..32029c3a 100644 --- a/app/models/account/investment.rb +++ b/app/models/account/investment.rb @@ -1,18 +1,7 @@ class Account::Investment < ApplicationRecord include Accountable - def icon - "icon-bank-accounts.svg" - end - def type_name "Investments" end - - def color - { - background: "bg-[#EDF7F4]", - text: "text-[#1BD5A1]" - } - end end diff --git a/app/models/account/loan.rb b/app/models/account/loan.rb index ba8cd645..51b1d1ea 100644 --- a/app/models/account/loan.rb +++ b/app/models/account/loan.rb @@ -1,18 +1,7 @@ class Account::Loan < ApplicationRecord include Accountable - def icon - "icon-bank-accounts.svg" - end - def type_name "Loan" end - - def color - { - background: "bg-[#EDF7F4]", - text: "text-[#1BD5A1]" - } - end end diff --git a/app/models/account/other_asset.rb b/app/models/account/other_asset.rb index e00c9f51..768ede91 100644 --- a/app/models/account/other_asset.rb +++ b/app/models/account/other_asset.rb @@ -1,18 +1,7 @@ class Account::OtherAsset < ApplicationRecord include Accountable - def icon - "icon-bank-accounts.svg" - end - def type_name "Other Asset" end - - def color - { - background: "bg-[#EDF7F4]", - text: "text-[#1BD5A1]" - } - end end diff --git a/app/models/account/other_liability.rb b/app/models/account/other_liability.rb index c9c51ead..d4e0958b 100644 --- a/app/models/account/other_liability.rb +++ b/app/models/account/other_liability.rb @@ -1,18 +1,7 @@ class Account::OtherLiability < ApplicationRecord include Accountable - def icon - "icon-bank-accounts.svg" - end - def type_name "Other Liability" end - - def color - { - background: "bg-[#EDF7F4]", - text: "text-[#1BD5A1]" - } - end end diff --git a/app/models/account/property.rb b/app/models/account/property.rb index 105ac600..dfd19af0 100644 --- a/app/models/account/property.rb +++ b/app/models/account/property.rb @@ -1,18 +1,7 @@ class Account::Property < ApplicationRecord include Accountable - def icon - "icon-real-estate.svg" - end - def type_name "Real Estate" end - - def color - { - background: "bg-[#FEF0F7]", - text: "text-[#F03695]" - } - end end diff --git a/app/models/account/vehicle.rb b/app/models/account/vehicle.rb index 6a43f4a6..174f95d3 100644 --- a/app/models/account/vehicle.rb +++ b/app/models/account/vehicle.rb @@ -1,18 +1,7 @@ class Account::Vehicle < ApplicationRecord include Accountable - def icon - "icon-bank-accounts.svg" - end - def type_name "Vehicle" end - - def color - { - background: "bg-[#EDF7F4]", - text: "text-[#1BD5A1]" - } - end end diff --git a/app/views/accounts/_account_type.html.erb b/app/views/accounts/_account_type.html.erb index 6d654ce9..2c9ea3d8 100644 --- a/app/views/accounts/_account_type.html.erb +++ b/app/views/accounts/_account_type.html.erb @@ -1,9 +1,9 @@
- <%= link_to new_account_path(type: account_type.class.name.demodulize), class: "flex flex-col items-center justify-center w-full text-center focus:outline-none" do %> + <%= link_to new_account_path(type: type.class.name.demodulize), class: "flex flex-col items-center justify-center w-full text-center focus:outline-none" do %> - - <%= inline_svg_tag(account_type.icon, class: "#{account_type.color[:text]} stroke-current") %> + + <%= inline_svg_tag(icon, class: "#{text_color} stroke-current") %> - <%= account_type.type_name %> + <%= type.type_name %> <% end %>
diff --git a/app/views/accounts/new.html.erb b/app/views/accounts/new.html.erb index a222244b..3560e4f9 100644 --- a/app/views/accounts/new.html.erb +++ b/app/views/accounts/new.html.erb @@ -2,7 +2,14 @@ <% if params[:type].blank? || Account.accountable_types.include?("Account::#{params[:type]}") == false %>
- <%= render partial: "account_type", collection: Account.accountable_type_instances %> + <%= render "account_type", type: Account::Credit.new, bg_color: "bg-[#E6F6FA]", text_color: "text-[#189FC7]", icon: "icon-credit-card.svg" %> + <%= render "account_type", type: Account::Depository.new, bg_color: "bg-[#EAF4FF]", text_color: "text-[#3492FB]", icon: "icon-bank-accounts.svg" %> + <%= render "account_type", type: Account::Investment.new, bg_color: "bg-[#EDF7F4]", text_color: "text-[#1BD5A1]", icon: "icon-bank-accounts.svg" %> + <%= render "account_type", type: Account::Loan.new, bg_color: "bg-[#EDF7F4]", text_color: "text-[#1BD5A1]", icon: "icon-bank-accounts.svg" %> + <%= render "account_type", type: Account::OtherAsset.new, bg_color: "bg-[#EDF7F4]", text_color: "text-[#1BD5A1]", icon: "icon-bank-accounts.svg" %> + <%= render "account_type", type: Account::OtherLiability.new, bg_color: "bg-[#EDF7F4]", text_color: "text-[#1BD5A1]", icon: "icon-bank-accounts.svg" %> + <%= render "account_type", type: Account::Property.new, bg_color: "bg-[#FEF0F7]", text_color: "text-[#F03695]", icon: "icon-real-estate.svg" %> + <%= render "account_type", type: Account::Vehicle.new, bg_color: "bg-[#EDF7F4]", text_color: "text-[#1BD5A1]", icon: "icon-bank-accounts.svg" %>
<% else %>
diff --git a/config/tailwind.config.js b/config/tailwind.config.js index 5618c738..4850d1b4 100644 --- a/config/tailwind.config.js +++ b/config/tailwind.config.js @@ -4,7 +4,6 @@ module.exports = { content: [ './public/*.html', './app/helpers/**/*.rb', - './app/models/**/*.rb', './app/javascript/**/*.js', './app/views/**/*.{erb,haml,html,slim}' ],