@@ -5,7 +5,7 @@ import { useState } from 'react';
55import type { SubmitHandler , UseFormRegister } from 'react-hook-form' ;
66import { FormProvider , useForm } from 'react-hook-form' ;
77
8- import type { TypeAlertSettingsIn } from '@/__generated__/data-contracts' ;
8+ import type { TypeAlertSettingsIn , TypeUserOut } from '@/__generated__/data-contracts' ;
99import Accordion from '@/ui/accordion/accordion' ;
1010import Button from '@/ui/button/button' ;
1111import Checkboxes from '@/ui/checkboxes/checkboxes' ;
@@ -49,12 +49,13 @@ function Option({
4949}
5050
5151type AlertSettingsFormProps = {
52+ user ?: TypeUserOut ;
5253 defaultValues : AlertSettingsSchema ;
5354 selfEdit ?: boolean ;
5455 onSubmit : ( data : TypeAlertSettingsIn ) => Promise < void > ;
5556} ;
5657
57- const AlertSettingsForm = ( { defaultValues, selfEdit = true , onSubmit : onSubmitAction } : AlertSettingsFormProps ) => {
58+ const AlertSettingsForm = ( { user , defaultValues, selfEdit = true , onSubmit : onSubmitAction } : AlertSettingsFormProps ) => {
5859 const t = useTranslations ( 'Forms.Alert_settings' ) ;
5960 const tCommon = useTranslations ( 'Common' ) ;
6061
@@ -105,8 +106,8 @@ const AlertSettingsForm = ({ defaultValues, selfEdit = true, onSubmit: onSubmitA
105106 )
106107 : (
107108 < >
108- < h1 className = "govuk-heading-xl" > { t ( 'title' , { whose : selfEdit ? 'your' : 'user\'s' } ) } </ h1 >
109- < p className = "govuk-body" > { t ( 'description' ) } </ p >
109+ < h1 className = "govuk-heading-xl" > { t ( 'title' , { whose : selfEdit ? 'your' : user ?. first_name ? ` ${ user . first_name } 's` : 'user\'s' } ) } </ h1 >
110+ < p className = "govuk-body" > { t ( 'description' , { to : user ?. first_name ? ` ${ user . first_name } ${ user . last_name } ` : 'you' } ) } </ p >
110111 { selfEdit && (
111112 < WarningText >
112113 { t ( 'warning' ) }
@@ -119,43 +120,6 @@ const AlertSettingsForm = ({ defaultValues, selfEdit = true, onSubmit: onSubmitA
119120 < Accordion
120121 id = "alert-settings"
121122 initialItems = { [
122- {
123- id : 'conjunction_alerts' ,
124- heading : t ( 'conjunction_alerts' ) ,
125- content : (
126- < >
127- < Checkboxes
128- aria-label = "Conjunction Alerts"
129- legend = { t (
130- `${ selfEdit ? 'self_which' : 'their_which' } ` ,
131- { type : 'conjunction' } ,
132- ) }
133- hint = { t ( 'select_one_option' ) }
134- items = { [ {
135- id : 'receive_all_conjunction_alerts' ,
136- value : 'standard' ,
137- children : t ( 'receive_all_conjunction_alerts' ) ,
138- hint : t ( 'recommended_for' ) ,
139- ...register ( 'conjunctionAlerts' ) ,
140- } , {
141- id : 'only_priority_conjunction_alerts' ,
142- value : 'priority' ,
143- children : t ( 'only_priority_conjunction_alerts' ) ,
144- hint : t ( 'recommended_for_all_other' ) ,
145- ...register ( 'conjunctionAlerts' ) ,
146- } ] }
147- />
148- < AlertSettingsDetails type = "conjunction" />
149- < Option
150- id = "receiveConjunction"
151- name = "receiveConjunction"
152- hint = { t ( 'select_one_option' ) }
153- label = { t ( 'how_would_you_like_conjunction' ) }
154- register = { register }
155- />
156- </ >
157- ) ,
158- } ,
159123 {
160124 id : 're_entry_alerts' ,
161125 heading : t ( 're_entry_alerts' ) ,
@@ -251,6 +215,43 @@ const AlertSettingsForm = ({ defaultValues, selfEdit = true, onSubmit: onSubmitA
251215 </ >
252216 ) ,
253217 } ,
218+ {
219+ id : 'conjunction_alerts' ,
220+ heading : t ( 'conjunction_alerts' ) ,
221+ content : (
222+ < >
223+ < Checkboxes
224+ aria-label = "Conjunction Alerts"
225+ legend = { t (
226+ `${ selfEdit ? 'self_which' : 'their_which' } ` ,
227+ { type : 'conjunction' } ,
228+ ) }
229+ hint = { t ( 'select_one_option' ) }
230+ items = { [ {
231+ id : 'receive_all_conjunction_alerts' ,
232+ value : 'standard' ,
233+ children : t ( 'receive_all_conjunction_alerts' ) ,
234+ hint : t ( 'recommended_for' ) ,
235+ ...register ( 'conjunctionAlerts' ) ,
236+ } , {
237+ id : 'only_priority_conjunction_alerts' ,
238+ value : 'priority' ,
239+ children : t ( 'only_priority_conjunction_alerts' ) ,
240+ hint : t ( 'recommended_for_all_other' ) ,
241+ ...register ( 'conjunctionAlerts' ) ,
242+ } ] }
243+ />
244+ < AlertSettingsDetails type = "conjunction" />
245+ < Option
246+ id = "receiveConjunction"
247+ name = "receiveConjunction"
248+ hint = { t ( 'select_one_option' ) }
249+ label = { t ( 'how_would_you_like_conjunction' ) }
250+ register = { register }
251+ />
252+ </ >
253+ ) ,
254+ } ,
254255 ] }
255256 />
256257 < div className = "govuk-button-group" >
0 commit comments