feat(manager): schedule a dolist report from manager

This commit is contained in:
Colin Darie 2023-01-17 17:34:05 +01:00
parent 1947fcf72b
commit deb40caae1
4 changed files with 33 additions and 1 deletions

View file

@ -1,4 +1,25 @@
module Manager
class EmailEventsController < Manager::ApplicationController
def index
@dolist_enabled = Dolist::API.new.properly_configured?
super
end
def generate_dolist_report
email = current_super_admin.email
DolistReportJob.perform_later(email)
respond_to do |format|
@message = "Le rapport sera envoyé sur #{email}. Il peut prendre plus d'1h pour être généré."
format.turbo_stream
format.html do
redirect_to manager_email_events_path, notice: @message
end
end
end
end
end

View file

@ -0,0 +1,7 @@
<footer class="main-content__body">
<% if @dolist_enabled %>
<%= form_tag(generate_dolist_report_manager_email_events_path, id: "dolist-report-form", data: { turbo: true }) do %>
<button>Recevoir un rapport Dolist</button>
<% end %>
<% end %>
</footer>

View file

@ -0,0 +1,2 @@
= turbo_stream.morph "dolist-report-form" do
= @message

View file

@ -65,7 +65,9 @@ Rails.application.routes.draw do
resources :team_accounts, only: [:index, :show]
resources :email_events, only: [:index, :show]
resources :email_events, only: [:index, :show] do
post :generate_dolist_report, on: :collection
end
resources :dubious_procedures, only: [:index]
resources :outdated_procedures, only: [:index] do