1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 15:49:39 +02:00
Maybe/app/views/accounts/new.html.erb
2024-02-03 02:50:10 +00:00

39 lines
2.3 KiB
Text

<h1 class="text-3xl font-semibold font-display">Add an account</h1>
<% if params[:type].blank? || Account.accountable_types.include?("Account::#{params[:type]}") == false %>
<div class="grid grid-cols-2 gap-4 mt-8 text-sm sm:grid-cols-3 md:grid-cols-4">
<%= render partial: "account_type", collection: Account.accountable_type_instances %>
</div>
<% else %>
<div class="relative flex items-center mb-5 space-x-2">
<%= link_to new_account_path, class: "" do %>
<%= inline_svg_tag('icon-arrow-left.svg', class: 'text-gray-500 fill-current') %>
<% end %>
<h2 class="text-2xl font-semibold font-display">Enter <%= params[:type] %> account</h2>
</div>
<%= form_with model: @account, url: accounts_path, scope: :account, html: { class: "space-y-4" } do |f| %>
<%= f.hidden_field :accountable_type %>
<div class="relative p-4 border border-gray-100 bg-offwhite rounded-xl focus-within:bg-white focus-within:shadow focus-within:opacity-100">
<%# <span class="absolute px-2 py-1 text-xs font-medium text-gray-400 uppercase bg-gray-200 rounded-full opacity-50 right-3">Optional</span> %>
<label for="account_name" class="block text-sm font-medium opacity-50 focus-within:opacity-100">Name</label>
<%= 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" %>
</div>
<%= render "accounts/#{permitted_accountable_partial(@account.accountable_type)}", f: f %>
<div class="relative p-4 border border-gray-100 bg-offwhite rounded-xl focus-within:bg-white focus-within:shadow focus-within:opacity-100">
<label for="account_name" class="block text-sm font-medium opacity-50 focus-within:opacity-100">Balance</label>
<div class="flex">
<%= 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" %>
</div>
</div>
<div class="absolute right-5 bottom-5">
<button type="submit" class="flex items-center justify-center w-12 h-12 mb-2 bg-black rounded-full shrink-0 grow-0 hover:bg-gray-600">
<i class="text-xl text-white fa-regular fa-check"></i>
</button>
</div>
<% end %>
<% end %>