From 60ac0ed31297dcc1a403ac6f70327a171ab9be91 Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Tue, 10 Sep 2024 14:09:59 +0200 Subject: [PATCH] ui: drop unreferenced types --- .../app/components/Session/MobilePlayer.tsx | 1 - frontend/app/components/Session/WebPlayer.tsx | 1 - .../Session_/EventsBlock/EventGroupWrapper.js | 1 - .../SessionsTabOverview.tsx | 4 +- .../components/Notes/NoteList.tsx | 2 +- frontend/app/duck/index.ts | 2 - frontend/app/duck/member.js | 40 ------ frontend/app/duck/site.js | 2 - frontend/app/duck/siteSlice.ts | 129 ------------------ 9 files changed, 2 insertions(+), 180 deletions(-) delete mode 100644 frontend/app/duck/member.js delete mode 100644 frontend/app/duck/siteSlice.ts diff --git a/frontend/app/components/Session/MobilePlayer.tsx b/frontend/app/components/Session/MobilePlayer.tsx index 3c7605208..d8a88b7f4 100644 --- a/frontend/app/components/Session/MobilePlayer.tsx +++ b/frontend/app/components/Session/MobilePlayer.tsx @@ -149,7 +149,6 @@ export default connect( jwt: state.getIn(['user', 'jwt']), fullscreen: state.getIn(['player']).fullcreen, showEvents: state.get('showEvents'), - members: state.getIn(['members', 'list']), }), { toggleFullscreen, diff --git a/frontend/app/components/Session/WebPlayer.tsx b/frontend/app/components/Session/WebPlayer.tsx index fdf45d68f..d98674f39 100644 --- a/frontend/app/components/Session/WebPlayer.tsx +++ b/frontend/app/components/Session/WebPlayer.tsx @@ -257,7 +257,6 @@ export default connect( jwt: state.getIn(['user', 'jwt']), fullscreen: state.getIn(['player', 'fullscreen']), showEvents: state.get('showEvents'), - members: state.getIn(['members', 'list']), startedAt: state.getIn(['sessions', 'current']).startedAt || 0, }), { diff --git a/frontend/app/components/Session_/EventsBlock/EventGroupWrapper.js b/frontend/app/components/Session_/EventsBlock/EventGroupWrapper.js index e638ad339..6f7a9d8b8 100644 --- a/frontend/app/components/Session_/EventsBlock/EventGroupWrapper.js +++ b/frontend/app/components/Session_/EventsBlock/EventGroupWrapper.js @@ -12,7 +12,6 @@ import NoteEvent from './NoteEvent'; @withToggle('showLoadInfo', 'toggleLoadInfo') @connect( (state) => ({ - members: state.getIn(['members', 'list']), currentUserId: state.getIn(['user', 'account', 'id']) }), ) diff --git a/frontend/app/components/shared/SessionsTabOverview/SessionsTabOverview.tsx b/frontend/app/components/shared/SessionsTabOverview/SessionsTabOverview.tsx index bf7974b2c..4dde017e3 100644 --- a/frontend/app/components/shared/SessionsTabOverview/SessionsTabOverview.tsx +++ b/frontend/app/components/shared/SessionsTabOverview/SessionsTabOverview.tsx @@ -12,10 +12,8 @@ import SessionList from './components/SessionList'; function SessionsTabOverview({ activeTab, appliedFilter, - members, }: { activeTab: string; - members: object[]; sites: object[]; siteId: string; appliedFilter: any; @@ -50,7 +48,7 @@ function SessionsTabOverview({ {activeTab !== 'notes' ? ( ) : ( - + )} ); diff --git a/frontend/app/components/shared/SessionsTabOverview/components/Notes/NoteList.tsx b/frontend/app/components/shared/SessionsTabOverview/components/Notes/NoteList.tsx index 053bb3758..0cae90242 100644 --- a/frontend/app/components/shared/SessionsTabOverview/components/Notes/NoteList.tsx +++ b/frontend/app/components/shared/SessionsTabOverview/components/Notes/NoteList.tsx @@ -6,7 +6,7 @@ import { observer } from 'mobx-react-lite'; import { useStore } from 'App/mstore'; import AnimatedSVG, { ICONS } from 'Shared/AnimatedSVG/AnimatedSVG'; -function NotesList({ members }: { members: Array> }) { +function NotesList() { const { notesStore } = useStore(); React.useEffect(() => { diff --git a/frontend/app/duck/index.ts b/frontend/app/duck/index.ts index dbf727d52..193e843ba 100644 --- a/frontend/app/duck/index.ts +++ b/frontend/app/duck/index.ts @@ -8,7 +8,6 @@ import filters from './filters'; import funnelFilters from './funnelFilters'; import player from './components/player' import sources from './sources'; -import members from './member'; import site from './site'; import customFields from './customField'; import integrations from './integrations'; @@ -25,7 +24,6 @@ const rootReducer = combineReducers({ filters, funnelFilters, player, - members, site, customFields, errors, diff --git a/frontend/app/duck/member.js b/frontend/app/duck/member.js deleted file mode 100644 index ce12c1659..000000000 --- a/frontend/app/duck/member.js +++ /dev/null @@ -1,40 +0,0 @@ -import { Map } from 'immutable'; -import Member from 'Types/member'; -import crudDuckGenerator from './tools/crudDuck'; -import { RequestTypes } from 'Duck/requestStateCreator'; -import { reduceDucks } from 'Duck/tools'; - -const GENERATE_LINK = new RequestTypes('member/GENERATE_LINK'); - -const crudDuck = crudDuckGenerator('client/member', Member, { idKey: 'id' }); -export const { fetchList, init, edit, remove, } = crudDuck.actions; - -const initialState = Map({ - definedPercent: 0, -}); - -const reducer = (state = initialState, action = {}) => { - switch (action.type) { - case GENERATE_LINK.SUCCESS: - return state.update( - 'list', - list => list - .map(member => { - if(member.id === action.id) { - return Member({...member.toJS(), invitationLink: action.data.invitationLink }) - } - return member - }) - ); - } - return state; -}; - -export function save(instance) { - return { - types: crudDuck.actionTypes.SAVE.toArray(), - call: client => client.put( instance.id ? `/client/members/${ instance.id }` : '/client/members', instance.toData()), - }; -} - -export default reduceDucks(crudDuck, { initialState, reducer }).reducer; diff --git a/frontend/app/duck/site.js b/frontend/app/duck/site.js index 86216cb99..98daab339 100644 --- a/frontend/app/duck/site.js +++ b/frontend/app/duck/site.js @@ -2,7 +2,6 @@ import Site from "Types/site"; import GDPR from 'Types/site/gdpr'; import { mergeReducers, - createItemInListUpdater, success, array, createListUpdater @@ -24,7 +23,6 @@ const storedSiteId = localStorage.getItem(SITE_ID_STORAGE_KEY); const name = 'project'; const idKey = 'id'; -const itemInListUpdater = createItemInListUpdater(idKey); const updateItemInList = createListUpdater(idKey); const EDIT_GDPR = 'sites/EDIT_GDPR'; diff --git a/frontend/app/duck/siteSlice.ts b/frontend/app/duck/siteSlice.ts deleted file mode 100644 index d59893a90..000000000 --- a/frontend/app/duck/siteSlice.ts +++ /dev/null @@ -1,129 +0,0 @@ -import { PayloadAction, createAsyncThunk, createSlice } from '@reduxjs/toolkit'; -import Site, { ISite } from "Types/site"; -import GDPR, { IGDPR } from 'Types/site/gdpr'; -import { apiClient } from 'App/api_client'; - -import { GLOBAL_HAS_NO_RECORDINGS, SITE_ID_STORAGE_KEY } from "../constants/storageKeys"; -import { array } from "./funcTools/tools"; - - -const storedSiteId = localStorage.getItem(SITE_ID_STORAGE_KEY); - -interface SiteState { - list: ISite[]; - instance: ISite | null; - remainingSites?: number; - siteId?: number; - active: ISite | null; -} - -const initialState: SiteState = { - list: [], - instance: null, - remainingSites: undefined, - siteId: undefined, - active: null, -}; - -const siteSlice = createSlice({ - name: 'site', - initialState, - reducers: { - init: (state, action: PayloadAction) => { - state.instance = action.payload; - }, - editGDPR(state, action: PayloadAction) { - state.instance = { - ...state.instance!, - gdpr: action.payload, - } - }, - setSiteId(state, action: PayloadAction) { - const siteId = action.payload; - const site = state.list.find((s) => s.id === parseInt(siteId)); - if (site) { - state.siteId = siteId; - state.active = site; - localStorage.setItem(SITE_ID_STORAGE_KEY, siteId); - } - }, - updateProjectRecordingStatus(state, action: PayloadAction<{ siteId: string; status: boolean }>) { - const { siteId, status } = action.payload; - const site = state.list.find((s) => s.id === parseInt(siteId)); - if (site) { - site.recorded = status; - } - }, - fetchGDPRSuccess(state, action: { data: IGDPR }) { - state.instance = { - ...state.instance!, - gdpr: GDPR(action.data), - } - }, - saveSiteSuccess(state, action: { data: ISite }) { - const newSite = Site(action.data); - state.siteId = newSite.id; - state.instance = newSite; - state.active = newSite; - }, - saveGDPRSuccess(state, action: { data: IGDPR }) { - const gdpr = GDPR(action.data); - state.instance = { - ...state.instance!, - gdpr: gdpr, - } - }, - fetchListSuccess(state, action: { data: ISite[], siteIdFromPath: number }) { - const siteId = state.siteId; - const ids = action.data.map(s => parseInt(s.projectId)) - const siteExists = ids.includes(parseInt(siteId!)); - if (action.siteIdFromPath && ids.includes(parseInt(action.siteIdFromPath))) { - state.siteId = action.siteIdFromPath; - } else if (!siteId || !siteExists) { - state.siteId = ids.includes(parseInt(storedSiteId!)) - ? storedSiteId - : action.data[0].projectId; - } - const list = action.data.map(Site); - const hasRecordings = list.some(s => s.recorded); - if (!hasRecordings) { - localStorage.setItem(GLOBAL_HAS_NO_RECORDINGS, 'true'); - } else { - localStorage.removeItem(GLOBAL_HAS_NO_RECORDINGS); - } - - state.list = list; - state.active = list.find(s => parseInt(s.id) === parseInt(state.siteId!)); - } - }, -}) - -export function save(site: ISite) { - return { - types: ['sites/saveSiteRequest', 'sites/saveSiteSuccess', 'sites/saveSiteFail'], - call: (client) => client.post(`/projects`, site), - }; -} - -export function fetchGDPR(siteId: number) { - return { - types: ['sites/fetchGDPRRequest', 'sites/fetchGDPRSuccess', 'sites/fetchGDPRFail'], - call: (client) => client.get(`/${siteId}/gdpr`), - }; -} - -export const saveGDPR = (siteId: number) => (dispatch, getState) => { - const g = getState().site.instance.gdpr; - return dispatch({ - types: ['sites/saveGDPRRequest', 'sites/saveGDPRSuccess', 'sites/saveGDPRFail'], - call: client => client.post(`/${siteId}/gdpr`, g) - }); -}; - -export function fetchList(siteId: number) { - return { - types: ['sites/fetchListRequest', 'sites/fetchListSuccess', 'sites/fetchListFail'], - call: client => client.get('/projects'), - siteIdFromPath: siteId - }; -} \ No newline at end of file