From a50e58baa045dd95bc9753c8e5be35e2aecd477c Mon Sep 17 00:00:00 2001 From: Matthias Feyll <matthias.feyll@@stud.h-da.de> Date: Wed, 11 Dec 2024 00:37:35 +0100 Subject: [PATCH] ui: fix linting issues --- react-ui/src/components/devices/index.module.ts | 5 ----- react-ui/src/components/login/view/login.view.tsx | 10 +++++----- .../json_viewer/reducer/json_viewer.reducer.ts | 2 +- .../json_viewer/viewmodel/json_viewer.viewmodel.tsx | 4 ++-- .../layouts/protected.layout/protected.layout.tsx | 2 +- react-ui/src/shared/provider/auth.provider.tsx | 2 +- react-ui/src/shared/provider/menu/menu.provider.tsx | 4 ++-- react-ui/src/shared/provider/utils.provider.tsx | 4 ++-- react-ui/src/shared/reducer/routine.reducer.ts | 13 +++++++++---- 9 files changed, 23 insertions(+), 23 deletions(-) delete mode 100755 react-ui/src/components/devices/index.module.ts diff --git a/react-ui/src/components/devices/index.module.ts b/react-ui/src/components/devices/index.module.ts deleted file mode 100755 index 5ef9299bd..000000000 --- a/react-ui/src/components/devices/index.module.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { fetchSelectedMneThunk } from './routines/mne.routine' - -const routines = { - fetchSelectedMneThunk: fetchSelectedMneThunk, -} diff --git a/react-ui/src/components/login/view/login.view.tsx b/react-ui/src/components/login/view/login.view.tsx index e393bb4b3..03d7406f4 100755 --- a/react-ui/src/components/login/view/login.view.tsx +++ b/react-ui/src/components/login/view/login.view.tsx @@ -1,12 +1,12 @@ -import { Alert, Button, Col, Container, Form, Image, Row, Spinner } from 'react-bootstrap' -import { useTranslation } from 'react-i18next' -import './login.scss' - import logo from '@assets/logo.svg' +import { BasicProp } from '@helper/interfaces' import React, { useRef } from 'react' +import { Alert, Button, Col, Container, Form, Image, Row, Spinner } from 'react-bootstrap' +import { useTranslation } from 'react-i18next' import useLoginViewModel from '../viewmodel/login.viewmodel' +import './login.scss' -const LoginView = ({ children }) => { +const LoginView: React.FC<BasicProp> = () => { const { t } = useTranslation('common') const { login, handleErrorMessageRendering, displayFormFieldChecks, loginLoading } = useLoginViewModel(); diff --git a/react-ui/src/shared/components/json_viewer/reducer/json_viewer.reducer.ts b/react-ui/src/shared/components/json_viewer/reducer/json_viewer.reducer.ts index 0779d0e18..dd432535c 100755 --- a/react-ui/src/shared/components/json_viewer/reducer/json_viewer.reducer.ts +++ b/react-ui/src/shared/components/json_viewer/reducer/json_viewer.reducer.ts @@ -55,7 +55,7 @@ const JsonViewerSlice = createSlice({ const { identifier, collapse } = payload // potentially find already collapsed - let i = state.collapseContainer.findIndex(i => compareIdentifier(identifier, i.identifier)) + const i = state.collapseContainer.findIndex(i => compareIdentifier(identifier, i.identifier)) if (i === -1) { diff --git a/react-ui/src/shared/components/json_viewer/viewmodel/json_viewer.viewmodel.tsx b/react-ui/src/shared/components/json_viewer/viewmodel/json_viewer.viewmodel.tsx index a1a9c8977..da78528f2 100644 --- a/react-ui/src/shared/components/json_viewer/viewmodel/json_viewer.viewmodel.tsx +++ b/react-ui/src/shared/components/json_viewer/viewmodel/json_viewer.viewmodel.tsx @@ -54,7 +54,7 @@ export const useJsonViewer = ({ json, search, container }: JsonViewerViewModelTy return !!item.length; } - const collapse = (key: string, nested: number, json: Object, collapseState: CollapseValues = CollapseValues.TOGGLE) => { + const collapse = (key: string, nested: number, json: object, collapseState: CollapseValues = CollapseValues.TOGGLE) => { const identifier = { key, nested }; dispatch(toggleCollapse({ identifier, collapse: collapseState })) @@ -95,7 +95,7 @@ export const useJsonViewer = ({ json, search, container }: JsonViewerViewModelTy } } - const innerSearch = (json: Object, searchValue: string, parentKey: string = "", path: string = "/"): boolean => { + const innerSearch = (json: object, searchValue: string, parentKey: string = "", path: string = "/"): boolean => { let found = false; path += parentKey + (parentKey === "" ? "" : "/") diff --git a/react-ui/src/shared/layouts/protected.layout/protected.layout.tsx b/react-ui/src/shared/layouts/protected.layout/protected.layout.tsx index 0708d87f1..c7e13c6fe 100755 --- a/react-ui/src/shared/layouts/protected.layout/protected.layout.tsx +++ b/react-ui/src/shared/layouts/protected.layout/protected.layout.tsx @@ -29,7 +29,7 @@ export const ProtectedLayout = () => { dispatch(fetchUser()); dispatch(fetchPnds()); - }, []); + }, [dispatch]); /** * Applies active css class to link if the link is active diff --git a/react-ui/src/shared/provider/auth.provider.tsx b/react-ui/src/shared/provider/auth.provider.tsx index 830a4d47d..69bdccbdf 100755 --- a/react-ui/src/shared/provider/auth.provider.tsx +++ b/react-ui/src/shared/provider/auth.provider.tsx @@ -103,7 +103,7 @@ export const AuthProvider: React.FC<BasicProp> = ({ children }) => { isAuthenticated, loginProperties }), - [] + [executeLogin, loginProperties, logout] ); return ( diff --git a/react-ui/src/shared/provider/menu/menu.provider.tsx b/react-ui/src/shared/provider/menu/menu.provider.tsx index 0cfc61f68..a91f46639 100644 --- a/react-ui/src/shared/provider/menu/menu.provider.tsx +++ b/react-ui/src/shared/provider/menu/menu.provider.tsx @@ -23,7 +23,7 @@ interface MenuProviderType { } const MenuContext = createContext<MenuProviderType>({ - subscribe: function (value: SubscriptionValue): MenuSubscription { + subscribe: function (): MenuSubscription { throw new Error("Function not implemented."); } }) @@ -86,7 +86,7 @@ export const MenuProvider: React.FC<BasicProp> = ({ children }) => { hideMenu(); } }); - }, []) + }, [hideMenu]) const value = useMemo<MenuProviderType>(() => { return { diff --git a/react-ui/src/shared/provider/utils.provider.tsx b/react-ui/src/shared/provider/utils.provider.tsx index 6f6775343..ca6aa1d32 100644 --- a/react-ui/src/shared/provider/utils.provider.tsx +++ b/react-ui/src/shared/provider/utils.provider.tsx @@ -8,7 +8,7 @@ interface UtilsProviderType { } const UtilsContext = createContext<UtilsProviderType>({ - toClipboard: function (text: string): void { + toClipboard: function (): void { throw new Error("Function not implemented."); } }) @@ -23,7 +23,7 @@ export const UtilsProvider: React.FC<BasicProp> = ({ children }) => { toast.info(t('global.toast.copied')) }, } as UtilsProviderType - }, []) + }, [t]) return ( <UtilsContext.Provider value={value}> diff --git a/react-ui/src/shared/reducer/routine.reducer.ts b/react-ui/src/shared/reducer/routine.reducer.ts index c7f9a43c1..a52ee84d3 100755 --- a/react-ui/src/shared/reducer/routine.reducer.ts +++ b/react-ui/src/shared/reducer/routine.reducer.ts @@ -6,7 +6,7 @@ import { setToken } from './user.reducer' interface ThunkEntityDTO { thunk: any - payload: any + payload: Object /** * Only one subscription per category is allowed. New subscription will unsubscribe and overwrite the old one @@ -45,14 +45,14 @@ const RoutineSlice = createSlice({ }, setThunkId: (state, { payload }: PayloadAction<{ id: number; category: CATEGORIES }>) => { - const thunk = state.thunks[CATEGORIES[payload.category]] + const thunk = state.thunks[CATEGORIES[payload.category] as any] if (!thunk) { // TODO throw new Error('Thunk not found') } - state.thunks[CATEGORIES[payload.category]] = { ...thunk, id: payload.id, locked: false } + state.thunks[CATEGORIES[payload.category] as any] = { ...thunk, id: payload.id, locked: false } }, removeAll: (state) => { @@ -107,8 +107,13 @@ startListening({ predicate: (action) => addRoutine.match(action), effect: async (action, listenerApi) => { const { routine } = listenerApi.getOriginalState() as RootState - const lastThunk = routine.thunks[CATEGORIES[action.payload.category]] + const lastThunk = routine.thunks[CATEGORIES[action.payload.category] as any] if (lastThunk) { + if (!lastThunk.id) { + throw new Error() + // TODO + } + RoutineManager.unsubscribe(lastThunk.id) } }, -- GitLab