diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 16f17183..835edb8b 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -1,10 +1,6 @@ class AccountsController < ApplicationController before_action :authenticate_user! - def index - @accounts = current_family.accounts - end - def new end @@ -12,6 +8,10 @@ class AccountsController < ApplicationController @account = Depository.new end + def new_credit + @account = Credit.new + end + def show end @@ -20,7 +20,7 @@ class AccountsController < ApplicationController @account.family = current_family if @account.save - redirect_to accounts_path + redirect_to root_path else render :new end diff --git a/app/models/credit.rb b/app/models/credit.rb new file mode 100644 index 00000000..069f76fe --- /dev/null +++ b/app/models/credit.rb @@ -0,0 +1,2 @@ +class Credit < Account +end diff --git a/app/views/accounts/index.html.erb b/app/views/accounts/index.html.erb deleted file mode 100644 index 8eda0d01..00000000 --- a/app/views/accounts/index.html.erb +++ /dev/null @@ -1,14 +0,0 @@ - -

Cash

-

<%#= number_to_currency current_family.cash_balance %>

- -<% current_family.accounts.depository.each do |account| %> -
-
- <%= account.name %> -
-

- <%= number_to_currency account.balance %> -

-
- <% end %> \ No newline at end of file diff --git a/app/views/accounts/new.html.erb b/app/views/accounts/new.html.erb index 7056e431..928767b8 100644 --- a/app/views/accounts/new.html.erb +++ b/app/views/accounts/new.html.erb @@ -11,6 +11,16 @@ <% end %> +
+ <%= link_to new_credit_path, class: "flex flex-col items-center justify-center w-full text-center focus:outline-none" do %> + + + <%= inline_svg_tag('icon-credit-card.svg', class: 'text-[#189FC7] stroke-current') %> + + Credit cards + <% end %> +
+
<%= link_to "new_investment_path", class: "flex flex-col items-center justify-center w-full text-center focus:outline-none" do %> @@ -21,16 +31,6 @@ <% end %>
-
- <%= link_to "new_credit_path", class: "flex flex-col items-center justify-center w-full text-center focus:outline-none" do %> - - - <%= inline_svg_tag('icon-credit-card.svg', class: 'text-[#189FC7] stroke-current') %> - - Credit cards - <% end %> -
-
<%= link_to "new_real_estate_path", class: "flex flex-col items-center justify-center w-full text-center focus:outline-none" do %> diff --git a/app/views/accounts/new_credit.html.erb b/app/views/accounts/new_credit.html.erb new file mode 100644 index 00000000..889243c1 --- /dev/null +++ b/app/views/accounts/new_credit.html.erb @@ -0,0 +1,37 @@ +
+ <%= link_to new_account_path, class: "" do %> + <%= inline_svg_tag('icon-arrow-left.svg', class: 'text-gray-500 fill-current') %> + <% end %> +

Enter credit card account

+
+ +<%= form_with model: @account, url: accounts_path, scope: :account, html: { class: "space-y-4" } do |f| %> + <%= f.hidden_field :type, value: "Credit" %> + +
+ <%# Optional %> + + <%= f.text_field :name, placeholder: "Account name", required: 'required', class: "p-0 mt-1 bg-transparent border-none opacity-50 focus:outline-none focus:ring-0 focus-within:opacity-100" %> +
+ +
+ Optional + +
+ <%= f.number_field :credit_limit, placeholder: "$0.00", in: 0.00..100000000.00, class: "p-0 mt-1 bg-transparent border-none opacity-50 focus:outline-none focus:ring-0 focus-within:opacity-100" %> +
+
+ +
+ +
+ <%= f.number_field :balance, placeholder: "$0.00", in: 0.00..100000000.00, required: 'required', class: "p-0 mt-1 bg-transparent border-none opacity-50 focus:outline-none focus:ring-0 focus-within:opacity-100" %> +
+
+ +
+ +
+<% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 3edbdf2a..f46a9718 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,6 +10,10 @@ Rails.application.routes.draw do scope "bank" do get "", to: "accounts#new_bank", as: "new_bank" end + + scope "credit" do + get "", to: "accounts#new_credit", as: "new_credit" + end end # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.