diff --git a/assets/js/dashboard/stats/behaviours/index.js b/assets/js/dashboard/stats/behaviours/index.js
index 2a767e98c..1a1bbaf81 100644
--- a/assets/js/dashboard/stats/behaviours/index.js
+++ b/assets/js/dashboard/stats/behaviours/index.js
@@ -10,55 +10,55 @@ import Conversions from './conversions'
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'
const CONVERSIONS = 'conversions'
-
-
-
-// export default function Behaviours({ query, site })
-// const [tab, setMode] = useState('conversions')
-// const tabs =
-//
-// if (site.flags.funnels) {
-// const selectedFunnel = site.funnels.find(funnel => funnel.name === tab)
-// const funnelNames = site.funnels.map(({ name }) => name)
-//
-// return (
-//
-// {tab == 'conversions' && }
-// {funnelNames.includes(tab) && }
-//
-// )
-// } else {
-// return
-// {tab == 'conversions' && }
-//
-// }
-// }
+const FUNNELS = 'funnels'
export default class Behaviours extends React.Component {
constructor(props) {
super(props)
this.tabKey = `behavioursTab__${props.site.domain}`
+ this.funnelKey = `behavioursTabFunnel__${props.site.domain}`
+
const storedTab = storage.getItem(this.tabKey)
+ const storedFunnelName = storage.getItem(this.funnelKey)
+
+ const funnelNames = props.site.funnels.map(({ name }) => name)
+
this.state = {
- mode: storedTab || CONVERSIONS
+ mode: storedTab || CONVERSIONS,
+ funnelNames: funnelNames,
+ selectedFunnelName: storedFunnelName
}
}
- setMode(mode) {
- console.info('setMode', mode)
+ setConversions() {
return () => {
- storage.setItem(this.tabKey, mode)
- this.setState({ mode })
+ storage.setItem(this.tabKey, CONVERSIONS)
+ this.setState({ mode: CONVERSIONS })
}
}
- tabFunnelPicker() {
- const funnelNames = this.props.site.funnels.map(({ name }) => name)
+ setFunnel(selectedFunnelName) {
+ return () => {
+ storage.setItem(this.tabKey, FUNNELS)
+ storage.setItem(this.funnelKey, selectedFunnelName)
+ this.setState({ mode: FUNNELS, selectedFunnelName: selectedFunnelName })
+ }
+ }
+
+ selectedFunnel() {
+ return this.props.site.funnels.find(funnel => funnel.name === this.state.selectedFunnelName)
+ }
+
+ hasFunnels() {
+ const site = this.props.site
+ return site.flags.funnels && site.funnels.length > 0
+ }
+ tabFunnelPicker() {
return