diff --git a/assets/js/dashboard/stats/behaviours/index.js b/assets/js/dashboard/stats/behaviours/index.js index e082f61da..64217db38 100644 --- a/assets/js/dashboard/stats/behaviours/index.js +++ b/assets/js/dashboard/stats/behaviours/index.js @@ -6,69 +6,77 @@ import classNames from 'classnames' import Funnel from './funnel' import Conversions from './conversions' -function Tabs({tab, setTab, funnelNames}) { - const activeClass = 'inline-block h-5 text-indigo-700 dark:text-indigo-500 font-bold active-prop-heading truncate text-left' - const defaultClass = 'hover:text-indigo-600 cursor-pointer truncate text-left' +const ACTIVE_CLASS = 'inline-block h-5 text-indigo-700 dark:text-indigo-500 font-bold active-prop-heading truncate text-left' +const DEFAULT_CLASS = 'hover:text-indigo-600 cursor-pointer truncate text-left' + +function Tabs({ tab, setTab, site }) { return (
-
setTab('conversions')}>Conversions
- -
- - Funnels - -
- - - -
- {funnelNames.map((option) => { - return ( - - {({ active }) => ( - setTab(option)} - className={classNames( - active ? 'bg-gray-100 dark:bg-gray-900 text-gray-900 dark:text-gray-200 cursor-pointer' : 'text-gray-700 dark:text-gray-200', - 'block px-4 py-2 text-sm', - tab === option ? 'font-bold' : '' - )} - > - {option} - - )} - - ) - })} -
-
-
-
+
setTab('conversions')}>Conversions
+ {FunnelTab({ tab, setTab, site })}
) } +function FunnelTab({ tab, setTab, site }) { + const funnelNames = site.funnels.map(({ name }) => name) + + return +
+ + Funnels + +
+ + + +
+ {funnelNames.map((option) => { + return ( + + {({ active }) => ( + setTab(option)} + className={classNames( + active ? 'bg-gray-100 dark:bg-gray-900 text-gray-900 dark:text-gray-200 cursor-pointer' : 'text-gray-700 dark:text-gray-200', + 'block px-4 py-2 text-sm', + tab === option ? 'font-bold' : '' + )} + > + {option} + + )} + + ) + })} +
+
+
+
+} + export default function Behaviours({ query, site }) { const [tab, setTab] = useState('conversions') - const funnelNames = site.funnels.map(({name}) => name) - const selectedFunnel = site.funnels.find(funnel => funnel.name === tab) - const tabs = + const tabs = + + const selectedFunnel = site.funnels.find(funnel => funnel.name === tab) + const funnelNames = site.funnels.map(({ name }) => name) return (
- { tab == 'conversions' && } - { funnelNames.includes(tab) && } + {tab == 'conversions' && } + {funnelNames.includes(tab) && }
) }