11class FormSubmissionConfirmationMailer < GovukNotifyRails ::Mailer
22 include NotifyUtils
33
4- def send_confirmation_email ( what_happens_next_markdown :, support_contact_details :, notify_response_id :, confirmation_email_address :, mailer_options : , submission_locale : :en , what_happens_next_markdown_cy : nil , support_contact_details_cy : nil )
5- @submission_locale = submission_locale . to_sym
4+ def send_confirmation_email ( form :, welsh_form :, submission :, notify_response_id :, confirmation_email_address : )
5+ @submission_locale = submission . submission_locale . to_sym
66 set_template ( template_id )
77
8+ what_happens_next_text = form . what_happens_next_markdown . presence || default_what_happens_next_text
89 set_personalisation (
9- title : mailer_options . title ,
10- what_happens_next_text : what_happens_next_markdown . presence || default_what_happens_next_text ,
11- what_happens_next_text_cy : what_happens_next_markdown_cy . presence || what_happens_next_markdown . presence || default_what_happens_next_text ,
12- support_contact_details : format_support_details ( support_contact_details ) . presence || default_support_contact_details_text ,
13- support_contact_details_cy : format_support_details ( support_contact_details_cy || support_contact_details , locale : :cy ) . presence || default_support_contact_details_text ,
14- submission_time : mailer_options . timestamp . strftime ( "%l:%M%P" ) . strip ,
15- submission_date : I18n . l ( mailer_options . timestamp , format : "%-d %B %Y" , locale : :en ) ,
16- submission_date_cy : I18n . l ( mailer_options . timestamp , format : "%-d %B %Y" , locale : :cy ) ,
17- # GOV.UK Notify's templates have conditionals, but only positive
18- # conditionals, so to simulate negative conditionals we add two boolean
19- # flags; but they must always have opposite values!
20- test : make_notify_boolean ( mailer_options . is_preview ) ,
21- submission_reference : mailer_options . submission_reference ,
22- include_payment_link : make_notify_boolean ( mailer_options . payment_url . present? ) ,
23- payment_link : mailer_options . payment_url || "" ,
10+ title : form . name ,
11+ what_happens_next_text :,
12+ what_happens_next_text_cy : welsh_form &.what_happens_next_markdown . presence || what_happens_next_text ,
13+ support_contact_details : format_support_details ( form . support_details ) . presence || default_support_contact_details_text ,
14+ support_contact_details_cy : welsh_support_details ( form , welsh_form ) ,
15+ submission_time : submission . submission_time . strftime ( "%l:%M%P" ) . strip ,
16+ submission_date : I18n . l ( submission . submission_time , format : "%-d %B %Y" , locale : :en ) ,
17+ submission_date_cy : I18n . l ( submission . submission_time , format : "%-d %B %Y" , locale : :cy ) ,
18+ test : make_notify_boolean ( submission . preview? ) ,
19+ submission_reference : submission . reference ,
20+ include_payment_link : make_notify_boolean ( submission . payment_url . present? ) ,
21+ payment_link : submission . payment_url || "" ,
2422 )
2523
2624 set_reference ( notify_response_id )
@@ -31,11 +29,11 @@ def send_confirmation_email(what_happens_next_markdown:, support_contact_details
3129 end
3230
3331 def format_support_details ( support_details , locale : :en )
34- phone = support_details . phone
35- call_charges_url = support_details . call_charges_url
36- email = support_details . email
37- url = support_details . url
38- url_text = support_details . url_text
32+ phone = support_details & .phone
33+ call_charges_url = support_details & .call_charges_url
34+ email = support_details & .email
35+ url = support_details & .url
36+ url_text = support_details & .url_text
3937
4038 support_details = [ ]
4139 support_details << normalize_whitespace ( phone ) if phone . present?
@@ -48,6 +46,12 @@ def format_support_details(support_details, locale: :en)
4846
4947private
5048
49+ def welsh_support_details ( form , welsh_form )
50+ format_support_details ( welsh_form &.support_details , locale : :cy ) . presence ||
51+ format_support_details ( form . support_details , locale : :cy ) . presence ||
52+ default_support_contact_details_text
53+ end
54+
5155 def default_what_happens_next_text
5256 I18n . t ( "mailer.submission_confirmation.default_what_happens_next" )
5357 end
0 commit comments