11import { yupResolver } from '@hookform/resolvers/yup'
22import Compact from '@uiw/react-color-compact'
33import { format } from 'date-fns'
4- import { Input } from 'ooni-components'
4+ import { Checkbox , Input } from 'ooni-components'
55import { Controller , FormProvider , useForm } from 'react-hook-form'
66import { FormattedMessage , useIntl } from 'react-intl'
77import * as Yup from 'yup'
@@ -51,6 +51,7 @@ export type TestList = {
5151 icon : string
5252 color : string
5353 author : string
54+ publish_email : boolean
5455 expiration_date : string
5556 nettests : Nettest [ ]
5657}
@@ -88,6 +89,7 @@ const validationSchema = Yup.object({
8889 icon : Yup . string ( ) . defined ( ) ,
8990 color : Yup . string ( ) . defined ( ) ,
9091 author : Yup . string ( ) . defined ( ) ,
92+ publish_email : Yup . boolean ( ) . defined ( ) ,
9193 expiration_date : Yup . string ( )
9294 . required ( 'TestListForm.Validation.Required' )
9395 . test (
@@ -274,7 +276,7 @@ const TestListForm = ({
274276 { ...field }
275277 label = { `${ intl . formatMessage ( { id : 'TestListForm.Label.Description' } ) } *` }
276278 placeholder = ""
277- minHeight = " 78px"
279+ style = { { minHeight : ' 78px' } }
278280 error = {
279281 ! ! fieldState ?. error ?. message &&
280282 intl . formatMessage ( { id : fieldState ?. error ?. message } )
@@ -287,20 +289,52 @@ const TestListForm = ({
287289 < IntlFields name = "description_intl" inputType = "textarea" />
288290 </ StyledInputWrapper >
289291 { isClient && (
290- < StyledInputWrapper >
292+ < >
291293 < Controller
292294 render = { ( { field } ) => (
293295 < Input
294296 { ...field }
295297 disabled
296298 bg = "gray3"
297299 label = { `${ intl . formatMessage ( { id : 'TestListForm.Label.Email' } ) } *` }
300+ className = "mb-2"
298301 />
299302 ) }
300303 name = "author"
301304 control = { control }
302305 />
303- </ StyledInputWrapper >
306+ < StyledInputWrapper >
307+ < Controller
308+ render = { ( {
309+ field : { value, onChange, ...fieldProps } ,
310+ } ) => (
311+ < >
312+ < Checkbox
313+ { ...fieldProps }
314+ onChange = { (
315+ event : React . ChangeEvent < HTMLInputElement > ,
316+ ) => onChange ( event . target . checked ) }
317+ checked = { value }
318+ aria-describedby = "publish_email-help"
319+ label = { intl . formatMessage ( {
320+ id : 'TestListForm.Label.PublishEmail' ,
321+ } ) }
322+ />
323+ < p
324+ id = "publish_email-help"
325+ className = "text-sm text-gray-600 mt-1 ms-7"
326+ >
327+ { intl . formatMessage ( {
328+ id : 'TestListForm.Help.PublishEmail' ,
329+ } ) }
330+ </ p >
331+ </ >
332+ ) }
333+ name = "publish_email"
334+ control = { control }
335+ />
336+ </ StyledInputWrapper >
337+ </ >
304338 ) }
305339
306340 < StyledInputWrapper >
0 commit comments