11import { useFormikContext } from 'formik' ;
22import { Trans , useTranslation } from 'react-i18next' ;
3- import { Button , MD , Span } from '@appquality/unguess-design-system' ;
3+ import { Button , MD , SM , Span } from '@appquality/unguess-design-system' ;
44import { appTheme } from 'src/app/theme' ;
55import styled from 'styled-components' ;
6+ import { VideoTag } from 'src/features/api' ;
7+ import { useMemo } from 'react' ;
68import { InsightFormValues } from './FormProvider' ;
79import { useInsightContext } from './InsightContext' ;
810
@@ -31,6 +33,21 @@ const ActionBar = () => {
3133 useFormikContext < InsightFormValues > ( ) ;
3234 const { isDrawerOpen, setIsDrawerOpen } = useInsightContext ( ) ;
3335
36+ const themesCount = useMemo ( ( ) => {
37+ const tags = values . observations . flatMap ( ( obs ) => obs . tags ) ;
38+ const titles = tags . filter ( ( tag ) => tag . group . name === 'title' ) ;
39+
40+ // Get count of unique titles (tag.name)
41+ const uniqueTitles = titles . reduce ( ( acc , tag ) => {
42+ if ( ! acc . find ( ( _t ) => _t . tag . name === tag . tag . name ) ) {
43+ acc . push ( tag ) ;
44+ }
45+ return acc ;
46+ } , [ ] as VideoTag [ ] ) ;
47+
48+ return uniqueTitles . length ;
49+ } , [ values . observations ] ) ;
50+
3451 // Do not show action bar cta if in editing or creating mode
3552 const hideCta = ( values . id > 0 || values . id === - 1 ) && isDrawerOpen ;
3653
@@ -39,15 +56,26 @@ const ActionBar = () => {
3956 return (
4057 < FloatingContainer >
4158 < Container >
42- < MD style = { { marginRight : appTheme . space . md } } >
43- < Trans
44- count = { values . observations . length }
45- i18nKey = "__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_LABEL"
46- >
47- Selected observations:
48- < Span isBold > { { count : values . observations . length } } </ Span >
49- </ Trans >
50- </ MD >
59+ < div style = { { marginRight : appTheme . space . md } } >
60+ < MD >
61+ < Trans
62+ count = { values . observations . length }
63+ i18nKey = "__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_OBSERVATIONS_LABEL"
64+ >
65+ Selected observations:
66+ < Span isBold > { { observations : values . observations . length } } </ Span >
67+ </ Trans >
68+ </ MD >
69+ < SM style = { { marginTop : appTheme . space . xs } } >
70+ < Trans
71+ count = { values . observations . length }
72+ i18nKey = "__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_THEMES_LABEL"
73+ >
74+ Selected themes:
75+ < Span isBold > { { themes : themesCount } } </ Span >
76+ </ Trans >
77+ </ SM >
78+ </ div >
5179 { ! hideCta && (
5280 < div style = { { marginLeft : appTheme . space . md } } >
5381 < Button
0 commit comments