# frozen_string_literal: true

class UxToolkitCronMonitorMailer < ActionMailer::Base
  layout 'mailer'

  def alert(recipient, alert_type, details = {})
    @alert_type = alert_type.to_s
    @details = details.stringify_keys
    locale = @details.delete('locale').presence || Setting.default_language

    I18n.with_locale(locale) do
      mail(
        to: recipient,
        from: Setting.mail_from,
        subject: I18n.t("mail_subject_ux_toolkit_cron_monitor_#{@alert_type}")
      )
    end
  end
end
