@@ -11,7 +11,7 @@ import {
1111 usePermissions ,
1212} from 'react-admin' ;
1313import Typography from '@mui/material/Typography' ;
14- import { GlobalStyles } from '@mui/material' ;
14+ import Box from '@mui/material/Box ' ;
1515import type { FieldValues , Resolver } from 'react-hook-form' ;
1616import { useFormContext } from 'react-hook-form' ;
1717import { yupResolver } from '@hookform/resolvers/yup' ;
@@ -125,50 +125,43 @@ const MessageForm = ({ protocol, ...delegatedProps }: Props) => {
125125 ) ;
126126
127127 return (
128- < >
129- < GlobalStyles
130- styles = { {
131- '.message-form-event-col' : { gridColumn : '1 !important' } ,
132- '.message-form-occurrences-col' : { gridColumn : '2 !important' } ,
133- '.message-form-full-width' : { width : '100%' } ,
134- } }
135- />
136- < SimpleForm
137- resolver = { resolver as unknown as Resolver < FieldValues > }
138- sx = { ( theme ) => ( {
139- '& > .MuiCardContent-root' : {
140- display : 'grid' ,
141- gridTemplateColumns : '1fr 1fr' ,
142- gridTemplateRows : 'auto' ,
143- columnGap : theme . spacing ( 2 ) ,
144- '& > *' : {
145- gridColumn : '1 / -1' ,
146- } ,
128+ < SimpleForm
129+ resolver = { resolver as unknown as Resolver < FieldValues > }
130+ sx = { ( theme ) => ( {
131+ '& > .MuiCardContent-root' : {
132+ display : 'grid' ,
133+ gridTemplateColumns : '1fr 1fr' ,
134+ gridTemplateRows : 'auto' ,
135+ columnGap : theme . spacing ( 2 ) ,
136+ '& > *' : {
137+ gridColumn : '1 / -1' ,
147138 } ,
148- } ) }
149- { ...delegatedProps }
150- >
151- < TranslatableProvider >
152- < TranslatableContext . Consumer >
153- { ( {
154- selector : languageTabsComponent ,
155- getSource : translatableField ,
156- } ) => (
157- < >
158- { protocol !== ProtocolType . Sms && languageTabsComponent }
159- < CustomOnChange onChange = { handleRecipientSelectionChange } >
160- < SelectInput
161- variant = "outlined"
162- source = "recipientSelection"
163- label = "messages.fields.recipientSelection.label"
164- choices = { recipientSelectionChoices }
165- validate = { validateRecipientSelection }
166- defaultValue = ""
167- fullWidth
168- sx = { { gridColumn : '1 !important' } }
169- />
170- </ CustomOnChange >
171- < FormDataConsumer formClassName = "message-form-event-col" >
139+ } ,
140+ } ) }
141+ { ...delegatedProps }
142+ >
143+ < TranslatableProvider >
144+ < TranslatableContext . Consumer >
145+ { ( {
146+ selector : languageTabsComponent ,
147+ getSource : translatableField ,
148+ } ) => (
149+ < >
150+ { protocol !== ProtocolType . Sms && languageTabsComponent }
151+ < CustomOnChange onChange = { handleRecipientSelectionChange } >
152+ < SelectInput
153+ variant = "outlined"
154+ source = "recipientSelection"
155+ label = "messages.fields.recipientSelection.label"
156+ choices = { recipientSelectionChoices }
157+ validate = { validateRecipientSelection }
158+ defaultValue = ""
159+ fullWidth
160+ sx = { { gridColumn : '1 !important' } }
161+ />
162+ </ CustomOnChange >
163+ < Box sx = { { gridColumn : '1 !important' } } >
164+ < FormDataConsumer >
172165 { ( { formData : { recipientSelection } , ...rest } ) =>
173166 recipientsWithEventSelection . includes (
174167 recipientSelection
@@ -180,7 +173,6 @@ const MessageForm = ({ protocol, ...delegatedProps }: Props) => {
180173 source = "eventId"
181174 label = "messages.fields.event.label"
182175 fullWidth
183- className = "message-form-full-width"
184176 emptyValue = "all"
185177 emptyText = "messages.fields.event.all"
186178 InputLabelProps = { {
@@ -193,63 +185,66 @@ const MessageForm = ({ protocol, ...delegatedProps }: Props) => {
193185 )
194186 }
195187 </ FormDataConsumer >
196- < FormDataConsumer formClassName = "message-form-occurrences-col" >
188+ </ Box >
189+ < Box sx = { { gridColumn : '2 !important' } } >
190+ < FormDataConsumer >
197191 { ( { formData : { eventId, recipientSelection } , ...rest } ) =>
198192 eventId &&
199193 eventId !== 'all' &&
200194 recipientSelection !== 'INVITED' && (
201- < OccurrenceArraySelect
202- { ...rest }
203- source = "occurrenceIds"
204- label = "messages.fields.occurrences.label"
205- eventId = { eventId }
206- className = "message-form-full-width"
207- defaultValue = { getInitialOccurrenceIds ( record ) }
208- allText = "messages.fields.occurrences.all"
209- />
195+ < Box sx = { { width : '100%' } } >
196+ < OccurrenceArraySelect
197+ { ...rest }
198+ source = "occurrenceIds"
199+ label = "messages.fields.occurrences.label"
200+ eventId = { eventId }
201+ defaultValue = { getInitialOccurrenceIds ( record ) }
202+ allText = "messages.fields.occurrences.all"
203+ />
204+ </ Box >
210205 )
211206 }
212207 </ FormDataConsumer >
213- { protocol === ProtocolType . Email && (
214- < TextInput
215- source = { translatableField ( 'subject' ) }
216- variant = "outlined"
217- label = "messages.fields.subject.label2"
218- validate = { validateSubject }
219- fullWidth
220- InputLabelProps = { {
221- shrink : true ,
222- } }
223- />
224- ) }
208+ </ Box >
209+ { protocol === ProtocolType . Email && (
225210 < TextInput
226- source = { translatableField ( 'bodyText' ) }
227- label = "messages.fields.bodyText.label"
211+ source = { translatableField ( 'subject' ) }
228212 variant = "outlined"
229- validate = { validateBodyText }
230- multiline
213+ label = "messages.fields.subject.label2"
214+ validate = { validateSubject }
231215 fullWidth
232- rows = { 10 }
233216 InputLabelProps = { {
234217 shrink : true ,
235218 } }
236219 />
237- { protocol === ProtocolType . Sms && (
238- < >
239- < Typography
240- variant = "subtitle2"
241- sx = { ( theme ) => ( { marginBottom : theme . spacing ( 1 ) } ) }
242- >
243- { t ( 'sms.create.messageSentImmediatelyNotice' ) }
244- </ Typography >
245- </ >
246- ) }
247- </ >
248- ) }
249- </ TranslatableContext . Consumer >
250- </ TranslatableProvider >
251- </ SimpleForm >
252- </ >
220+ ) }
221+ < TextInput
222+ source = { translatableField ( 'bodyText' ) }
223+ label = "messages.fields.bodyText.label"
224+ variant = "outlined"
225+ validate = { validateBodyText }
226+ multiline
227+ fullWidth
228+ rows = { 10 }
229+ InputLabelProps = { {
230+ shrink : true ,
231+ } }
232+ />
233+ { protocol === ProtocolType . Sms && (
234+ < >
235+ < Typography
236+ variant = "subtitle2"
237+ sx = { ( theme ) => ( { marginBottom : theme . spacing ( 1 ) } ) }
238+ >
239+ { t ( 'sms.create.messageSentImmediatelyNotice' ) }
240+ </ Typography >
241+ </ >
242+ ) }
243+ </ >
244+ ) }
245+ </ TranslatableContext . Consumer >
246+ </ TranslatableProvider >
247+ </ SimpleForm >
253248 ) ;
254249} ;
255250
0 commit comments