import React, { useEffect } from 'react'; import Widget from 'App/mstore/types/widget'; import Funnelbar from './FunnelBar'; import cn from 'classnames'; import stl from './FunnelWidget.module.css'; import { useObserver } from 'mobx-react-lite'; import { NoContent, Icon } from 'UI'; import { useModal } from 'App/components/Modal'; interface Props { metric: Widget; isWidget?: boolean; data: any; } function FunnelWidget(props: Props) { const { metric, isWidget = false, data } = props; const funnel = data.funnel || { stages: [] }; const totalSteps = funnel.stages.length; const stages = isWidget ? [...funnel.stages.slice(0, 1), funnel.stages[funnel.stages.length - 1]] : funnel.stages; const hasMoreSteps = funnel.stages.length > 2; const lastStage = funnel.stages[funnel.stages.length - 1]; const remainingSteps = totalSteps - 2; const { hideModal } = useModal(); useEffect(() => { return () => { if (isWidget) return; hideModal(); } }, []); return useObserver(() => (
{ !isWidget && ( stages.map((filter: any, index: any) => ( )) )} { isWidget && ( <> { hasMoreSteps && ( <> )} {funnel.stages.length > 1 && ( )} )}
Lost conversions
{funnel.lostConversions} ({funnel.lostConversionsPercentage}%)
Total conversions
{funnel.totalConversions} ({funnel.totalConversionsPercentage}%)
{funnel.totalDropDueToIssues &&
{funnel.totalDropDueToIssues} sessions dropped due to issues.
} )); } function EmptyStage({ total }: any) { return useObserver( () => (
{`+${total} ${total > 1 ? 'steps' : 'step'}`}
)) } function Stage({ stage, index, isWidget }: any) { return useObserver(() => stage ? (
{!isWidget && ( )}
) : <>) } function IndexNumber({ index }: any) { return (
{index === 0 ? : index}
); } function BarActions({ bar }: any) { return useObserver(() => (
)) } export default FunnelWidget;