Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

add state to redux

kruzhambuse46f8487e4b2
diff --git a/src/pages/Project/View/Panels.tsx b/src/pages/Project/View/Panels.tsx
index 48f111868..07d544ce7 100644
--- a/src/pages/Project/View/Panels.tsx
+++ b/src/pages/Project/View/Panels.tsx
@@ -756,7 +756,6 @@ const Panel = ({
}
if (id === 'pg' && activeFragment === 1) {
- // setModal(true)
return (
<PanelContainer
name={name}
diff --git a/src/pages/Project/View/components/SankeyChart.tsx b/src/pages/Project/View/components/SankeyChart.tsx
index 8b14fe755..52023fb00 100644
--- a/src/pages/Project/View/components/SankeyChart.tsx
+++ b/src/pages/Project/View/components/SankeyChart.tsx
@@ -1,5 +1,7 @@
import React from 'react'
import { ResponsiveSankey } from '@nivo/sankey'
+import { connect } from 'react-redux'
+import { StateType } from 'redux/store'
const dataTest = {
nodes: [
diff --git a/src/redux/models/IUserFlow.ts b/src/redux/models/IUserFlow.ts
new file mode 100644
index 000000000..1f307da48
--- /dev/null
+++ b/src/redux/models/IUserFlow.ts
@@ -0,0 +1,12 @@
+interface UserFlow {
+ nodes: {
+ id: string
+ }[]
+ links: {
+ source: string
+ target: string
+ value: number
+ }[]
+}
+
+export type IUserFLow = UserFlow | {}
diff --git a/src/redux/reducers/ui/cache.ts b/src/redux/reducers/ui/cache.ts
index f141a32c7..a6b04cb03 100644
--- a/src/redux/reducers/ui/cache.ts
+++ b/src/redux/reducers/ui/cache.ts
@@ -5,6 +5,7 @@ import { getItem, removeItem, setItem } from 'utils/localstorage'
import {
getProjectCacheKey, LS_VIEW_PREFS_SETTING, LS_CAPTCHA_VIEW_PREFS_SETTING, getProjectCaptchaCacheKey,
} from 'redux/constants'
+import { IUserFlow } from 'redux/models/IUserFlow'
export const getInitialViewPrefs = (LS_VIEW: string) => {
if (typeof window !== 'undefined' && window.localStorage) {
@@ -32,6 +33,12 @@ interface IInitialState {
rangeDate?: Date[]
},
} | null
+ userFlowAscending: {
+ [key: string]: IUserFlow
+ }
+ userFlowDescending: {
+ [key: string]: IUserFlow
+ }
}
const initialState: IInitialState = {
@@ -41,6 +48,8 @@ const initialState: IInitialState = {
captchaProjectsViewPrefs: getInitialViewPrefs(LS_CAPTCHA_VIEW_PREFS_SETTING) || {},
projectViewPrefs: getInitialViewPrefs(LS_VIEW_PREFS_SETTING),
customEventsPrefs: {},
+ userFlowAscending: {},
+ userFlowDescending: {},
}
const cacheSlice = createSlice({
@@ -201,6 +210,22 @@ const cacheSlice = createSlice({
},
}
},
+ setUserFlowAscending(state, { payload }: PayloadAction<{ pid: string, period: string, data: IUserFlow }>) {
+ const key = payload.period + payload.pid
+
+ state.userFlowAscending = {
+ ...state.userFlowAscending,
+ [key]: payload.data,
+ }
+ },
+ setUserFlowDescending(state, { payload }: PayloadAction<{ pid: string, period: string, data: IUserFlow }>) {
+ const key = payload.period + payload.pid
+
+ state.userFlowDescending = {
+ ...state.userFlowDescending,
+ [key]: payload.data,
+ }
+ },
},
})