From ba45cfd79685fc61b2477f5a3aa9416ba11a1200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sarstr=C3=B6m?= Date: Fri, 12 Nov 2021 15:19:03 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fixes=20inheritance=20fro?= =?UTF-8?q?m=20@skolplattformen-api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 - apps/skolplattformen-sthlm/App.js | 2 +- .../components/login.component.tsx | 41 +++++++++++-------- libs/api-hjarntorget/lib/index.ts | 2 +- libs/api/lib/api.ts | 6 ++- libs/hooks/src/childlists.ts | 6 +-- libs/hooks/src/hooks.ts | 2 +- libs/hooks/src/middleware.ts | 1 - libs/hooks/src/provider.tsx | 5 +-- libs/hooks/src/reducers.ts | 2 +- libs/hooks/src/types.ts | 2 +- 11 files changed, 35 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 1fbd0a095..150e633ab 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,6 @@ Check out the documentation [here](libs/hooks). To clone and build the project, you first need to install the required dependencies: ```bash $ sudo apt install git npm -$ npx lerna bootstrap ``` Clone the repo with diff --git a/apps/skolplattformen-sthlm/App.js b/apps/skolplattformen-sthlm/App.js index 56ef8ba65..65e4be529 100644 --- a/apps/skolplattformen-sthlm/App.js +++ b/apps/skolplattformen-sthlm/App.js @@ -5,7 +5,7 @@ import init from '@skolplattformen/api-hjarntorget' import { ApiProvider } from '@skolplattformen/hooks' import { ApplicationProvider, IconRegistry } from '@ui-kitten/components' import { EvaIconsPack } from '@ui-kitten/eva-icons' -import React from 'react' +import React, { useState } from 'react' import { StatusBar, useColorScheme } from 'react-native' import { SafeAreaProvider } from 'react-native-safe-area-context' import { AppNavigator } from './components/navigation.component' diff --git a/apps/skolplattformen-sthlm/components/login.component.tsx b/apps/skolplattformen-sthlm/components/login.component.tsx index 18e5ef432..df1139ff0 100644 --- a/apps/skolplattformen-sthlm/components/login.component.tsx +++ b/apps/skolplattformen-sthlm/components/login.component.tsx @@ -47,7 +47,8 @@ export const Login = () => { >(() => () => null) const [visible, showModal] = useState(false) const [showLoginMethod, setShowLoginMethod] = useState(false) - const [showSchoolPlatformPicker, setShowSchoolPlatformPicker] = useState(false) + const [showSchoolPlatformPicker, setShowSchoolPlatformPicker] = + useState(false) const [error, setError] = useState(null) const [personalIdNumber, setPersonalIdNumber] = useSettingsStorage( 'cachedPersonalIdentityNumber' @@ -55,8 +56,9 @@ export const Login = () => { const [loginMethodIndex, setLoginMethodIndex] = useSettingsStorage('loginMethodIndex') - const [schoolPlatform, setSchoolPlatform] = - useSettingsStorage('currentSchoolPlatform') + const [schoolPlatform, setSchoolPlatform] = useSettingsStorage( + 'currentSchoolPlatform' + ) const { t } = useTranslation() @@ -71,12 +73,12 @@ export const Login = () => { const schoolPlatforms = [ { id: 'stockholm-skolplattformen', - displayName: 'Stockholm stad' + displayName: 'Stockholm stad', }, { id: 'goteborg-hjarnkontoret', - displayName: 'Göteborg stad' - } + displayName: 'Göteborg stad', + }, ] const loginHandler = async () => { @@ -96,7 +98,8 @@ export const Login = () => { } const getSchoolPlatformName = () => { - return schoolPlatforms.find(item => item.id === schoolPlatform)?.displayName; + return schoolPlatforms.find((item) => item.id === schoolPlatform) + ?.displayName } const openBankId = (token: string) => { @@ -207,13 +210,14 @@ export const Login = () => { @@ -281,8 +285,9 @@ export const Login = () => { visible={showSchoolPlatformPicker} style={styles.modal} onBackdropPress={() => setShowSchoolPlatformPicker(false)} - backdropStyle={styles.backdrop}> - + backdropStyle={styles.backdrop} + > + { /> )} /> - + ) @@ -331,5 +336,5 @@ const themedStyles = StyleService.create({ }, platformPicker: { width: '100%', - } + }, }) diff --git a/libs/api-hjarntorget/lib/index.ts b/libs/api-hjarntorget/lib/index.ts index e72e8b8e3..566e5a5bd 100644 --- a/libs/api-hjarntorget/lib/index.ts +++ b/libs/api-hjarntorget/lib/index.ts @@ -6,7 +6,7 @@ import { Api, FetcherOptions, Fetch, RNCookieManager, const init = ( fetchImpl: Fetch, - cookieManagerImpl: any, + cookieManagerImpl: RNCookieManager | ToughCookieJar, options?: FetcherOptions ): Api => { // prettier-ignore diff --git a/libs/api/lib/api.ts b/libs/api/lib/api.ts index b4ee6850d..890176b49 100644 --- a/libs/api/lib/api.ts +++ b/libs/api/lib/api.ts @@ -1,4 +1,5 @@ import { Language } from '@skolplattformen/curriculum' +import { EventEmitter } from 'events' import { DateTime } from 'luxon' import { LoginStatusChecker } from './loginStatus' import { @@ -14,8 +15,9 @@ import { ScheduleItem, } from './types' -export interface Api { - isFake:boolean +export interface Api extends EventEmitter { + isFake: boolean + isLoggedIn: boolean getPersonalNumber(): string | undefined login(personalNumber?: string): Promise setSessionCookie(sessionCookie: string): Promise diff --git a/libs/hooks/src/childlists.ts b/libs/hooks/src/childlists.ts index 1e337458b..725aad0a0 100644 --- a/libs/hooks/src/childlists.ts +++ b/libs/hooks/src/childlists.ts @@ -1,8 +1,4 @@ -import { - Child, - EtjanstChild, - Skola24Child, -} from '@skolplattformen/api-skolplattformen' +import { Child, EtjanstChild, Skola24Child } from '@skolplattformen/api' export const merge = ( etjanstChildren: EtjanstChild[], diff --git a/libs/hooks/src/hooks.ts b/libs/hooks/src/hooks.ts index ddad88130..594a0cbeb 100644 --- a/libs/hooks/src/hooks.ts +++ b/libs/hooks/src/hooks.ts @@ -12,7 +12,7 @@ import { Skola24Child, TimetableEntry, User, -} from '@skolplattformen/api-skolplattformen' +} from '@skolplattformen/api' import { Language } from '@skolplattformen/curriculum' import { DateTime } from 'luxon' import { useEffect, useState } from 'react' diff --git a/libs/hooks/src/middleware.ts b/libs/hooks/src/middleware.ts index a57a9d5ac..9a0d450d3 100644 --- a/libs/hooks/src/middleware.ts +++ b/libs/hooks/src/middleware.ts @@ -1,4 +1,3 @@ -/* eslint-disable default-case */ import { Middleware } from 'redux' import { EntityAction, EntityStoreRootState, ExtraActionProps } from './types' diff --git a/libs/hooks/src/provider.tsx b/libs/hooks/src/provider.tsx index 528268838..1255f3a22 100644 --- a/libs/hooks/src/provider.tsx +++ b/libs/hooks/src/provider.tsx @@ -1,6 +1,4 @@ -/* eslint-disable react/prop-types */ -/* eslint-disable import/prefer-default-export */ -import { Api } from '@skolplattformen/api-skolplattformen' +import { Api } from '@skolplattformen/api' import React, { FC, PropsWithChildren, useEffect, useState } from 'react' import { Provider } from 'react-redux' import { ApiContext } from './context' @@ -56,6 +54,7 @@ export const ApiProvider: TApiProvider = ({ api.off('login', handler) api.off('logout', handler) } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [api.isLoggedIn, api.isFake]) return ( diff --git a/libs/hooks/src/reducers.ts b/libs/hooks/src/reducers.ts index 1e0512ce8..44f97b884 100644 --- a/libs/hooks/src/reducers.ts +++ b/libs/hooks/src/reducers.ts @@ -9,7 +9,7 @@ import { Skola24Child, TimetableEntry, User, -} from '@skolplattformen/api-skolplattformen' +} from '@skolplattformen/api' import { EntityName, EntityReducer, EntityState } from './types' const createReducer = (entity: EntityName): EntityReducer => { diff --git a/libs/hooks/src/types.ts b/libs/hooks/src/types.ts index a6529115f..3e1f6e100 100644 --- a/libs/hooks/src/types.ts +++ b/libs/hooks/src/types.ts @@ -10,7 +10,7 @@ import { Skola24Child, TimetableEntry, User, -} from '@skolplattformen/api-skolplattformen' +} from '@skolplattformen/api' import { Action, Reducer } from 'redux' export interface Reporter {