Skip to content

Commit

Permalink
fixed issues from feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Hasjanov authored and Oleg Hasjanov committed Mar 1, 2024
1 parent d4d35d6 commit 1a61c48
Show file tree
Hide file tree
Showing 51 changed files with 339 additions and 190 deletions.
1 change: 0 additions & 1 deletion app/components/common/footer/component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
</span>
</div>
<div style="line-height: 23px;"><span style="color: rgb(255, 255, 255);"><b></b>
<span style="font-size: 15px;"><a href="#" target="_self">.</a></span>
<span style="font-size: 13px;"><a href="https://internet.ee/domains/ee-domain-regulation" target="_self"><%= t('common.footer.domain_regulation')%></a></span>
<span style="font-size: 15px;"><br></span>
<span style="font-size: 13px;"><a href="https://internet.ee/help-and-info/faq" target="_self"><%= t('common.footer.faq')%></a> </span>
Expand Down
8 changes: 4 additions & 4 deletions app/components/common/header/component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="c-toolbar__nav">
<ul class="s-toolbar-nav">
<li>
<a href="https://internet.ee"><%= t('common.open_portal') %></a>
<a href="https://internet.ee"><%= t('common.header.open_portal') %></a>
<span class="o-arrow js-submenu-toggle"></span>
<ul class="submenu">
<li>
Expand All @@ -37,13 +37,13 @@
</ul>
</li>
<li>
<a href="https://www.internet.ee/registrar-portal"><%= t('common.registrar_portal') %></a>
<a href="https://www.internet.ee/registrar-portal"><%= t('common.header.registrar_portal') %></a>
</li>
<li>
<a href="https://registrant.internet.ee"><%= t('common.registrant_portal') %></a>
<a href="https://registrant.internet.ee"><%= t('common.header.registrant_portal') %></a>
</li>
<li>
<a href="#">eeIDc-hero</a>
<a href="#">eeID</a>
</li>
</ul>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/components/common/header/component_deprecated.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="c-toolbar__nav">
<ul class="s-toolbar-nav">
<li>
<a href="https://internet.ee"><%= t('common.open_portal') %></a>
<a href="https://internet.ee"><%= t('common.header.open_portal') %></a>
</li>

<li class="is-active" data-controller='navbar--expandable'>
Expand All @@ -32,7 +32,7 @@
<a href="https://registrant.internet.ee"><%= t('common.registrant_portal') %></a>
</li>
<li>
<a href="#">eeIDc-hero</a>
<a href="#">eeID</a>
</li>
</ul>
</div>
Expand Down
103 changes: 9 additions & 94 deletions app/components/modals/pay_invoice/component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,102 +23,17 @@
</div>
</div>

<div class="c-modal__main">
<div class="c-modal__grid u-align-start u-flex-wrap">
<div class="c-modal__col">
<%= turbo_frame_tag "invoice_information" do %>
<%= render partial: 'invoices/invoice_information', locals: { invoice: @invoice } %>
<% end %>

<%= form_with model: @invoice, url: invoice_path(@invoice.uuid), data: { controller: 'form--debounce', action: 'change->form--debounce#search', form__debounce_target: 'form' } do |f| %>
<%= component 'common/form/label', form: f, attribute: :billing_profile_id, title: t('billing_profiles_name') %>
<%= component 'common/form/dropdown_input', form: f, attribute: :billing_profile_id,
enum: options_for_select(BillingProfile.where(user_id: invoice.user_id).pluck(:name, :id), current_billing_profile),
first_options: { include_blank: false } %>
<% end %>
</div>
<div class="c-modal__col">
<label class="c-modal__text-title"><%= t('invoices.issuer') %></label>
<span class="c-modal__text"><%= invoice_issuer%></span>
</div>
</div>
<div class="c-modal__grid u-flex-wrap u-mt-24">
<div class="c-modal__col">
<label class="c-modal__text-title"><%= t('invoices.issued_for') %></label>
<span class="c-modal__text"><%= issuer_for %></span>
</div>
<div class="c-modal__col">
<label class="c-modal__text-title"><%= t('invoices.address') %></label>
<span class="c-modal__text"><%= invoice_issuer_address %></span>
<div class="c-modal__extrainfo u-flex u-align-start u-mt-32">
<div class="c-modal__extrainfo-col">
<label class="c-modal__text-title"><%= t('reg_no') %></label>
<span class="c-modal__text"><%= invoice_issuer_reg_no %></span>
</div>
<div class="c-modal__extrainfo-col">
<label class="c-modal__text-title">VAT nr</label>
<span class="c-modal__text"><%= invoice_issuer_vat_number %></span>
</div>
</div>
</div>
</div>
<!-- Table -->
<div class="c-table--responsive u-flex-wrap u-mt-40">
<% header_collection = [{ column: nil, caption: '#', options: { class: "" } },
{ column: nil, caption: t('invoices.item'), options: { class: "" } },
{ column: nil, caption: nil, options: { class: "" } },
{ column: nil, caption: t('invoices.price'), options: { class: "" } },
] %>
<%= component 'common/table', header_collection:, options: { class: '' } do %>
<tbody>
<% @invoice.items.each_with_index do |item, index| %>
<tr>
<td><%= index + 1 %></td>
<td>
<%= I18n.t('invoice_items.name',
domain_name: item.invoice.result.auction.domain_name,
auction_end: item.invoice.result.auction.ends_at.to_date) %>
</td>
<td></td>
<td><%= item.price %></td>
</tr>
<% end %>
</tbody>
<tfoot>
<tr>
<td scope="col"></td>
<td scope="col"><%= t('invoices.vat_amount') %></td>
<td><%= number_to_percentage(@invoice.vat_rate * 100, precision: 0) %></td>
<td scope="col"><%= t('offers.price_in_currency', price: @invoice.vat) %></td>
</tr>
<tr>
<th scope="col"></th>
<th scope="col"><%= t('invoices.total') %></th>
<td></td>
<th scope="col"><%= t('offers.price_in_currency', price: @invoice.total + (@invoice.enable_deposit? ? @invoice.deposit : 0.0)) %>
</th>
</tr>
<% if @invoice.enable_deposit? %>
<tr style=''>
<td scope="col" style='font-weight: bold; background-color: #f0e68c; border-top-color: "#ccc";'></td>
<td scope="col" style='font-weight: bold; background-color: #f0e68c; border-top-color: "#ccc";'><%= t('invoices.deposit') %></td>
<td style='background-color: #f0e68c;'></td>
<td scope="col" style='font-weight: bold; background-color: #f0e68c; border-top-color: "#ccc";'><%= t('offers.price_in_currency', price: @invoice.deposit) %></td>
</tr>
<tr>
<td scope="col" style='font-weight: bold; background-color: #f0e68c;'></td>
<td scope="col" style='font-weight: bold; background-color: #f0e68c;'><%= t('invoices.amount_due') %></td>
<td style='background-color: #f0e68c;'></td>
<td scope="col" style='font-weight: bold; color: red; background-color: #f0e68c;'><%= t('offers.price_in_currency', price: @invoice.total) %></td>
</tr>
<% end %>
<% end %>
</div>
<!-- Table -->
</div>
<div class="c-modal__footer u-flex u-align-center u-content-sp">
<%= link_to t('invoices.download'), download_invoice_path(@invoice.uuid), { class: 'c-btn c-btn--ghost', download: true } %>
<%= button_to t('invoices.show.pay'), oneoff_invoice_path(uuid: @invoice.uuid), class: 'c-btn c-btn--green', data: {turbo: false} if @invoice.payable? %>
</div>
</div>

<div class="c-modal__footer u-flex u-align-center u-content-sp">
<%= link_to t('invoices.download'), download_invoice_path(@invoice.uuid), { class: 'c-btn c-btn--ghost', download: true } %>
<%= button_to t('invoices.show.pay'), oneoff_invoice_path(uuid: @invoice.uuid), class: 'c-btn c-btn--green', data: {turbo: false} if @invoice.payable? %>
</div>
</div>

</div>
</div>
</div>
14 changes: 14 additions & 0 deletions app/components/modals/pay_invoice/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ def invoice_issuer_reg_no
def invoice_issuer_vat_number
Setting.find_by(code: 'invoice_issuer_vat_number').retrieve
end

def billing_profile_dropdown_properties
{
attribute: :billing_profile_id,
enum: billing_profiles = BillingProfile.where(user_id: invoice.user_id).collect do |b|
[b.name, b.id, { 'data-vat-rate' => b.vat_rate }]
end,
first_options: {},
second_options: {
class: billing_profiles.size == 1 ? 'disabled' : '',
data: { action: 'change->invoice-autotax-counterr#updateTax', invoice_autotax_counter_target: 'dropdown'}
}
}
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ def issued_invoice_table_headers
[{ column: nil, caption: t('invoices.item'), options: { class: '' } },
{ column: nil, caption: t('invoices.due_date'), options: { class: '' } },
{ column: nil, caption: t('invoices.total'), options: { class: '' } },
{ column: nil, caption: 'Tegevused',
{ column: nil, caption: t('actions_name'),
options: { class: 'u-text-center-l' } }]
end

def overdue_invoice_table_headers
[{ column: nil, caption: t('invoices.item'), options: { class: '' } },
{ column: nil, caption: t('invoices.due_date'), options: { class: '' } },
{ column: nil, caption: t('invoices.total'), options: { class: '' } },
{ column: nil, caption: 'Tegevused',
{ column: nil, caption: t('actions_name'),
options: { class: 'u-text-center-l' } }]
end

def cancel_invoice_table_headers
[{ column: nil, caption: t('invoices.item'), options: { class: '' } },
{ column: nil, caption: t('invoices.due_date'), options: { class: '' } },
{ column: nil, caption: t('invoices.total'), options: { class: '' } },
{ column: nil, caption: 'Tegevused',
{ column: nil, caption: t('actions_name'),
options: { class: 'u-text-center-l' } }]
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/components/pages/invoices/paid_invoices/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def paid_invoices_headers
[{ column: nil, caption: t('invoices.item'), options: { class: '' } },
{ column: nil, caption: t('invoices.due_date'), options: { class: '' } },
{ column: nil, caption: t('invoices.total'), options: { class: '' } },
{ column: nil, caption: 'Tegevused', options: { class: 'u-text-center-l' } }]
{ column: nil, caption: t('actions_name'), options: { class: 'u-text-center-l' } }]
end

def deposit_paid_headers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!-- Table -->
<div class="o-container">
<div class="c-block" data-controller="auction-timezone" data-auction-timezone-end-time-value="<%= auction.ends_at.iso8601 %>">
<div class="c-block" data-controller="auction-timezone" data-auction-timezone-end-time-value="<%= @offer.auction.ends_at.iso8601 %>">
<h2 class="c-block__title u-h3"><%= t('offers.overview') %></h2>
<%= component 'common/table', header_collection: overview_table_headers, options: { class: 'table--black' } do %>
<%= tag.tbody do %>
<tr>
<td><strong><%= @offer.auction.domain_name %></strong></td>
<td><span data-auction-timezone-target="endtime"><%= auction.ends_at %></span></td>
<td><span data-auction-timezone-target="endtime"><%= @offer.auction.ends_at %></span></td>
<td><%= t('offers.price_in_currency', price: @offer.price) %></td>
<td><%= t('offers.price_in_currency', price: @offer.total) %></td>
</tr>
Expand Down
4 changes: 2 additions & 2 deletions app/components/pages/offers/offers_table/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def initialize(offers:)

def header_collection
[{ column: 'auctions.domain_name', caption: t('auctions.domain_name'), options: { class: 'sorting' } },
{ column: 'auctions.platform', caption: 'Tüüp', options: { class: 'sorting' } },
{ column: nil, caption: t('.your_last_offer'), options: { class: '' } },
{ column: 'auctions.platform', caption: t('auctions.type'), options: { class: 'sorting' } },
{ column: nil, caption: t('offers.show.your_last_offer'), options: { class: '' } },
{ column: nil, caption: t('offers.total'), options: { class: '' } },
{ column: 'auctions.ends_at', caption: t('auctions.ends_at'),
options: { class: 'sorting' } },
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/billing_profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def create
@billing_profile = BillingProfile.new(create_params)
authorize! :manage, @billing_profile

flash.clear

respond_to do |format|
if create_predicate
redirect_uri = "#{session[:return_to]}?billing_profile_id=#{@billing_profile.id}" || billing_profile_path(@billing_profile.uuid)
Expand All @@ -45,7 +47,7 @@ def create
format.html { redirect_to redirect_uri }
format.json { render :show, status: :created, location: @billing_profile }
else
flash[:alert] = @billing_profile.errors.full_messages.to_sentence
flash.now[:alert] = @billing_profile.errors.full_messages.to_sentence

format.turbo_stream do
render turbo_stream: [
Expand Down
6 changes: 2 additions & 4 deletions app/controllers/concerns/recaptcha_validatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module RecaptchaValidatable

included do
before_action :set_captcha_required
before_action :check_recaptcha, only: %i[create update]
before_action :check_recaptcha, only: %i[create update], unless: -> { Rails.env.development? || Rails.env.test? }
end

module ClassMethods
Expand All @@ -17,9 +17,7 @@ def recaptcha_action(action)
end

def set_captcha_required
# return if Rails.env.development?

@captcha_required = current_user.requires_captcha?
@captcha_required = Rails.env.development? ? false : current_user.requires_captcha?
@recaptcha2_site_key = AuctionCenter::Application.config.customization.dig(:recaptcha, :recaptcha2_site_key)
@recaptcha3_site_key = AuctionCenter::Application.config.customization.dig(:recaptcha, :recaptcha3_site_key)
end
Expand Down
35 changes: 27 additions & 8 deletions app/controllers/english_offers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ class EnglishOffersController < ApplicationController
# GET /auctions/aa450f1a-45e2-4f22-b2c3-f5f46b5f906b/offers/new
def new
offer = @auction.offer_from_user(current_user.id)
redirect_to edit_english_offer_path(offer.uuid) if offer

if turbo_frame_request?
render turbo_stream: turbo_stream.action(:redirect, root_path), notice: t('offers.already_exists') and return
else
redirect_to root_path, status: :see_other, notice: t('offers.already_exists') and return
end if offer

BillingProfile.create_default_for_user(current_user.id)
@offer = Offer.new(auction_id: @auction.id, user_id: current_user.id)
Expand All @@ -31,7 +36,12 @@ def create
unless check_first_bid_for_english_auction(create_params, @auction)
formatted_starting_price = format('%.2f', @auction.starting_price)
flash[:alert] = t('english_offers.create.bid_must_be', minimum: formatted_starting_price)
redirect_to new_auction_english_offer_path(auction_uuid: @auction.uuid) and return

if turbo_frame_request?
render turbo_stream: turbo_stream.action(:redirect, root_path)
else
redirect_to root_path, status: :see_other
end
end

@offer = Offer.new(create_params)
Expand Down Expand Up @@ -91,6 +101,7 @@ def update
redirect_to root_path
end
else

@show_checkbox_recaptcha = true unless @success
flash.now[:alert] = t('english_offers.form.captcha_verification')
redirect_to root_path, status: :see_other
Expand Down Expand Up @@ -126,7 +137,6 @@ def update_auction_values(auction, message_text)
auction.update_ends_at(@offer)

flash[:notice] = message_text
# redirect_to edit_english_offer_path(@offer.uuid)
redirect_to root_path
end

Expand All @@ -135,9 +145,13 @@ def prevent_check_for_invalid_bid

return unless bid_is_bad?(auction: auction, update_params: update_params)

flash[:alert] =
"#{t('english_offers.show.bid_failed', price: format('%.2f', auction.highest_price.to_f).tr('.', ','))}"
redirect_to edit_english_offer_path(auction.users_offer_uuid) and return
flash[:alert] = "#{t('english_offers.show.bid_failed', price: format('%.2f', auction.highest_price.to_f).tr('.', ','))}"

if turbo_frame_request?
render turbo_stream: turbo_stream.action(:redirect, root_path)
else
redirect_to root_path, status: :see_other
end
end

def bid_is_bad?(auction:, update_params:)
Expand Down Expand Up @@ -195,8 +209,13 @@ def set_offer
def authorize_phone_confirmation
return unless current_user.requires_phone_number_confirmation?

redirect_to new_user_phone_confirmation_path(current_user.uuid),
notice: t('phone_confirmations.confirmation_required')
flash[:notice] = t('phone_confirmations.confirmation_required')

if turbo_frame_request?
render turbo_stream: turbo_stream.action(:redirect, new_user_phone_confirmation_path(current_user.uuid))
else
redirect_to new_user_phone_confirmation_path(current_user.uuid), status: :see_other
end
end

def authorize_offer_for_user
Expand Down
21 changes: 19 additions & 2 deletions app/controllers/invoices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,27 @@ def edit; end
def update
respond_to do |format|
if update_predicate
format.html { redirect_to invoice_path(@invoice.uuid), notice: t(:updated) }
format.turbo_stream do
render turbo_stream: [
turbo_stream.update('invoice_information', partial: 'invoices/invoice_information', locals: { invoice: @invoice }),
turbo_stream.toast(t(:updated), position: "right", background: 'linear-gradient(to right, #11998e, #38ef7d)')
]
end

format.html { redirect_to invoices_path, notice: t(:updated) }
format.json { render :show, status: :ok, location: @invoice }
else
format.html { redirect_to invoice_path(@invoice.uuid), notice: t(:something_went_wrong) }
error_str = if @invoice.errors.empty?
@invoice.payable? ? t(:something_went_wrong) : t('invoices.invoice_already_paid')
else
@invoice.errors.full_messages.join('; ')
end

format.turbo_stream do
render turbo_stream: turbo_stream.toast(error_str, position: "right", background: 'linear-gradient(to right, #93291E, #ED213A)')
end

format.html { redirect_to invoices_path, status: :see_other, alert: error_str }
format.json { render json: @invoice.errors, status: :unprocessable_entity }
end
end
Expand Down
Loading

0 comments on commit 1a61c48

Please sign in to comment.