Browse Source

refactor: linting

pull/980/head
natdeanlewissoftwire 2 years ago
parent
commit
eb9db873d9
  1. 24
      app/controllers/schemes_controller.rb

24
app/controllers/schemes_controller.rb

@ -26,18 +26,16 @@ class SchemesController < ApplicationController
if @scheme.errors.present? if @scheme.errors.present?
render "toggle_active", locals: { action: "deactivate" }, status: :unprocessable_entity render "toggle_active", locals: { action: "deactivate" }, status: :unprocessable_entity
else elsif deactivation_date_value.blank?
if deactivation_date_value.blank? render "toggle_active", locals: { action: "deactivate" }
render "toggle_active", locals: { action: "deactivate" } elsif params[:scheme][:confirm].present?
elsif (params[:scheme][:confirm].present?) if @scheme.update(deactivation_date: deactivation_date_value)
if @scheme.update(deactivation_date: deactivation_date_value) # update the logs
# update the logs flash[:notice] = "#{@scheme.service_name} has been deactivated"
flash[:notice] = "#{@scheme.service_name} has been deactivated"
end
redirect_to scheme_details_path(@scheme)
else
render "toggle_active_confirm", locals: {action: "deactivate", deactivation_date: deactivation_date_value}
end end
redirect_to scheme_details_path(@scheme)
else
render "toggle_active_confirm", locals: { action: "deactivate", deactivation_date: deactivation_date_value }
end end
end end
@ -148,8 +146,8 @@ class SchemesController < ApplicationController
end end
def deactivation_date def deactivation_date
return unless params[:scheme].present? return if params[:scheme].blank?
return @scheme.errors.add(:deactivation_date, message: I18n.t("validations.scheme.deactivation_date.not_selected")) unless params[:scheme][:deactivation_date].present? return @scheme.errors.add(:deactivation_date, message: I18n.t("validations.scheme.deactivation_date.not_selected")) if params[:scheme][:deactivation_date].blank?
return params[:scheme][:deactivation_date] unless params[:scheme][:deactivation_date] == "other" return params[:scheme][:deactivation_date] unless params[:scheme][:deactivation_date] == "other"
day = params[:scheme]["deactivation_date(3i)"] day = params[:scheme]["deactivation_date(3i)"]

Loading…
Cancel
Save