Refactor admin donation pages, fix errors
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Not sending the right response codes for Turbo to handle.
This commit is contained in:
parent
95fac38b53
commit
f050d010fd
@ -10,6 +10,10 @@
|
||||
@apply inline-block;
|
||||
}
|
||||
|
||||
.field_with_errors input {
|
||||
@apply w-full bg-red-100;
|
||||
}
|
||||
|
||||
.error-msg {
|
||||
@apply text-red-700;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class Admin::DonationsController < Admin::BaseController
|
||||
end
|
||||
format.json { render :show, status: :created, location: @donation }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.html { render :new, status: :unprocessable_entity }
|
||||
format.json { render json: @donation.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
@ -59,7 +59,7 @@ class Admin::DonationsController < Admin::BaseController
|
||||
end
|
||||
format.json { render :show, status: :ok, location: @donation }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.html { render :edit, status: :unprocessable_entity }
|
||||
format.json { render json: @donation.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
|
@ -3,7 +3,9 @@ class Donation < ApplicationRecord
|
||||
belongs_to :user
|
||||
|
||||
# Validations
|
||||
validates_presence_of :user
|
||||
validates_presence_of :amount_sats
|
||||
validates_presence_of :paid_at
|
||||
|
||||
# Hooks
|
||||
# TODO before_create :store_fiat_value
|
||||
|
@ -1,16 +1,16 @@
|
||||
<%= form_with(url: url, model: donation, local: true) do |form| %>
|
||||
<% if donation.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<section id="error_explanation">
|
||||
<h3><%= pluralize(donation.errors.count, "error") %> prohibited this donation from being saved:</h3>
|
||||
<ul>
|
||||
<ul class="list-disc list-inside">
|
||||
<% donation.errors.full_messages.each do |message| %>
|
||||
<li><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
<% end %>
|
||||
|
||||
<div class="sm:w-1/2 grid grid-cols-2 items-center gap-y-2">
|
||||
<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: "kosmos.org").order(:cn), :id, :cn, {} %>
|
||||
|
||||
@ -28,9 +28,14 @@
|
||||
|
||||
<%= form.label :paid_at %>
|
||||
<%= form.text_field :paid_at %>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<p class="mt-8">
|
||||
<%= form.submit class: 'btn-md btn-blue' %>
|
||||
<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 %>
|
||||
|
@ -2,8 +2,4 @@
|
||||
|
||||
<%= render MainSimpleComponent.new do %>
|
||||
<%= render 'form', donation: @donation, url: admin_donation_path(@donation) %>
|
||||
|
||||
<p class="mt-8">
|
||||
<%= link_to 'Cancel', admin_donation_path(@donation), class: 'btn-sm btn-gray' %>
|
||||
<p>
|
||||
<% end %>
|
||||
|
@ -2,8 +2,4 @@
|
||||
|
||||
<%= render MainSimpleComponent.new do %>
|
||||
<%= render 'form', donation: @donation, url: admin_donations_path %>
|
||||
|
||||
<p class="mt-8">
|
||||
<%= link_to 'Back', admin_donations_path, class: 'ks-text-link' %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
@ -33,9 +33,9 @@
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<p>
|
||||
<%= link_to 'Edit', edit_admin_donation_path(@donation), class: 'btn-md btn-blue mr-1' %>
|
||||
<p class="pt-6 border-t border-gray-200 text-right">
|
||||
<%= link_to 'Back', admin_donations_path, class: 'btn-md btn-gray' %>
|
||||
<%= link_to 'Edit', edit_admin_donation_path(@donation), class: 'ml-2 btn-md btn-blue mr-1' %>
|
||||
</p>
|
||||
</section>
|
||||
<% end %>
|
||||
|
Loading…
x
Reference in New Issue
Block a user