@@ -28,7 +28,19 @@ interface ValidLabelsResponse {
2828}
2929
3030export const LabelMessagePopup = ( { message, show, onClose } : LabelMessagePopupProps ) => {
31+ return (
32+ < Modal isOpen = { show } onClose = { onClose } >
33+ < ModalOverlay />
34+ < ModalContent >
35+ < LabelMessagePopupContent onClose = { onClose } message = { message } > </ LabelMessagePopupContent >
36+ </ ModalContent >
37+ </ Modal >
38+ ) ;
39+ } ;
40+
41+ const LabelMessagePopupContent = ( { message, onClose } : Omit < LabelMessagePopupProps , "show" > ) => {
3142 const { t } = useTranslation ( ) ;
43+
3244 const { data : response } = useSWRImmutable < ValidLabelsResponse > ( `/api/valid_labels?message_id=${ message . id } ` , get ) ;
3345 const valid_labels = useMemo ( ( ) => response ?. valid_labels ?? [ ] , [ response ] ) ;
3446 const [ values , setValues ] = useState < number [ ] > ( new Array ( valid_labels . length ) . fill ( null ) ) ;
@@ -57,30 +69,27 @@ export const LabelMessagePopup = ({ message, show, onClose }: LabelMessagePopupP
5769 } , [ message . id , onClose , setLabels , valid_labels , values ] ) ;
5870
5971 return (
60- < Modal isOpen = { show } onClose = { onClose } >
61- < ModalOverlay />
62- < ModalContent >
63- < ModalHeader > { t ( "message:label_title" ) } </ ModalHeader >
64- < ModalCloseButton />
65- < ModalBody >
66- < LabelInputGroup
67- labels = { valid_labels }
68- values = { values }
69- instructions = { {
70- yesNoInstruction : t ( "labelling:label_message_yes_no_instruction" ) ,
71- flagInstruction : t ( "labelling:label_message_flag_instruction" ) ,
72- likertInstruction : t ( "labelling:label_message_likert_instruction" ) ,
73- } }
74- expectedLanguage = { message . lang }
75- onChange = { setValues }
76- />
77- </ ModalBody >
78- < ModalFooter >
79- < Button colorScheme = "blue" mr = { 3 } onClick = { submit } >
80- { t ( "message:submit_labels" ) }
81- </ Button >
82- </ ModalFooter >
83- </ ModalContent >
84- </ Modal >
72+ < >
73+ < ModalHeader > { t ( "message:label_title" ) } </ ModalHeader >
74+ < ModalCloseButton />
75+ < ModalBody >
76+ < LabelInputGroup
77+ labels = { valid_labels }
78+ values = { values }
79+ instructions = { {
80+ yesNoInstruction : t ( "labelling:label_message_yes_no_instruction" ) ,
81+ flagInstruction : t ( "labelling:label_message_flag_instruction" ) ,
82+ likertInstruction : t ( "labelling:label_message_likert_instruction" ) ,
83+ } }
84+ expectedLanguage = { message . lang }
85+ onChange = { setValues }
86+ />
87+ </ ModalBody >
88+ < ModalFooter >
89+ < Button colorScheme = "blue" mr = { 3 } onClick = { submit } >
90+ { t ( "message:submit_labels" ) }
91+ </ Button >
92+ </ ModalFooter >
93+ </ >
8594 ) ;
8695} ;
0 commit comments