Skip to content

Commit

Permalink
Merge pull request #1277 from internetee/comma-issue
Browse files Browse the repository at this point in the history
Comma issue
  • Loading branch information
vohmar authored Jul 2, 2024
2 parents 9185c8e + 318b488 commit 9b302b3
Show file tree
Hide file tree
Showing 26 changed files with 220 additions and 160 deletions.
4 changes: 4 additions & 0 deletions app/components/application_view_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@ def company_name
def main_app
Rails.application.class.routes.url_helpers
end

def price_format(price)
"#{number_to_currency(price, unit: '', separator: ',', delimiter: '', precision: 2)} €"
end
end
8 changes: 4 additions & 4 deletions app/components/common/footer/component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<span style="font-size: 13px;"><a href="https://internet.ee/help-and-info/faq" target="_self"><%= t('common.footer.faq')%></a> </span>
<span style="font-size: 13px;"><a href="https://internet.ee/help-and-info/statistics" target="_self"><%= t('common.footer.statistics')%></a></span>
<span style="font-size: 15px;"><br></span>
<span style="font-size: 13px;"><a href="https://internet.ee/domain-disputes/domain-disuptes-committee" target="_self"><%= t('common.footer.dispute_committee') %></a></span>
<span style="font-size: 13px;"><a href="<%= footer_link(:dispute_committee) %>" target="_self"><%= t('common.footer.dispute_committee') %></a></span>
<b><span style="font-size: 15px;"><br></span></b>
</span>
</div>
Expand All @@ -57,11 +57,11 @@
<div><b><br></b></div>
<div>
<b></b>
<span style="font-size: 13px;"><a href="https://internet.ee/registrars/accredited-registrars" target="_self"> <%= t('common.footer.list_of_accredited_registrars')%></a></span><br>
<span style="font-size: 13px;"><a href="<%= footer_link(:list_of_accredited_registrars) %>" target="_self"> <%= t('common.footer.list_of_accredited_registrars')%></a></span><br>
<span style="font-size: 13px;">
<a href="https://internet.ee/registrars/terms-and-conditions-for-becoming-a-registrar" target="_self"> <%= t('common.footer.terms_and_conditions_for_registrars') %></a>
<a href="<%= footer_link(:terms_and_conditions_for_registrars) %>" target="_self"> <%= t('common.footer.terms_and_conditions_for_registrars') %></a>
</span><br>
<span style="font-size: 13px;"><a href="https://internet.ee/registrars/become-a-ee-elite-partner" target="_self"> <%= t('common.footer.partner_programme') %></a></span>
<span style="font-size: 13px;"><a href="<%= footer_link(:partner_programme) %>" target="_self"> <%= t('common.footer.partner_programme') %></a></span>
<b><br></b>
</div>
</div>
Expand Down
26 changes: 25 additions & 1 deletion app/components/common/footer/component.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
module Common
module Footer
class Component < ApplicationViewComponent; end
class Component < ApplicationViewComponent
def footer_link(key) = if I18n.locale == :et
et_footer_links[key]
else
en_footer_links[key]
end

def et_footer_links
{
dispute_committee: 'https://www.internet.ee/domeenivaidlused/domeenivaidluste-komisjon',
list_of_accredited_registrars: 'https://www.internet.ee/registripidaja/akrediteeritud-registripidajad',
terms_and_conditions_for_registrars: 'https://www.internet.ee/registripidaja/kuidas-saada-ee-akrediteeritud-registripidajaks',
partner_programme: 'https://www.internet.ee/registripidaja/kuidas-saada-ee-elite-partneriks'
}
end

def en_footer_links
{
dispute_committee: 'https://www.internet.ee/domain-disputes/domain-disputes-committee',
list_of_accredited_registrars: 'https://www.internet.ee/registrar-portal/accredited-registrars',
terms_and_conditions_for_registrars: 'https://www.internet.ee/registrar-portal/terms-and-conditions-for-becoming-a-registrar',
partner_programme: 'https://www.internet.ee/registrar-portal/become-a-ee-elite-partner'
}
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</div>
</div>
<% end %>

<%= banned_banner %>
<%= invalid_data_banner %>
</div>
</div>
75 changes: 75 additions & 0 deletions app/components/common/static_notice/component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
module Common
module StaticNotice
class Component < ViewComponent::Base
attr_accessor :current_user

def initialize(current_user:)
super

@current_user = current_user
end

def banned_banner
return unless current_user&.current_bans

domains, valid_until = current_user&.current_bans
message = ban_error_message(domains, valid_until)
return unless message

content_tag(:div, class: 'c-toast js-toast c-toast--error') do
content_tag(:div, class: 'c-toast__content') do
concat(content_tag(:p, message))
concat(content_tag(:p, violation_message(domains.size))) if eligible_violations_present?(domains:)
end
end
end

def invalid_data_banner
return unless session['user.invalid_user_data']

if current_user.not_phone_number_confirmed_unique?
content_tag(:div, class: 'c-toast js-toast c-toast--error') do
content_tag(:div, t('already_confirmed'), class: 'c-toast__content')
end
else
content_tag(:div, class: 'c-toast js-toast c-toast--error') do
content_tag(:div, t('users.invalid_user_data'), class: 'c-toast__content')
end
end
end

def start_of_procedure = Rails.configuration.customization[:start_of_procedure]

def end_of_procdure = Rails.configuration.customization[:end_of_procedure]

private

def ban_error_message(domains, valid_until)
if current_user&.completely_banned?
t('auctions.banned_completely', valid_until: valid_until.to_date,
ban_number_of_strikes: Setting.find_by(
code: 'ban_number_of_strikes'
).retrieve)
else
I18n.t('auctions.banned', domain_names: domains.join(', '))
end
end

def violation_message(domains_count)
link = Setting.find_by(code: 'violations_count_regulations_link').retrieve
t('auctions.violation_message_html', violations_count_regulations_link: link,
violations_count: domains_count,
ban_number_of_strikes: Setting.find_by(
code: 'ban_number_of_strikes'
).retrieve)
end

def eligible_violations_present?(domains: nil)
num_of_strikes = Setting.find_by(code: 'ban_number_of_strikes').retrieve
return true if domains && domains.size < num_of_strikes

false
end
end
end
end
8 changes: 6 additions & 2 deletions app/components/modals/change_offer/component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@
<div class="c-modal__grid">
<div class="c-modal__main__info">
<span><%= t('english_offers.show.min_bid') %></span>
<h3 class="u-h2 u-m-none"><span id="mini"><%= Money.from_amount(@auction.min_bids_step.to_f, Setting.find_by(code: 'auction_currency').retrieve, precision: 2) %></span></h3>
<h3 class="u-h2 u-m-none">
<span id="mini">
<%= price_format(Money.from_amount(@auction.min_bids_step.to_f, Setting.find_by(code: 'auction_currency').retrieve)) %>
</span>
</h3>
</div>
<div class="c-modal__main__info c-modal__main__info--black">
<strong><%= t('english_offers.show.current_price') %></strong>
<h3 class="u-h2 u-m-none">
<span id="current_<%= @auction.id %>_price">
<%= current_price %>
<%= price_format(current_price) %>
</span>
</h3>
<span><%= current_bidder %></span>
Expand Down
2 changes: 1 addition & 1 deletion app/components/modals/change_offer/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def offer_form_properties
controller: 'autotax-counter',
autotax_counter_template_value: t('english_offers.price_with_wat_template'),
autotax_counter_tax_value: "#{offer.billing_profile.present? ? offer.billing_profile.vat_rate : 0.0}",
autotax_counter_defaulttemplate_value: t('offers.price_is_without_vat')
autotax_counter_defaulttemplate_value: t('offers.price_is_without_vat'),
}
}
end
Expand Down
2 changes: 1 addition & 1 deletion app/components/modals/change_offer_po/component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<div class="c-modal__grid">
<div class="c-modal__main__info">
<span><%= t('english_offers.show.min_bid') %></span>
<h3 class="u-h2 u-m-none"><%= Money.new(Setting.find_by(code: 'auction_minimum_offer').retrieve) %></h3>
<h3 class="u-h2 u-m-none"><%= price_format(Money.new(Setting.find_by(code: 'auction_minimum_offer').retrieve)) %></h3>
</div>
<div class="c-modal__main__info c-modal__main__info--black">
<strong><%= t('auctions.you') %></strong>
Expand Down
17 changes: 10 additions & 7 deletions app/components/modals/deposit/component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,27 @@
<div class="c-modal__main__info">
<span><%= t('english_offers.show.min_bid') %></span>
<h3 class="u-h2 u-mt-0 u-mb-40-l">
<%= number_with_precision(Money.from_amount(@auction.min_bids_step.to_f, Setting.find_by(code: 'auction_currency').retrieve, precision: 2)) %>
<%#= @auction.min_bids_step.to_f %>
<%= price_format(Money.from_amount(@auction.min_bids_step, Setting.find_by(code: 'auction_currency').retrieve)) %>
</h3>
</div>
<div class="c-modal__main__info c-modal__main__info--black">
<strong><%= t('english_offers.show.current_price') %></strong>
<h3 class="u-h2 u-mt-0 u-mb-40-l"><span id="current_<%= @auction.id %>_price"><%= @auction&.currently_winning_offer&.price || Money.new(0) %></span></h3>
<h3 class="u-h2 u-mt-0 u-mb-40-l">
<span id="current_<%= @auction.id %>_price">
<%= price_format(@auction&.currently_winning_offer&.price || Money.new(0)) %>
</span>
</h3>
</div>
<div class="c-modal__main__info c-modal__main__info--white c-modal__header__desc">
<div class="c-modal__main__info__wrapper u-flex u-align-start u-content-sp u-flex-col">
<span class="u-mb-60"><strong><%= t('offers.new.deposit_description_html', deposit: number_with_precision(@auction.deposit, precision: 2)) %></strong></span>
<button class="c-btn c-btn--ghost c-btn--fs" data-action='modals--offer-modal#close'>Tagasi</button>
<span class="u-mb-60"><strong><%= t('offers.new.deposit_description_html', deposit: price_format(@auction.deposit)) %></strong></span>
<button class="c-btn c-btn--ghost c-btn--fs" data-action='modals--offer-modal#close'><%= t('close') %></button>
</div>
</div>
<div class="c-modal__main__info c-modal__main__info--orange u-align-center u-content-center u-flex-col">
<div><span><%= t('offers.new.deposit_enable') %></span>
<h3 class="u-h2 u-mt-0 u-mb-30"><%= "#{number_with_precision(@auction.deposit, precision: 2)} €" %></h3>
<%#= button_to t('offers.new.make_deposit'), english_offer_deposit_auction_path(uuid: @auction.uuid, current_user: @current_user),
class: "c-btn c-btn-white c-btn--fs", method: :post, data: { turbo: false } %>
<h3 class="u-h2 u-mt-0 u-mb-30"><%= "#{price_format(@auction.deposit)}" %></h3>

<%= form_with url: english_offer_deposit_auction_path(uuid: @auction.uuid, current_user: @current_user), data: { turbo: false} do |f| %>
<%= component 'captcha', captcha_required: @captcha_required, show_checkbox_recaptcha: @show_checkbox_recaptcha, action: 'english_offer' %>
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ class ApplicationController < ActionController::Base
end

rescue_from CanCan::AccessDenied do |_exception|
flash[:alert] = I18n.t('unauthorized.message')
flash[:alert] = if current_user.banned?
I18n.t('unauthorized.banned.message')
else
I18n.t('unauthorized.message')
end

if turbo_frame_request?
render turbo_stream: turbo_stream.replace('flash', partial: 'common/flash', locals: { flash: })
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/english_offers/offerable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def inform_about_invalid_bid_amount
end

def find_or_initialize_autobidder
@autobider = current_user&.autobiders&.find_or_initialize_by(domain_name: @auction.domain_name)
@autobider = current_user&.autobiders&.find_or_initialize_by(domain_name: @offer.auction.domain_name)
end

# rubocop:disable Metrics/AbcSize
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/english_offers_controller.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# frozen_string_literal: true

class EnglishOffersController < ApplicationController
before_action :set_offer, only: %i[show edit update]

include BeforeRender
include Offerable
protect_from_forgery with: :null_session

# order is important
before_action :set_offer, only: %i[show edit update]
include EnglishOffers::Offerable

include RecaptchaValidatable
Expand Down
58 changes: 2 additions & 56 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def application_name

def google_analytics
tracking_id = Rails.configuration.customization.dig(:google_analytics, :tracking_id)
GoogleAnalytics.new(tracking_id: tracking_id)
GoogleAnalytics.new(tracking_id:)
end

def component(name, *args, **kwargs, &block)
Expand All @@ -29,31 +29,6 @@ def locale_links
end
end

def banned_banner
return unless current_user&.current_bans

domains, valid_until = current_user&.current_bans
message = ban_error_message(domains, valid_until)
return unless message

content_tag(:div, class: 'c-toast js-toast c-toast--error') do
content_tag(:div, class: 'c-toast__content') do
concat(content_tag(:p, message))
if eligible_violations_present?(domains: domains)
concat(content_tag(:p, violation_message(domains.size)))
end
end
end
end

def start_of_procedure
Rails.configuration.customization[:start_of_procedure]
end

def end_of_procdure
Rails.configuration.customization[:end_of_procedure]
end

def show_cookie_dialog?
cookies[:cookie_dialog] != 'accepted'
end
Expand All @@ -64,33 +39,6 @@ def show_google_analytics?

private

def ban_error_message(domains, valid_until)
if current_user&.completely_banned?
t('auctions.banned_completely', valid_until: valid_until.to_date,
ban_number_of_strikes: Setting.find_by(
code: 'ban_number_of_strikes'
).retrieve)
else
I18n.t('auctions.banned', domain_names: domains.join(', '))
end
end

def violation_message(domains_count)
link = Setting.find_by(code: 'violations_count_regulations_link').retrieve
t('auctions.violation_message_html', violations_count_regulations_link: link,
violations_count: domains_count,
ban_number_of_strikes: Setting.find_by(
code: 'ban_number_of_strikes'
).retrieve)
end

def eligible_violations_present?(domains: nil)
num_of_strikes = Setting.find_by(code: 'ban_number_of_strikes').retrieve
return true if domains && domains.size < num_of_strikes

false
end

def links(links_list)
links_list.each do |item|
concat(
Expand All @@ -106,12 +54,10 @@ def links(links_list)
def locale_link_list
locales = I18n.available_locales.reject { |item| item == I18n.locale }

items = locales.map do |item|
locales.map do |item|
{ name: I18n.t(:in_local_language, locale: item), path: locale_path(locale: item),
method: :put, data: { "turbo-method": 'put' } }
end

items
end

def user_link_list
Expand Down
14 changes: 0 additions & 14 deletions app/helpers/invalid_user_data_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,6 @@ def set_invalid_data_flag_in_session
session['user.invalid_user_data'] = user_data_invalid?
end

def invalid_data_banner
return unless session['user.invalid_user_data']

if current_user.not_phone_number_confirmed_unique?
content_tag(:div, class: 'c-toast js-toast c-toast--error') do
content_tag(:div, t('already_confirmed'), class: 'c-toast__content')
end
else
content_tag(:div, class: 'c-toast js-toast c-toast--error') do
content_tag(:div, t('users.invalid_user_data'), class: 'c-toast__content')
end
end
end

private

def user_data_invalid?
Expand Down
6 changes: 4 additions & 2 deletions app/javascript/controllers/autotax_counter_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default class extends Controller {
tax: String,
template: String,
defaulttemplate: String,
priceElement: { default: 'input[name="offer[price]"]', type: String }
priceElement: { default: 'input[name="offer[price]"]', type: String },
}

connect() {
Expand All @@ -22,7 +22,9 @@ export default class extends Controller {
const taxAmount = value * tax;
const totalAmount = value + taxAmount;

result.innerHTML = this.templateValue.replace('{price}', totalAmount.toFixed(2)).replace('{tax}', (tax * 100.0).toFixed(2));
let tem = this.templateValue.replace('{price}', totalAmount.toFixed(2)).replace('{tax}', (tax * 100.0).toFixed(2));
tem = tem.replace('.', ',').replace('.', ',');
result.innerHTML = tem
} else {
result.innerHTML = this.defaulttemplateValue;
}
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<main>
<%= turbo_frame_tag "modal", data: { turbo_temporary: true } %>
<%= component 'common/hero', title: yield(:title) %>
<%= render "common/static_notices" %>
<%= component 'common/static_notice', current_user: current_user %>
<%= yield %>
</main>

Expand Down
Loading

0 comments on commit 9b302b3

Please sign in to comment.