import React from 'react'; import { connect } from 'react-redux'; import { withRouter } from 'react-router-dom'; import { sessions as sessionsRoute, assist as assistRoute, liveSession as liveSessionRoute, withSiteId } from 'App/routes'; import { Icon, BackLink, Link } from 'UI'; import { toggleFavorite, setSessionPath } from 'Duck/sessions'; import cn from 'classnames'; import { connectPlayer, toggleEvents } from 'Player'; import SessionMetaList from 'Shared/SessionItem/SessionMetaList'; import UserCard from './EventsBlock/UserCard'; import Tabs from 'Components/Session/Tabs'; import stl from './playerBlockHeader.module.css'; import AssistActions from '../Assist/components/AssistActions'; import AssistTabs from '../Assist/components/AssistTabs'; const SESSIONS_ROUTE = sessionsRoute(); const ASSIST_ROUTE = assistRoute(); @connectPlayer(state => ({ width: state.width, height: state.height, live: state.live, loading: state.cssLoading || state.messagesLoading, showEvents: state.showEvents, }), { toggleEvents }) @connect((state, props) => { const isAssist = window.location.pathname.includes('/assist/'); const session = state.getIn([ 'sessions', 'current' ]); return { isAssist, session, sessionPath: state.getIn([ 'sessions', 'sessionPath' ]), loading: state.getIn([ 'sessions', 'toggleFavoriteRequest', 'loading' ]), disabled: state.getIn([ 'components', 'targetDefiner', 'inspectorMode' ]) || props.loading, local: state.getIn(['sessions', 'timezone']), funnelRef: state.getIn(['funnels', 'navRef']), siteId: state.getIn([ 'site', 'siteId' ]), metaList: state.getIn(['customFields', 'list']).map(i => i.key), closedLive: !!state.getIn([ 'sessions', 'errors' ]) || (isAssist && !session.live), } }, { toggleFavorite, setSessionPath }) @withRouter export default class PlayerBlockHeader extends React.PureComponent { getDimension = (width, height) => { return width && height ? (
{ width || 'x' } { height || 'x' }
) : Resolution N/A; } backHandler = () => { const { history, siteId, sessionPath, isAssist } = this.props; if (sessionPath.pathname === history.location.pathname || sessionPath.pathname.includes("/session/") || isAssist) { history.push(withSiteId(isAssist ? ASSIST_ROUTE: SESSIONS_ROUTE, siteId)); } else { history.push(sessionPath ? sessionPath.pathname + sessionPath.search : withSiteId(SESSIONS_ROUTE, siteId)); } } toggleFavorite = () => { const { session } = this.props; this.props.toggleFavorite(session.sessionId); } render() { const { width, height, session, fullscreen, metaList, closedLive = false, siteId, isAssist, setActiveTab, activeTab, showEvents, toggleEvents, } = this.props; // const _live = isAssist; const { sessionId, userId, userNumericHash, live, metadata, } = session; let _metaList = Object.keys(metadata).filter(i => metaList.includes(i)).map(key => { const value = metadata[key]; return { label: key, value }; }); const TABS = [ this.props.tabs.EVENTS, this.props.tabs.HEATMAPS ].map(tab => ({ text: tab, key: tab })); return (
{ isAssist && }
{ live && !isAssist && ( <>
This Session is Now Continuing Live
{_metaList.length > 0 &&
} )} {_metaList.length > 0 && (
)} { isAssist && }
{!isAssist && (
{ setActiveTab(tab); !showEvents && toggleEvents(true) } } border={ true } />
)}
); } }