-
{title}
- {subtitle &&
{subtitle}
}
+const Header = ({
+ title, subtitle, startDate, endDate, isDownloadCSV, activeTab, granularity, calculation, chartType, enterpriseId,
+}) => (
+
+
+
{title}
+ {subtitle &&
{subtitle}
}
+
+ {isDownloadCSV && (
+
+
+
+ )}
);
Header.defaultProps = {
subtitle: undefined,
+ isDownloadCSV: false,
+ granularity: 'Daily',
+ calculation: 'Total',
+ chartType: '',
};
Header.propTypes = {
title: PropTypes.string.isRequired,
subtitle: PropTypes.string,
+ isDownloadCSV: PropTypes.bool,
+ startDate: PropTypes.string.isRequired,
+ endDate: PropTypes.string.isRequired,
+ activeTab: PropTypes.string.isRequired,
+ enterpriseId: PropTypes.string.isRequired,
+ chartType: PropTypes.string,
+ granularity: PropTypes.string,
+ calculation: PropTypes.string,
};
export default Header;
diff --git a/src/components/AdvanceAnalyticsV2/data/constants.js b/src/components/AdvanceAnalyticsV2/data/constants.js
new file mode 100644
index 0000000000..1e591db955
--- /dev/null
+++ b/src/components/AdvanceAnalyticsV2/data/constants.js
@@ -0,0 +1,35 @@
+export const advancedAnalyticsV2QueryKeys = {
+ chartCSV: (enterpriseId, chartName) => [...advancedAnalyticsV2QueryKeys.all, 'chartCSV', enterpriseId, chartName],
+};
+
+export const CHART_TYPES = {
+ // Charts types for Skills tab
+ BUBBLE: 'bubble',
+ TOP_SKILLS_ENROLLMENT: 'top_skills_enrollment',
+ TOP_SKILLS_COMPLETION: 'top_skills_completion',
+
+ // Charts types for Completions tab
+ COMPLETIONS_OVER_TIME: 'completions_over_time',
+ TOP_COURSES_BY_COMPLETIONS: 'top_courses_by_completions',
+ TOP_SUBJECTS_BY_COMPLETIONS: 'top_subjects_by_completions',
+
+ // Charts types for Enrollments tab
+ ENROLLMENTS_OVER_TIME: 'enrollments_over_time',
+ TOP_COURSES_BY_ENROLLMENTS: 'top_courses_by_enrollments',
+ TOP_SUBJECTS_BY_ENROLLMENTS: 'top_subjects_by_enrollments',
+ INDIVIDUAL_ENROLLMENTS: 'individual_enrollments',
+
+ // Charts types for Engagements tab
+ ENGAGEMENTS_OVER_TIME: 'engagements_over_time',
+ TOP_COURSES_BY_ENGAGEMENTS: 'top_courses_by_engagements',
+ TOP_SUBJECTS_BY_ENGAGEMENTS: 'top_subjects_by_engagements',
+ INDIVIDUAL_ENGAGEMENTS: 'individual_engagements',
+};
+
+export const ANALYTICS_TABS = {
+ SKILLS: 'skills',
+ COMPLETIONS: 'completions',
+ ENROLLMENTS: 'enrollments',
+ LEADERBOARD: 'leaderboard',
+ ENGAGEMENTS: 'engagements',
+};
diff --git a/src/components/AdvanceAnalyticsV2/data/utils.js b/src/components/AdvanceAnalyticsV2/data/utils.js
new file mode 100644
index 0000000000..d7bfb0250d
--- /dev/null
+++ b/src/components/AdvanceAnalyticsV2/data/utils.js
@@ -0,0 +1,10 @@
+import { CHART_TYPES } from './constants';
+
+const simulateURL = (activeTab, chartType) => {
+ if (!Object.values(CHART_TYPES).includes(chartType)) {
+ return activeTab;
+ }
+ return `${activeTab}/stats`;
+};
+
+export default simulateURL;
diff --git a/src/components/AdvanceAnalyticsV2/tabs/Completions.jsx b/src/components/AdvanceAnalyticsV2/tabs/Completions.jsx
index d672e0e103..4d68d74a58 100644
--- a/src/components/AdvanceAnalyticsV2/tabs/Completions.jsx
+++ b/src/components/AdvanceAnalyticsV2/tabs/Completions.jsx
@@ -1,9 +1,13 @@
import React from 'react';
import { useIntl } from '@edx/frontend-platform/i18n';
+import PropTypes from 'prop-types';
import EmptyChart from '../charts/EmptyChart';
import Header from '../Header';
+import { ANALYTICS_TABS, CHART_TYPES } from '../data/constants';
-const Completions = () => {
+const Completions = ({
+ startDate, endDate, granularity, calculation, enterpriseId,
+}) => {
const intl = useIntl();
return (
@@ -20,6 +24,14 @@ const Completions = () => {
defaultMessage: 'See the course completions that result in a passing grade over time.',
description: 'Subtitle for the completions over time chart.',
})}
+ startDate={startDate}
+ endDate={endDate}
+ activeTab={ANALYTICS_TABS.COMPLETIONS}
+ granularity={granularity}
+ calculation={calculation}
+ chartType={CHART_TYPES.COMPLETIONS_OVER_TIME}
+ enterpriseId={enterpriseId}
+ isDownloadCSV
/>
@@ -35,6 +47,14 @@ const Completions = () => {
defaultMessage: 'See the courses in which your learners are most often achieving a passing grade.',
description: 'Subtitle for the top 10 courses by completions chart.',
})}
+ startDate={startDate}
+ endDate={endDate}
+ activeTab={ANALYTICS_TABS.COMPLETIONS}
+ granularity={granularity}
+ calculation={calculation}
+ chartType={CHART_TYPES.TOP_COURSES_BY_COMPLETIONS}
+ enterpriseId={enterpriseId}
+ isDownloadCSV
/>