akkounts/app/views/admin/donations/_form.html.erb

52 lines
1.8 KiB
Plaintext

<%= form_with(url: url, model: donation, local: true) do |form| %>
<% if donation.errors.any? %>
<section id="error_explanation">
<h3><%= pluralize(donation.errors.count, "error") %> prohibited this donation from being saved:</h3>
<ul class="list-disc list-inside">
<% donation.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</section>
<% end %>
<section class="sm:w-1/2 grid grid-cols-2 items-center gap-y-2">
<%= form.label :user_id %>
<%= form.collection_select :user_id, User.where(ou: Setting.primary_domain).order(:cn), :id, :cn, {} %>
<%= form.label :donation_method, "Donation method" %>
<%= form.select :donation_method, options_for_select([
["Custom (manual)", "custom"],
["BTCPay", "btcpay"],
["LndHub account", "lndhub"],
["OpenCollective", "opencollective"]
], selected: (donation.donation_method || "custom")) %>
<%= form.label :amount_sats, "Amount BTC (sats)" %>
<%= form.number_field :amount_sats %>
<%= form.label :fiat_amount, "Fiat Amount (cents)" %>
<%= form.number_field :fiat_amount %>
<%= form.label :fiat_currency, "Fiat Currency" %>
<%= form.select :fiat_currency, options_for_select([
["EUR", "EUR"], ["USD", "USD"], ["sats", "sats"]
], selected: donation.fiat_currency) %>
<%= form.label :public_name %>
<%= form.text_field :public_name %>
<%= form.label :paid_at %>
<%= form.text_field :paid_at %>
</section>
<section>
<p class="pt-6 border-t border-gray-200 text-right">
<%= link_to 'Cancel',
@donation.id.present? ? admin_donation_path(@donation) : admin_donations_path,
class: 'btn-md btn-gray' %>
<%= form.submit class: 'ml-2 btn-md btn-blue' %>
</p>
</section>
<% end %>