diff --git a/src/api/projectReports.js b/src/api/projectReports.js deleted file mode 100644 index 9ccb0411c..000000000 --- a/src/api/projectReports.js +++ /dev/null @@ -1,63 +0,0 @@ -import _ from 'lodash' -import { axiosInstance as axios } from './requestInterceptor' -import { PROJECTS_API_URL } from '../config/constants' - -/** - * Get a project summary - * - * @param {integer} projectId unique identifier of the project - */ -export function getProjectSummary(projectId) { - - const summaryPromise = axios.get(`${PROJECTS_API_URL}/v5/projects/${projectId}/reports?reportName=summary`) - const budgetPromise = axios.get(`${PROJECTS_API_URL}/v5/projects/${projectId}/reports?reportName=projectBudget`) - - return Promise.all([summaryPromise, budgetPromise]).then(responses => { - const res = responses[0].data - const designMetrics = _.find(res, c => c['challenge.track'] === 'Design') || {} - const totalRegistrants = _.sumBy(res, c => c['challenge.num_registrations']) - - const res1 = responses[1].data - const filterReport = c => `${c['project_stream.tc_connect_project_id']}` === projectId.toString() - const projectBudget = _.find(res1, filterReport) || {} - - return { - projectId, - budget: { - work: parseFloat(projectBudget['project_stream.total_actual_member_payment'] || 0), - fees: parseFloat(projectBudget['project_stream.total_actual_challenge_fee'] || 0), - revenue: parseFloat(projectBudget['project_stream.total_invoiced_amount'] || 0), - remaining: parseFloat(projectBudget['project_stream.remaining_invoiced_budget'] || 0) - }, - // null values will be filled in as back-end implementation/integration is done. - topcoderDifference: { - countries: null, - registrants: totalRegistrants, - designs: designMetrics['challenge.num_submissions'], - linesOfCode: null, - hoursSaved: null, - costSavings: null, - valueCreated: null, - } - } - }) -} - -/** - * Gets signed URL for embeding the requested report. - * @param {*} projectId id of the project for which report is to be fecthed - * @param {*} reportName unique name of the report - */ -export function getProjectReportUrl(projectId, reportName) { - return axios.get(`${PROJECTS_API_URL}/v5/projects/${projectId}/reports/embed?reportName=${reportName}`) - .then(resp => resp.data) -} - -/** - * Gets signed URL for embeding the requested report. - * @param {*} reportName unique name of the report - */ -export function getUserReportUrl(reportName) { - return axios.get(`${PROJECTS_API_URL}/v5/projects/reports/embed?reportName=${reportName}`) - .then(resp => resp.data) -} \ No newline at end of file diff --git a/src/config/constants.js b/src/config/constants.js index 420aeda9f..9d26ae45a 100644 --- a/src/config/constants.js +++ b/src/config/constants.js @@ -462,19 +462,6 @@ export const UPDATE_PROJECT_ATTACHMENT_FAILURE = 'UPDATE_PROJECT_ATTACHMENT_FAIL export const REMOVE_PENDING_ATTACHMENT = 'REMOVE_PENDING_ATTACHMENT' export const UPDATE_PENDING_ATTACHMENT = 'UPDATE_PENDING_ATTACHMENT' -// Project summary -export const LOAD_PROJECT_SUMMARY = 'LOAD_PROJECT_SUMMARY' -export const LOAD_PROJECT_SUMMARY_PENDING = 'LOAD_PROJECT_SUMMARY_PENDING' -export const LOAD_PROJECT_SUMMARY_SUCCESS = 'LOAD_PROJECT_SUMMARY_SUCCESS' -export const LOAD_PROJECT_SUMMARY_FAILURE = 'LOAD_PROJECT_SUMMARY_FAILURE' -export const SET_LOOKER_SESSION_EXPIRED = 'SET_LOOKER_SESSION_EXPIRED' - -// User Reports -export const LOAD_USER_REPORTS = 'LOAD_USER_REPORTS' -export const LOAD_USER_REPORTS_PENDING = 'LOAD_USER_REPORTS_PENDING' -export const LOAD_USER_REPORTS_SUCCESS = 'LOAD_USER_REPORTS_SUCCESS' -export const LOAD_USER_REPORTS_FAILURE = 'LOAD_USER_REPORTS_FAILURE' - // Product attachments export const ADD_PRODUCT_ATTACHMENT = 'ADD_PRODUCT_ATTACHMENT' export const ADD_PRODUCT_ATTACHMENT_PENDING = 'ADD_PRODUCT_ATTACHMENT_PENDING' @@ -1055,21 +1042,6 @@ export const PROJECT_ASSETS_SHARED_WITH_TOPCODER_MEMBERS = 'Only Topcoder Member export const PROJECT_ASSETS_SHARED_WITH_ADMIN = 'Only Admins' - -/** - * REPORTS - */ -export const PROJECT_REPORTS = { - PROJECT_SUMMARY : 'summary', - TAAS_MEMBERS : 'taas_members', -} - -/** - * Report session length in seconds - */ -export const REPORT_SESSION_LENGTH = 25 * 60 // 25 minutes (5 minutes less than the report session) - - /** * Contentful Content Ids */ diff --git a/src/projects/actions/projectReports.js b/src/projects/actions/projectReports.js deleted file mode 100644 index 42cbdffee..000000000 --- a/src/projects/actions/projectReports.js +++ /dev/null @@ -1,47 +0,0 @@ -import { - LOAD_PROJECT_SUMMARY, - SET_LOOKER_SESSION_EXPIRED, -} from '../../config/constants' -import { - getProjectSummary, - getProjectReportUrl, -} from '../../api/projectReports' - -export function loadProjectSummary(projectId) { - return (dispatch) => { - return dispatch({ - type: LOAD_PROJECT_SUMMARY, - payload: getProjectSummary(projectId), - meta: { projectId } - }) - } -} - -/** - * Redux action to start fetching the signed URL for embeding the given report - * @param {*} projectId id of the project - * @param {*} reportName unique name of the report - */ -export function loadProjectReportsUrls(projectId, reportName) { - return (dispatch) => { - return dispatch({ - type: LOAD_PROJECT_SUMMARY, - payload: getProjectReportUrl(projectId, reportName), - meta: { projectId } - }) - } -} - -/** - * Redux action set the flag `lookerSessionExpired` - * - * @param {Boolean} isExpired true to indicate that looker session is expired - */ -export function setLookerSessionExpired(isExpired) { - return (dispatch) => { - return dispatch({ - type: SET_LOOKER_SESSION_EXPIRED, - payload: { lookerSessionExpired: isExpired } - }) - } -} \ No newline at end of file diff --git a/src/projects/detail/containers/ProjectSummaryReportContainer.jsx b/src/projects/detail/containers/ProjectSummaryReportContainer.jsx index 5e51aa7c3..74c815ede 100644 --- a/src/projects/detail/containers/ProjectSummaryReportContainer.jsx +++ b/src/projects/detail/containers/ProjectSummaryReportContainer.jsx @@ -1,85 +1,25 @@ -import _ from 'lodash' import React from 'react' import PT from 'prop-types' import { connect } from 'react-redux' import { withRouter } from 'react-router-dom' import MediaQuery from 'react-responsive' -import Modal from 'react-modal' import { SCREEN_BREAKPOINT_MD, PROJECT_FEED_TYPE_PRIMARY, PROJECT_FEED_TYPE_MESSAGES, - PROJECT_REPORTS, - REPORT_SESSION_LENGTH, } from '../../../config/constants' import TwoColsLayout from '../../../components/TwoColsLayout' import Sticky from '../../../components/Sticky' import ProjectInfoContainer from './ProjectInfoContainer' import { PERMISSIONS } from '../../../config/permissions' import { hasPermission } from '../../../helpers/permissions' -import { loadProjectReportsUrls, setLookerSessionExpired } from '../../actions/projectReports' -import spinnerWhileLoading from '../../../components/LoadingSpinner' import './ProjectSummaryReportContainer.scss' -const LookerEmbedReport = (props) => { - return (