From 5ced35b4785e29e9e5d427206cb074e9e73cc01e Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Fri, 15 Mar 2024 09:33:00 +0200 Subject: [PATCH] added phone number assigned from mobile id auth and remove role from profile form --- app/controllers/registrant/domains_controller.rb | 10 ++++++++++ app/controllers/registrant/profiles_controller.rb | 2 +- app/models/user.rb | 2 ++ app/views/registrant/profiles/_form.html.erb | 7 ------- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/controllers/registrant/domains_controller.rb b/app/controllers/registrant/domains_controller.rb index 116ece8..8eb5009 100644 --- a/app/controllers/registrant/domains_controller.rb +++ b/app/controllers/registrant/domains_controller.rb @@ -54,6 +54,16 @@ def edit; end def create # TODO: Need to add validation for ident of contacts, email and other attributes + unless DomainPrice.all.any? + flash.now[:alert] = t('.no_domain_prices') + + render turbo_stream: [ + turbo_stream.append('flash', partial: 'layouts/flash') + ] + + return + end + domain_price = DomainPrice.find(domain_params[:domain_price]) pending = PendingAction.create( diff --git a/app/controllers/registrant/profiles_controller.rb b/app/controllers/registrant/profiles_controller.rb index 5d3a08a..fe7a9c8 100644 --- a/app/controllers/registrant/profiles_controller.rb +++ b/app/controllers/registrant/profiles_controller.rb @@ -16,7 +16,7 @@ def update def user_params params.require(:user).permit( - :name, :email, :phone, :phone_code, :ident, :role, :country_code, + :name, :email, :phone, :phone_code, :ident, :country_code, :city, :street, :zip, :state, :legal_document, :code ) end diff --git a/app/models/user.rb b/app/models/user.rb index 525fc2e..19dfa01 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -38,6 +38,8 @@ def self.from_omniauth(tara_params) user = User.find_or_initialize_by(ident:) user.name = full_name user.ident = ident + user.role = User.roles[:priv] + user.phone = tara_params.dig('info', 'phone_number') if user.phone.blank? user end diff --git a/app/views/registrant/profiles/_form.html.erb b/app/views/registrant/profiles/_form.html.erb index eb0b6cf..89177df 100644 --- a/app/views/registrant/profiles/_form.html.erb +++ b/app/views/registrant/profiles/_form.html.erb @@ -7,10 +7,6 @@ <%= component 'form/text_input', form: form, attribute: :ident, heroicon_name: 'identification', placeholder: '2323232323', options: { readonly: true } %> -
- <%= component 'form/dropdown_input', form: form, attribute: :role, enum: User.human_enum_options(:role), heroicon_name: 'user-circle' %> -
-
<%= component 'form/text_input', form: form, attribute: :code, heroicon_name: 'identification', placeholder: 'ABC:123', options: { readonly: true } %>
@@ -22,9 +18,6 @@
- <%#= component 'form/text_input', form: form, attribute: :phone_code, heroicon_name: 'phone', placeholder: '+372' %> - <%#= component 'form/text_input', form: form, attribute: :phone, heroicon_name: 'phone', placeholder: '56722123' %> - <%= component 'form/phone_input', form: form, phone_attribute: :phone, code_attribute: :phone_code, code_placeholder: '372', phone_placeholder: '56722123' %>