@@ -18,10 +18,11 @@ import { ReactComponent as PresentationIcon } from 'src/assets/icons/file-icon-p
1818import { ReactComponent as DownloadIcon } from 'src/assets/icons/download-stroke.svg' ;
1919import { ReactComponent as OpenLinkIcon } from 'src/assets/icons/new-window-stroke.svg' ;
2020import { ReactComponent as EmptyReportsImage } from 'src/assets/emptyReports.svg' ;
21- import { Report } from 'src/features/api' ;
21+ import { Campaign , Report } from 'src/features/api' ;
2222import { format } from 'date-fns' ;
2323import { t } from 'i18next' ;
2424import styled from 'styled-components' ;
25+ import { getLocalizeIntegrationCenterRoute } from 'src/hooks/useLocalizeIntegrationCenterUrl' ;
2526
2627const CenteredContent = styled . div `
2728 display: flex;
@@ -84,81 +85,110 @@ const getFileTypeIcon = (type: string, url: string) => {
8485 }
8586} ;
8687
87- export const ReportRow = ( { reports } : { reports ?: Report [ ] } ) => (
88- < Row >
89- { reports && reports . length ? (
90- reports . map ( ( report ) => (
91- < Col xs = { 12 } md = { 4 } lg = { 3 } >
92- < SpecialCard >
93- < SpecialCard . Meta
94- justifyContent = "start"
95- style = { { fontSize : theme . fontSizes . sm } }
96- >
97- { report . update_date ? (
98- < >
99- { t ( '__CAMPAIGN_PAGE_REPORTS_CARDS_UPDATED_ON_LABEL' ) } { ' ' }
100- { format ( new Date ( report . update_date ) , 'dd/MM/yyyy' ) }
101- </ >
102- ) : (
103- < >
104- { t ( '__CAMPAIGN_PAGE_REPORTS_CARDS_UPLOADED_ON_LABEL' ) } { ' ' }
105- { format ( new Date ( report . creation_date ?? '' ) , 'dd/MM/yyyy' ) }
106- </ >
107- ) }
108- </ SpecialCard . Meta >
88+ export const ReportRow = ( {
89+ reports,
90+ campaign,
91+ } : {
92+ reports ?: Report [ ] ;
93+ campaign : Campaign ;
94+ } ) => {
95+ const { id : campaignId , family } = campaign ;
96+ const { name : cpFamily } = family ;
10997
110- < SpecialCard . Thumb >
111- { getFileTypeIcon ( report . file_type ?. type ?? '' , report . url ) }
112- </ SpecialCard . Thumb >
98+ return (
99+ < Row >
100+ { reports && reports . length ? (
101+ reports . map ( ( report ) => (
102+ < Col xs = { 12 } md = { 4 } lg = { 3 } >
103+ < SpecialCard >
104+ < SpecialCard . Meta
105+ justifyContent = "start"
106+ style = { { fontSize : theme . fontSizes . sm } }
107+ >
108+ { report . update_date ? (
109+ < >
110+ { t ( '__CAMPAIGN_PAGE_REPORTS_CARDS_UPDATED_ON_LABEL' ) } { ' ' }
111+ { format ( new Date ( report . update_date ) , 'dd/MM/yyyy' ) }
112+ </ >
113+ ) : (
114+ < >
115+ { t ( '__CAMPAIGN_PAGE_REPORTS_CARDS_UPLOADED_ON_LABEL' ) } { ' ' }
116+ { format ( new Date ( report . creation_date ?? '' ) , 'dd/MM/yyyy' ) }
117+ </ >
118+ ) }
119+ </ SpecialCard . Meta >
120+
121+ < SpecialCard . Thumb >
122+ { getFileTypeIcon ( report . file_type ?. type ?? '' , report . url ) }
123+ </ SpecialCard . Thumb >
113124
114- < SpecialCard . Header >
115- < SpecialCard . Header . Label >
116- { getFileTypeName ( report . file_type ?. type ?? '' , report . url ) }
117- </ SpecialCard . Header . Label >
118- < SpecialCard . Header . Title >
119- { report . title }
120- </ SpecialCard . Header . Title >
121- </ SpecialCard . Header >
125+ < SpecialCard . Header >
126+ < SpecialCard . Header . Label >
127+ { getFileTypeName ( report . file_type ?. type ?? '' , report . url ) }
128+ </ SpecialCard . Header . Label >
129+ < SpecialCard . Header . Title >
130+ { report . title }
131+ </ SpecialCard . Header . Title >
132+ </ SpecialCard . Header >
122133
123- < SpecialCard . Footer direction = "column" justifyContent = "center" >
134+ < SpecialCard . Footer direction = "column" justifyContent = "center" >
135+ < Button
136+ isPill
137+ isStretched
138+ onClick = { ( ) => {
139+ // eslint-disable-next-line security/detect-non-literal-fs-filename
140+ window . open ( report . url || '' , '_blank' ) ;
141+ } }
142+ >
143+ < Button . StartIcon >
144+ { report . file_type ?. type === 'link' ? (
145+ < OpenLinkIcon />
146+ ) : (
147+ < DownloadIcon />
148+ ) }
149+ </ Button . StartIcon >
150+ { report . file_type ?. type === 'link'
151+ ? t ( '__CAMPAIGN_PAGE_REPORTS_CARDS_OPEN_LINK_LABEL' )
152+ : t ( '__CAMPAIGN_PAGE_REPORTS_CARDS_DOWNLOAD_LABEL' ) }
153+ </ Button >
154+ </ SpecialCard . Footer >
155+ </ SpecialCard >
156+ </ Col >
157+ ) )
158+ ) : (
159+ < CenteredContent >
160+ < EmptyReportsImage />
161+ < XL
162+ style = { {
163+ fontWeight : theme . fontWeights . medium ,
164+ marginTop : theme . space . xl ,
165+ marginBottom : theme . space . sm ,
166+ } }
167+ >
168+ { t ( '__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_TITLE' ) }
169+ </ XL >
170+ < Paragraph style = { { textAlign : 'center' } } >
171+ { t ( '__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_TEXT' ) }
172+ </ Paragraph >
173+ { cpFamily . toLocaleLowerCase ( ) === 'functional' ? (
174+ < >
175+ < Paragraph style = { { textAlign : 'center' } } >
176+ { t ( '__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_INTEGRATIONS_TEXT' ) }
177+ </ Paragraph >
124178 < Button
125179 isPill
126- isStretched
127180 onClick = { ( ) => {
128- // eslint-disable-next-line security/detect-non-literal-fs-filename
129- window . open ( report . url || '' , '_blank' ) ;
181+ window . location . href =
182+ getLocalizeIntegrationCenterRoute ( campaignId ) ;
130183 } }
184+ style = { { marginTop : theme . space . md } }
131185 >
132- < Button . StartIcon >
133- { report . file_type ?. type === 'link' ? (
134- < OpenLinkIcon />
135- ) : (
136- < DownloadIcon />
137- ) }
138- </ Button . StartIcon >
139- { report . file_type ?. type === 'link'
140- ? t ( '__CAMPAIGN_PAGE_REPORTS_CARDS_OPEN_LINK_LABEL' )
141- : t ( '__CAMPAIGN_PAGE_REPORTS_CARDS_DOWNLOAD_LABEL' ) }
186+ { t ( '__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_INTEGRATIONS_BUTTON' ) }
142187 </ Button >
143- </ SpecialCard . Footer >
144- </ SpecialCard >
145- </ Col >
146- ) )
147- ) : (
148- < CenteredContent >
149- < EmptyReportsImage />
150- < XL
151- style = { {
152- fontWeight : theme . fontWeights . medium ,
153- marginBottom : theme . space . sm ,
154- } }
155- >
156- { t ( '__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_TITLE' ) }
157- </ XL >
158- < Paragraph style = { { textAlign : 'center' } } >
159- { t ( '__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_TEXT' ) }
160- </ Paragraph >
161- </ CenteredContent >
162- ) }
163- </ Row >
164- ) ;
188+ </ >
189+ ) : null }
190+ </ CenteredContent >
191+ ) }
192+ </ Row >
193+ ) ;
194+ } ;
0 commit comments