Skip to content

Commit e2373a5

Browse files
authored
Merge pull request #861 from AppQuality/UTT-34-quotes
Utt 34 quotes
2 parents 0308f8a + c1ee990 commit e2373a5

File tree

5 files changed

+34
-29
lines changed

5 files changed

+34
-29
lines changed

src/common/schema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,7 @@ export interface components {
759759
/** Format: float */
760760
end: number;
761761
tags: components['schemas']['VideoTag'][];
762+
quotes: string;
762763
};
763764
/**
764765
* Output
@@ -2775,6 +2776,7 @@ export interface operations {
27752776
start?: number;
27762777
/** Format: float */
27772778
end?: number;
2779+
quotes?: string;
27782780
tags?: number[];
27792781
};
27802782
};

src/features/api/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,7 @@ export type PatchVideosByVidObservationsAndOidApiArg = {
13891389
description?: string;
13901390
start?: number;
13911391
end?: number;
1392+
quotes?: string;
13921393
tags?: number[];
13931394
};
13941395
};
@@ -1810,6 +1811,7 @@ export type Observation = {
18101811
start: number;
18111812
end: number;
18121813
tags: VideoTag[];
1814+
quotes: string;
18131815
};
18141816
export type Insight = {
18151817
id: number;

src/pages/Video/components/Observation.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,6 @@ const Observation = ({
6363
const title = tags.find((tag) => tag.group.name.toLowerCase() === 'title')
6464
?.tag.name;
6565

66-
const quots = transcript?.paragraphs
67-
.flatMap((paragraph) =>
68-
paragraph.words.filter(
69-
(w) => w.start >= observation.start && w.end <= observation.end
70-
)
71-
)
72-
.map((w) => w.word)
73-
.join(' ');
74-
7566
const handleAccordionChange = () => {
7667
setIsOpen(!isOpen);
7768
if (!isOpen) {
@@ -237,7 +228,7 @@ const Observation = ({
237228
<ObservationForm
238229
observation={observation}
239230
onSubmit={handleSubmit}
240-
{...(quots && { quots })}
231+
paragraphs={transcript?.paragraphs}
241232
/>
242233
</Accordion.Panel>
243234
</Accordion.Section>

src/pages/Video/components/ObservationForm.tsx

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { useParams } from 'react-router-dom';
1919
import {
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-
5757
const 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')}

src/pages/Video/components/TitleDropdown.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface ObservationFormValues {
2525
title: number;
2626
severity: number;
2727
notes: string;
28+
quotes?: string;
2829
}
2930

3031
export const TitleDropdown = ({

0 commit comments

Comments
 (0)