@@ -19,6 +19,7 @@ import { useParams } from 'react-router-dom';
1919import {
2020 GetCampaignsByCidVideoTagsApiResponse ,
2121 GetVideosByVidObservationsApiResponse ,
22+ Paragraph ,
2223 useGetCampaignsByCidVideoTagsQuery ,
2324 usePatchVideosByVidObservationsAndOidMutation ,
2425 usePostCampaignsByCidVideoTagsMutation ,
@@ -53,14 +54,13 @@ const RadioTag = styled(Tag)<{
5354 user-select: none;
5455 }
5556` ;
56-
5757const ObservationForm = ( {
5858 observation,
59- quots ,
59+ paragraphs ,
6060 onSubmit,
6161} : {
6262 observation : GetVideosByVidObservationsApiResponse [ number ] ;
63- quots ?: string ;
63+ paragraphs ?: Paragraph [ ] ;
6464 onSubmit : (
6565 values : ObservationFormValues ,
6666 actions : FormikHelpers < ObservationFormValues >
@@ -145,6 +145,18 @@ const ObservationForm = ({
145145 }
146146 } , [ tags , selectedOptions ] ) ;
147147
148+ function generateQuotes ( ) {
149+ if ( ! paragraphs ) return undefined ;
150+ return paragraphs
151+ . flatMap ( ( paragraph ) =>
152+ paragraph . words . filter (
153+ ( w ) => w . start >= observation . start && w . end <= observation . end
154+ )
155+ )
156+ . map ( ( w ) => w . word )
157+ . join ( ' ' ) ;
158+ }
159+
148160 const formInitialValues = {
149161 title :
150162 observation ?. tags ?. find ( ( tag ) => tag . group . name . toLowerCase ( ) === 'title' )
@@ -154,6 +166,7 @@ const ObservationForm = ({
154166 ( tag ) => tag . group . name . toLowerCase ( ) === 'severity'
155167 ) ?. tag . id || 0 ,
156168 notes : observation ?. description || '' ,
169+ quotes : observation ?. quotes || generateQuotes ( ) || '' ,
157170 } ;
158171
159172 const onSubmitPatch = async (
@@ -166,6 +179,7 @@ const ObservationForm = ({
166179 oid : observation . id . toString ( ) ,
167180 body : {
168181 description : values . notes ,
182+ quotes : values . quotes ,
169183 start : observation . start ,
170184 end : observation . end ,
171185 tags : [
@@ -376,22 +390,17 @@ const ObservationForm = ({
376390 />
377391 ) }
378392 </ div >
379- { quots && (
380- < div style = { { marginTop : appTheme . space . md } } >
381- < StyledLabel >
382- { t (
383- '__VIDEO_PAGE_ACTIONS_OBSERVATION_FORM_FIELD_QUOTS_LABEL'
384- ) }
385- </ StyledLabel >
386- < Textarea
387- readOnly
388- disabled
389- style = { { margin : 0 } }
390- value = { quots }
391- rows = { 4 }
392- />
393- </ div >
394- ) }
393+
394+ < div style = { { marginTop : appTheme . space . md } } >
395+ < StyledLabel >
396+ { t ( '__VIDEO_PAGE_ACTIONS_OBSERVATION_FORM_FIELD_QUOTS_LABEL' ) }
397+ </ StyledLabel >
398+ < Textarea
399+ style = { { margin : 0 } }
400+ { ...formProps . getFieldProps ( 'quotes' ) }
401+ rows = { 4 }
402+ />
403+ </ div >
395404 < div style = { { marginTop : appTheme . space . md } } >
396405 < StyledLabel >
397406 { t ( '__VIDEO_PAGE_ACTIONS_OBSERVATION_FORM_FIELD_NOTES_LABEL' ) }
0 commit comments