diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb index 8eb46884d..186efb921 100644 --- a/app/controllers/schemes_controller.rb +++ b/app/controllers/schemes_controller.rb @@ -22,6 +22,16 @@ class SchemesController < ApplicationController end def deactivate + if params[:confirm] && params[:deactivation_date].present? + if @scheme.update!(deactivation_date: params[:deactivation_date]) + # update the logs + end + redirect_to scheme_details_path(@scheme) + return + elsif params[:deactivation_date].present? + render "toggle_active_confirm", locals: { action: "deactivate", deactivation_date: params[:deactivation_date] } + return + end render "toggle_active", locals: { action: "deactivate" } end @@ -210,7 +220,8 @@ private :support_type, :arrangement_type, :intended_stay, - :confirmed) + :confirmed, + :deactivation_date) if arrangement_type_changed_to_different_org?(required_params) required_params[:managing_organisation_id] = nil diff --git a/app/views/schemes/toggle_active.html.erb b/app/views/schemes/toggle_active.html.erb index 7d0738cf1..eb3c11b3c 100644 --- a/app/views/schemes/toggle_active.html.erb +++ b/app/views/schemes/toggle_active.html.erb @@ -1,4 +1,4 @@ -<%= form_with url: scheme_details_path(@scheme), method: "get", local: true do |f| %> +<%= form_with url: scheme_deactivate_path(@scheme), method: "get", local: true do |f| %> <% content_for :before_content do %> <%= govuk_back_link(href: :back) %> <% end %> diff --git a/app/views/schemes/toggle_active_confirm.html.erb b/app/views/schemes/toggle_active_confirm.html.erb new file mode 100644 index 000000000..271a4df48 --- /dev/null +++ b/app/views/schemes/toggle_active_confirm.html.erb @@ -0,0 +1,16 @@ +<%= form_with url: scheme_deactivate_path(@scheme), method: "get", local: true do |f| %> + <% content_for :before_content do %> + <%= govuk_back_link(href: :back) %> + <% end %> +