Skip to content

Commit 32d5847

Browse files
authored
Merge pull request #246 from AppQuality/develop
Pull Request triggered from POEditor
2 parents 64aef35 + 52ba5dc commit 32d5847

File tree

14 files changed

+360
-327
lines changed

14 files changed

+360
-327
lines changed

src/common/GoogleTagManager.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { useEffect } from 'react';
22
import TagManager from 'react-gtm-module';
33
import { Helmet } from 'react-helmet';
44
import { useAppSelector } from 'src/app/hooks';
@@ -32,18 +32,21 @@ export const GoogleTagManager = ({
3232
</Helmet>
3333
);
3434

35-
if (userData?.role && userData?.tryber_wp_user_id) {
36-
tagManagerArgs.dataLayer = {
37-
role: userData.role,
38-
wp_user_id: userData.tryber_wp_user_id,
39-
tester_id: userData.id,
40-
name: userData.name,
41-
email: userData.email,
42-
company: activeWorkspace?.company || 'unknown',
43-
};
44-
}
35+
useEffect(() => {
36+
if (userData?.role && userData?.tryber_wp_user_id) {
37+
tagManagerArgs.dataLayer = {
38+
role: userData.role,
39+
wp_user_id: userData.tryber_wp_user_id,
40+
tester_id: userData.id,
41+
name: userData.name,
42+
email: userData.email,
43+
company: activeWorkspace?.company || 'unknown',
44+
};
45+
}
46+
47+
TagManager.dataLayer(tagManagerArgs);
48+
}, [userData, activeWorkspace]);
4549

46-
TagManager.dataLayer(tagManagerArgs);
4750
return (
4851
<>
4952
{helmet()}

src/common/Pages.tsx

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,34 @@
1-
import { Navigate, Route, Routes, useLocation } from 'react-router-dom';
2-
import TagManager from 'react-gtm-module';
1+
import { Navigate, Route, Routes } from 'react-router-dom';
32
import LoginPage from 'src/pages/LoginPage';
43
import Dashboard from 'src/pages/Dashboard';
54
import Project from 'src/pages/Dashboard/Project';
65
import NotFound from 'src/pages/NotFound';
76
import Catalog from 'src/pages/Services';
87
import Service from 'src/pages/Service';
9-
import { useEffect } from 'react';
108
import Campaign from 'src/pages/Campaign';
119

1210
const base = ':locale';
1311

14-
const Pages = () => {
15-
const location = useLocation();
12+
const Pages = () => (
13+
<Routes>
14+
<Route path={`${base}/login`} element={<LoginPage />} />
15+
<Route path="/login" element={<LoginPage />} />
16+
<Route path="/" element={<Dashboard />} />
17+
<Route path="/it" element={<Dashboard />} />
18+
<Route path="/projects/:projectId" element={<Project />} />
19+
<Route path="/it/projects/:projectId" element={<Project />} />
20+
<Route path="/campaigns/:campaignId" element={<Campaign />} />
21+
<Route path="/it/campaigns/:campaignId" element={<Campaign />} />
22+
<Route path="/services" element={<Catalog />} />
23+
<Route path="/it/services" element={<Catalog />} />
24+
<Route path="/services/:templateId" element={<Service />} />
25+
<Route path="/it/services/:templateId" element={<Service />} />
1626

17-
const trackPageView = (pathName: string) => {
18-
TagManager.dataLayer({
19-
dataLayer: {
20-
event: 'pageview',
21-
path: pathName,
22-
},
23-
});
24-
};
25-
26-
// useEffect(() => {
27-
// trackPageView(location.pathname);
28-
// }, [location]);
29-
30-
return (
31-
<Routes>
32-
<Route path={`${base}/login`} element={<LoginPage />} />
33-
<Route path="/login" element={<LoginPage />} />
34-
<Route path="/" element={<Dashboard />} />
35-
<Route path="/it" element={<Dashboard />} />
36-
<Route path="/projects/:projectId" element={<Project />} />
37-
<Route path="/it/projects/:projectId" element={<Project />} />
38-
<Route path="/campaigns/:campaignId" element={<Campaign />} />
39-
<Route path="/it/campaigns/:campaignId" element={<Campaign />} />
40-
<Route path="/services" element={<Catalog />} />
41-
<Route path="/it/services" element={<Catalog />} />
42-
<Route path="/services/:templateId" element={<Service />} />
43-
<Route path="/it/services/:templateId" element={<Service />} />
44-
45-
{/* No route found */}
46-
<Route path="/oops" element={<NotFound />} />
47-
<Route path=":language/oops" element={<NotFound />} />
48-
<Route path="*" element={<Navigate replace to="/oops" />} />
49-
</Routes>
50-
);
51-
};
27+
{/* No route found */}
28+
<Route path="/oops" element={<NotFound />} />
29+
<Route path=":language/oops" element={<NotFound />} />
30+
<Route path="*" element={<Navigate replace to="/oops" />} />
31+
</Routes>
32+
);
5233

5334
export default Pages;

src/hooks/useLocalizeDashboardUrl.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,21 @@ export function getLocalizeDashboardRoute(props: CampaignActionProps): string {
2828
} else if (cpFamily.toLocaleLowerCase() === 'functional') {
2929
localizedRoute =
3030
currentLang === 'en'
31-
? `/functional-customer-dashboard/?cid=${campaignId}`
32-
: `it/dashboard-campagne-funzionali/?cid=${campaignId}`;
31+
? `${
32+
process.env.REACT_APP_CROWD_WP_URL ?? ''
33+
}/functional-customer-dashboard/?cid=${campaignId}`
34+
: `${
35+
process.env.REACT_APP_CROWD_WP_URL ?? ''
36+
}/it/dashboard-campagne-funzionali/?cid=${campaignId}`;
3337
} else {
3438
localizedRoute =
3539
currentLang === 'en'
36-
? `/ux-customer-dashboard/?cid=${campaignId}`
37-
: `it/dashboard-campagne-esperienziali/?cid=${campaignId}`;
40+
? `${
41+
process.env.REACT_APP_CROWD_WP_URL ?? ''
42+
}/ux-customer-dashboard/?cid=${campaignId}`
43+
: `${
44+
process.env.REACT_APP_CROWD_WP_URL ?? ''
45+
}/it/dashboard-campagne-esperienziali/?cid=${campaignId}`;
3846
}
3947

4048
// in case of base route ("") we already have a forward slash

src/locales/en/translation.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@
200200
"__EXPRESS_WIZARD_STEP_RECAP_OUT_OF_SCOPE_PLACEHOLDER": "Insert any sections that do not fit within the perimeter of the test.",
201201
"__EXPRESS_WIZARD_STEP_RECAP_TITLE": "Summary and launch",
202202
"__EXPRESS_WIZARD_STEP_RECAP_WHAT_CONTENT_TEXT": "You are launching the campaign <1><0>{{campaign_name}}</0></1> in the project <3><0>{{project_name}}</0></3> for a <5><0>{{product_type}}</0></5>.",
203-
"__EXPRESS_WIZARD_STEP_RECAP_WHEN_CONTENT_TEXT": "Campaign starts on <1><0>{{campaign_date}}</0></1> and ends on <3><0>{{campaign_date_end}}</0></3>.",
204203
"__EXPRESS_WIZARD_STEP_RECAP_WHERE_CONTENT_TEXT_BROWSERS": "On the following browsers:",
205204
"__EXPRESS_WIZARD_STEP_RECAP_WHERE_CONTENT_TEXT_BROWSERS_EMPTY": "You didn't select any browser.",
206205
"__EXPRESS_WIZARD_STEP_RECAP_WHERE_CONTENT_TEXT_DEVICES": "The test will be executed on:",
@@ -233,7 +232,6 @@
233232
"__EXPRESS_WIZARD_STEP_WHEN_FIELD_CAMPAIGN_DATE_RESULTS_LABEL": "Results delivery date",
234233
"__EXPRESS_WIZARD_STEP_WHEN_FIELD_CAMPAIGN_DATE_RESULTS_PLACEHOLDER": "Delivery date",
235234
"__EXPRESS_WIZARD_STEP_WHEN_FIELD_CAMPAIGN_DATE_TODAY_LABEL": "Today",
236-
"__EXPRESS_WIZARD_STEP_WHEN_LABEL": "When",
237235
"__EXPRESS_WIZARD_STEP_WHERE_ANDROID_LINK_DESCRIPTION": "Insert the link to the Android app",
238236
"__EXPRESS_WIZARD_STEP_WHERE_ANDROID_LINK_ERROR": "Please provide a valid URL",
239237
"__EXPRESS_WIZARD_STEP_WHERE_ANDROID_LINK_INFO": "Be sure the link is publicly accessible",

src/locales/it/translation.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@
200200
"__EXPRESS_WIZARD_STEP_RECAP_OUT_OF_SCOPE_PLACEHOLDER": "Indica eventuali sezioni che non rientrano nel perimetro del test.",
201201
"__EXPRESS_WIZARD_STEP_RECAP_TITLE": "Recap e lancio",
202202
"__EXPRESS_WIZARD_STEP_RECAP_WHAT_CONTENT_TEXT": "Stai lanciando la campagna <1><0>{{campaign_name}}</0></1> all'interno del progetto <3><0>{{project_name}}</0></3> per <5><0>{{product_type}}</0></5>.",
203-
"__EXPRESS_WIZARD_STEP_RECAP_WHEN_CONTENT_TEXT": "La campagna parte il <1><0>{{campaign_date}}</0></1> e finisce il <3><0>{{campaign_date_end}}</0></3>.",
204203
"__EXPRESS_WIZARD_STEP_RECAP_WHERE_CONTENT_TEXT_BROWSERS": "Sui browser:",
205204
"__EXPRESS_WIZARD_STEP_RECAP_WHERE_CONTENT_TEXT_BROWSERS_EMPTY": "Non hai selezionato alcun browser.",
206205
"__EXPRESS_WIZARD_STEP_RECAP_WHERE_CONTENT_TEXT_DEVICES": "Il test verrà eseguito su:",
@@ -233,7 +232,6 @@
233232
"__EXPRESS_WIZARD_STEP_WHEN_FIELD_CAMPAIGN_DATE_RESULTS_LABEL": "Data di consegna risultati",
234233
"__EXPRESS_WIZARD_STEP_WHEN_FIELD_CAMPAIGN_DATE_RESULTS_PLACEHOLDER": "Data di consegna",
235234
"__EXPRESS_WIZARD_STEP_WHEN_FIELD_CAMPAIGN_DATE_TODAY_LABEL": "Oggi",
236-
"__EXPRESS_WIZARD_STEP_WHEN_LABEL": "Quando",
237235
"__EXPRESS_WIZARD_STEP_WHERE_ANDROID_LINK_DESCRIPTION": "Inserisci un link ad una pagina web o di Google Play",
238236
"__EXPRESS_WIZARD_STEP_WHERE_ANDROID_LINK_ERROR": "Per favore inserisci un link valido",
239237
"__EXPRESS_WIZARD_STEP_WHERE_ANDROID_LINK_INFO": "Accertati che il link sia pubblico",

src/pages/Campaign/ReportRow.tsx

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
import {
2+
Col,
3+
Row,
4+
SpecialCard,
5+
Button,
6+
theme,
7+
XL,
8+
Paragraph,
9+
} from '@appquality/unguess-design-system';
10+
import { ReactComponent as ArchiveIcon } from 'src/assets/icons/file-icon-archive.svg';
11+
import { ReactComponent as BoardIcon } from 'src/assets/icons/file-icon-board.svg';
12+
import { ReactComponent as DocumentIcon } from 'src/assets/icons/file-icon-document.svg';
13+
import { ReactComponent as DriveIcon } from 'src/assets/icons/file-icon-drive.svg';
14+
import { ReactComponent as ExcelIcon } from 'src/assets/icons/file-icon-excel.svg';
15+
import { ReactComponent as LinkIcon } from 'src/assets/icons/file-icon-link.svg';
16+
import { ReactComponent as PdfIcon } from 'src/assets/icons/file-icon-pdf.svg';
17+
import { ReactComponent as PresentationIcon } from 'src/assets/icons/file-icon-presentation.svg';
18+
import { ReactComponent as DownloadIcon } from 'src/assets/icons/download-stroke.svg';
19+
import { ReactComponent as OpenLinkIcon } from 'src/assets/icons/new-window-stroke.svg';
20+
import { ReactComponent as EmptyReportsImage } from 'src/assets/emptyReports.svg';
21+
import { Report } from 'src/features/api';
22+
import { format } from 'date-fns';
23+
import { t } from 'i18next';
24+
import styled from 'styled-components';
25+
26+
const CenteredContent = styled.div`
27+
display: flex;
28+
justify-content: center;
29+
align-items: center;
30+
flex-direction: column;
31+
height: 100%;
32+
width: 100%;
33+
`;
34+
35+
const getFileTypeName = (type: string, url: string) => {
36+
const urlHostname = new URL(url).hostname;
37+
38+
switch (type) {
39+
case 'spreadsheet':
40+
return t('__CAMPAIGN_PAGE_REPORTS_FILE_TYPE_EXCEL');
41+
case 'pdf':
42+
return t('__CAMPAIGN_PAGE_REPORTS_FILE_TYPE_PDF');
43+
case 'text':
44+
case 'document':
45+
return t('__CAMPAIGN_PAGE_REPORTS_FILE_TYPE_DOCUMENT');
46+
case 'presentation':
47+
return t('__CAMPAIGN_PAGE_REPORTS_FILE_TYPE_PRESENTATION');
48+
case 'archive':
49+
return t('__CAMPAIGN_PAGE_REPORTS_FILE_TYPE_ARCHIVE');
50+
case 'link':
51+
// Check url to see if is a recognized domain
52+
if (urlHostname.includes('miro.com'))
53+
return t('__CAMPAIGN_PAGE_REPORTS_FILE_TYPE_BOARD');
54+
if (urlHostname.includes('drive.google.com'))
55+
return t('__CAMPAIGN_PAGE_REPORTS_FILE_TYPE_DRIVE');
56+
return t('__CAMPAIGN_PAGE_REPORTS_FILE_TYPE_LINK');
57+
default:
58+
return t('__CAMPAIGN_PAGE_REPORTS_FILE_TYPE_LINK');
59+
}
60+
};
61+
62+
const getFileTypeIcon = (type: string, url: string) => {
63+
const urlHostname = new URL(url).hostname;
64+
65+
switch (type) {
66+
case 'spreadsheet':
67+
return <ExcelIcon />;
68+
case 'pdf':
69+
return <PdfIcon />;
70+
case 'text':
71+
case 'document':
72+
return <DocumentIcon />;
73+
case 'presentation':
74+
return <PresentationIcon />;
75+
case 'archive':
76+
return <ArchiveIcon />;
77+
case 'link':
78+
// Check url to see if is a recognized domain
79+
if (urlHostname.includes('miro.com')) return <BoardIcon />;
80+
if (urlHostname.includes('drive.google.com')) return <DriveIcon />;
81+
return <LinkIcon />;
82+
default:
83+
return <LinkIcon />;
84+
}
85+
};
86+
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>
109+
110+
<SpecialCard.Thumb>
111+
{getFileTypeIcon(report.file_type?.type ?? '', report.url)}
112+
</SpecialCard.Thumb>
113+
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>
122+
123+
<SpecialCard.Footer direction="column" justifyContent="center">
124+
<Button
125+
isPill
126+
isStretched
127+
onClick={() => {
128+
// eslint-disable-next-line security/detect-non-literal-fs-filename
129+
window.open(report.url || '', '_blank');
130+
}}
131+
>
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')}
142+
</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+
);

0 commit comments

Comments
 (0)