From aea848f66abb45485cd816005aa4d20f57732b74 Mon Sep 17 00:00:00 2001 From: Erik Eng Date: Thu, 2 Dec 2021 12:32:08 +0100 Subject: [PATCH 01/41] Fix: Styles, pricing & contact email (#576) * Use constant to ensure consistent pricing across pages * Correct email address anchor * Add correct h4 color in dark mode --- apps/website/components/FunFacts.tsx | 3 ++- apps/website/components/Pricing.tsx | 2 +- apps/website/components/QA.tsx | 6 ++++-- apps/website/tailwind.config.js | 3 +++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/website/components/FunFacts.tsx b/apps/website/components/FunFacts.tsx index bf7db530..3d645043 100644 --- a/apps/website/components/FunFacts.tsx +++ b/apps/website/components/FunFacts.tsx @@ -1,6 +1,7 @@ import React from 'react' import CountUp from 'react-countup' import VisibilitySensor from 'react-visibility-sensor' +import { price } from './Pricing' const FUNFACTS_DATA = [ { @@ -12,7 +13,7 @@ const FUNFACTS_DATA = [ title: 'år att utveckla', }, { - count: 11, + count: price, title: 'kronor kostar vår app :)', }, { diff --git a/apps/website/components/Pricing.tsx b/apps/website/components/Pricing.tsx index 32a60b4c..f48def54 100644 --- a/apps/website/components/Pricing.tsx +++ b/apps/website/components/Pricing.tsx @@ -3,7 +3,7 @@ import DownloadButtons from './DownloadButtons' import Icon from './Icon' import SectionTitle from './SectionTitle' -const price = 12 +export const price = 11 const baseFeatures = [ { diff --git a/apps/website/components/QA.tsx b/apps/website/components/QA.tsx index 60859410..0ed1bda6 100644 --- a/apps/website/components/QA.tsx +++ b/apps/website/components/QA.tsx @@ -1,5 +1,7 @@ import Link from './Link' +import { price } from './Pricing' + const QA = () => { return (
@@ -249,7 +251,7 @@ const QA = () => { de?

- Appen kostar 12 kronor. Intäkten registreras i aktiebolaget Not Free + Appen kostar {price} kronor. Intäkten registreras i aktiebolaget Not Free Beer som ägs av tre av utvecklarna och går till att täcka kostnader för inköp. Det täcker inte på långa vägar den tid vi lagt ner. Med en låg engångskostnad ökar vi chansen att vi orkar syssla med underhåll @@ -315,7 +317,7 @@ const QA = () => {

Kontakta oss

Tveka inte att kontakta oss. Skicka ett mail till{' '} - dev@skolplattformen.org. + info@skolplattformen.org.

diff --git a/apps/website/tailwind.config.js b/apps/website/tailwind.config.js index b54d8b31..7f7838cd 100644 --- a/apps/website/tailwind.config.js +++ b/apps/website/tailwind.config.js @@ -35,6 +35,9 @@ module.exports = { h3: { color: theme('colors.white'), }, + h4: { + color: theme('colors.white'), + }, a: { color: theme('colors.indigo.500'), } From 7fb6710eade53e70b801414511ba8a2599a85e80 Mon Sep 17 00:00:00 2001 From: Erik Eng Date: Thu, 2 Dec 2021 12:50:07 +0100 Subject: [PATCH 02/41] Fix: Inconsistent pricing (last one) --- apps/website/components/PricingTemp.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/website/components/PricingTemp.tsx b/apps/website/components/PricingTemp.tsx index b64d16bc..33d7a783 100644 --- a/apps/website/components/PricingTemp.tsx +++ b/apps/website/components/PricingTemp.tsx @@ -2,8 +2,7 @@ import { formatPrice } from '../utils/intl' import DownloadButtons from './DownloadButtons' import Icon from './Icon' import SectionTitle from './SectionTitle' - -const price = 12 +import { price } from './Pricing' const baseFeatures = [ { From bf4ed46c2bdc51e22b94779777e9cd410e98d48d Mon Sep 17 00:00:00 2001 From: Erik Eng Date: Thu, 2 Dec 2021 15:27:34 +0100 Subject: [PATCH 03/41] Include Gbg when we talk about supported platforms --- apps/website/components/Privacy.tsx | 2 +- apps/website/components/featureData.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/website/components/Privacy.tsx b/apps/website/components/Privacy.tsx index d8ecb57b..cdb240f5 100644 --- a/apps/website/components/Privacy.tsx +++ b/apps/website/components/Privacy.tsx @@ -9,7 +9,7 @@ const Privacy = () => {

"Öppna Skolplattformen", hädanefter "appen", byggs av "Not free beer AB" som en kommersiell app. Appen hämtar all information från - Stockholms stads skolplattform, hädanefter Skolplattformen, efter + respektive skolplattform, hädanefter Skolplattformen, efter inloggning via BankID. Appens funktion är därmed direkt knuten till att Skolplattformen fungerar. Vi kan endast ta ansvar för att vår kod fungerar – inte deras. diff --git a/apps/website/components/featureData.tsx b/apps/website/components/featureData.tsx index 6cab0425..65186aff 100644 --- a/apps/website/components/featureData.tsx +++ b/apps/website/components/featureData.tsx @@ -66,7 +66,7 @@ export const FEATURES_DATA = [ { title: 'Kan byggas ut till fler skolsystem', text: - 'Just nu stöds bara Stockholm Stads skolplattform men med din hjälp kan fler skolplattformar integreras så att du slipper logga in i flera appar om du har barn i olika skolor.', + 'Just nu stöds Stockholms och Göteborgs stads skolplattformar. Med din hjälp kan fler integreras så att du slipper använda flera appar om du har barn i olika skolor.', image: ( Date: Thu, 2 Dec 2021 15:34:15 +0100 Subject: [PATCH 04/41] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Fix=20image=20load?= =?UTF-8?q?=20and=20typescript=20errors=20(#570)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update Cocoapods version * Use new api GetRequestHeaders to get headers * Remove warnings of missing colors and brushes * Fix typing errors * Change affected main branch to main * Remove unused feature toggle * Add dummy login checker to remove using any --- .../components/calendar.component.tsx | 2 +- .../components/childContext.component.tsx | 2 +- .../components/childListItem.component.tsx | 2 +- .../components/children.component.tsx | 2 +- .../components/classmates.component.tsx | 2 +- .../components/contactMenu.component.tsx | 2 +- .../components/daySummary.component.tsx | 2 +- .../components/image.component.tsx | 4 ++-- .../components/menu.component.tsx | 2 +- .../components/menuListItem.component.tsx | 2 +- .../components/modalWebView.component.tsx | 4 ++-- .../components/navigation.component.tsx | 2 +- .../components/newsListItem.component.tsx | 2 +- .../components/notification.component.tsx | 2 +- .../components/saveToCalendar.component.tsx | 2 +- .../components/week.component.tsx | 6 +----- .../context/feature/featureContext.tsx | 3 ++- .../schoolPlatform/schoolPlatformContext.tsx | 2 +- apps/skolplattformen-app/data/schoolPlatforms.ts | 4 ++-- .../hooks/__tests__/usePersonalStorage.tests.ts | 2 +- apps/skolplattformen-app/ios/Podfile.lock | 2 +- .../services/__tests__/appStorage.tests.ts | 2 +- apps/skolplattformen-app/services/appStorage.ts | 2 +- apps/skolplattformen-app/utils/peopleHelpers.ts | 2 +- apps/skolplattformen-app/utils/search.tsx | 2 +- apps/skolplattformen-app/utils/testHelpers.tsx | 3 ++- libs/api-hjarntorget/lib/apiHjarntorget.ts | 16 ++++++++++++---- libs/api-hjarntorget/lib/fake/calendars.ts | 13 +++++++------ libs/api-hjarntorget/lib/fake/fakeFetcher.ts | 3 +-- libs/api-hjarntorget/lib/loginStatus.ts | 9 ++++++++- libs/api-skolplattformen/README.md | 4 ++-- libs/api-skolplattformen/lib/api.ts | 15 ++++++++++++--- .../lib/loginStatusChecker.ts | 9 ++++++++- libs/api/lib/api.ts | 1 + libs/hooks/README.md | 2 +- libs/hooks/src/hooks.ts | 2 +- 36 files changed, 84 insertions(+), 54 deletions(-) diff --git a/apps/skolplattformen-app/components/calendar.component.tsx b/apps/skolplattformen-app/components/calendar.component.tsx index b3c5f147..6651e312 100644 --- a/apps/skolplattformen-app/components/calendar.component.tsx +++ b/apps/skolplattformen-app/components/calendar.component.tsx @@ -1,4 +1,4 @@ -import { CalendarItem } from '@skolplattformen/api-skolplattformen' +import { CalendarItem } from '@skolplattformen/api' import { useCalendar } from '@skolplattformen/hooks' import { Divider, diff --git a/apps/skolplattformen-app/components/childContext.component.tsx b/apps/skolplattformen-app/components/childContext.component.tsx index 555c4852..d4bbc51b 100644 --- a/apps/skolplattformen-app/components/childContext.component.tsx +++ b/apps/skolplattformen-app/components/childContext.component.tsx @@ -1,4 +1,4 @@ -import { Child } from '@skolplattformen/api-skolplattformen' +import { Child } from '@skolplattformen/api' import React, { createContext, useContext } from 'react' interface ChildProviderProps { diff --git a/apps/skolplattformen-app/components/childListItem.component.tsx b/apps/skolplattformen-app/components/childListItem.component.tsx index bac10817..d8fb3491 100644 --- a/apps/skolplattformen-app/components/childListItem.component.tsx +++ b/apps/skolplattformen-app/components/childListItem.component.tsx @@ -1,7 +1,7 @@ /* eslint-disable react-native-a11y/has-accessibility-hint */ import { useNavigation } from '@react-navigation/native' import { StackNavigationProp } from '@react-navigation/stack' -import { Child } from '@skolplattformen/api-skolplattformen' +import { Child } from '@skolplattformen/api' import { useCalendar, useClassmates, diff --git a/apps/skolplattformen-app/components/children.component.tsx b/apps/skolplattformen-app/components/children.component.tsx index 7fe185c3..1e2a6acc 100644 --- a/apps/skolplattformen-app/components/children.component.tsx +++ b/apps/skolplattformen-app/components/children.component.tsx @@ -1,5 +1,5 @@ import { useNavigation } from '@react-navigation/core' -import { Child } from '@skolplattformen/api-skolplattformen' +import { Child } from '@skolplattformen/api' import { useApi, useChildList } from '@skolplattformen/hooks' import { Button, diff --git a/apps/skolplattformen-app/components/classmates.component.tsx b/apps/skolplattformen-app/components/classmates.component.tsx index 5d85dd58..5bf142db 100644 --- a/apps/skolplattformen-app/components/classmates.component.tsx +++ b/apps/skolplattformen-app/components/classmates.component.tsx @@ -1,4 +1,4 @@ -import { Classmate } from '@skolplattformen/api-skolplattformen' +import { Classmate } from '@skolplattformen/api' import { useClassmates } from '@skolplattformen/hooks' import { Divider, diff --git a/apps/skolplattformen-app/components/contactMenu.component.tsx b/apps/skolplattformen-app/components/contactMenu.component.tsx index 3b287431..6421291a 100644 --- a/apps/skolplattformen-app/components/contactMenu.component.tsx +++ b/apps/skolplattformen-app/components/contactMenu.component.tsx @@ -1,5 +1,5 @@ /* eslint-disable react-native-a11y/has-accessibility-hint */ -import { Classmate } from '@skolplattformen/api-skolplattformen' +import { Classmate } from '@skolplattformen/api' import { Button, MenuGroup, diff --git a/apps/skolplattformen-app/components/daySummary.component.tsx b/apps/skolplattformen-app/components/daySummary.component.tsx index 592ac975..8c908c09 100644 --- a/apps/skolplattformen-app/components/daySummary.component.tsx +++ b/apps/skolplattformen-app/components/daySummary.component.tsx @@ -1,4 +1,4 @@ -import { Child } from '@skolplattformen/api-skolplattformen' +import { Child } from '@skolplattformen/api' import { useTimetable } from '@skolplattformen/hooks' import { StyleService, Text, useStyleSheet } from '@ui-kitten/components' import moment, { Moment } from 'moment' diff --git a/apps/skolplattformen-app/components/image.component.tsx b/apps/skolplattformen-app/components/image.component.tsx index 2b17b1eb..86595485 100644 --- a/apps/skolplattformen-app/components/image.component.tsx +++ b/apps/skolplattformen-app/components/image.component.tsx @@ -31,7 +31,7 @@ export const Image = ({ resizeMode = 'contain', }: ImageProps) => { const { api } = useApi() - const [headers, setHeaders] = useState() + const [headers, setHeaders] = useState<{ [index: string]: string }>() const { width: windowWidth } = useWindowDimensions() const [dimensions, setDimensions] = useState({ width: 0, height: 0 }) @@ -40,7 +40,7 @@ export const Image = ({ const prefetchImageInformation = useCallback( async (url: string) => { if (!url) return - const { headers: newHeaders } = await api.getSession(url) + const newHeaders = await api.getSessionHeaders(url) console.log('[IMAGE] Getting image dimensions with headers', { debugImageName, diff --git a/apps/skolplattformen-app/components/menu.component.tsx b/apps/skolplattformen-app/components/menu.component.tsx index b1f18842..970060ee 100644 --- a/apps/skolplattformen-app/components/menu.component.tsx +++ b/apps/skolplattformen-app/components/menu.component.tsx @@ -1,4 +1,4 @@ -import { MenuItem } from '@skolplattformen/api-skolplattformen' +import { MenuItem } from '@skolplattformen/api' import { useMenu } from '@skolplattformen/hooks' import { Divider, diff --git a/apps/skolplattformen-app/components/menuListItem.component.tsx b/apps/skolplattformen-app/components/menuListItem.component.tsx index 77556007..235d9c92 100644 --- a/apps/skolplattformen-app/components/menuListItem.component.tsx +++ b/apps/skolplattformen-app/components/menuListItem.component.tsx @@ -1,4 +1,4 @@ -import { MenuItem } from '@skolplattformen/api-skolplattformen' +import { MenuItem } from '@skolplattformen/api' import { StyleService, Text, useStyleSheet } from '@ui-kitten/components' import React from 'react' import { View } from 'react-native' diff --git a/apps/skolplattformen-app/components/modalWebView.component.tsx b/apps/skolplattformen-app/components/modalWebView.component.tsx index 6a07b923..ab4fa26f 100644 --- a/apps/skolplattformen-app/components/modalWebView.component.tsx +++ b/apps/skolplattformen-app/components/modalWebView.component.tsx @@ -20,12 +20,12 @@ export const ModalWebView = ({ const [modalVisible, setModalVisible] = React.useState(true) const { api } = useApi() const [title, setTitle] = React.useState('...') - const [headers, setHeaders] = useState() + const [headers, setHeaders] = useState<{ [index: string]: string }>() useEffect(() => { const getHeaders = async (urlToGetSessionFor: string) => { if (sharedCookiesEnabled) return - const { headers: newHeaders } = await api.getSession(urlToGetSessionFor) + const newHeaders = await api.getSessionHeaders(urlToGetSessionFor) setHeaders(newHeaders) } diff --git a/apps/skolplattformen-app/components/navigation.component.tsx b/apps/skolplattformen-app/components/navigation.component.tsx index 412c6083..ec70d41d 100644 --- a/apps/skolplattformen-app/components/navigation.component.tsx +++ b/apps/skolplattformen-app/components/navigation.component.tsx @@ -2,7 +2,7 @@ import { NavigationContainer } from '@react-navigation/native' import { Child as ChildType, NewsItem as NewsItemType, -} from '@skolplattformen/api-skolplattformen' +} from '@skolplattformen/api' import { useApi } from '@skolplattformen/hooks' import { useTheme } from '@ui-kitten/components' import { Library } from 'libraries.json' diff --git a/apps/skolplattformen-app/components/newsListItem.component.tsx b/apps/skolplattformen-app/components/newsListItem.component.tsx index 226d6686..1b917043 100644 --- a/apps/skolplattformen-app/components/newsListItem.component.tsx +++ b/apps/skolplattformen-app/components/newsListItem.component.tsx @@ -1,6 +1,6 @@ import { useNavigation } from '@react-navigation/native' import { StackNavigationProp } from '@react-navigation/stack' -import { NewsItem } from '@skolplattformen/api-skolplattformen' +import { NewsItem } from '@skolplattformen/api' import { StyleService, useStyleSheet } from '@ui-kitten/components' import moment from 'moment' import React, { ReactNode } from 'react' diff --git a/apps/skolplattformen-app/components/notification.component.tsx b/apps/skolplattformen-app/components/notification.component.tsx index 5c7a0354..e859d026 100644 --- a/apps/skolplattformen-app/components/notification.component.tsx +++ b/apps/skolplattformen-app/components/notification.component.tsx @@ -1,4 +1,4 @@ -import { Notification as NotificationType } from '@skolplattformen/api-skolplattformen' +import { Notification as NotificationType } from '@skolplattformen/api' import { StyleService, Text, useStyleSheet } from '@ui-kitten/components' import moment from 'moment' import React from 'react' diff --git a/apps/skolplattformen-app/components/saveToCalendar.component.tsx b/apps/skolplattformen-app/components/saveToCalendar.component.tsx index 39118fe6..ff2491e6 100644 --- a/apps/skolplattformen-app/components/saveToCalendar.component.tsx +++ b/apps/skolplattformen-app/components/saveToCalendar.component.tsx @@ -1,4 +1,4 @@ -import { CalendarItem } from '@skolplattformen/api-skolplattformen' +import { CalendarItem } from '@skolplattformen/api' import { Button, MenuItem, OverflowMenu, Text } from '@ui-kitten/components' import React from 'react' import RNCalendarEvents from 'react-native-calendar-events' diff --git a/apps/skolplattformen-app/components/week.component.tsx b/apps/skolplattformen-app/components/week.component.tsx index 8be3925f..3eab8ee2 100644 --- a/apps/skolplattformen-app/components/week.component.tsx +++ b/apps/skolplattformen-app/components/week.component.tsx @@ -1,8 +1,4 @@ -import { - Child, - MenuItem, - TimetableEntry, -} from '@skolplattformen/api-skolplattformen' +import { Child, MenuItem, TimetableEntry } from '@skolplattformen/api' import { useMenu, useTimetable } from '@skolplattformen/hooks' import { List, diff --git a/apps/skolplattformen-app/context/feature/featureContext.tsx b/apps/skolplattformen-app/context/feature/featureContext.tsx index 82ae6762..250f7c96 100644 --- a/apps/skolplattformen-app/context/feature/featureContext.tsx +++ b/apps/skolplattformen-app/context/feature/featureContext.tsx @@ -2,8 +2,9 @@ import { Features, FeatureType } from '@skolplattformen/api' import React from 'react' export const FeatureFlagsContext = React.createContext({ - LOGIN_BANK_ID_SAME_DEVICE: false, + LOGIN_BANK_ID_SAME_DEVICE_WITHOUT_ID: true, FOOD_MENU: false, + CLASS_LIST: true, }) interface Props { diff --git a/apps/skolplattformen-app/context/schoolPlatform/schoolPlatformContext.tsx b/apps/skolplattformen-app/context/schoolPlatform/schoolPlatformContext.tsx index e223ec41..5baece05 100644 --- a/apps/skolplattformen-app/context/schoolPlatform/schoolPlatformContext.tsx +++ b/apps/skolplattformen-app/context/schoolPlatform/schoolPlatformContext.tsx @@ -16,7 +16,7 @@ export const SchoolPlatformProvider: React.FC = ({ children }) => { 'currentSchoolPlatform' ) - const changeSchoolPlatform = (platform: string) => { + const changeSchoolPlatform = (platform) => { setCurrentSchoolPlatform(platform) } diff --git a/apps/skolplattformen-app/data/schoolPlatforms.ts b/apps/skolplattformen-app/data/schoolPlatforms.ts index 70f66019..d0d84536 100644 --- a/apps/skolplattformen-app/data/schoolPlatforms.ts +++ b/apps/skolplattformen-app/data/schoolPlatforms.ts @@ -10,13 +10,13 @@ export const schoolPlatforms = [ { id: 'stockholm-skolplattformen', displayName: 'Stockholm stad (Skolplattformen)', - api: initSkolplattformen(fetch, CookieManager), + api: initSkolplattformen(fetch as any, CookieManager), features: featuresSkolPlattformen, }, { id: 'goteborg-hjarntorget', displayName: 'Göteborg stad (Hjärntorget)', - api: initHjarntorget(fetch, CookieManager), + api: initHjarntorget(fetch as any, CookieManager), features: featuresHjarntorget, }, ] diff --git a/apps/skolplattformen-app/hooks/__tests__/usePersonalStorage.tests.ts b/apps/skolplattformen-app/hooks/__tests__/usePersonalStorage.tests.ts index 4fbb2df4..754f7fde 100644 --- a/apps/skolplattformen-app/hooks/__tests__/usePersonalStorage.tests.ts +++ b/apps/skolplattformen-app/hooks/__tests__/usePersonalStorage.tests.ts @@ -1,5 +1,5 @@ import AsyncStorage from '@react-native-async-storage/async-storage' -import { User } from '@skolplattformen/api-skolplattformen' +import { User } from '@skolplattformen/api' import { act, renderHook } from '@testing-library/react-hooks' import usePersonalStorage from '../usePersonalStorage' diff --git a/apps/skolplattformen-app/ios/Podfile.lock b/apps/skolplattformen-app/ios/Podfile.lock index fda48c7f..fef1aa99 100644 --- a/apps/skolplattformen-app/ios/Podfile.lock +++ b/apps/skolplattformen-app/ios/Podfile.lock @@ -669,4 +669,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 85f5a2dfa1de342b427eecb6e9652410ad153247 -COCOAPODS: 1.10.1 +COCOAPODS: 1.11.2 diff --git a/apps/skolplattformen-app/services/__tests__/appStorage.tests.ts b/apps/skolplattformen-app/services/__tests__/appStorage.tests.ts index 08946f82..230e017a 100644 --- a/apps/skolplattformen-app/services/__tests__/appStorage.tests.ts +++ b/apps/skolplattformen-app/services/__tests__/appStorage.tests.ts @@ -1,5 +1,5 @@ import AsyncStorage from '@react-native-async-storage/async-storage' -import { User } from '@skolplattformen/api-skolplattformen' +import { User } from '@skolplattformen/api' import AppStorage from '../appStorage' beforeEach(() => { diff --git a/apps/skolplattformen-app/services/appStorage.ts b/apps/skolplattformen-app/services/appStorage.ts index bbe2a6a4..c881e11e 100644 --- a/apps/skolplattformen-app/services/appStorage.ts +++ b/apps/skolplattformen-app/services/appStorage.ts @@ -1,5 +1,5 @@ import AsyncStorage from '@react-native-async-storage/async-storage' -import { User } from '@skolplattformen/api-skolplattformen' +import { User } from '@skolplattformen/api' export default class AppStorage { static settingsStorageKeyPrefix = 'appsetting_' diff --git a/apps/skolplattformen-app/utils/peopleHelpers.ts b/apps/skolplattformen-app/utils/peopleHelpers.ts index f44d34a1..32ec3639 100644 --- a/apps/skolplattformen-app/utils/peopleHelpers.ts +++ b/apps/skolplattformen-app/utils/peopleHelpers.ts @@ -1,4 +1,4 @@ -import { Guardian } from '@skolplattformen/api-skolplattformen' +import { Guardian } from '@skolplattformen/api' export const studentName = (name?: string) => name?.replace(/\s?\(\w+\)$/, '') diff --git a/apps/skolplattformen-app/utils/search.tsx b/apps/skolplattformen-app/utils/search.tsx index 2752ef98..defa5ba6 100644 --- a/apps/skolplattformen-app/utils/search.tsx +++ b/apps/skolplattformen-app/utils/search.tsx @@ -1,4 +1,4 @@ -import { NewsItem } from '@skolplattformen/api-skolplattformen' +import { NewsItem } from '@skolplattformen/api' import { useNews } from '@skolplattformen/hooks' import { MatchData, Searcher } from 'fast-fuzzy' import React, { ReactNode, useMemo } from 'react' diff --git a/apps/skolplattformen-app/utils/testHelpers.tsx b/apps/skolplattformen-app/utils/testHelpers.tsx index c915d566..37899527 100644 --- a/apps/skolplattformen-app/utils/testHelpers.tsx +++ b/apps/skolplattformen-app/utils/testHelpers.tsx @@ -5,6 +5,7 @@ import { EvaIconsPack } from '@ui-kitten/eva-icons' import React, { ReactElement } from 'react' import { LanguageProvider } from '../context/language/languageContext' import { translations } from './translation' +import { lightTheme } from '../design/themes' export const render = ( ui: ReactElement, @@ -14,7 +15,7 @@ export const render = ( return ( <> - + { + const cookie = await this.cookieManager.getCookieString(url) + return { + cookie, + } + } + async setSessionCookie(sessionCookie: string): Promise { await this.fetch('login-cookie', hjarntorgetUrl, { headers: { @@ -490,13 +498,13 @@ export class ApiHjarntorget extends EventEmitter implements Api { if((beginLoginRedirectResponse as any).url.endsWith("startPage.do")) { // already logged in! - const emitter = new EventEmitter() + const emitter = new DummyStatusChecker() setTimeout(() => { this.isLoggedIn = true emitter.emit('OK') this.emit('login') }, 50) - return emitter; + return emitter as LoginStatusChecker; } console.log('prepping??? shibboleth') diff --git a/libs/api-hjarntorget/lib/fake/calendars.ts b/libs/api-hjarntorget/lib/fake/calendars.ts index fc7cbf7f..1657cee3 100644 --- a/libs/api-hjarntorget/lib/fake/calendars.ts +++ b/libs/api-hjarntorget/lib/fake/calendars.ts @@ -1,17 +1,17 @@ +import { Response } from '@skolplattformen/api'; /* eslint-disable no-useless-escape */ export const calendars = () => ({ "url": "https://hjarntorget.goteborg.se/pp/system/calendar/cal_events.jsp", "headers": { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36", - "cookie": "REMOVED" + "cookie": "REMOVED" }, "status": 200, "statusText": "200", "text": () => Promise.resolve("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nThe PING PONG Calendar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t

\n\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\n\t\n\n\n\n\t\t\n\n\t\t
\n\t\t\t\n\t\t\t
\n\t\t\t\t

Make a selection

\n\n\t\t\t\t

Here you get an overview of your calendars. Choose from which calendars you wish to see events. Choose if you want to search for a word. Click Show to see the result.

\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
Show calendar events for the checked calendars
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\n\n
\"\"
\n\n\n\n
removed checkbox
\"\"
\n\n\n\n
removed checkbox
\"\"
\n\n\t\t\t\t\t\t\t
\n\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
Group the events per calendar\n\t\t\t\t\t\t\t\t\t
Don't group\n\t\t\t\t\t\t\t\t\t
From - to:\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t
Search for
\n\t\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
\n\n\t\t\t\t\t\t
\n\t\t\t
\n\n\t\t\t

Calendar events

\n\n\t\t\t\t\n\t\t\t\t

\n\t\t\t\t\t No events was found \n\t\t\t\t\t\n\t\t\t\t

\n\t\t\t\t\n\n\t\t\t
\n\t\t
\n\t
\n\n\n\n\n") }) as any as Response -export const calendar_14241345 = () => { - return { +export const calendar_14241345 = () => ({ "url": "https://hjarntorget.goteborg.se/pp/system/calendar/cal_events.jsp?order_by=start_date&show_cal_ids=14241345&mode=separate&filter_start_date=2021-11-09&filter_end_date=2021-12-09&search_for=", "headers": { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36", @@ -19,6 +19,8 @@ export const calendar_14241345 = () => { }, "status": 200, "statusText": "200", + "json": null, + "ok": true, "text": () => { const now = new Date() const dateYearMonth = `${now.getFullYear()}-${now.getMonth() + 1}` @@ -27,7 +29,6 @@ export const calendar_14241345 = () => { const result = ` \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nThe PING PONG Calendar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t
\n\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\n\t\n\n\n\n\t\t\n\n\t\t
\n\t\t\t\n\t\t\t
\n\t\t\t\t

Make a selection

\n\n\t\t\t\t

Here you get an overview of your calendars. Choose from which calendars you wish to see events. Choose if you want to search for a word. Click Show to see the result.

\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
Show calendar events for the checked calendars
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\n\n
removed checkbox
\"\"
\n\n\n\n
removed checkbox
\"\"
\n\n\n\n
removed checkbox
\"\"
\n\n\t\t\t\t\t\t\t
\n\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
Group the events per calendar\n\t\t\t\t\t\t\t\t\t
Don't group\n\t\t\t\t\t\t\t\t\t
From - to:\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t
Search for
\n\t\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
\n\n\t\t\t\t\t\t
\n\t\t\t
\n\n\t\t\t

Calendar events

\n\n\t\t\t\t\n\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\n\t\t\t\t\t\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\t\t\t\tTitle\n\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tDates\n\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tTimes\n\n\t\t\t\t\t\t\t
138JÄTS Provschema år 8
\"\"
\nProv/komplettering franska ${dateYearMonth}-0113:00-14:00
\"\"
\nTyska läxförhör${dateYearMonth}-0113:00-13:30\"The
\"\"
\nLäxa i franska${dateYearMonth}-0309:40-10:20\"The
\"\"
\nSpanskaprov Repasamos 1- 4${dateYearMonth}-0310:00-11:00
\"\"
\nTyska läxförhör${dateYearMonth}-0813:00-13:30\"The
\"\"
\nLäxa i franska${dateYearMonth}-1009:40-10:20\"The
\"\"
\nDeadline engelska - Postcard from Great Britain${dateYearMonth}-1115:00-16:00\"The
\"\"
\nLäxa engelska${dateYearMonth}-1408:00-09:00\"The
\"\"
\nTyska läxförhör${dateYearMonth}-1513:00-13:30\"The
\"\"
\nLäxa i franska${dateYearMonth}-1709:40-10:20\"The
\"\"
\nLäxa engelska${dateYearMonth}-1908:00-09:00\"The
\"\"
\nProv franska åk 7${dateYearMonth}-2012:00-13:00
\"\"
\nLäxa i franska${dateYearMonth}-2209:40-10:20\"The
\"\"
\nLäxa engelska${nextMonth}-0108:00-09:00\"The
\n\n\t\t\t\t\n\n\t\t\t
\n\t\t
\n\t
\n\n\n\n\n ` - return Promise.resolve(result as any as Response) + return Promise.resolve(result) } - } -} \ No newline at end of file + }) as any as Response diff --git a/libs/api-hjarntorget/lib/fake/fakeFetcher.ts b/libs/api-hjarntorget/lib/fake/fakeFetcher.ts index 87595ba3..d9a9e6f5 100644 --- a/libs/api-hjarntorget/lib/fake/fakeFetcher.ts +++ b/libs/api-hjarntorget/lib/fake/fakeFetcher.ts @@ -28,10 +28,9 @@ const fetchMappings: { [name:string]: () => Response} = { 'event-role-members-24-821': eventRoleMembers24, 'calendars': calendars, 'calendar-14241345': calendar_14241345, - } export const fakeFetcher: Fetcher = (name: string, url: string, init?: any): Promise => { const responder = fetchMappings[name] ?? (() => {throw new Error("Request not faked for name: " + name)}) return Promise.resolve(responder()); -} +} diff --git a/libs/api-hjarntorget/lib/loginStatus.ts b/libs/api-hjarntorget/lib/loginStatus.ts index aeeeda68..c96665f2 100644 --- a/libs/api-hjarntorget/lib/loginStatus.ts +++ b/libs/api-hjarntorget/lib/loginStatus.ts @@ -10,7 +10,7 @@ import { pollStatusUrl, } from './routes' -export class HjarntorgetChecker extends EventEmitter { +export class HjarntorgetChecker extends EventEmitter implements LoginStatusChecker { private fetcher: Fetcher private basePollingUrl: string @@ -120,3 +120,10 @@ export const checkStatus = ( fetch: Fetcher, basePollingUrl: string ): LoginStatusChecker => new HjarntorgetChecker(fetch, basePollingUrl) + +export class DummyStatusChecker extends EventEmitter implements LoginStatusChecker { + token = "" + async cancel(): Promise { + // do nothing + } +} diff --git a/libs/api-skolplattformen/README.md b/libs/api-skolplattformen/README.md index 85053458..37c23583 100644 --- a/libs/api-skolplattformen/README.md +++ b/libs/api-skolplattformen/README.md @@ -16,7 +16,7 @@ the concrete implementation of fetch and cookie handler must be injected. #### react-native ```javascript -import init from '@skolplattformen/api-skolplattformen' +import init from '@skolplattformen/api' import CookieManager from '@react-native-cookies/cookies' const api = init(fetch, () => CookieManager.clearAll()) @@ -25,7 +25,7 @@ const api = init(fetch, () => CookieManager.clearAll()) #### node ```javascript -import init from '@skolplattformen/api-skolplattformen' +import init from '@skolplattformen/api' import nodeFetch from 'node-fetch' import fetchCookie from 'fetch-cookie/node-fetch' import { CookieJar } from 'tough-cookie' diff --git a/libs/api-skolplattformen/lib/api.ts b/libs/api-skolplattformen/lib/api.ts index 66d94ced..4774804f 100644 --- a/libs/api-skolplattformen/lib/api.ts +++ b/libs/api-skolplattformen/lib/api.ts @@ -28,7 +28,7 @@ import { decode } from 'he' import { DateTime } from 'luxon' import * as html from 'node-html-parser' import * as fake from './fakeData' -import { checkStatus } from './loginStatusChecker' +import { checkStatus, DummyStatusChecker } from './loginStatusChecker' import * as parse from './parse/index' import * as routes from './routes' @@ -94,6 +94,16 @@ export class ApiSkolplattformen extends EventEmitter implements Api { } } + public async getSessionHeaders(url: string): Promise<{ [index: string]: string }> { + const init = this.getRequestInit() + const cookie = await this.cookieManager.getCookieString(url) + return { + ...init.headers, + cookie, + } + } + + public async getSession( url: string, options?: RequestInit @@ -203,8 +213,7 @@ export class ApiSkolplattformen extends EventEmitter implements Api { this.emit('login') }, 50) - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const emitter: any = new EventEmitter() + const emitter = new DummyStatusChecker() emitter.token = 'fake' return emitter } diff --git a/libs/api-skolplattformen/lib/loginStatusChecker.ts b/libs/api-skolplattformen/lib/loginStatusChecker.ts index a2fab185..0cdb4593 100644 --- a/libs/api-skolplattformen/lib/loginStatusChecker.ts +++ b/libs/api-skolplattformen/lib/loginStatusChecker.ts @@ -2,7 +2,7 @@ import { EventEmitter } from 'events'; import { loginStatus } from './routes'; import { AuthTicket, Fetcher, LoginStatusChecker } from '@skolplattformen/api'; -export class Checker extends EventEmitter { +export class Checker extends EventEmitter implements LoginStatusChecker { public token: string; private fetcher: Fetcher; @@ -41,3 +41,10 @@ export const checkStatus = ( fetch: Fetcher, ticket: AuthTicket ): LoginStatusChecker => new Checker(fetch, ticket) + +export class DummyStatusChecker extends EventEmitter implements LoginStatusChecker { + token = "" + async cancel(): Promise { + // do nothing + } +} diff --git a/libs/api/lib/api.ts b/libs/api/lib/api.ts index 890176b4..4ba711a1 100644 --- a/libs/api/lib/api.ts +++ b/libs/api/lib/api.ts @@ -21,6 +21,7 @@ export interface Api extends EventEmitter { getPersonalNumber(): string | undefined login(personalNumber?: string): Promise setSessionCookie(sessionCookie: string): Promise + getSessionHeaders(url: string): Promise<{ [index: string]: string }> getUser(): Promise getChildren(): Promise getCalendar(child: EtjanstChild): Promise diff --git a/libs/hooks/README.md b/libs/hooks/README.md index 16f570fc..2ec4bd52 100644 --- a/libs/hooks/README.md +++ b/libs/hooks/README.md @@ -18,7 +18,7 @@ In order to use api hooks, you must wrap your app in an ApiProvider ```javascript import React from 'react' import { ApiProvider } from '@skolplattformen/hooks' -import init from '@skolplattformen/api-skolplattformen' +import init from '@skolplattformen/api-skolplattformet' import { CookieManager } from '@react-native-cookies/cookies' import AsyncStorage from '@react-native-async-storage/async-storage' import { RootComponent } from './components/root' diff --git a/libs/hooks/src/hooks.ts b/libs/hooks/src/hooks.ts index 594a0cbe..d3bbef7a 100644 --- a/libs/hooks/src/hooks.ts +++ b/libs/hooks/src/hooks.ts @@ -107,7 +107,7 @@ const hook = ( if (newState.error) { const description = `Error getting ${entityName} from API` - reporter.error(newState.error, description) + reporter.error && reporter.error(newState.error, description) } } } From bf29ab58edd13db62b34f873a3429d319c0e7297 Mon Sep 17 00:00:00 2001 From: Andreas Eriksson Date: Thu, 2 Dec 2021 15:37:52 +0100 Subject: [PATCH 05/41] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Clear=20personal?= =?UTF-8?q?=20cache=20on=20login=20and=20logout=20(#572)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Until we have a better cache-clearing function in hooks lib this will help with not filling the phone with old data --- apps/skolplattformen-app/components/login.component.tsx | 3 +++ apps/skolplattformen-app/components/settings.component.tsx | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/skolplattformen-app/components/login.component.tsx b/apps/skolplattformen-app/components/login.component.tsx index 66dc2b8b..5f63c14d 100644 --- a/apps/skolplattformen-app/components/login.component.tsx +++ b/apps/skolplattformen-app/components/login.component.tsx @@ -34,6 +34,7 @@ import { PersonIcon, SelectIcon, } from './icon.component' +import AppStorage from '../services/appStorage' const BankId = () => ( { ] as const const loginHandler = async () => { + const user = await api.getUser() + await AppStorage.clearPersonalData(user) showModal(false) } diff --git a/apps/skolplattformen-app/components/settings.component.tsx b/apps/skolplattformen-app/components/settings.component.tsx index d633202e..d2dc60e2 100644 --- a/apps/skolplattformen-app/components/settings.component.tsx +++ b/apps/skolplattformen-app/components/settings.component.tsx @@ -1,5 +1,5 @@ import { NavigationProp, useNavigation } from '@react-navigation/core' -import { useApi } from '@skolplattformen/hooks' +import { useApi, useUser } from '@skolplattformen/hooks' import React, { useCallback } from 'react' import { ScrollView } from 'react-native' import { NativeStackNavigationOptions } from 'react-native-screens/native-stack' @@ -28,14 +28,16 @@ export const SettingsScreen = () => { const langCode = LanguageService.getLanguageCode() const language = languages.find((l) => l.langCode === langCode) const { api } = useApi() + const { data: user } = useUser() const logout = useCallback(async () => { await AppStorage.clearTemporaryItems() + await AppStorage.clearPersonalData(user) await api.logout() navigation.reset({ routes: [{ name: 'Login' }], }) - }, [api, navigation]) + }, [api, navigation, user]) return ( Date: Thu, 2 Dec 2021 15:42:17 +0100 Subject: [PATCH 06/41] chore(release): 2.4.0 [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # [2.4.0](https://github.com/kolplattformen/skolplattformen/compare/v2.3.2...v2.4.0) (2021-12-02) ### Features * 🎸 Clear personal cache on login and logout ([#572](https://github.com/kolplattformen/skolplattformen/issues/572)) ([bf29ab5](https://github.com/kolplattformen/skolplattformen/commit/bf29ab58edd13db62b34f873a3429d319c0e7297)) * 🎸 Fix image load and typescript errors ([#570](https://github.com/kolplattformen/skolplattformen/issues/570)) ([933a884](https://github.com/kolplattformen/skolplattformen/commit/933a8840a3ebd049711a000ca6faf3e534f77ace)) --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2be3a594..14e3faab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# [2.4.0](https://github.com/kolplattformen/skolplattformen/compare/v2.3.2...v2.4.0) (2021-12-02) + + +### Features + +* 🎸 Clear personal cache on login and logout ([#572](https://github.com/kolplattformen/skolplattformen/issues/572)) ([bf29ab5](https://github.com/kolplattformen/skolplattformen/commit/bf29ab58edd13db62b34f873a3429d319c0e7297)) +* 🎸 Fix image load and typescript errors ([#570](https://github.com/kolplattformen/skolplattformen/issues/570)) ([933a884](https://github.com/kolplattformen/skolplattformen/commit/933a8840a3ebd049711a000ca6faf3e534f77ace)) + ## [2.3.2](https://github.com/kolplattformen/skolplattformen/compare/v2.3.1...v2.3.2) (2021-12-01) diff --git a/package.json b/package.json index a2b491db..768da0b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "skolplattformen", - "version": "2.3.2", + "version": "2.4.0", "license": "MIT", "scripts": { "start": "nx start", From c92b352a6dde09fff4a016461ea20702f2215826 Mon Sep 17 00:00:00 2001 From: Andreas Eriksson Date: Thu, 2 Dec 2021 23:58:57 +0100 Subject: [PATCH 07/41] Add refresh control to views --- apps/skolplattformen-app/App.tsx | 2 +- .../components/calendar.component.tsx | 89 +++++++++++++------ .../components/childListItem.component.tsx | 54 ++++++++--- .../components/children.component.tsx | 25 ++++-- .../components/classmates.component.tsx | 7 +- .../components/icon.component.tsx | 1 + .../components/menu.component.tsx | 13 ++- .../components/newsItem.component.tsx | 13 ++- .../components/newsList.component.tsx | 18 +++- .../notificationsList.component.tsx | 6 +- .../ios/app.xcodeproj/project.pbxproj | 12 +-- apps/skolplattformen-app/translations/sv.json | 4 +- 12 files changed, 180 insertions(+), 64 deletions(-) diff --git a/apps/skolplattformen-app/App.tsx b/apps/skolplattformen-app/App.tsx index 4b278c6c..fde47127 100644 --- a/apps/skolplattformen-app/App.tsx +++ b/apps/skolplattformen-app/App.tsx @@ -19,7 +19,7 @@ import { translations } from './utils/translation' const reporter: Reporter | undefined = __DEV__ ? { log: (message: string) => console.log(message), - error: (error: Error, label?: string) => console.error(label, error), + error: (error: Error, label?: string) => console.log(label, error), } : undefined diff --git a/apps/skolplattformen-app/components/calendar.component.tsx b/apps/skolplattformen-app/components/calendar.component.tsx index 6651e312..25c9b6d1 100644 --- a/apps/skolplattformen-app/components/calendar.component.tsx +++ b/apps/skolplattformen-app/components/calendar.component.tsx @@ -1,5 +1,5 @@ -import { CalendarItem } from '@skolplattformen/api' import { useCalendar } from '@skolplattformen/hooks' +import { CalendarItem } from '@skolplattformen/api' import { Divider, List, @@ -10,8 +10,9 @@ import { } from '@ui-kitten/components' import moment from 'moment' import React from 'react' -import { ListRenderItemInfo, View } from 'react-native' -import { Typography } from '../styles' +import { ListRenderItemInfo, RefreshControl, View } from 'react-native' +import { Layout as LayoutStyle, Sizing, Typography } from '../styles' +import { translate } from '../utils/translation' import { useChild } from './childContext.component' import { CalendarOutlineIcon } from './icon.component' import { SaveToCalendar } from './saveToCalendar.component' @@ -19,7 +20,7 @@ import { Week } from './week.component' export const Calendar = () => { const child = useChild() - const { data } = useCalendar(child) + const { data, status, reload } = useCalendar(child) const styles = useStyleSheet(themedStyles) const formatStartDate = (startDate: moment.MomentInput) => { @@ -28,37 +29,55 @@ export const Calendar = () => { 'll' )} • ${date.fromNow()}` - // Hack to remove yarn if it is this year + // Hack to remove year if it is this year const currentYear = moment().year().toString(10) return output.replace(currentYear, '') } + const sortedData = () => { + if (!data) return [] + + return data.sort((a, b) => + a.startDate && b.startDate ? a.startDate.localeCompare(b.startDate) : 0 + ) + } + return ( - {data && data.length > 0 && ( - - a.startDate && b.startDate - ? a.startDate.localeCompare(b.startDate) - : 0 - )} - ItemSeparatorComponent={Divider} - renderItem={({ item }: ListRenderItemInfo) => ( - ( - - {formatStartDate(item.startDate)} - - )} - accessoryLeft={CalendarOutlineIcon} - accessoryRight={() => } - /> - )} - /> - )} + + + {translate('calender.emptyHeadline')} + + + {translate('calender.emptyText')} + + + } + renderItem={({ item }: ListRenderItemInfo) => ( + ( + + {formatStartDate(item.startDate)} + + )} + accessoryLeft={CalendarOutlineIcon} + accessoryRight={() => } + /> + )} + refreshControl={ + + } + /> ) } @@ -73,4 +92,18 @@ const themedStyles = StyleService.create({ ...Typography.fontSize.xs, color: 'text-hint-color', }, + emptyState: { + ...LayoutStyle.center, + ...LayoutStyle.flex.full, + }, + emptyStateHeadline: { + ...Typography.align.center, + margin: Sizing.t4, + }, + emptyStateDescription: { + ...Typography.align.center, + lineHeight: 21, + paddingHorizontal: Sizing.t3, + margin: Sizing.t4, + }, }) diff --git a/apps/skolplattformen-app/components/childListItem.component.tsx b/apps/skolplattformen-app/components/childListItem.component.tsx index d8fb3491..f718a7c7 100644 --- a/apps/skolplattformen-app/components/childListItem.component.tsx +++ b/apps/skolplattformen-app/components/childListItem.component.tsx @@ -17,7 +17,7 @@ import { useStyleSheet, } from '@ui-kitten/components' import moment from 'moment' -import React from 'react' +import React, { useEffect } from 'react' import { TouchableOpacity, useColorScheme, View } from 'react-native' import { useTranslation } from '../hooks/useTranslation' import { Colors, Layout, Sizing } from '../styles' @@ -30,13 +30,18 @@ import { StudentAvatar } from './studentAvatar.component' interface ChildListItemProps { child: Child color: string + updated: string } type ChildListItemNavigationProp = StackNavigationProp< RootStackParamList, 'Children' > -export const ChildListItem = ({ child, color }: ChildListItemProps) => { +export const ChildListItem = ({ + child, + color, + updated, +}: ChildListItemProps) => { // Forces rerender when child.id changes React.useEffect(() => { // noop @@ -44,17 +49,38 @@ export const ChildListItem = ({ child, color }: ChildListItemProps) => { const navigation = useNavigation() const { t } = useTranslation() - const { data: notifications } = useNotifications(child) - const { data: news } = useNews(child) - const { data: classmates } = useClassmates(child) - const { data: calendar } = useCalendar(child) - const { data: menu } = useMenu(child) - const { data: schedule } = useSchedule( + const { data: notifications, reload: notificationsReload } = + useNotifications(child) + const { data: news, status: newsStatus, reload: newsReload } = useNews(child) + const { data: classmates, reload: classmatesReload } = useClassmates(child) + const { data: calendar, reload: calendarReload } = useCalendar(child) + const { data: menu, reload: menuReload } = useMenu(child) + const { data: schedule, reload: scheduleReload } = useSchedule( child, moment().toISOString(), moment().add(7, 'days').toISOString() ) + useEffect(() => { + // Do not refresh if updated is empty (first render of component) + if (updated === '') return + + console.log('Reload', child.name, updated) + + newsReload() + classmatesReload() + notificationsReload() + calendarReload() + menuReload() + scheduleReload() + + // Without eslint-disable below we get into a forever loop + // because the function pointers to reload functions change on every reload. + // I do not know a workaround for this. + + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [updated]) + const notificationsThisWeek = notifications.filter( ({ dateCreated, dateModified }) => { const date = dateModified || dateCreated @@ -168,7 +194,6 @@ export const ChildListItem = ({ child, color }: ChildListItemProps) => { {t('news.noNewNewsItemsThisWeek')} )} - {!menu[moment().isoWeekday() - 1] ? null : ( <> @@ -177,7 +202,7 @@ export const ChildListItem = ({ child, color }: ChildListItemProps) => { {menu[moment().isoWeekday() - 1]?.description} )} - + - - - - - ) : ( - - - - {translate('general.loading')} - - - )} + + } + renderItem={({ item: child, index }: ListRenderItemInfo) => ( + + )} + /> + ) : ( + + + {status === 'error' ? ( + + {translate('children.loadingErrorHeading')} + + {translate('children.loadingErrorInformationText')} + + + + + + + + ) : ( + + + + {translate('general.loading')} + )} - + ) } diff --git a/apps/skolplattformen-app/components/daySummary.component.tsx b/apps/skolplattformen-app/components/daySummary.component.tsx index 8c908c09..a9b93dfb 100644 --- a/apps/skolplattformen-app/components/daySummary.component.tsx +++ b/apps/skolplattformen-app/components/daySummary.component.tsx @@ -2,7 +2,7 @@ import { Child } from '@skolplattformen/api' import { useTimetable } from '@skolplattformen/hooks' import { StyleService, Text, useStyleSheet } from '@ui-kitten/components' import moment, { Moment } from 'moment' -import React from 'react' +import React, { useCallback, useEffect, useState } from 'react' import { View } from 'react-native' import { LanguageService } from '../services/languageService' import { translate } from '../utils/translation' @@ -12,9 +12,13 @@ interface DaySummaryProps { date?: Moment } -export const DaySummary = ({ child, date = moment() }: DaySummaryProps) => { +export const DaySummary = ({ + child, + date: currentDate = moment(), +}: DaySummaryProps) => { const styles = useStyleSheet(themedStyles) - const [year, week] = [moment().isoWeekYear(), moment().isoWeek()] + const [week, year] = [currentDate.isoWeek(), currentDate.isoWeekYear()] + const { data: weekLessons } = useTimetable( child, week, @@ -23,7 +27,7 @@ export const DaySummary = ({ child, date = moment() }: DaySummaryProps) => { ) const lessons = weekLessons - .filter((lesson) => lesson.dayOfWeek === date.isoWeekday()) + .filter((lesson) => lesson.dayOfWeek === currentDate.isoWeekday()) .sort((a, b) => a.dateStart.localeCompare(b.dateStart)) if (lessons.length <= 0) { @@ -53,15 +57,21 @@ export const DaySummary = ({ child, date = moment() }: DaySummaryProps) => { + + + +   + + + {gymBag + ? ` 🤼‍♀️ ${translate('schedule.gymBag', { + defaultValue: 'Gympapåse', + })}` + : ''} + + + - - - {gymBag - ? ` 🤼‍♀️ ${translate('schedule.gymBag', { - defaultValue: 'Gympapåse', - })}` - : ''} - ) } @@ -76,4 +86,7 @@ const themedStyles = StyleService.create({ label: { marginTop: 10, }, + heading: { + marginBottom: -10, + }, }) diff --git a/apps/skolplattformen-app/components/week.component.tsx b/apps/skolplattformen-app/components/week.component.tsx index 3eab8ee2..e7b07ffb 100644 --- a/apps/skolplattformen-app/components/week.component.tsx +++ b/apps/skolplattformen-app/components/week.component.tsx @@ -16,6 +16,7 @@ import { View } from 'react-native' import { LanguageService } from '../services/languageService' import { Sizing, Typography } from '../styles' import { TransitionView } from './transitionView.component' +import { getMeaningfulStartingDate } from '../utils/calendarHelpers' interface WeekProps { child: Child @@ -107,10 +108,12 @@ export const Day = ({ weekDay, lunch, lessons }: DayProps) => { export const Week = ({ child }: WeekProps) => { moment.locale(LanguageService.getLocale()) const days = moment.weekdaysShort().slice(1, 6) - const currentDayIndex = Math.min(moment().isoWeekday() - 1, 5) + const displayDate = getMeaningfulStartingDate() + + const currentDayIndex = Math.min(moment(displayDate).isoWeekday() - 1, 5) const [selectedIndex, setSelectedIndex] = useState(currentDayIndex) const [showSchema, setShowSchema] = useState(false) - const [year, week] = [moment().isoWeekYear(), moment().isoWeek()] + const [year, week] = [displayDate.isoWeekYear(), displayDate.isoWeek()] const { data: lessons } = useTimetable( child, week, diff --git a/apps/skolplattformen-app/translations/en.json b/apps/skolplattformen-app/translations/en.json index d85f7932..188a51d6 100644 --- a/apps/skolplattformen-app/translations/en.json +++ b/apps/skolplattformen-app/translations/en.json @@ -80,7 +80,8 @@ "send": "Send", "settings": "Settings", "socialSecurityNumber": "Personal identity number", - "title": "Öppna skolplattformen" + "title": "Öppna skolplattformen", + "tomorrow": "Tomorrow" }, "language": { "changeLanguage": "Change language", diff --git a/apps/skolplattformen-app/translations/sv.json b/apps/skolplattformen-app/translations/sv.json index 1a7846cb..1fd88625 100644 --- a/apps/skolplattformen-app/translations/sv.json +++ b/apps/skolplattformen-app/translations/sv.json @@ -82,7 +82,8 @@ "title": "Öppna skolplattformen", "cancel": "Avbryt", "logoutAndClearAllDataInclSettings": "Logga ut och rensa all sparad data inkl inställningar", - "logoutAndClearPersonalData": "Logga ut och rensa all personlig data" + "logoutAndClearPersonalData": "Logga ut och rensa all personlig data", + "tomorrow": "Imorgon" }, "language": { "changeLanguage": "Byt språk", diff --git a/apps/skolplattformen-app/utils/calendarHelpers.ts b/apps/skolplattformen-app/utils/calendarHelpers.ts new file mode 100644 index 00000000..335d74d9 --- /dev/null +++ b/apps/skolplattformen-app/utils/calendarHelpers.ts @@ -0,0 +1,9 @@ +import moment from 'moment' + +export const getMeaningfulStartingDate = (date = moment()) => { + // are we on the evening? + if (date.hour() > 17) date = date.add('1', 'day') + // are we on the weekend + if (date.isoWeekday() > 5) date = date.add(5, 'days').startOf('isoWeek') + return date +} diff --git a/libs/api-skolplattformen/lib/parse/timetable.ts b/libs/api-skolplattformen/lib/parse/timetable.ts index 9be35042..3719245e 100644 --- a/libs/api-skolplattformen/lib/parse/timetable.ts +++ b/libs/api-skolplattformen/lib/parse/timetable.ts @@ -84,6 +84,11 @@ export const timetable = ( if (response.error) { throw new Error(response.error) } + + if(!response.data.lessonInfo){ + throw new Error("Empty lessonInfo received") + } + return response.data.lessonInfo.map((entry) => timetableEntry(entry, year, week, lang) ) From 3fbd08c794aeb4dff9199213738058ac4f123ec6 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 3 Dec 2021 11:31:34 +0100 Subject: [PATCH 09/41] chore(release): 2.5.0 [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # [2.5.0](https://github.com/kolplattformen/skolplattformen/compare/v2.4.0...v2.5.0) (2021-12-03) ### Features * 🎸 Skip to the next day in calendar ([#425](https://github.com/kolplattformen/skolplattformen/issues/425)) ([fce1d98](https://github.com/kolplattformen/skolplattformen/commit/fce1d98847f4cc7c27bfa359b1d2b1bdc86e12ea)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14e3faab..0eaaa9c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [2.5.0](https://github.com/kolplattformen/skolplattformen/compare/v2.4.0...v2.5.0) (2021-12-03) + + +### Features + +* 🎸 Skip to the next day in calendar ([#425](https://github.com/kolplattformen/skolplattformen/issues/425)) ([fce1d98](https://github.com/kolplattformen/skolplattformen/commit/fce1d98847f4cc7c27bfa359b1d2b1bdc86e12ea)) + # [2.4.0](https://github.com/kolplattformen/skolplattformen/compare/v2.3.2...v2.4.0) (2021-12-02) diff --git a/package.json b/package.json index 768da0b5..c824f6b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "skolplattformen", - "version": "2.4.0", + "version": "2.5.0", "license": "MIT", "scripts": { "start": "nx start", From df2806648ab6b573d277a338f76fb199cdd307a2 Mon Sep 17 00:00:00 2001 From: Andreas Eriksson Date: Fri, 3 Dec 2021 21:12:16 +0100 Subject: [PATCH 10/41] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Show=20the=20weekda?= =?UTF-8?q?y=20on=20startpage=20if=20not=20today?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/childListItem.component.tsx | 2 +- .../utils/__tests__/calendarHelpers.test.ts | 39 +++++++++++++++++++ .../utils/calendarHelpers.ts | 10 ++++- 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 apps/skolplattformen-app/utils/__tests__/calendarHelpers.test.ts diff --git a/apps/skolplattformen-app/components/childListItem.component.tsx b/apps/skolplattformen-app/components/childListItem.component.tsx index b259457c..8df5de92 100644 --- a/apps/skolplattformen-app/components/childListItem.component.tsx +++ b/apps/skolplattformen-app/components/childListItem.component.tsx @@ -172,7 +172,7 @@ export const ChildListItem = ({ /> - {currentDate.hour() > 17 && currentDate.hour() <= 23 ? ( + {moment().weekday() !== currentDate.weekday() ? ( {capitalizeFirstLetter(currentDate.format('dddd'))} diff --git a/apps/skolplattformen-app/utils/__tests__/calendarHelpers.test.ts b/apps/skolplattformen-app/utils/__tests__/calendarHelpers.test.ts new file mode 100644 index 00000000..bbe6af63 --- /dev/null +++ b/apps/skolplattformen-app/utils/__tests__/calendarHelpers.test.ts @@ -0,0 +1,39 @@ +import moment from 'moment' +import { getMeaningfulStartingDate } from '../calendarHelpers' + +const tuesdayMorning = moment('2021-11-30T08:20:00+0100') +const tuesdayEvening = moment('2021-11-30T19:20:26+0100') +const wednesdayEvening = moment('2021-12-01T19:20:26+0100') +const fridayEvening = moment('2021-12-03T19:20:26+0100') +const saturdayEvening = moment('2021-12-04T19:20:26+0100') +const sundayEvening = moment('2021-12-05T19:20:26+0100') +const mondayEvening = moment('2021-12-06T19:20:26+0100') + +describe('getMeaningfulStartingDate on weekends', () => { + it('should give next monday if on friday evening', () => { + const startDate = getMeaningfulStartingDate(fridayEvening) + expect(startDate.toISOString()).toEqual(mondayEvening.toISOString()) + }) + + it('should give next monday if on saturday', () => { + const startDate = getMeaningfulStartingDate(saturdayEvening) + expect(startDate.toISOString()).toEqual(mondayEvening.toISOString()) + }) + + it('should give next monday if on sunday', () => { + const startDate = getMeaningfulStartingDate(sundayEvening) + expect(startDate.toISOString()).toEqual(mondayEvening.toISOString()) + }) +}) + +describe('getMeaningfulStartingDate on weekdays', () => { + it('should give next day if on tuesday evening', () => { + const startDate = getMeaningfulStartingDate(tuesdayEvening) + expect(startDate.toISOString()).toEqual(wednesdayEvening.toISOString()) + }) + + it('should give same day if on tuesday morning', () => { + const startDate = getMeaningfulStartingDate(tuesdayMorning) + expect(startDate.toISOString()).toEqual(tuesdayMorning.toISOString()) + }) +}) diff --git a/apps/skolplattformen-app/utils/calendarHelpers.ts b/apps/skolplattformen-app/utils/calendarHelpers.ts index 335d74d9..6b0c6ce8 100644 --- a/apps/skolplattformen-app/utils/calendarHelpers.ts +++ b/apps/skolplattformen-app/utils/calendarHelpers.ts @@ -1,9 +1,17 @@ import moment from 'moment' export const getMeaningfulStartingDate = (date = moment()) => { + const originalDate = date.clone() // are we on the evening? if (date.hour() > 17) date = date.add('1', 'day') // are we on the weekend - if (date.isoWeekday() > 5) date = date.add(5, 'days').startOf('isoWeek') + if (date.isoWeekday() > 5) { + date = date.add(5, 'days').startOf('isoWeek') + date + .hour(originalDate.hour()) + .minute(originalDate.minute()) + .second(originalDate.second()) + } + return date } From 7c017e460b40cadedcd8dfbd2204d35bdf0bf1df Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 3 Dec 2021 21:29:25 +0100 Subject: [PATCH 11/41] chore(release): 2.5.1 [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## [2.5.1](https://github.com/kolplattformen/skolplattformen/compare/v2.5.0...v2.5.1) (2021-12-03) ### Bug Fixes * 🐛 Show the weekday on startpage if not today ([df28066](https://github.com/kolplattformen/skolplattformen/commit/df2806648ab6b573d277a338f76fb199cdd307a2)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eaaa9c4..08d20ffe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [2.5.1](https://github.com/kolplattformen/skolplattformen/compare/v2.5.0...v2.5.1) (2021-12-03) + + +### Bug Fixes + +* 🐛 Show the weekday on startpage if not today ([df28066](https://github.com/kolplattformen/skolplattformen/commit/df2806648ab6b573d277a338f76fb199cdd307a2)) + # [2.5.0](https://github.com/kolplattformen/skolplattformen/compare/v2.4.0...v2.5.0) (2021-12-03) diff --git a/package.json b/package.json index c824f6b5..9c461bd0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "skolplattformen", - "version": "2.5.0", + "version": "2.5.1", "license": "MIT", "scripts": { "start": "nx start", From 66e7811b83e96f9fb83aa82cb34736f38a3bf16a Mon Sep 17 00:00:00 2001 From: Andreas Eriksson Date: Sun, 5 Dec 2021 00:12:20 +0100 Subject: [PATCH 12/41] feat: Frontpage date tweaks (#582) * Only the daySummary part (timetable info) should use date for next day or next week. * Restructured test-data * Add test for parsing Microsoft special date json format --- .../components/childListItem.component.tsx | 19 +- .../components/children.component.tsx | 4 - .../components/daySummary.component.tsx | 13 + .../utils/__tests__/calendarHelpers.test.ts | 8 + .../utils/calendarHelpers.ts | 11 +- .../lib/fakeData/children.ts | 29 + .../lib/fakeData/classmates.ts | 448 +++++++++++++++ libs/api-skolplattformen/lib/fakeData/data.ts | 509 ++++++++++++++++++ .../api-skolplattformen/lib/fakeData/dates.ts | 14 + .../api-skolplattformen/lib/fakeData/index.ts | 6 + libs/api-skolplattformen/lib/fakeData/menu.ts | 64 +++ libs/api-skolplattformen/lib/fakeData/news.ts | 143 +++++ .../lib/fakeData/timetable.ts | 465 ++++++++++++++++ .../lib/utils/__tests__/dateHandling.test.ts | 1 + 14 files changed, 1710 insertions(+), 24 deletions(-) create mode 100644 libs/api-skolplattformen/lib/fakeData/children.ts create mode 100644 libs/api-skolplattformen/lib/fakeData/classmates.ts create mode 100644 libs/api-skolplattformen/lib/fakeData/data.ts create mode 100644 libs/api-skolplattformen/lib/fakeData/dates.ts create mode 100644 libs/api-skolplattformen/lib/fakeData/index.ts create mode 100644 libs/api-skolplattformen/lib/fakeData/menu.ts create mode 100644 libs/api-skolplattformen/lib/fakeData/news.ts create mode 100644 libs/api-skolplattformen/lib/fakeData/timetable.ts diff --git a/apps/skolplattformen-app/components/childListItem.component.tsx b/apps/skolplattformen-app/components/childListItem.component.tsx index 8df5de92..76e6c67b 100644 --- a/apps/skolplattformen-app/components/childListItem.component.tsx +++ b/apps/skolplattformen-app/components/childListItem.component.tsx @@ -21,6 +21,7 @@ import React, { useEffect } from 'react' import { TouchableOpacity, useColorScheme, View } from 'react-native' import { useTranslation } from '../hooks/useTranslation' import { Colors, Layout, Sizing } from '../styles' +import { getMeaningfulStartingDate } from '../utils/calendarHelpers' import { studentName } from '../utils/peopleHelpers' import { DaySummary } from './daySummary.component' import { AlertIcon, RightArrowIcon } from './icon.component' @@ -109,10 +110,6 @@ export const ChildListItem = ({ return moment(inputDate).fromNow() } - const capitalizeFirstLetter = (string) => { - return string.charAt(0).toUpperCase() + string.slice(1) - } - const getClassName = () => { // hack: we can find the class name (ex. 8C) from the classmates. // let's pick the first one and select theirs class @@ -148,7 +145,7 @@ export const ChildListItem = ({ const className = getClassName() const styles = useStyleSheet(themeStyles) const isDarkMode = useColorScheme() === 'dark' - + const meaningfulStartingDate = getMeaningfulStartingDate(currentDate) return ( navigation.navigate('Child', { child, color })} @@ -172,12 +169,8 @@ export const ChildListItem = ({ /> - {moment().weekday() !== currentDate.weekday() ? ( - - {capitalizeFirstLetter(currentDate.format('dddd'))} - - ) : null} - + + {scheduleAndCalendarThisWeek.slice(0, 3).map((calendarItem, i) => ( @@ -288,8 +281,4 @@ const themeStyles = StyleService.create({ marginBottom: 0, }, noNewNewsItemsText: {}, - weekday: { - marginBottom: -5, - padding: 0, - }, }) diff --git a/apps/skolplattformen-app/components/children.component.tsx b/apps/skolplattformen-app/components/children.component.tsx index 1f6b1b53..4f99a108 100644 --- a/apps/skolplattformen-app/components/children.component.tsx +++ b/apps/skolplattformen-app/components/children.component.tsx @@ -26,7 +26,6 @@ import { Colors, Layout as LayoutStyle, Sizing, Typography } from '../styles' import { translate } from '../utils/translation' import { ChildListItem } from './childListItem.component' import { SettingsIcon, RefreshIcon } from './icon.component' -import { getMeaningfulStartingDate } from '../utils/calendarHelpers' const colors = ['primary', 'success', 'info', 'warning', 'danger'] @@ -81,8 +80,6 @@ export const Children = () => { }) }, [navigation, reloadChildren]) - const currentDate = getMeaningfulStartingDate() - // We need to skip safe area view here, due to the reason that it's adding a white border // when this view is actually lightgrey. Taking the padding top value from the use inset hook. return status === 'loaded' ? ( @@ -107,7 +104,6 @@ export const Children = () => { diff --git a/apps/skolplattformen-app/components/daySummary.component.tsx b/apps/skolplattformen-app/components/daySummary.component.tsx index a9b93dfb..881f9662 100644 --- a/apps/skolplattformen-app/components/daySummary.component.tsx +++ b/apps/skolplattformen-app/components/daySummary.component.tsx @@ -12,6 +12,10 @@ interface DaySummaryProps { date?: Moment } +const capitalizeFirstLetter = (string) => { + return string.charAt(0).toUpperCase() + string.slice(1) +} + export const DaySummary = ({ child, date: currentDate = moment(), @@ -38,6 +42,11 @@ export const DaySummary = ({ return ( + {moment().weekday() !== currentDate.weekday() ? ( + + {capitalizeFirstLetter(currentDate.format('dddd'))} + + ) : null} @@ -89,4 +98,8 @@ const themedStyles = StyleService.create({ heading: { marginBottom: -10, }, + weekday: { + marginBottom: -10, + padding: 0, + }, }) diff --git a/apps/skolplattformen-app/utils/__tests__/calendarHelpers.test.ts b/apps/skolplattformen-app/utils/__tests__/calendarHelpers.test.ts index bbe6af63..2e1b996e 100644 --- a/apps/skolplattformen-app/utils/__tests__/calendarHelpers.test.ts +++ b/apps/skolplattformen-app/utils/__tests__/calendarHelpers.test.ts @@ -9,6 +9,14 @@ const saturdayEvening = moment('2021-12-04T19:20:26+0100') const sundayEvening = moment('2021-12-05T19:20:26+0100') const mondayEvening = moment('2021-12-06T19:20:26+0100') +describe('getMeaningfulStartingDate should not touch inputdate', () => { + const origDate = moment() + const origDateClone = origDate.clone() + getMeaningfulStartingDate(origDate) + + expect(origDate).toEqual(origDateClone) +}) + describe('getMeaningfulStartingDate on weekends', () => { it('should give next monday if on friday evening', () => { const startDate = getMeaningfulStartingDate(fridayEvening) diff --git a/apps/skolplattformen-app/utils/calendarHelpers.ts b/apps/skolplattformen-app/utils/calendarHelpers.ts index 6b0c6ce8..26a87a5b 100644 --- a/apps/skolplattformen-app/utils/calendarHelpers.ts +++ b/apps/skolplattformen-app/utils/calendarHelpers.ts @@ -2,16 +2,17 @@ import moment from 'moment' export const getMeaningfulStartingDate = (date = moment()) => { const originalDate = date.clone() + let returnDate = date.clone() // are we on the evening? - if (date.hour() > 17) date = date.add('1', 'day') + if (date.hour() > 17) returnDate.add('1', 'day') // are we on the weekend - if (date.isoWeekday() > 5) { - date = date.add(5, 'days').startOf('isoWeek') - date + if (returnDate.isoWeekday() > 5) { + returnDate = returnDate.add(5, 'days').startOf('isoWeek') + returnDate .hour(originalDate.hour()) .minute(originalDate.minute()) .second(originalDate.second()) } - return date + return returnDate } diff --git a/libs/api-skolplattformen/lib/fakeData/children.ts b/libs/api-skolplattformen/lib/fakeData/children.ts new file mode 100644 index 00000000..b37bc8e2 --- /dev/null +++ b/libs/api-skolplattformen/lib/fakeData/children.ts @@ -0,0 +1,29 @@ +import { EtjanstChild, Skola24Child } from "@skolplattformen/api" + +export const children = (): EtjanstChild[] => [ + { + name: 'Shanel Nilsson (elev)', + id: '39b59e-bf4b9f-f68ac25321-977218-bf0', + sdsId: '8e81a06-53f55fb-d1b93-f0e5b357ad0b7caaf1d36', + status: 'F;GR', + schoolId: '9e58434-8800-da59547-614bf0e-e09c015', + }, + { + name: 'Alan Nilsson (elev)', + id: 'eea96a-a3e045-caab589391-ed7d17-029', + sdsId: 'bc2d341-8d970cc-69526-43501c082aaa870d9fe99', + status: 'GR', + schoolId: '8e6b13b-3116-e66c39b-a4c3fa5-a1d72d9', + }, +] +export const skola24Children = (): Skola24Child[] => [ + { + firstName: 'Shanel', + lastName: 'Jonsson Nilsson', + personGuid: 'abc123', + schoolGuid: 'def456', + schoolID: 'Superskolan', + timetableID: 'jkl012', + unitGuid: 'mno345' + }, +] diff --git a/libs/api-skolplattformen/lib/fakeData/classmates.ts b/libs/api-skolplattformen/lib/fakeData/classmates.ts new file mode 100644 index 00000000..688a12fe --- /dev/null +++ b/libs/api-skolplattformen/lib/fakeData/classmates.ts @@ -0,0 +1,448 @@ +import { Child, Classmate } from '@skolplattformen/api'; +import { children } from './children' + +export const classmates = (child: Child): Classmate[] => classmatesData.get(child.id) ?? [] + +const [child1, child2] = children() + +const classmatesData = new Map([ + [ + child1.id, [ + { + sisId: 'd004a-98d965a-45174-d2894ca2-f74ebcb', + firstname: 'Darion', + lastname: 'Gustafsson', + guardians: [ + { + email: 'Mike_Svensson@example.net', + firstname: 'Tad', + lastname: 'Eriksson', + mobile: '07074791613', + address: 'Martinvägen 50', + }, + ], + className: '2B', + }, + { + sisId: '54075-284de06-5664c-750b7b13-520fb61', + firstname: 'Brock', + lastname: 'Andersson', + guardians: [ + { + email: 'Brad56@example.org', + firstname: 'Camren', + lastname: 'Eriksson', + mobile: '07075129297', + address: undefined, + }, + ], + className: '2B', + }, + { + sisId: 'c1fc7-285f95d-c0f37-ea48a297-281e985', + firstname: 'Eloy', + lastname: 'Karlsson', + guardians: [ + { + email: 'Samara.Larsson@example.net', + firstname: 'Ike', + lastname: 'Gustafsson', + mobile: '07077667407', + address: undefined, + }, + ], + className: '2B', + }, + { + sisId: '212e9-8a2609c-b29c1-97a32bd8-5f84645', + firstname: 'Kristina', + lastname: 'Eriksson', + guardians: [ + { + email: 'Doug57@example.com', + firstname: 'Rollin', + lastname: 'Olsson', + mobile: '07071720107', + address: 'Höckertsvägen 2', + }, + ], + className: '2B', + }, + { + sisId: '01d21-ebc6f8b-526f8-7cfba0ab-26b9956', + firstname: 'Cydney', + lastname: 'Larsson', + guardians: [ + { + email: 'Davon6@example.org', + firstname: 'Oleta', + lastname: 'Svensson', + mobile: '07079762186', + address: undefined, + }, + ], + className: '2B', + }, + { + sisId: 'a45bb-8a481af-0ad12-7bd1fa4c-1eed4b1', + firstname: 'Berneice', + lastname: 'Persson', + guardians: [ + { + email: 'Milford_Johansson72@example.com', + firstname: 'Arely', + lastname: 'Johansson', + mobile: '07071926019', + address: 'Roslinvägen 36', + }, + ], + className: '2B', + }, + { + sisId: '32f31-039fbed-9060b-2d857c46-e47177d', + firstname: 'Emory', + lastname: 'Svensson', + guardians: [ + { + email: 'Alfredo_Nilsson96@example.org', + firstname: 'Dolores', + lastname: 'Andersson', + mobile: '070752561937', + address: 'Börjesonsvägen 6', + }, + ], + className: '2B', + }, + { + sisId: 'c9d0a-28c371d-e7be2-9781386b-6841eb0', + firstname: 'Maryjane', + lastname: 'Eriksson', + guardians: [ + { + email: 'Eula_Olsson@example.net', + firstname: 'Wendy', + lastname: 'Andersson', + mobile: '07078513037', + address: undefined, + }, + { + email: 'Lesley_Persson45@example.org', + firstname: 'Erich', + lastname: 'Persson', + mobile: '070788191316', + address: undefined, + }, + ], + className: '2B', + }, + { + sisId: 'e0f51-3fbd0be-5a8c3-ded7bbed-1d655d5', + firstname: 'Rosendo', + lastname: 'Eriksson', + guardians: [ + { + email: 'Mitchell.Gustafsson84@example.org', + firstname: 'Mariam', + lastname: 'Johansson', + mobile: '07074537423', + address: 'Molinvägen 29', + }, + { + email: 'Rachelle_Olsson@example.net', + firstname: 'Shaniya', + lastname: 'Persson', + mobile: '070765878480', + address: 'Molinvägen 29', + }, + ], + className: '2B', + }, + { + sisId: '298c2-46a24d4-548b9-3d1f90ee-4fae0ab', + firstname: 'Sammy', + lastname: 'Persson', + guardians: [ + { + email: 'Gloria_Svensson@example.com', + firstname: 'Simeon', + lastname: 'Olsson', + mobile: '070753525610', + address: 'Börjesonsvägen 43', + }, + ], + className: '2B', + }, + { + sisId: 'e7628-09352ea-b5d19-1af845b7-63b3e08', + firstname: 'Abraham', + lastname: 'Svensson', + guardians: [ + { + email: 'Erica_Johansson40@example.net', + firstname: 'Carlotta', + lastname: 'Nilsson', + mobile: '070737951712', + address: 'Aroseniusvägen 27', + }, + { + email: 'Malcolm_Gustafsson55@example.org', + firstname: 'Ramon', + lastname: 'Persson', + mobile: '07070395626', + address: 'Aroseniusvägen 27', + }, + ], + className: '2B', + }, + { + sisId: 'ae315-4696438-b3db6-8f0a5b39-74e34bd', + firstname: 'Devante', + lastname: 'Olsson', + guardians: [ + { + email: 'Alf.Johansson39@example.com', + firstname: 'Schuyler', + lastname: 'Gustafsson', + mobile: '07070724289', + address: undefined, + }, + ], + className: '2B', + }, + { + sisId: '0d812-350f1d5-323aa-d5d93cdd-406e337', + firstname: 'Tyrell', + lastname: 'Eriksson', + guardians: [ + { + email: 'Brennon.Svensson@example.com', + firstname: 'Belle', + lastname: 'Nilsson', + mobile: '07070137347', + address: undefined, + }, + ], + className: '2B', + }, + ]], + [ + child2.id, [ + { + sisId: '9ee9e-312233c-0df98-05fa5a65-a3787ec', + firstname: 'Raphael', + lastname: 'Olsson', + guardians: [ + { + email: 'Johan99@example.com', + firstname: 'Alessandra', + lastname: 'Svensson', + mobile: '070767120463', + address: 'Franklandsvägen 34', + }, + ], + className: '8C', + }, + { + sisId: 'd3a4b-16b53de-63c22-56d1ad24-4a64a2d', + firstname: 'Fanny', + lastname: 'Karlsson', + guardians: [ + { + email: 'Bernadette.Eriksson@example.org', + firstname: 'Bernadette', + lastname: 'Karlsson', + mobile: '070759877956', + address: undefined, + }, + { + email: 'Candice29@example.net', + firstname: 'Kelley', + lastname: 'Gustafsson', + mobile: '070748592035', + address: undefined, + }, + ], + className: '8C', + }, + { + sisId: '42bde-8fabd1c-7a00e-28aea88a-8481bac', + firstname: 'Jamie', + lastname: 'Persson', + guardians: [ + { + email: 'Louisa82@example.net', + firstname: 'Mose', + lastname: 'Larsson', + mobile: '07076548362', + address: undefined, + }, + ], + className: '8C', + }, + { + sisId: 'dad49-74308c8-83612-5eb7f3a5-e1c4047', + firstname: 'Iris', + lastname: 'Eriksson', + guardians: [ + { + email: 'Vaughn90@example.net', + firstname: 'Ezra', + lastname: 'Andersson', + mobile: '07078700165', + address: 'Björnsonsgatan 251 D Lgh 1503', + }, + { + email: 'Stephany_Svensson22@example.net', + firstname: 'Mia', + lastname: 'Larsson', + mobile: '070761752378', + address: 'Björnsonsgatan 251 D Lgh 1503', + }, + ], + className: '8C', + }, + { + sisId: 'b3425-ada6d70-d3acc-a49a12a6-8b3afdc', + firstname: 'Evans', + lastname: 'Nilsson', + guardians: [ + { + email: 'Terry_Svensson@example.com', + firstname: 'Christop', + lastname: 'Olsson', + mobile: '070767660094', + address: undefined, + }, + { + email: 'Johanna_Svensson30@example.org', + firstname: 'Madisen', + lastname: 'Johansson', + mobile: '07072269029', + address: undefined, + }, + ], + className: '8C', + }, + { + sisId: '67471-6c03979-9ef6e-bb2827c4-96d00d5', + firstname: 'Evy', + lastname: 'Larsson', + guardians: [ + { + email: 'Serenity.Gustafsson@example.net', + firstname: 'Toni', + lastname: 'Larsson', + mobile: '07075211567', + address: 'Roslinvägen 48', + }, + ], + className: '8C', + }, + { + sisId: 'f4040-516c4ed-34555-fd525183-6a2f666', + firstname: 'Maximillia', + lastname: 'Karlsson', + guardians: [ + { + email: 'Faustino.Andersson@example.com', + firstname: 'Eriberto', + lastname: 'Nilsson', + mobile: '07076024039', + address: 'Beckombergavägen 213 Lgh 1304', + }, + ], + className: '8C', + }, + { + sisId: 'a9494-75d8ca7-a5fd4-977eca3c-40edbc1', + firstname: 'Pia', + lastname: 'Karlsson', + guardians: [ + { + email: 'Arthur.Karlsson4@example.org', + firstname: 'Eldred', + lastname: 'Svensson', + mobile: '07077609534', + address: 'Börjesonsvägen 6', + }, + ], + className: '8C', + }, + { + sisId: '42a6d-3eaf407-fed01-4a9538de-b822503', + firstname: 'Logan', + lastname: 'Larsson', + guardians: [ + { + email: 'Blake4@example.org', + firstname: 'Jan', + lastname: 'Karlsson', + mobile: '070728715653', + address: 'Bällstavägen 162', + }, + ], + className: '8C', + }, + { + sisId: '9077d-c323c8d-d0d29-5690abfb-d348317', + firstname: 'Torun', + lastname: 'Eriksson', + guardians: [ + { + email: 'Blanca98@example.net', + firstname: 'Dallin', + lastname: 'Eriksson', + mobile: '070766214425', + address: 'Molinvägen 1', + }, + ], + className: '8C', + }, + { + sisId: '31c68-5b86667-0701d-6b7e2471-89e6df9', + firstname: 'Izabella', + lastname: 'Johansson', + guardians: [ + { + email: 'Elouise_Johansson25@example.org', + firstname: 'Jerrold', + lastname: 'Nilsson', + mobile: '07073789274', + address: 'Stobaeusvägen 11', + }, + ], + className: '8C', + }, + { + sisId: '1bb69-5f1c3a6-f0ea8-e1dbb608-2756a52', + firstname: 'Ella', + lastname: 'Persson', + guardians: [ + { + email: 'Shayna.Olsson54@example.net', + firstname: 'Onie', + lastname: 'Nilsson', + mobile: '07076957797', + address: undefined, + }, + ], + className: '8C', + }, + { + sisId: '348a7-2d0eccc-02981-a02ccb03-cb2a8f2', + firstname: 'Jaylen', + lastname: 'Larsson', + guardians: [ + { + email: 'Aileen_Andersson@example.net', + firstname: 'Tess', + lastname: 'Karlsson', + mobile: '070715315590', + address: 'Peringskiöldsvägen 64', + }, + ], + className: '8C', + } + ], +] +]) diff --git a/libs/api-skolplattformen/lib/fakeData/data.ts b/libs/api-skolplattformen/lib/fakeData/data.ts new file mode 100644 index 00000000..81deb8b2 --- /dev/null +++ b/libs/api-skolplattformen/lib/fakeData/data.ts @@ -0,0 +1,509 @@ +import { fourDaysAgo, oneDayAgo, oneWeekAgo } from './dates'; +/* eslint-disable max-len */ +import { + CalendarItem, + Child, + Notification, + ScheduleItem, + User, +} from '@skolplattformen/api'; +import { oneDayForward, oneWeekForward, twoDaysForward } from './dates'; + +const data: any = { + '39b59e-bf4b9f-f68ac25321-977218-bf0': { + calendar: [ + { + title: 'Terminslut', + id: 73, + description: null, + location: null, + startDate: '2020-12-18', + endDate: '2020-12-18', + allDay: true, + }, + { + title: 'Terminen börjar', + id: 74, + description: null, + location: null, + startDate: '2021-01-12', + endDate: '2021-01-12', + allDay: true, + }, + { + title: 'APT - fritids stänger 15:45', + id: 75, + description: null, + location: null, + startDate: '2021-01-21', + endDate: '2021-01-21', + allDay: true, + }, + { + title: 'Utvecklingsamtal', + id: 76, + description: null, + location: null, + startDate: '2021-02-04', + endDate: '2021-02-04', + allDay: true, + }, + { + title: 'Vänliga veckan', + id: 77, + description: null, + location: null, + startDate: '2021-02-08', + endDate: '2021-02-12', + allDay: true, + }, + { + title: 'Utvecklingsamtal', + id: 79, + description: null, + location: null, + startDate: '2021-02-09', + endDate: '2021-02-09', + allDay: true, + }, + { + title: 'Trygghetsdag', + id: 78, + description: null, + location: null, + startDate: '2021-02-12', + endDate: '2021-02-12', + allDay: true, + }, + { + title: 'APT fritids stänger 15:45', + id: 80, + description: null, + location: null, + startDate: '2021-02-25', + endDate: '2021-02-25', + allDay: true, + }, + { + title: 'Sportlov', + id: 81, + description: null, + location: null, + startDate: '2021-03-01', + endDate: '2021-03-05', + allDay: true, + }, + { + title: 'Studiedag', + id: 82, + description: null, + location: null, + startDate: oneWeekForward.startOf('day').toISODate(), + endDate: oneWeekForward.endOf('day').toISODate(), + allDay: true, + }, + { + title: 'APT - fritids stänger 15:45', + id: 83, + description: null, + location: null, + startDate: '2021-04-01', + endDate: '2021-04-01', + allDay: true, + }, + { + title: 'Långfredag', + id: 84, + description: null, + location: null, + startDate: '2021-04-02', + endDate: '2021-04-02', + allDay: true, + }, + { + title: 'Påsklov', + id: 85, + description: null, + location: null, + startDate: '2021-04-05', + endDate: '2021-04-09', + allDay: true, + }, + { + title: 'Föräldraråd', + id: 86, + description: null, + location: null, + startDate: '2021-04-20', + endDate: '2021-04-20', + allDay: true, + }, + { + title: 'Prao åk 8', + id: 97, + description: null, + location: null, + startDate: '2021-04-26', + endDate: '2021-05-12', + allDay: true, + }, + { + title: 'Kristi Himmelfärd', + id: 87, + description: null, + location: null, + startDate: '2021-05-13', + endDate: '2021-05-13', + allDay: true, + }, + { + title: 'Lov', + id: 88, + description: null, + location: null, + startDate: '2021-05-14', + endDate: '2021-05-14', + allDay: true, + }, + { + title: 'APT Fritids stänger 15:45', + id: 90, + description: null, + location: null, + startDate: '2021-05-20', + endDate: '2021-05-20', + allDay: true, + }, + { + title: 'Läsårsslut', + id: 91, + description: + "

 

", + location: null, + startDate: '2021-06-11', + endDate: '2021-06-11', + allDay: true, + }, + { + title: 'Fritids stängt', + id: 92, + description: + "

 

", + location: null, + startDate: '2021-06-14', + endDate: '2021-06-14', + allDay: true, + }, + ], + schedule: [ + { + title: 'Läsläxan tillbaka', + description: 'Ta med boken tillbaka till skolan', + location: '', + allDayEvent: false, + startDate: oneDayForward.startOf('day').toISO(), + endDate: oneDayForward.endOf('day').toISO(), + oneDayEvent: true + } as ScheduleItem + ], + notifications: [ + { + id: 'bfe19b-766db3-b38d99d321-bbed3d-506', + sender: 'Planering och Bedömning', + dateCreated: oneDayAgo.minus({months: 6}).toISO(), + dateModified: fourDaysAgo.toISO(), + message: 'Ett nytt inlägg i en lärlogg har skapats.', + url: + 'https://www.breakit.se/artikel/21423/har-ar-it-bolaget-bakom-haveriet-pa-skolplattformen', + category: 'Lärlogg', + type: 'avisering', + }, + { + id: '9025f9-a1e685-d7c4668f09-e14bc5-0ab', + sender: 'Elevdokumentation', + dateCreated: '2020-12-10T14:31:29.966Z', + message: + 'Nu kan du ta del av ditt barns dokumentation av utvecklingssamtal', + url: + 'https://www.breakit.se/artikel/21404/kodaren-slog-larm-nu-akutstoppas-skolplattformen-i-stockholm', + category: null, + type: 'webnotify', + }, + { + id: 'a24061-1c9a4e-83dc479d7c-f44fe9-376', + sender: 'Planering och Bedömning', + dateCreated: '2020-06-10T12:18:00.000Z', + message: 'Nu finns det en bedömning att titta på.', + url: + 'https://www.svt.se/nyheter/lokalt/stockholm/skolplattformen-i-stockholm-beratta-om-era-erfarenheter', + category: 'Bedömning', + type: 'avisering', + }, + { + id: '79d65c-1f8240-35c94296ec-9f4bdc-cea', + sender: 'Planering och Bedömning', + dateCreated: '2020-03-24T14:28:00.000Z', + message: 'Nu finns det en bedömning att titta på.', + url: + 'https://www.breakit.se/artikel/18120/skolplattformen-kostade-700-miljoner-strid-med-entreprenor-om-varumarket', + category: 'Bedömning', + type: 'avisering', + }, + { + id: '9c5b7b-52c16d-b9fc2e8248-e4de76-279', + sender: 'Planering och Bedömning', + dateCreated: '2020-03-24T13:48:00.000Z', + message: 'Nu finns det en bedömning att titta på.', + url: + 'https://www.mitti.se/nyheter/forskolans-tur-att-fa-kritiserade-skolplattformen-app/lmsau!5338007/', + category: 'Bedömning', + type: 'avisering', + }, + ], + }, + 'eea96a-a3e045-caab589391-ed7d17-029': { + calendar: [ + { + title: 'Terminslut', + id: 73, + description: null, + location: null, + startDate: '2020-12-18', + endDate: '2020-12-18', + allDay: true, + }, + { + title: 'Terminen börjar', + id: 74, + description: null, + location: null, + startDate: '2021-01-12', + endDate: '2021-01-12', + allDay: true, + }, + { + title: 'APT - fritids stänger 15:45', + id: 75, + description: null, + location: null, + startDate: oneWeekForward.startOf('day').toISODate(), + endDate: oneWeekForward.endOf('day').toISODate(), + allDay: true, + }, + { + title: 'Utvecklingsamtal', + id: 76, + description: null, + location: null, + startDate: '2021-02-04', + endDate: '2021-02-04', + allDay: true, + }, + { + title: 'Vänliga veckan', + id: 77, + description: null, + location: null, + startDate: '2021-02-08', + endDate: '2021-02-12', + allDay: true, + }, + { + title: 'Utvecklingsamtal', + id: 79, + description: null, + location: null, + startDate: '2021-02-09', + endDate: '2021-02-09', + allDay: true, + }, + { + title: 'Trygghetsdag', + id: 78, + description: null, + location: null, + startDate: '2021-02-12', + endDate: '2021-02-12', + allDay: true, + }, + { + title: 'APT fritids stänger 15:45', + id: 80, + description: null, + location: null, + startDate: '2021-02-25', + endDate: '2021-02-25', + allDay: true, + }, + { + title: 'Sportlov', + id: 81, + description: null, + location: null, + startDate: '2021-03-01', + endDate: '2021-03-05', + allDay: true, + }, + { + title: 'Studiedag', + id: 82, + description: null, + location: null, + startDate: '2021-03-22', + endDate: '2021-03-22', + allDay: true, + }, + { + title: 'APT - fritids stänger 15:45', + id: 83, + description: null, + location: null, + startDate: '2021-04-01', + endDate: '2021-04-01', + allDay: true, + }, + { + title: 'Långfredag', + id: 84, + description: null, + location: null, + startDate: '2021-04-02', + endDate: '2021-04-02', + allDay: true, + }, + { + title: 'Påsklov', + id: 85, + description: null, + location: null, + startDate: '2021-04-05', + endDate: '2021-04-09', + allDay: true, + }, + { + title: 'Föräldraråd', + id: 86, + description: null, + location: null, + startDate: '2021-04-20', + endDate: '2021-04-20', + allDay: true, + }, + { + title: 'Prao åk 8', + id: 97, + description: null, + location: null, + startDate: '2021-04-26', + endDate: '2021-05-12', + allDay: true, + }, + { + title: 'Kristi Himmelfärd', + id: 87, + description: null, + location: null, + startDate: '2021-05-13', + endDate: '2021-05-13', + allDay: true, + }, + { + title: 'Lov', + id: 88, + description: null, + location: null, + startDate: '2021-05-14', + endDate: '2021-05-14', + allDay: true, + }, + { + title: 'APT Fritids stänger 15:45', + id: 90, + description: null, + location: null, + startDate: '2021-05-20', + endDate: '2021-05-20', + allDay: true, + }, + ], + schedule: [ + { + title: 'Läxförhör franska', + description: 'Läxförhör, glosor samt verben!', + location: 'Klassrummet', + allDayEvent: false, + startDate: twoDaysForward.startOf('day').toISO(), + endDate: twoDaysForward.endOf('day').toISO(), + oneDayEvent: false + } as ScheduleItem + ], + notifications: [ + { + id: 'e1b5bc-597fa8-5511794939-3614e1-615', + sender: 'Planering och Bedömning', + dateCreated: fourDaysAgo.toISO(), + dateModified: fourDaysAgo.toISO(), + message: 'Ett nytt inlägg i en lärlogg har skapats.', + url: + 'https://www.mitti.se/nyheter/rekorddyr-skolplattform-kostar-258-miljoner-till/lmsao!5381301/', + category: 'Lärlogg', + messageType: 'avisering', + }, + { + id: '7dbc20-bfa1ac-e20171b865-82c1f7-f3c', + sender: 'Planering och Bedömning', + dateCreated: '2020-12-01T12:43:00.000Z', + message: 'Ett nytt inlägg i en lärlogg har skapats.', + url: + 'https://computersweden.idg.se/2.2683/1.722561/lacka-skolplattformen-datainspektionen', + category: 'Lärlogg', + messageType: 'avisering', + }, + { + id: 'a6829b-ecf912-b71582e8fb-b6dc14-f60', + sender: 'Planering och Bedömning', + dateCreated: '2020-11-24T13:34:00.000Z', + message: 'Ett nytt inlägg i en lärlogg har skapats.', + url: 'https://www.dagensarena.se/redaktionen/en-systemkramare-ger-upp/', + category: 'Lärlogg', + messageType: 'avisering', + }, + { + id: '3cedb4-767d24-8ccd6ac3ac-c05cb7-a3a', + sender: 'Planering och Bedömning', + dateCreated: '2020-11-16T13:24:00.000Z', + message: 'Ett nytt inlägg i en lärlogg har skapats.', + url: + 'https://www.breakit.se/artikel/27075/skolplattformen-kostade-1-miljard-att-bygga-nu-tvingas-stockholm-bota', + category: 'Lärlogg', + messageType: 'avisering', + }, + { + id: '6ace13-5f99da-d1d50ac7a6-4a6108-d8e', + sender: 'Planering och Bedömning', + dateCreated: '2020-11-12T13:27:00.000Z', + message: 'Ett nytt inlägg i en lärlogg har skapats.', + url: + 'https://www.nyteknik.se/sakerhet/ygeman-om-datalackan-i-skolplattformen-det-ar-upprorande-6968853', + category: 'Lärlogg', + messageType: 'avisering', + }, + ], + }, +} + +export const user = (): User => ({ + personalNumber: '195001182046', // Test personal number from Skatteverket + firstName: 'Namn', + lastName: 'Namnsson', + isAuthenticated: true +}) + +export const calendar = (child: Child): CalendarItem[] => + data[child.id].calendar + +export const schedule = (child: Child): ScheduleItem[] => + data[child.id].schedule + +export const notifications = (child: Child): Notification[] => + data[child.id].notifications diff --git a/libs/api-skolplattformen/lib/fakeData/dates.ts b/libs/api-skolplattformen/lib/fakeData/dates.ts new file mode 100644 index 00000000..9858fa50 --- /dev/null +++ b/libs/api-skolplattformen/lib/fakeData/dates.ts @@ -0,0 +1,14 @@ +import { DateTime } from "luxon" + +export const getDate = () => DateTime.now() +export const oneDayAgo = getDate().minus({days: 1}) +export const twoDaysAgo = getDate().minus({days: 2}) +export const fourDaysAgo = getDate().minus({days: 4}) +export const oneWeekAgo = getDate().minus({weeks: 1}) + +export const oneDayForward = getDate().plus({days: 1}) +export const twoDaysForward = getDate().plus({days: 2}) +export const fourDaysForward = getDate().plus({days: 4}) +export const oneWeekForward = getDate().plus({weeks: 1}) + +export const week = getDate().weekNumber.toString() diff --git a/libs/api-skolplattformen/lib/fakeData/index.ts b/libs/api-skolplattformen/lib/fakeData/index.ts new file mode 100644 index 00000000..aeac5a8b --- /dev/null +++ b/libs/api-skolplattformen/lib/fakeData/index.ts @@ -0,0 +1,6 @@ +export * from './data' +export * from './children' +export * from './menu' +export * from './classmates' +export * from './timetable' +export * from './news' diff --git a/libs/api-skolplattformen/lib/fakeData/menu.ts b/libs/api-skolplattformen/lib/fakeData/menu.ts new file mode 100644 index 00000000..128f26f9 --- /dev/null +++ b/libs/api-skolplattformen/lib/fakeData/menu.ts @@ -0,0 +1,64 @@ +import { Child, MenuItem } from '@skolplattformen/api' +import { DateTime } from 'luxon' +import { children } from './children' + +export const menu = (child: Child): MenuItem[] => menuData.get(child.id) ?? [] + +const getDate = () => DateTime.now() +const week = getDate().weekNumber.toString() + +const [child1, child2] = children() + +const menuData = new Map([ +[ + child1.id, + [ + { + title: 'Måndag - Vecka ' + week, + description: 'Kebabgryta ris
Ratatouille med kikärter', + }, + { + title: 'Tisdag - Vecka ' + week, + description: 'Ost-broccolisås pasta Fusilli', + }, + { + title: 'Onsdag - Vecka ' + week, + description: 'Köttbullar potatis gräddsås lingon
Falafel', + }, + { + title: 'Torsdag - Vecka ' + week, + description: + 'Prinskorv potatis rödbetssallad +
Inlagd och senapssill', + }, + { + title: 'Fredag - Vecka ' + week, + description: + 'Avslutning Varmkorv bröd ketchup senap
( F-3 i matsalen från 10:30 )', + }, + ], + ], + [child2.id, + [ + { + title: "Måndag - Vecka " + week, + description: "Thailändsk kycklinggryta med kokosmjölk, rödcurry och jasminris
Thailänsk grönsaksgryta med kokosmjölk, rödcurry och jasminris" + }, + { + title: "Tisdag - Vecka " + week, + description: "Örtomlett med potatis , medelhavsost och olivtapenad" + }, + { + title: "Onsdag - Vecka " + week, + description: "Spagetti med rökt kalkon , grädde, dijon och persilja
Spagetti med rostade bönor , grädde , dijon och persilja" + }, + { + title: "Torsdag - Vecka " + week, + description: "Panerad flundra med dansk remoulad och koktåotatis
morot och linsbiff med danska remoulad och koktpotatis" + }, + { + title: "Fredag - Vecka " + week, + description: "Texaschili på högrev med picklad rödlök och bulgur
Texaschili på svartabönor picklad rödlök och bulgur" + } + ], + ] +]) diff --git a/libs/api-skolplattformen/lib/fakeData/news.ts b/libs/api-skolplattformen/lib/fakeData/news.ts new file mode 100644 index 00000000..234fcab8 --- /dev/null +++ b/libs/api-skolplattformen/lib/fakeData/news.ts @@ -0,0 +1,143 @@ +import { children } from './children' +import { Child, NewsItem } from '@skolplattformen/api' +import * as dates from './dates' + +export const news = (child: Child): NewsItem[] => newsData.get(child.id) ?? [] + +const [child1, child2] = children() + +const newsData = new Map([ +[child1.id, [ + { + id: 'asdfasdfasdfw', + author: 'Vaktmästare Persson', + header: 'Brandsläckare!', + intro: 'Idag hade vi en incident med en brandsläckare.', + body: + '## Information om brandsläckarincidenten\n\nHej, idag vid lunchtid utlöste en elev av misstag en pulverbrandsläckare i kapprummet. En del pulver yrde runt i rummet och under saneringen fick eleverna i angränsande klassrum vara i aulan istället för klassrummet.\n\nFlera elever var på plats i hallen när detta inträffade men utrymdes kort därefter. Pulvret är INTE hälsovådligt men kan ge upphov till halsirritation vid inandning.\n\nJag har pratat med berörda elever om det inträffade och uppmanat dem att ta hem kläder och tillhörigheter som fanns i kapprummet eftersom de troligen blivit dammiga. Vi rekommenderar att ni tvättar eller vädrar dessa.', + imageUrl: '6607f9b923edb6f85aa4417bab43c0f8.jpg', + fullImageUrl: + 'https://cdn.breakit.se/assets/article/6607f9b923edb6f85aa4417bab43c0f8.jpg?d=980x500', + imageAltText: 'Nyhetsbild. Bildtext ej tillgänglig.', + published: dates.twoDaysAgo.toISO(), + modified: dates.twoDaysAgo.plus({ hours: 1 }).toISO(), + }, + { + id: 'asdfabbuasdfs', + author: 'Ada L.', + header: 'Bygg din egen app', + intro: 'Denna vecka bygger vi appar!', + body: + '## Appar med öppen data \n\nDenna vecka har vi förmånen att få besök av några föräldrar som visar hur vi enkelt kan skapa appar som visar information ifrån öppna datakällor.\n\nEn fantastisk möjlighet att lära oss hur digitalisering skapar nya möjligheter i såväl skolan som arbetslivet.', + imageUrl: '6607f9b923edb6f85aa4417bab43c0f8.jpg', + fullImageUrl: + 'https://live.staticflickr.com/4063/4369776892_5cd42d27ba.jpg', + imageAltText: 'Nyhetsbild. Bildtext ej tillgänglig.', + published: dates.oneWeekAgo.toISO(), + modified: dates.oneWeekAgo.toISO(), + }, + { + id: 'asdfasdfasdfs', + author: 'Magister Svensson', + header: 'Läxor vecka 6.', + intro: 'Alla elever måste göra sina läxor!', + body: + '## Läxor vecka 6 \n\nFöljande läxor är obligatoriska:\n\n- Antikens historia\n- Svenska stormaktstiden\n- Statistik A\n- Flerdimensionell analys, del 1', + imageUrl: '6607f9b923edb6f85aa4417bab43c0f8.jpg', + fullImageUrl: + 'https://www.mitti.se/_internal/cimg!0/ejf8efxee735ymm8tm40q3hhkl36sdt.jpeg', + imageAltText: 'Nyhetsbild. Bildtext ej tillgänglig.', + published: dates.oneWeekAgo.toISO(), + modified: dates.oneWeekAgo.minus({ hours: 3 }).toISO(), + }, + ] +], + +[child2.id, [ + { + id: 'asdfasdfasdfa', + author: 'Rektor Gustavsson', + header: 'Välkommen till skolan!', + intro: + 'Hej alla barn och föräldrar och välkomna till Storskolan! Här kommer en del information som kan vara bra att känna till inför första dagen.', + body: + '## Information till föräldrar \n\nSkolan börjar kl 08.00 och slutar 18.00. Kommer man sent eller blir sjuk så ska det anmälas via Skolplattformen. Se till så att dina barn har ätit frukost. Frukt är nyttigt! \n\n## Information till barn\n\nLek är tillåtet på rasterna men enbart på skolgården. Medtag ej egna leksaker. Tvätta händerna.', + imageUrl: '6607f9b923edb6f85aa4417bab43c0f8.jpg', + fullImageUrl: + 'https://timbro.se/app/uploads/2020/10/broman-skolplattformen-1280x752.jpg', + imageAltText: 'Nyhetsbild. Bildtext ej tillgänglig.', + published: dates.oneWeekAgo.toISO(), + modified: dates.oneWeekAgo.toISO(), + }, + { + id: 'asdfabbuasdfs', + author: 'Ada L.', + header: 'App, App, App', + intro: 'Denna vecka bygger vi appar!', + body: + '## Appar med öppen data \n\nDenna vecka har vi förmånen att få besök av några föräldrar som visar hur vi enkelt kan skapa appar som visar information ifrån öppna datakällor.\n\nEn fantastisk möjlighet att lära oss hur digitalisering skapar nya möjligheter i såväl skolan som arbetslivet.', + imageUrl: '6607f9b923edb6f85aa4417bab43c0f8.jpg', + fullImageUrl: + 'https://live.staticflickr.com/4063/4369776892_5cd42d27ba.jpg', + imageAltText: 'Nyhetsbild. Bildtext ej tillgänglig.', + published: dates.fourDaysAgo.toISO(), + modified: dates.fourDaysAgo.plus({minutes: 45}).toISO(), + }, + { + id: 'asdfasdfasdfs', + author: 'Magister Svensson', + header: 'Läxor i veckan', + intro: 'Alla elever måste göra sina läxor!', + body: + '## Läxor vecka 6 \n\nFöljande läxor är obligatoriska:\n\n- Antikens historia\n- Svenska stormaktstiden\n- Statistik A\n- Flerdimensionell analys, del 1', + imageUrl: '6607f9b923edb6f85aa4417bab43c0f8.jpg', + fullImageUrl: + 'https://www.mitti.se/_internal/cimg!0/ejf8efxee735ymm8tm40q3hhkl36sdt.jpeg', + imageAltText: 'Nyhetsbild. Bildtext ej tillgänglig.', + published: dates.oneWeekAgo.toISO(), + modified: dates.oneWeekAgo.toISO(), + }, + { + id: 'asdfasdfasdfd', + author: 'Information från Förskoleklass', + header: 'Vinteraktiviteter', + intro: + 'Vi kommer efter att förskoleklassen är slut arrangera olika vinteraktiviteter genom fridtidsverksamheten.', + body: + '## Vänligen ta med hjälm, skridskor eller stjärtlapp.\n\n ![Bild](https://images.unsplash.com/photo-1495377701095-00261b767581?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=988&q=80)\n\n Alla barn måste ha hjälm på sig samt varma kläder. Vi kommer åka i backen bakom skolbyggnaden samt använda isen som spolats vid Mullsjöskolan. Personal kommer finnas på plats samt att vi erbjuda varm dryck, frukt och lek för de barn som ej har hjälm eller lämpligt åkdon.', + imageUrl: '6607f9b923edb6f85aa4417bab43c0f8.jpg', + fullImageUrl: 'https://unsplash.com/photos/yB_aiAWkm40', + imageAltText: 'Nyhetsbild. Bildtext ej tillgänglig.', + published: dates.oneWeekAgo.minus({weeks: 2}).toISO(), + modified: dates.oneWeekAgo.minus({weeks: 1}).toISO(), + }, + { + id: 'asdfasdfasdfdsa', + author: 'Köket', + header: 'Ekologisk vecka i matsalen', + intro: 'Ekologiska veckan i matsalen vecka 11', + body: + '## Vi kommer ha tema jorden i matsalen och servera ekologisk mat från hela världen med tema jorden. Detta för att belysa att man kan använda alla delar av råvaorna. Det kommer erbjudas rätter från alla världsdelar som är producerat för jordens bästa. Smaklig spis hälsar Gunnel i köket med personal.', + imageUrl: '6607f9b923edb6f85aa4417bab43c0f8.jpg', + fullImageUrl: 'https://unsplash.com/photos/7K17MvT8qBg', + imageAltText: 'Nyhetsbild. Bildtext ej tillgänglig.', + published: dates.oneWeekAgo.minus({weeks: 3}).toISO(), + modified: dates.oneWeekAgo.minus({days: 2}).toISO(), + }, + { + id: 'asdfasdfasdfbvdsa', + author: 'Vaktmästaren', + header: 'Klotter i korridoren (igen)', + intro: + 'Ännu en gång har vi råka ut för skadegörelse i korridorerna vid åk 5', + body: + '## Tyvärr har flera elever klottat på skåp och väggar vid åk5 skåpen. Detta är helt oacceptablet beteende och kostar skolan stora belopp att åtgärda. Vi ber alla föräldrar prata med sina barn om klotter samt att det var väldigt grovt spårkbruk. Personalen på skolan kommer att hålla extra uppsikt och vi har även pratat med en del av de inblandade eleverna i denna skadegörelse.\n\nPersonalen har även börjat forska på vad vissa av de skrivna orden betyder och Eva-Britt är förfasad över språkbruket samt vad de innebär. Bernt kommer att påbörja saneringen och återställningen av skadegörelsen samt vakta korridorerna nogrannare för att säkerställa att detta ej kommer ske igen.\n\n Klotter\n\nUPPDATERING: Det som är skrivet om Sara är inte sant! ', + imageUrl: '6607f9b923edb6f85aa4417bab43c0f8.jpg', + fullImageUrl: 'https://unsplash.com/photos/SkbEZ16VywM', + imageAltText: 'Nyhetsbild. Bildtext ej tillgänglig.', + published: dates.oneWeekAgo.minus({weeks: 4}).toISO(), + modified: dates.oneWeekAgo.minus({weeks: 2}).toISO(), + }, + ] +] +]) diff --git a/libs/api-skolplattformen/lib/fakeData/timetable.ts b/libs/api-skolplattformen/lib/fakeData/timetable.ts new file mode 100644 index 00000000..7fb8de8e --- /dev/null +++ b/libs/api-skolplattformen/lib/fakeData/timetable.ts @@ -0,0 +1,465 @@ +import { Skola24Child, TimetableEntry } from "@skolplattformen/api" + + +export const timetable = (child: Skola24Child): TimetableEntry[] => { + if (!child.personGuid || !child.unitGuid) return [] + return [ + { + id: 'N2FjMDc1NjYtZmM2Yy0wZDQyLTY3M2YtZWI5NGNiZDA3ZGU4', + code: 'Lunch', + name: 'Lunch', + category: '', + blockName: '', + dayOfWeek: 1, + location: 'Ö5', + teacher: '', + timeEnd: '12:05:00', + timeStart: '11:40:00', + dateStart: '2021-04-12T11:40:00.000+02:00', + dateEnd: '2021-04-12T12:05:00.000+02:00', + }, + { + id: 'ZTQ1NWE0N2EtNzAwOS0wZTAzLTQ1ZDYtNTA1NWI4Y2JhNDYw', + code: 'BL', + name: 'Bild', + category: '', + blockName: '', + dayOfWeek: 1, + location: '221', + teacher: 'KUr', + timeEnd: '11:35:00', + timeStart: '09:40:00', + dateStart: '2021-04-12T09:40:00.000+02:00', + dateEnd: '2021-04-12T11:35:00.000+02:00', + }, + { + id: 'YjAxODRmY2QtNTJjZS0wMDJlLTYxOGItYmFlNTVlNDgzZmVk', + code: 'NO', + name: 'Naturorienterande ämnen', + category: '', + comment: 'a)', + blockName: '', + dayOfWeek: 1, + location: '307', + teacher: 'TBo', + timeEnd: '13:30:00', + timeStart: '12:30:00', + dateStart: '2021-04-12T12:30:00.000+02:00', + dateEnd: '2021-04-12T13:30:00.000+02:00', + }, + { + id: 'MWRiZGI1NzgtYWIzNy0wYzMwLTVkMmEtMWFjNWRkMTRmOTdh', + code: 'IDH', + name: 'Idrott & hälsa', + category: '', + blockName: '', + dayOfWeek: 1, + location: '215', + teacher: 'HAl', + timeEnd: '15:45:00', + timeStart: '14:40:00', + dateStart: '2021-04-12T14:40:00.000+02:00', + dateEnd: '2021-04-12T15:45:00.000+02:00', + }, + { + id: 'MmZkZTZiMzMtMjdjMS0wZGIzLTUzYWYtZTg0Zjc1NDRlNzQw', + code: 'M2FR', + name: 'Franska', + category: 'Moderna språk, språkval', + blockName: '', + dayOfWeek: 1, + location: '304', + teacher: 'DNi', + timeEnd: '14:25:00', + timeStart: '13:40:00', + dateStart: '2021-04-12T13:40:00.000+02:00', + dateEnd: '2021-04-12T14:25:00.000+02:00', + }, + { + id: 'MzAxMzU3MWItZGM1Ny0wOGVhLTVkZjUtOGFkMGIyYTY2OTAx', + code: 'SO', + name: 'Samhällsorienterande ämnen', + category: '', + blockName: '', + dayOfWeek: 1, + location: '303', + teacher: 'HRr', + timeEnd: '09:25:00', + timeStart: '08:15:00', + dateStart: '2021-04-12T08:15:00.000+02:00', + dateEnd: '2021-04-12T09:25:00.000+02:00', + }, + { + id: 'NDY3MDY1MmYtOTIzYi0wZmQ0LTVlZGEtNGVhZDRkOTExNTgz', + code: 'M2FR', + name: 'Franska', + category: 'Moderna språk, språkval', + blockName: '', + dayOfWeek: 2, + location: '302,Fjärr asd asdasd asdad aasdds', + teacher: 'DNi', + timeEnd: '09:50:00', + timeStart: '09:05:00', + dateStart: '2021-04-13T09:05:00.000+02:00', + dateEnd: '2021-04-13T09:50:00.000+02:00', + }, + { + id: 'NmE4OTU1NmItYzM0ZS0wYTI1LTYzM2QtYzBiN2M4OTVmYTQ3', + code: 'EN', + name: 'Engelska', + category: '', + blockName: '', + dayOfWeek: 2, + location: 'Fjärr', + teacher: 'TPe', + timeEnd: '13:15:00', + timeStart: '12:30:00', + dateStart: '2021-04-13T12:30:00.000+02:00', + dateEnd: '2021-04-13T13:15:00.000+02:00', + }, + { + id: 'NDAxODRjOTctMmE5ZC0wMzdjLTY2NDMtODhlODEzOTQ3YTJh', + code: 'Lunch', + name: 'Lunch', + category: '', + blockName: '', + dayOfWeek: 2, + location: 'Fjärr', + teacher: '', + timeEnd: '12:05:00', + timeStart: '11:40:00', + dateStart: '2021-04-13T11:40:00.000+02:00', + dateEnd: '2021-04-13T12:05:00.000+02:00', + }, + { + id: 'ZTc4YTcyZTUtMDc0NS0wNDE0LTVjODctYjY0MzQ2MGM3MDll', + code: 'MA', + name: 'Matematik', + category: '', + blockName: '', + dayOfWeek: 2, + location: 'Fjärr', + teacher: 'CBr', + timeEnd: '11:20:00', + timeStart: '10:00:00', + dateStart: '2021-04-13T10:00:00.000+02:00', + dateEnd: '2021-04-13T11:20:00.000+02:00', + }, + { + id: 'MjRkMWE4YTItYTk5ZC0wYTFmLTVhMDgtMThiMmNhZDc1ZDUz', + code: 'MU', + name: 'Musik', + category: '', + blockName: '', + dayOfWeek: 2, + location: 'Fjärr', + teacher: 'KBj', + timeEnd: '14:15:00', + timeStart: '13:30:00', + dateStart: '2021-04-13T13:30:00.000+02:00', + dateEnd: '2021-04-13T14:15:00.000+02:00', + }, + { + id: 'NTU4ZTc4ZTctNDQyMy0wMjVkLTRiYzktZGUwYmFmYzk2YTlj', + code: 'EN', + name: 'Engelska', + category: '', + blockName: '', + dayOfWeek: 3, + location: '303', + teacher: 'TPe', + timeEnd: '09:55:00', + timeStart: '09:10:00', + dateStart: '2021-04-14T09:10:00.000+02:00', + dateEnd: '2021-04-14T09:55:00.000+02:00', + }, + { + id: 'NDUyNjIxODItYzFiOC0wOTFjLTYwODYtZDllZjZjN2QyYzA3', + code: 'SV', + name: 'Svenska', + category: '', + comment: 'a)', + blockName: '', + dayOfWeek: 3, + location: '303', + teacher: 'JCa', + timeEnd: '14:45:00', + timeStart: '14:00:00', + dateStart: '2021-04-14T14:00:00.000+02:00', + dateEnd: '2021-04-14T14:45:00.000+02:00', + }, + { + id: 'NDdkMGI0ZjItMjkxMC0wYWI1LTQ0YWMtNDY3NTdkZTE2Njg3', + code: 'SO', + name: 'Engelska', + category: 'Samhällsorienterande ämnen', + blockName: '', + dayOfWeek: 3, + location: '303', + teacher: 'HRr', + timeEnd: '11:00:00', + timeStart: '10:05:00', + dateStart: '2021-04-14T10:05:00.000+02:00', + dateEnd: '2021-04-14T11:00:00.000+02:00', + }, + { + id: 'ZTI2ZDgyNWUtM2ZlOS0wZDVmLTY5NTctNGYzZThjMTMxOTdh', + code: 'NO', + name: 'Naturorienterande ämnen', + category: '', + comment: 'a)', + blockName: '', + dayOfWeek: 3, + location: '307', + teacher: 'TBo', + timeEnd: '13:50:00', + timeStart: '12:50:00', + dateStart: '2021-04-14T12:50:00.000+02:00', + dateEnd: '2021-04-14T13:50:00.000+02:00', + }, + { + id: 'NzMxNjczNGMtMmZmZi0wM2YzLTU0ZjMtODdjOTAwYzIwNTUw', + code: 'Lunch', + name: 'Lunch', + category: '', + blockName: '', + dayOfWeek: 3, + location: 'Ö5', + teacher: '', + timeEnd: '12:40:00', + timeStart: '12:15:00', + dateStart: '2021-04-14T12:15:00.000+02:00', + dateEnd: '2021-04-14T12:40:00.000+02:00', + }, + { + id: 'MWRkZjhlZTktNTBmMC0wZjNhLTQ1OTgtMWJkOWM3MjI2NWQ4', + code: 'SV', + name: 'Svenska', + category: '', + blockName: '', + dayOfWeek: 3, + location: '303', + teacher: 'JCa', + timeEnd: '12:05:00', + timeStart: '11:20:00', + dateStart: '2021-04-14T11:20:00.000+02:00', + dateEnd: '2021-04-14T12:05:00.000+02:00', + }, + { + id: 'NzM2Mjc2ZTYtY2JlYy0wOTc1LTU1ZGYtNjMwZjhjZWVjNjgy', + code: 'MA', + name: 'Matematik', + category: '', + comment: 'a)', + blockName: '', + dayOfWeek: 3, + location: '307', + teacher: 'CBr', + timeEnd: '15:45:00', + timeStart: '15:00:00', + dateStart: '2021-04-14T15:00:00.000+02:00', + dateEnd: '2021-04-14T15:45:00.000+02:00', + }, + { + id: 'YWNlZmEzZjYtM2EwNC0wYWY3LTU1N2MtMDBlMTA4MDQzMzRl', + code: 'MU', + name: 'Musik', + category: '', + blockName: '', + dayOfWeek: 3, + location: '504', + teacher: 'KBj', + timeEnd: '09:00:00', + timeStart: '08:15:00', + dateStart: '2021-04-14T08:15:00.000+02:00', + dateEnd: '2021-04-14T09:00:00.000+02:00', + }, + { + id: 'NDc4MThmMDYtYmYxYi0wZDBkLTdhNmItZGVjMjY3OWY3MmYz', + code: 'IDH', + name: 'Idrott & Hälsa', + category: '', + blockName: '', + dayOfWeek: 4, + location: 'Fjärr', + teacher: 'AKö,CSv,HAl', + timeEnd: '15:45:00', + timeStart: '14:35:00', + dateStart: '2021-04-15T14:35:00.000+02:00', + dateEnd: '2021-04-15T15:45:00.000+02:00', + }, + { + id: 'ZjQyZjNkOWItYWMzZi0wYWRhLTQ3YzItNTZiNTJkOTRmY2Iy', + code: 'M2FR', + name: 'Franska', + category: 'Moderna språk, språkval', + blockName: '', + dayOfWeek: 4, + location: 'Fjärr', + teacher: 'DNi', + timeEnd: '11:55:00', + timeStart: '11:10:00', + dateStart: '2021-04-15T11:10:00.000+02:00', + dateEnd: '2021-04-15T11:55:00.000+02:00', + }, + { + id: 'YzQ2NWZlOWMtYzM3ZC0wYzBlLTQzNTQtODMyYmU3ODcxMDQ3', + code: 'MTID', + name: 'Mentorstid', + category: 'Diverse', + comment: 'Arbetslagsråd 6C', + blockName: '', + dayOfWeek: 4, + location: 'Fjärr', + teacher: 'JCa,CBr', + timeEnd: '10:00:00', + timeStart: '09:15:00', + dateStart: '2021-04-15T09:15:00.000+02:00', + dateEnd: '2021-04-15T10:00:00.000+02:00', + }, + { + id: 'YzMwMGY0YzAtNjhjNi0wYzY0LTU1MjctODg2MWQ4ZTRmZTI2', + code: 'MU', + name: 'Musik', + category: '', + blockName: '', + dayOfWeek: 4, + location: 'Fjärr', + teacher: 'KBj', + timeEnd: '10:55:00', + timeStart: '10:10:00', + dateStart: '2021-04-15T10:10:00.000+02:00', + dateEnd: '2021-04-15T10:55:00.000+02:00', + }, + { + id: 'ZDNlNTFhMGUtYWFlYy0wOGI0LTVlMGItOTc0MzFiZmIwODcx', + code: 'Lunch', + name: 'Lunch', + category: 'Diverse', + blockName: '', + dayOfWeek: 4, + location: 'Fjärr', + teacher: '', + timeEnd: '12:25:00', + timeStart: '12:00:00', + dateStart: '2021-04-15T12:00:00.000+02:00', + dateEnd: '2021-04-15T12:25:00.000+02:00', + }, + { + id: 'MDRiZWMyODMtNjEwZC0wZDYwLTRlOWItYTY1MjAwZTc0YTZm', + code: 'SO', + name: 'Samhällsorienterande ämnen', + category: '', + blockName: '', + dayOfWeek: 4, + location: 'Fjärr', + teacher: 'HRr', + timeEnd: '13:10:00', + timeStart: '12:35:00', + dateStart: '2021-04-15T12:35:00.000+02:00', + dateEnd: '2021-04-15T13:10:00.000+02:00', + }, + { + id: 'YTA0ZTA2NTktYTU5MS0wMTFmLTVlYWYtNWM1MTgxNDJlMDcy', + code: 'EN', + name: 'Engelska', + category: '', + comment: 'a)', + blockName: '', + dayOfWeek: 4, + location: 'Fjärr', + teacher: 'TPe', + timeEnd: '14:20:00', + timeStart: '13:35:00', + dateStart: '2021-04-15T13:35:00.000+02:00', + dateEnd: '2021-04-15T14:20:00.000+02:00', + }, + { + id: 'OGJhN2MxYTYtMDQ4NS0wNWNhLTUwZWEtZDQ5YzQyMzFhYzc5', + code: 'Lunch', + name: 'Lunch', + category: 'Diverse', + blockName: '', + dayOfWeek: 5, + location: 'Ö5', + teacher: '', + timeEnd: '12:05:00', + timeStart: '11:40:00', + dateStart: '2021-04-16T11:40:00.000+02:00', + dateEnd: '2021-04-16T12:05:00.000+02:00', + }, + { + id: 'ZmUwMGEwM2QtNTExMy0wODliLTY1ZGEtODM0YmRjNjc1NDIw', + code: 'MA', + name: 'Matematik', + category: '', + comment: 'a)', + blockName: '', + dayOfWeek: 5, + location: '303', + teacher: 'CBr', + timeEnd: '14:00:00', + timeStart: '13:15:00', + dateStart: '2021-04-16T13:15:00.000+02:00', + dateEnd: '2021-04-16T14:00:00.000+02:00', + }, + { + id: 'Y2IwYjYzZDEtODAxYi0wMTNjLTRjNDMtMDFlODgzMmY4MWEy', + code: 'MU', + name: 'Musik', + category: '', + comment: 'a)', + blockName: '', + dayOfWeek: 5, + location: '510', + teacher: 'KBj', + timeEnd: '13:05:00', + timeStart: '12:20:00', + dateStart: '2021-04-16T12:20:00.000+02:00', + dateEnd: '2021-04-16T13:05:00.000+02:00', + }, + { + id: 'N2JkMGFiOTYtMjI5OC0wMjZiLTc3OGEtN2JkN2Q4MDZkNTEy', + code: 'SL', + name: 'Slöjd', + category: '', + comment: 'tmtx)', + blockName: '', + dayOfWeek: 5, + location: '860', + teacher: 'EAl', + timeEnd: '15:10:00', + timeStart: '14:10:00', + dateStart: '2021-04-16T14:10:00.000+02:00', + dateEnd: '2021-04-16T15:10:00.000+02:00', + }, + { + id: 'NzkxMjE3MDctMWExNS0wN2RmLTQwMzQtNTEyZTczZjQyZTUw', + code: 'SV', + name: 'Svenska', + category: '', + blockName: '', + dayOfWeek: 5, + location: '303', + teacher: 'JCa', + timeEnd: '10:35:00', + timeStart: '09:20:00', + dateStart: '2021-04-16T09:20:00.000+02:00', + dateEnd: '2021-04-16T10:35:00.000+02:00', + }, + { + id: 'ZTU1ZDQxNzQtN2Q3Yy0wMDMxLTY2ZmYtZmIyNGM5MjM3ZTRj', + code: 'MA', + name: 'Matematik', + category: '', + blockName: '', + dayOfWeek: 5, + location: '303', + teacher: 'CBr', + timeEnd: '11:35:00', + timeStart: '10:40:00', + dateStart: '2021-04-16T10:40:00.000+02:00', + dateEnd: '2021-04-16T11:35:00.000+02:00', + } + ] +} diff --git a/libs/api/lib/utils/__tests__/dateHandling.test.ts b/libs/api/lib/utils/__tests__/dateHandling.test.ts index 57232b3c..a90d1509 100644 --- a/libs/api/lib/utils/__tests__/dateHandling.test.ts +++ b/libs/api/lib/utils/__tests__/dateHandling.test.ts @@ -9,6 +9,7 @@ test.each([ ['15 oktober 2020 11:34', '2020-10-15T09:34:00.000Z'], ['2020-12-18T15:59:46.34', '2020-12-18T14:59:46.340Z'], ['2020-12-18T15:59:46.340Z', '2020-12-18T15:59:46.340Z'], + ['/Date(1637935089877)/', '2021-11-26T13:58:09.877Z'], ['This is an invalid date', undefined], ])('handles date parsing of %s', (input, expected) => { expect(parseDate(input)).toEqual(expected) From d66e87f5dbc8f5c192e4dff873f9196652e00dec Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sun, 5 Dec 2021 00:16:58 +0100 Subject: [PATCH 13/41] chore(release): 2.6.0 [skip ci] # [2.6.0](https://github.com/kolplattformen/skolplattformen/compare/v2.5.1...v2.6.0) (2021-12-04) ### Features * Frontpage date tweaks ([#582](https://github.com/kolplattformen/skolplattformen/issues/582)) ([66e7811](https://github.com/kolplattformen/skolplattformen/commit/66e7811b83e96f9fb83aa82cb34736f38a3bf16a)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08d20ffe..3ced6d2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [2.6.0](https://github.com/kolplattformen/skolplattformen/compare/v2.5.1...v2.6.0) (2021-12-04) + + +### Features + +* Frontpage date tweaks ([#582](https://github.com/kolplattformen/skolplattformen/issues/582)) ([66e7811](https://github.com/kolplattformen/skolplattformen/commit/66e7811b83e96f9fb83aa82cb34736f38a3bf16a)) + ## [2.5.1](https://github.com/kolplattformen/skolplattformen/compare/v2.5.0...v2.5.1) (2021-12-03) diff --git a/package.json b/package.json index 9c461bd0..127c0cd1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "skolplattformen", - "version": "2.5.1", + "version": "2.6.0", "license": "MIT", "scripts": { "start": "nx start", From 3359ba85f40d45371439bab2f65aea0a94e691c6 Mon Sep 17 00:00:00 2001 From: Andreas Eriksson Date: Sun, 5 Dec 2021 00:15:07 +0100 Subject: [PATCH 14/41] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20Remove=20old?= =?UTF-8?q?=20fakeData=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/api-skolplattformen/lib/fakeData.ts | 1603 ---------------------- 1 file changed, 1603 deletions(-) delete mode 100644 libs/api-skolplattformen/lib/fakeData.ts diff --git a/libs/api-skolplattformen/lib/fakeData.ts b/libs/api-skolplattformen/lib/fakeData.ts deleted file mode 100644 index 12c23cec..00000000 --- a/libs/api-skolplattformen/lib/fakeData.ts +++ /dev/null @@ -1,1603 +0,0 @@ -/* eslint-disable max-len */ -import { - CalendarItem, - Child, - Classmate, - EtjanstChild, - MenuItem, - NewsItem, - Notification, - ScheduleItem, - Skola24Child, - TimetableEntry, - User, -} from '@skolplattformen/api'; - -const data: any = { - '39b59e-bf4b9f-f68ac25321-977218-bf0': { - classmates: [ - { - sisId: 'd004a-98d965a-45174-d2894ca2-f74ebcb', - firstname: 'Darion', - lastname: 'Gustafsson', - guardians: [ - { - email: 'Mike_Svensson@example.net', - firstname: 'Tad', - lastname: 'Eriksson', - mobile: '07074791613', - address: 'Martinvägen 50', - }, - ], - className: '2B', - }, - { - sisId: '54075-284de06-5664c-750b7b13-520fb61', - firstname: 'Brock', - lastname: 'Andersson', - guardians: [ - { - email: 'Brad56@example.org', - firstname: 'Camren', - lastname: 'Eriksson', - mobile: '07075129297', - address: null, - }, - ], - className: '2B', - }, - { - sisId: 'c1fc7-285f95d-c0f37-ea48a297-281e985', - firstname: 'Eloy', - lastname: 'Karlsson', - guardians: [ - { - email: 'Samara.Larsson@example.net', - firstname: 'Ike', - lastname: 'Gustafsson', - mobile: '07077667407', - address: null, - }, - ], - className: '2B', - }, - { - sisId: '212e9-8a2609c-b29c1-97a32bd8-5f84645', - firstname: 'Kristina', - lastname: 'Eriksson', - guardians: [ - { - email: 'Doug57@example.com', - firstname: 'Rollin', - lastname: 'Olsson', - mobile: '07071720107', - address: 'Höckertsvägen 2', - }, - ], - className: '2B', - }, - { - sisId: '01d21-ebc6f8b-526f8-7cfba0ab-26b9956', - firstname: 'Cydney', - lastname: 'Larsson', - guardians: [ - { - email: 'Davon6@example.org', - firstname: 'Oleta', - lastname: 'Svensson', - mobile: '07079762186', - address: null, - }, - ], - className: '2B', - }, - { - sisId: 'a45bb-8a481af-0ad12-7bd1fa4c-1eed4b1', - firstname: 'Berneice', - lastname: 'Persson', - guardians: [ - { - email: 'Milford_Johansson72@example.com', - firstname: 'Arely', - lastname: 'Johansson', - mobile: '07071926019', - address: 'Roslinvägen 36', - }, - ], - className: '2B', - }, - { - sisId: '32f31-039fbed-9060b-2d857c46-e47177d', - firstname: 'Emory', - lastname: 'Svensson', - guardians: [ - { - email: 'Alfredo_Nilsson96@example.org', - firstname: 'Dolores', - lastname: 'Andersson', - mobile: '070752561937', - address: 'Börjesonsvägen 6', - }, - ], - className: '2B', - }, - { - sisId: 'c9d0a-28c371d-e7be2-9781386b-6841eb0', - firstname: 'Maryjane', - lastname: 'Eriksson', - guardians: [ - { - email: 'Eula_Olsson@example.net', - firstname: 'Wendy', - lastname: 'Andersson', - mobile: '07078513037', - address: null, - }, - { - email: 'Lesley_Persson45@example.org', - firstname: 'Erich', - lastname: 'Persson', - mobile: '070788191316', - address: null, - }, - ], - className: '2B', - }, - { - sisId: 'e0f51-3fbd0be-5a8c3-ded7bbed-1d655d5', - firstname: 'Rosendo', - lastname: 'Eriksson', - guardians: [ - { - email: 'Mitchell.Gustafsson84@example.org', - firstname: 'Mariam', - lastname: 'Johansson', - mobile: '07074537423', - address: 'Molinvägen 29', - }, - { - email: 'Rachelle_Olsson@example.net', - firstname: 'Shaniya', - lastname: 'Persson', - mobile: '070765878480', - address: 'Molinvägen 29', - }, - ], - className: '2B', - }, - { - sisId: '298c2-46a24d4-548b9-3d1f90ee-4fae0ab', - firstname: 'Sammy', - lastname: 'Persson', - guardians: [ - { - email: 'Gloria_Svensson@example.com', - firstname: 'Simeon', - lastname: 'Olsson', - mobile: '070753525610', - address: 'Börjesonsvägen 43', - }, - ], - className: '2B', - }, - { - sisId: 'e7628-09352ea-b5d19-1af845b7-63b3e08', - firstname: 'Abraham', - lastname: 'Svensson', - guardians: [ - { - email: 'Erica_Johansson40@example.net', - firstname: 'Carlotta', - lastname: 'Nilsson', - mobile: '070737951712', - address: 'Aroseniusvägen 27', - }, - { - email: 'Malcolm_Gustafsson55@example.org', - firstname: 'Ramon', - lastname: 'Persson', - mobile: '07070395626', - address: 'Aroseniusvägen 27', - }, - ], - className: '2B', - }, - { - sisId: 'ae315-4696438-b3db6-8f0a5b39-74e34bd', - firstname: 'Devante', - lastname: 'Olsson', - guardians: [ - { - email: 'Alf.Johansson39@example.com', - firstname: 'Schuyler', - lastname: 'Gustafsson', - mobile: '07070724289', - address: null, - }, - ], - className: '2B', - }, - { - sisId: '0d812-350f1d5-323aa-d5d93cdd-406e337', - firstname: 'Tyrell', - lastname: 'Eriksson', - guardians: [ - { - email: 'Brennon.Svensson@example.com', - firstname: 'Belle', - lastname: 'Nilsson', - mobile: '07070137347', - address: null, - }, - ], - className: '2B', - }, - ], - news: [ - { - id: 'asdfasdfasdfw', - author: 'Vaktmästare Persson', - header: 'Brandsläckare.', - intro: 'Idag hade vi en incident med en brandsläckare.', - body: - '## Information om brandsläckarincidenten\n\nHej, idag vid lunchtid utlöste en elev av misstag en pulverbrandsläckare i kapprummet. En del pulver yrde runt i rummet och under saneringen fick eleverna i angränsande klassrum vara i aulan istället för klassrummet.\n\nFlera elever var på plats i hallen när detta inträffade men utrymdes kort därefter. Pulvret är INTE hälsovådligt men kan ge upphov till halsirritation vid inandning.\n\nJag har pratat med berörda elever om det inträffade och uppmanat dem att ta hem kläder och tillhörigheter som fanns i kapprummet eftersom de troligen blivit dammiga. Vi rekommenderar att ni tvättar eller vädrar dessa.', - imageUrl: '6607f9b923edb6f85aa4417bab43c0f8.jpg', - fullImageUrl: - 'https://cdn.breakit.se/assets/article/6607f9b923edb6f85aa4417bab43c0f8.jpg?d=980x500', - imageAltText: 'Nyhetsbild. Bildtext ej tillgänglig.', - published: '2020-08-16T21:10:00.000Z', - modified: '2021-01-22T14:49:00.000Z', - }, - { - id: 'asdfabbuasdfs', - author: 'Ada L.', - header: 'App, App, App', - intro: 'Denna vecka bygger vi appar!', - body: - '## Appar med öppen data \n\nDenna vecka har vi förmånen att få besök av några föräldrar som visar hur vi enkelt kan skapa appar som visar information ifrån öppna datakällor.\n\nEn fantastisk möjlighet att lära oss hur digitalisering skapar nya möjligheter i såväl skolan som arbetslivet.', - imageUrl: '6607f9b923edb6f85aa4417bab43c0f8.jpg', - fullImageUrl: - 'https://live.staticflickr.com/4063/4369776892_5cd42d27ba.jpg', - imageAltText: 'Nyhetsbild. Bildtext ej tillgänglig.', - published: '2020-10-13T09:10:00.000Z', - modified: '2021-02-09T15:45:00.000Z', - }, - { - id: 'asdfasdfasdfs', - author: 'Magister Svensson', - header: 'Läxor vecka 6.', - intro: 'Alla elever måste göra sina läxor!', - body: - '## Läxor vecka 6 \n\nFöljande läxor är obligatoriska:\n\n- Antikens historia\n- Svenska stormaktstiden\n- Statistik A\n- Flerdimensionell analys, del 1', - imageUrl: '6607f9b923edb6f85aa4417bab43c0f8.jpg', - fullImageUrl: - 'https://www.mitti.se/_internal/cimg!0/ejf8efxee735ymm8tm40q3hhkl36sdt.jpeg', - imageAltText: 'Nyhetsbild. Bildtext ej tillgänglig.', - published: '2020-08-16T21:10:00.000Z', - modified: '2021-01-22T14:49:00.000Z', - }, - ], - calendar: [ - { - title: 'Terminslut', - id: 73, - description: null, - location: null, - startDate: '2020-12-18', - endDate: '2020-12-18', - allDay: true, - }, - { - title: 'Terminen börjar', - id: 74, - description: null, - location: null, - startDate: '2021-01-12', - endDate: '2021-01-12', - allDay: true, - }, - { - title: 'APT - fritids stänger 15:45', - id: 75, - description: null, - location: null, - startDate: '2021-01-21', - endDate: '2021-01-21', - allDay: true, - }, - { - title: 'Utvecklingsamtal', - id: 76, - description: null, - location: null, - startDate: '2021-02-04', - endDate: '2021-02-04', - allDay: true, - }, - { - title: 'Vänliga veckan', - id: 77, - description: null, - location: null, - startDate: '2021-02-08', - endDate: '2021-02-12', - allDay: true, - }, - { - title: 'Utvecklingsamtal', - id: 79, - description: null, - location: null, - startDate: '2021-02-09', - endDate: '2021-02-09', - allDay: true, - }, - { - title: 'Trygghetsdag', - id: 78, - description: null, - location: null, - startDate: '2021-02-12', - endDate: '2021-02-12', - allDay: true, - }, - { - title: 'APT fritids stänger 15:45', - id: 80, - description: null, - location: null, - startDate: '2021-02-25', - endDate: '2021-02-25', - allDay: true, - }, - { - title: 'Sportlov', - id: 81, - description: null, - location: null, - startDate: '2021-03-01', - endDate: '2021-03-05', - allDay: true, - }, - { - title: 'Studiedag', - id: 82, - description: null, - location: null, - startDate: '2021-03-22', - endDate: '2021-03-22', - allDay: true, - }, - { - title: 'APT - fritids stänger 15:45', - id: 83, - description: null, - location: null, - startDate: '2021-04-01', - endDate: '2021-04-01', - allDay: true, - }, - { - title: 'Långfredag', - id: 84, - description: null, - location: null, - startDate: '2021-04-02', - endDate: '2021-04-02', - allDay: true, - }, - { - title: 'Påsklov', - id: 85, - description: null, - location: null, - startDate: '2021-04-05', - endDate: '2021-04-09', - allDay: true, - }, - { - title: 'Föräldraråd', - id: 86, - description: null, - location: null, - startDate: '2021-04-20', - endDate: '2021-04-20', - allDay: true, - }, - { - title: 'Prao åk 8', - id: 97, - description: null, - location: null, - startDate: '2021-04-26', - endDate: '2021-05-12', - allDay: true, - }, - { - title: 'Kristi Himmelfärd', - id: 87, - description: null, - location: null, - startDate: '2021-05-13', - endDate: '2021-05-13', - allDay: true, - }, - { - title: 'Lov', - id: 88, - description: null, - location: null, - startDate: '2021-05-14', - endDate: '2021-05-14', - allDay: true, - }, - { - title: 'APT Fritids stänger 15:45', - id: 90, - description: null, - location: null, - startDate: '2021-05-20', - endDate: '2021-05-20', - allDay: true, - }, - { - title: 'Läsårsslut', - id: 91, - description: - "

 

", - location: null, - startDate: '2021-06-11', - endDate: '2021-06-11', - allDay: true, - }, - { - title: 'Fritids stängt', - id: 92, - description: - "

 

", - location: null, - startDate: '2021-06-14', - endDate: '2021-06-14', - allDay: true, - }, - ], - schedule: [], - menu: [ - { - title: 'Måndag - Vecka 51', - description: 'Kebabgryta ris
Ratatouille med kikärter', - }, - { - title: 'Tisdag - Vecka 51', - description: 'Ost-broccolisås pasta Fusilli', - }, - { - title: 'Onsdag - Vecka 51', - description: 'Köttbullar potatis gräddsås lingon
Falafel', - }, - { - title: 'Torsdag - Vecka 51', - description: - 'Prinskorv potatis rödbetssallad +
Inlagd och senapssill', - }, - { - title: 'Fredag - Vecka 51', - description: - 'Avslutning Varmkorv bröd ketchup senap
( F-3 i matsalen från 10:30 )', - }, - ], - notifications: [ - { - id: '9025f9-a1e685-d7c4668f09-e14bc5-0ab', - sender: 'Elevdokumentation', - dateCreated: '2020-12-10T14:31:29.966Z', - message: - 'Nu kan du ta del av ditt barns dokumentation av utvecklingssamtal', - url: - 'https://www.breakit.se/artikel/21404/kodaren-slog-larm-nu-akutstoppas-skolplattformen-i-stockholm', - category: null, - type: 'webnotify', - }, - { - id: 'bfe19b-766db3-b38d99d321-bbed3d-506', - sender: 'Planering och Bedömning', - dateCreated: '2020-11-16T13:24:00.000Z', - message: 'Ett nytt inlägg i en lärlogg har skapats.', - url: - 'https://www.breakit.se/artikel/21423/har-ar-it-bolaget-bakom-haveriet-pa-skolplattformen', - category: 'Lärlogg', - type: 'avisering', - }, - { - id: 'a24061-1c9a4e-83dc479d7c-f44fe9-376', - sender: 'Planering och Bedömning', - dateCreated: '2020-06-10T12:18:00.000Z', - message: 'Nu finns det en bedömning att titta på.', - url: - 'https://www.svt.se/nyheter/lokalt/stockholm/skolplattformen-i-stockholm-beratta-om-era-erfarenheter', - category: 'Bedömning', - type: 'avisering', - }, - { - id: '79d65c-1f8240-35c94296ec-9f4bdc-cea', - sender: 'Planering och Bedömning', - dateCreated: '2020-03-24T14:28:00.000Z', - message: 'Nu finns det en bedömning att titta på.', - url: - 'https://www.breakit.se/artikel/18120/skolplattformen-kostade-700-miljoner-strid-med-entreprenor-om-varumarket', - category: 'Bedömning', - type: 'avisering', - }, - { - id: '9c5b7b-52c16d-b9fc2e8248-e4de76-279', - sender: 'Planering och Bedömning', - dateCreated: '2020-03-24T13:48:00.000Z', - message: 'Nu finns det en bedömning att titta på.', - url: - 'https://www.mitti.se/nyheter/forskolans-tur-att-fa-kritiserade-skolplattformen-app/lmsau!5338007/', - category: 'Bedömning', - type: 'avisering', - }, - ], - }, - 'eea96a-a3e045-caab589391-ed7d17-029': { - classmates: [ - { - sisId: '9ee9e-312233c-0df98-05fa5a65-a3787ec', - firstname: 'Raphael', - lastname: 'Olsson', - guardians: [ - { - email: 'Johan99@example.com', - firstname: 'Alessandra', - lastname: 'Svensson', - mobile: '070767120463', - address: 'Franklandsvägen 34', - }, - ], - className: '8C', - }, - { - sisId: 'd3a4b-16b53de-63c22-56d1ad24-4a64a2d', - firstname: 'Fanny', - lastname: 'Karlsson', - guardians: [ - { - email: 'Bernadette.Eriksson@example.org', - firstname: 'Bernadette', - lastname: 'Karlsson', - mobile: '070759877956', - address: null, - }, - { - email: 'Candice29@example.net', - firstname: 'Kelley', - lastname: 'Gustafsson', - mobile: '070748592035', - address: null, - }, - ], - className: '8C', - }, - { - sisId: '42bde-8fabd1c-7a00e-28aea88a-8481bac', - firstname: 'Jamie', - lastname: 'Persson', - guardians: [ - { - email: 'Louisa82@example.net', - firstname: 'Mose', - lastname: 'Larsson', - mobile: '07076548362', - address: null, - }, - ], - className: '8C', - }, - { - sisId: 'dad49-74308c8-83612-5eb7f3a5-e1c4047', - firstname: 'Iris', - lastname: 'Eriksson', - guardians: [ - { - email: 'Vaughn90@example.net', - firstname: 'Ezra', - lastname: 'Andersson', - mobile: '07078700165', - address: 'Björnsonsgatan 251 D Lgh 1503', - }, - { - email: 'Stephany_Svensson22@example.net', - firstname: 'Mia', - lastname: 'Larsson', - mobile: '070761752378', - address: 'Björnsonsgatan 251 D Lgh 1503', - }, - ], - className: '8C', - }, - { - sisId: 'b3425-ada6d70-d3acc-a49a12a6-8b3afdc', - firstname: 'Evans', - lastname: 'Nilsson', - guardians: [ - { - email: 'Terry_Svensson@example.com', - firstname: 'Christop', - lastname: 'Olsson', - mobile: '070767660094', - address: null, - }, - { - email: 'Johanna_Svensson30@example.org', - firstname: 'Madisen', - lastname: 'Johansson', - mobile: '07072269029', - address: null, - }, - ], - className: '8C', - }, - { - sisId: '67471-6c03979-9ef6e-bb2827c4-96d00d5', - firstname: 'Evy', - lastname: 'Larsson', - guardians: [ - { - email: 'Serenity.Gustafsson@example.net', - firstname: 'Toni', - lastname: 'Larsson', - mobile: '07075211567', - address: 'Roslinvägen 48', - }, - ], - className: '8C', - }, - { - sisId: 'f4040-516c4ed-34555-fd525183-6a2f666', - firstname: 'Maximillia', - lastname: 'Karlsson', - guardians: [ - { - email: 'Faustino.Andersson@example.com', - firstname: 'Eriberto', - lastname: 'Nilsson', - mobile: '07076024039', - address: 'Beckombergavägen 213 Lgh 1304', - }, - ], - className: '8C', - }, - { - sisId: 'a9494-75d8ca7-a5fd4-977eca3c-40edbc1', - firstname: 'Pia', - lastname: 'Karlsson', - guardians: [ - { - email: 'Arthur.Karlsson4@example.org', - firstname: 'Eldred', - lastname: 'Svensson', - mobile: '07077609534', - address: 'Börjesonsvägen 6', - }, - ], - className: '8C', - }, - { - sisId: '42a6d-3eaf407-fed01-4a9538de-b822503', - firstname: 'Logan', - lastname: 'Larsson', - guardians: [ - { - email: 'Blake4@example.org', - firstname: 'Jan', - lastname: 'Karlsson', - mobile: '070728715653', - address: 'Bällstavägen 162', - }, - ], - className: '8C', - }, - { - sisId: '9077d-c323c8d-d0d29-5690abfb-d348317', - firstname: 'Torun', - lastname: 'Eriksson', - guardians: [ - { - email: 'Blanca98@example.net', - firstname: 'Dallin', - lastname: 'Eriksson', - mobile: '070766214425', - address: 'Molinvägen 1', - }, - ], - className: '8C', - }, - { - sisId: '31c68-5b86667-0701d-6b7e2471-89e6df9', - firstname: 'Izabella', - lastname: 'Johansson', - guardians: [ - { - email: 'Elouise_Johansson25@example.org', - firstname: 'Jerrold', - lastname: 'Nilsson', - mobile: '07073789274', - address: 'Stobaeusvägen 11', - }, - ], - className: '8C', - }, - { - sisId: '1bb69-5f1c3a6-f0ea8-e1dbb608-2756a52', - firstname: 'Ella', - lastname: 'Persson', - guardians: [ - { - email: 'Shayna.Olsson54@example.net', - firstname: 'Onie', - lastname: 'Nilsson', - mobile: '07076957797', - address: null, - }, - ], - className: '8C', - }, - { - sisId: '348a7-2d0eccc-02981-a02ccb03-cb2a8f2', - firstname: 'Jaylen', - lastname: 'Larsson', - guardians: [ - { - email: 'Aileen_Andersson@example.net', - firstname: 'Tess', - lastname: 'Karlsson', - mobile: '070715315590', - address: 'Peringskiöldsvägen 64', - }, - ], - className: '8C', - }, - ], - news: [ - { - id: 'asdfasdfasdfa', - author: 'Rektor Gustavsson', - header: 'Välkommen till skolan!', - intro: - 'Hej alla barn och föräldrar och välkomna till Storskolan! Här kommer en del information som kan vara bra att känna till inför första dagen.', - body: - '## Information till föräldrar \n\nSkolan börjar kl 08.00 och slutar 18.00. Kommer man sent eller blir sjuk så ska det anmälas via Skolplattformen. Se till så att dina barn har ätit frukost. Frukt är nyttigt! \n\n## Information till barn\n\nLek är tillåtet på rasterna men enbart på skolgården. Medtag ej egna leksaker. Tvätta händerna.', - imageUrl: '6607f9b923edb6f85aa4417bab43c0f8.jpg', - fullImageUrl: - 'https://timbro.se/app/uploads/2020/10/broman-skolplattformen-1280x752.jpg', - imageAltText: 'Nyhetsbild. Bildtext ej tillgänglig.', - published: '2020-08-16T21:10:00.000Z', - modified: '2021-01-22T14:49:00.000Z', - }, - { - id: 'asdfabbuasdfs', - author: 'Ada L.', - header: 'App, App, App', - intro: 'Denna vecka bygger vi appar!', - body: - '## Appar med öppen data \n\nDenna vecka har vi förmånen att få besök av några föräldrar som visar hur vi enkelt kan skapa appar som visar information ifrån öppna datakällor.\n\nEn fantastisk möjlighet att lära oss hur digitalisering skapar nya möjligheter i såväl skolan som arbetslivet.', - imageUrl: '6607f9b923edb6f85aa4417bab43c0f8.jpg', - fullImageUrl: - 'https://live.staticflickr.com/4063/4369776892_5cd42d27ba.jpg', - imageAltText: 'Nyhetsbild. Bildtext ej tillgänglig.', - published: '2020-10-13T09:10:00.000Z', - modified: '2021-02-09T15:45:00.000Z', - }, - { - id: 'asdfasdfasdfs', - author: 'Magister Svensson', - header: 'Läxor vecka 6.', - intro: 'Alla elever måste göra sina läxor!', - body: - '## Läxor vecka 6 \n\nFöljande läxor är obligatoriska:\n\n- Antikens historia\n- Svenska stormaktstiden\n- Statistik A\n- Flerdimensionell analys, del 1', - imageUrl: '6607f9b923edb6f85aa4417bab43c0f8.jpg', - fullImageUrl: - 'https://www.mitti.se/_internal/cimg!0/ejf8efxee735ymm8tm40q3hhkl36sdt.jpeg', - imageAltText: 'Nyhetsbild. Bildtext ej tillgänglig.', - published: '2020-08-16T21:10:00.000Z', - modified: '2021-01-22T14:49:00.000Z', - }, - { - id: 'asdfasdfasdfd', - author: 'Information från Förskoleklass', - header: 'Vinteraktiviteter', - intro: - 'Vi kommer efter att förskoleklassen är slut arrangera olika vinteraktiviteter genom fridtidsverksamheten.', - body: - '## Vänligen ta med hjälm, skridskor eller stjärtlapp.\n\n ![Bild](https://images.unsplash.com/photo-1495377701095-00261b767581?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=988&q=80)\n\n Alla barn måste ha hjälm på sig samt varma kläder. Vi kommer åka i backen bakom skolbyggnaden samt använda isen som spolats vid Mullsjöskolan. Personal kommer finnas på plats samt att vi erbjuda varm dryck, frukt och lek för de barn som ej har hjälm eller lämpligt åkdon.', - imageUrl: '6607f9b923edb6f85aa4417bab43c0f8.jpg', - fullImageUrl: 'https://unsplash.com/photos/yB_aiAWkm40', - imageAltText: 'Nyhetsbild. Bildtext ej tillgänglig.', - published: '2020-08-16T21:10:00.000Z', - modified: '2021-01-22T14:49:00.000Z', - }, - { - id: 'asdfasdfasdfdsa', - author: 'Köket', - header: 'Ekologisk vecka i matsalen', - intro: 'Ekologiska veckan i matsalen vecka 11', - body: - '## Vi kommer ha tema jorden i matsalen och servera ekologisk mat från hela världen med tema jorden. Detta för att belysa att man kan använda alla delar av råvaorna. Det kommer erbjudas rätter från alla världsdelar som är producerat för jordens bästa. Smaklig spis hälsar Gunnel i köket med personal.', - imageUrl: '6607f9b923edb6f85aa4417bab43c0f8.jpg', - fullImageUrl: 'https://unsplash.com/photos/7K17MvT8qBg', - imageAltText: 'Nyhetsbild. Bildtext ej tillgänglig.', - published: '2021-01-16T21:10:03.000Z', - modified: '2021-01-17T14:40:00.000Z', - }, - { - id: 'asdfasdfasdfbvdsa', - author: 'Vaktmästaren', - header: 'Klotter i korridoren (igen)', - intro: - 'Ännu en gång har vi råka ut för skadegörelse i korridorerna vid åk 5', - body: - '## Tyvärr har flera elever klottat på skåp och väggar vid åk5 skåpen. Detta är helt oacceptablet beteende och kostar skolan stora belopp att åtgärda. Vi ber alla föräldrar prata med sina barn om klotter samt att det var väldigt grovt spårkbruk. Personalen på skolan kommer att hålla extra uppsikt och vi har även pratat med en del av de inblandade eleverna i denna skadegörelse.\n\nPersonalen har även börjat forska på vad vissa av de skrivna orden betyder och Eva-Britt är förfasad över språkbruket samt vad de innebär. Bernt kommer att påbörja saneringen och återställningen av skadegörelsen samt vakta korridorerna nogrannare för att säkerställa att detta ej kommer ske igen.\n\n Klotter\n\nUPPDATERING: Det som är skrivet om Sara är inte sant! ', - imageUrl: '6607f9b923edb6f85aa4417bab43c0f8.jpg', - fullImageUrl: 'https://unsplash.com/photos/SkbEZ16VywM', - imageAltText: 'Nyhetsbild. Bildtext ej tillgänglig.', - published: '2021-02-02T14:10:03.000Z', - modified: '2021-02-02T14:15:00.000Z', - }, - ], - calendar: [ - { - title: 'Terminslut', - id: 73, - description: null, - location: null, - startDate: '2020-12-18', - endDate: '2020-12-18', - allDay: true, - }, - { - title: 'Terminen börjar', - id: 74, - description: null, - location: null, - startDate: '2021-01-12', - endDate: '2021-01-12', - allDay: true, - }, - { - title: 'APT - fritids stänger 15:45', - id: 75, - description: null, - location: null, - startDate: '2021-01-21', - endDate: '2021-01-21', - allDay: true, - }, - { - title: 'Utvecklingsamtal', - id: 76, - description: null, - location: null, - startDate: '2021-02-04', - endDate: '2021-02-04', - allDay: true, - }, - { - title: 'Vänliga veckan', - id: 77, - description: null, - location: null, - startDate: '2021-02-08', - endDate: '2021-02-12', - allDay: true, - }, - { - title: 'Utvecklingsamtal', - id: 79, - description: null, - location: null, - startDate: '2021-02-09', - endDate: '2021-02-09', - allDay: true, - }, - { - title: 'Trygghetsdag', - id: 78, - description: null, - location: null, - startDate: '2021-02-12', - endDate: '2021-02-12', - allDay: true, - }, - { - title: 'APT fritids stänger 15:45', - id: 80, - description: null, - location: null, - startDate: '2021-02-25', - endDate: '2021-02-25', - allDay: true, - }, - { - title: 'Sportlov', - id: 81, - description: null, - location: null, - startDate: '2021-03-01', - endDate: '2021-03-05', - allDay: true, - }, - { - title: 'Studiedag', - id: 82, - description: null, - location: null, - startDate: '2021-03-22', - endDate: '2021-03-22', - allDay: true, - }, - { - title: 'APT - fritids stänger 15:45', - id: 83, - description: null, - location: null, - startDate: '2021-04-01', - endDate: '2021-04-01', - allDay: true, - }, - { - title: 'Långfredag', - id: 84, - description: null, - location: null, - startDate: '2021-04-02', - endDate: '2021-04-02', - allDay: true, - }, - { - title: 'Påsklov', - id: 85, - description: null, - location: null, - startDate: '2021-04-05', - endDate: '2021-04-09', - allDay: true, - }, - { - title: 'Föräldraråd', - id: 86, - description: null, - location: null, - startDate: '2021-04-20', - endDate: '2021-04-20', - allDay: true, - }, - { - title: 'Prao åk 8', - id: 97, - description: null, - location: null, - startDate: '2021-04-26', - endDate: '2021-05-12', - allDay: true, - }, - { - title: 'Kristi Himmelfärd', - id: 87, - description: null, - location: null, - startDate: '2021-05-13', - endDate: '2021-05-13', - allDay: true, - }, - { - title: 'Lov', - id: 88, - description: null, - location: null, - startDate: '2021-05-14', - endDate: '2021-05-14', - allDay: true, - }, - { - title: 'APT Fritids stänger 15:45', - id: 90, - description: null, - location: null, - startDate: '2021-05-20', - endDate: '2021-05-20', - allDay: true, - }, - ], - schedule: [], - menu: [ - { - title: 'Måndag - Vecka 51', - description: 'Kebabgryta ris
Ratatouille med kikärter', - }, - { - title: 'Tisdag - Vecka 51', - description: 'Ost-broccolisås pasta Fusilli', - }, - { - title: 'Onsdag - Vecka 51', - description: 'Köttbullar potatis gräddsås lingon
Falafel', - }, - { - title: 'Torsdag - Vecka 51', - description: - 'Prinskorv potatis rödbetssallad +
Inlagd och senapssill', - }, - { - title: 'Fredag - Vecka 51', - description: - 'Avslutning Varmkorv bröd ketchup senap
( F-3 i matsalen från 10:30 )', - }, - ], - notifications: [ - { - id: 'e1b5bc-597fa8-5511794939-3614e1-615', - sender: 'Planering och Bedömning', - dateCreated: '2020-12-02T14:02:00.000Z', - message: 'Ett nytt inlägg i en lärlogg har skapats.', - url: - 'https://www.mitti.se/nyheter/rekorddyr-skolplattform-kostar-258-miljoner-till/lmsao!5381301/', - category: 'Lärlogg', - messageType: 'avisering', - }, - { - id: '7dbc20-bfa1ac-e20171b865-82c1f7-f3c', - sender: 'Planering och Bedömning', - dateCreated: '2020-12-01T12:43:00.000Z', - message: 'Ett nytt inlägg i en lärlogg har skapats.', - url: - 'https://computersweden.idg.se/2.2683/1.722561/lacka-skolplattformen-datainspektionen', - category: 'Lärlogg', - messageType: 'avisering', - }, - { - id: 'a6829b-ecf912-b71582e8fb-b6dc14-f60', - sender: 'Planering och Bedömning', - dateCreated: '2020-11-24T13:34:00.000Z', - message: 'Ett nytt inlägg i en lärlogg har skapats.', - url: 'https://www.dagensarena.se/redaktionen/en-systemkramare-ger-upp/', - category: 'Lärlogg', - messageType: 'avisering', - }, - { - id: '3cedb4-767d24-8ccd6ac3ac-c05cb7-a3a', - sender: 'Planering och Bedömning', - dateCreated: '2020-11-16T13:24:00.000Z', - message: 'Ett nytt inlägg i en lärlogg har skapats.', - url: - 'https://www.breakit.se/artikel/27075/skolplattformen-kostade-1-miljard-att-bygga-nu-tvingas-stockholm-bota', - category: 'Lärlogg', - messageType: 'avisering', - }, - { - id: '6ace13-5f99da-d1d50ac7a6-4a6108-d8e', - sender: 'Planering och Bedömning', - dateCreated: '2020-11-12T13:27:00.000Z', - message: 'Ett nytt inlägg i en lärlogg har skapats.', - url: - 'https://www.nyteknik.se/sakerhet/ygeman-om-datalackan-i-skolplattformen-det-ar-upprorande-6968853', - category: 'Lärlogg', - messageType: 'avisering', - }, - ], - }, -} - -export const user = (): User => ({ - personalNumber: '195001182046', // Test personal number from Skatteverket - firstName: 'Namn', - lastName: 'Namnsson', - isAuthenticated: true -}) - -export const children = (): EtjanstChild[] => [ - { - name: 'Shanel Nilsson (elev)', - id: '39b59e-bf4b9f-f68ac25321-977218-bf0', - sdsId: '8e81a06-53f55fb-d1b93-f0e5b357ad0b7caaf1d36', - status: 'F;GR', - schoolId: '9e58434-8800-da59547-614bf0e-e09c015', - }, - { - name: 'Alan Nilsson (elev)', - id: 'eea96a-a3e045-caab589391-ed7d17-029', - sdsId: 'bc2d341-8d970cc-69526-43501c082aaa870d9fe99', - status: 'GR', - schoolId: '8e6b13b-3116-e66c39b-a4c3fa5-a1d72d9', - }, -] -export const skola24Children = (): Skola24Child[] => [ - { - firstName: 'Shanel', - lastName: 'Jonsson Nilsson', - personGuid: 'abc123', - schoolGuid: 'def456', - schoolID: 'ghi789', - timetableID: 'jkl012', - unitGuid: 'mno345' - }, -] - -export const classmates = (child: EtjanstChild): Classmate[] => - data[child.id].classmates - -export const news = (child: Child): NewsItem[] => data[child.id].news - -export const calendar = (child: Child): CalendarItem[] => - data[child.id].calendar - -export const schedule = (child: Child): ScheduleItem[] => - data[child.id].schedule - -export const menu = (child: Child): MenuItem[] => data[child.id].menu - -export const notifications = (child: Child): Notification[] => - data[child.id].notifications - -export const timetable = (child: Skola24Child): TimetableEntry[] => { - if (!child.personGuid || !child.unitGuid) return [] - return [ - { - id: 'N2FjMDc1NjYtZmM2Yy0wZDQyLTY3M2YtZWI5NGNiZDA3ZGU4', - code: 'Lunch', - name: 'Lunch', - category: '', - blockName: '', - dayOfWeek: 1, - location: 'Ö5', - teacher: '', - timeEnd: '12:05:00', - timeStart: '11:40:00', - dateStart: '2021-04-12T11:40:00.000+02:00', - dateEnd: '2021-04-12T12:05:00.000+02:00', - }, - { - id: 'ZTQ1NWE0N2EtNzAwOS0wZTAzLTQ1ZDYtNTA1NWI4Y2JhNDYw', - code: 'BL', - name: 'Bild', - category: '', - blockName: '', - dayOfWeek: 1, - location: '221', - teacher: 'KUr', - timeEnd: '11:35:00', - timeStart: '09:40:00', - dateStart: '2021-04-12T09:40:00.000+02:00', - dateEnd: '2021-04-12T11:35:00.000+02:00', - }, - { - id: 'YjAxODRmY2QtNTJjZS0wMDJlLTYxOGItYmFlNTVlNDgzZmVk', - code: 'NO', - name: 'Naturorienterande ämnen', - category: '', - comment: 'a)', - blockName: '', - dayOfWeek: 1, - location: '307', - teacher: 'TBo', - timeEnd: '13:30:00', - timeStart: '12:30:00', - dateStart: '2021-04-12T12:30:00.000+02:00', - dateEnd: '2021-04-12T13:30:00.000+02:00', - }, - { - id: 'MWRiZGI1NzgtYWIzNy0wYzMwLTVkMmEtMWFjNWRkMTRmOTdh', - code: 'IDH', - name: 'Idrott & hälsa', - category: '', - blockName: '', - dayOfWeek: 1, - location: '215', - teacher: 'HAl', - timeEnd: '15:45:00', - timeStart: '14:40:00', - dateStart: '2021-04-12T14:40:00.000+02:00', - dateEnd: '2021-04-12T15:45:00.000+02:00', - }, - { - id: 'MmZkZTZiMzMtMjdjMS0wZGIzLTUzYWYtZTg0Zjc1NDRlNzQw', - code: 'M2FR', - name: 'Franska', - category: 'Moderna språk, språkval', - blockName: '', - dayOfWeek: 1, - location: '304', - teacher: 'DNi', - timeEnd: '14:25:00', - timeStart: '13:40:00', - dateStart: '2021-04-12T13:40:00.000+02:00', - dateEnd: '2021-04-12T14:25:00.000+02:00', - }, - { - id: 'MzAxMzU3MWItZGM1Ny0wOGVhLTVkZjUtOGFkMGIyYTY2OTAx', - code: 'SO', - name: 'Samhällsorienterande ämnen', - category: '', - blockName: '', - dayOfWeek: 1, - location: '303', - teacher: 'HRr', - timeEnd: '09:25:00', - timeStart: '08:15:00', - dateStart: '2021-04-12T08:15:00.000+02:00', - dateEnd: '2021-04-12T09:25:00.000+02:00', - }, - { - id: 'NDY3MDY1MmYtOTIzYi0wZmQ0LTVlZGEtNGVhZDRkOTExNTgz', - code: 'M2FR', - name: 'Franska', - category: 'Moderna språk, språkval', - blockName: '', - dayOfWeek: 2, - location: '302,Fjärr asd asdasd asdad aasdds', - teacher: 'DNi', - timeEnd: '09:50:00', - timeStart: '09:05:00', - dateStart: '2021-04-13T09:05:00.000+02:00', - dateEnd: '2021-04-13T09:50:00.000+02:00', - }, - { - id: 'NmE4OTU1NmItYzM0ZS0wYTI1LTYzM2QtYzBiN2M4OTVmYTQ3', - code: 'EN', - name: 'Engelska', - category: '', - blockName: '', - dayOfWeek: 2, - location: 'Fjärr', - teacher: 'TPe', - timeEnd: '13:15:00', - timeStart: '12:30:00', - dateStart: '2021-04-13T12:30:00.000+02:00', - dateEnd: '2021-04-13T13:15:00.000+02:00', - }, - { - id: 'NDAxODRjOTctMmE5ZC0wMzdjLTY2NDMtODhlODEzOTQ3YTJh', - code: 'Lunch', - name: 'Lunch', - category: '', - blockName: '', - dayOfWeek: 2, - location: 'Fjärr', - teacher: '', - timeEnd: '12:05:00', - timeStart: '11:40:00', - dateStart: '2021-04-13T11:40:00.000+02:00', - dateEnd: '2021-04-13T12:05:00.000+02:00', - }, - { - id: 'ZTc4YTcyZTUtMDc0NS0wNDE0LTVjODctYjY0MzQ2MGM3MDll', - code: 'MA', - name: 'Matematik', - category: '', - blockName: '', - dayOfWeek: 2, - location: 'Fjärr', - teacher: 'CBr', - timeEnd: '11:20:00', - timeStart: '10:00:00', - dateStart: '2021-04-13T10:00:00.000+02:00', - dateEnd: '2021-04-13T11:20:00.000+02:00', - }, - { - id: 'MjRkMWE4YTItYTk5ZC0wYTFmLTVhMDgtMThiMmNhZDc1ZDUz', - code: 'MU', - name: 'Musik', - category: '', - blockName: '', - dayOfWeek: 2, - location: 'Fjärr', - teacher: 'KBj', - timeEnd: '14:15:00', - timeStart: '13:30:00', - dateStart: '2021-04-13T13:30:00.000+02:00', - dateEnd: '2021-04-13T14:15:00.000+02:00', - }, - { - id: 'NTU4ZTc4ZTctNDQyMy0wMjVkLTRiYzktZGUwYmFmYzk2YTlj', - code: 'EN', - name: 'Engelska', - category: '', - blockName: '', - dayOfWeek: 3, - location: '303', - teacher: 'TPe', - timeEnd: '09:55:00', - timeStart: '09:10:00', - dateStart: '2021-04-14T09:10:00.000+02:00', - dateEnd: '2021-04-14T09:55:00.000+02:00', - }, - { - id: 'NDUyNjIxODItYzFiOC0wOTFjLTYwODYtZDllZjZjN2QyYzA3', - code: 'SV', - name: 'Svenska', - category: '', - comment: 'a)', - blockName: '', - dayOfWeek: 3, - location: '303', - teacher: 'JCa', - timeEnd: '14:45:00', - timeStart: '14:00:00', - dateStart: '2021-04-14T14:00:00.000+02:00', - dateEnd: '2021-04-14T14:45:00.000+02:00', - }, - { - id: 'NDdkMGI0ZjItMjkxMC0wYWI1LTQ0YWMtNDY3NTdkZTE2Njg3', - code: 'SO', - name: 'Engelska', - category: 'Samhällsorienterande ämnen', - blockName: '', - dayOfWeek: 3, - location: '303', - teacher: 'HRr', - timeEnd: '11:00:00', - timeStart: '10:05:00', - dateStart: '2021-04-14T10:05:00.000+02:00', - dateEnd: '2021-04-14T11:00:00.000+02:00', - }, - { - id: 'ZTI2ZDgyNWUtM2ZlOS0wZDVmLTY5NTctNGYzZThjMTMxOTdh', - code: 'NO', - name: 'Naturorienterande ämnen', - category: '', - comment: 'a)', - blockName: '', - dayOfWeek: 3, - location: '307', - teacher: 'TBo', - timeEnd: '13:50:00', - timeStart: '12:50:00', - dateStart: '2021-04-14T12:50:00.000+02:00', - dateEnd: '2021-04-14T13:50:00.000+02:00', - }, - { - id: 'NzMxNjczNGMtMmZmZi0wM2YzLTU0ZjMtODdjOTAwYzIwNTUw', - code: 'Lunch', - name: 'Lunch', - category: '', - blockName: '', - dayOfWeek: 3, - location: 'Ö5', - teacher: '', - timeEnd: '12:40:00', - timeStart: '12:15:00', - dateStart: '2021-04-14T12:15:00.000+02:00', - dateEnd: '2021-04-14T12:40:00.000+02:00', - }, - { - id: 'MWRkZjhlZTktNTBmMC0wZjNhLTQ1OTgtMWJkOWM3MjI2NWQ4', - code: 'SV', - name: 'Svenska', - category: '', - blockName: '', - dayOfWeek: 3, - location: '303', - teacher: 'JCa', - timeEnd: '12:05:00', - timeStart: '11:20:00', - dateStart: '2021-04-14T11:20:00.000+02:00', - dateEnd: '2021-04-14T12:05:00.000+02:00', - }, - { - id: 'NzM2Mjc2ZTYtY2JlYy0wOTc1LTU1ZGYtNjMwZjhjZWVjNjgy', - code: 'MA', - name: 'Matematik', - category: '', - comment: 'a)', - blockName: '', - dayOfWeek: 3, - location: '307', - teacher: 'CBr', - timeEnd: '15:45:00', - timeStart: '15:00:00', - dateStart: '2021-04-14T15:00:00.000+02:00', - dateEnd: '2021-04-14T15:45:00.000+02:00', - }, - { - id: 'YWNlZmEzZjYtM2EwNC0wYWY3LTU1N2MtMDBlMTA4MDQzMzRl', - code: 'MU', - name: 'Musik', - category: '', - blockName: '', - dayOfWeek: 3, - location: '504', - teacher: 'KBj', - timeEnd: '09:00:00', - timeStart: '08:15:00', - dateStart: '2021-04-14T08:15:00.000+02:00', - dateEnd: '2021-04-14T09:00:00.000+02:00', - }, - { - id: 'NDc4MThmMDYtYmYxYi0wZDBkLTdhNmItZGVjMjY3OWY3MmYz', - code: 'IDH', - name: 'Idrott & Hälsa', - category: '', - blockName: '', - dayOfWeek: 4, - location: 'Fjärr', - teacher: 'AKö,CSv,HAl', - timeEnd: '15:45:00', - timeStart: '14:35:00', - dateStart: '2021-04-15T14:35:00.000+02:00', - dateEnd: '2021-04-15T15:45:00.000+02:00', - }, - { - id: 'ZjQyZjNkOWItYWMzZi0wYWRhLTQ3YzItNTZiNTJkOTRmY2Iy', - code: 'M2FR', - name: 'Franska', - category: 'Moderna språk, språkval', - blockName: '', - dayOfWeek: 4, - location: 'Fjärr', - teacher: 'DNi', - timeEnd: '11:55:00', - timeStart: '11:10:00', - dateStart: '2021-04-15T11:10:00.000+02:00', - dateEnd: '2021-04-15T11:55:00.000+02:00', - }, - { - id: 'YzQ2NWZlOWMtYzM3ZC0wYzBlLTQzNTQtODMyYmU3ODcxMDQ3', - code: 'MTID', - name: 'Mentorstid', - category: 'Diverse', - comment: 'Arbetslagsråd 6C', - blockName: '', - dayOfWeek: 4, - location: 'Fjärr', - teacher: 'JCa,CBr', - timeEnd: '10:00:00', - timeStart: '09:15:00', - dateStart: '2021-04-15T09:15:00.000+02:00', - dateEnd: '2021-04-15T10:00:00.000+02:00', - }, - { - id: 'YzMwMGY0YzAtNjhjNi0wYzY0LTU1MjctODg2MWQ4ZTRmZTI2', - code: 'MU', - name: 'Musik', - category: '', - blockName: '', - dayOfWeek: 4, - location: 'Fjärr', - teacher: 'KBj', - timeEnd: '10:55:00', - timeStart: '10:10:00', - dateStart: '2021-04-15T10:10:00.000+02:00', - dateEnd: '2021-04-15T10:55:00.000+02:00', - }, - { - id: 'ZDNlNTFhMGUtYWFlYy0wOGI0LTVlMGItOTc0MzFiZmIwODcx', - code: 'Lunch', - name: 'Lunch', - category: 'Diverse', - blockName: '', - dayOfWeek: 4, - location: 'Fjärr', - teacher: '', - timeEnd: '12:25:00', - timeStart: '12:00:00', - dateStart: '2021-04-15T12:00:00.000+02:00', - dateEnd: '2021-04-15T12:25:00.000+02:00', - }, - { - id: 'MDRiZWMyODMtNjEwZC0wZDYwLTRlOWItYTY1MjAwZTc0YTZm', - code: 'SO', - name: 'Samhällsorienterande ämnen', - category: '', - blockName: '', - dayOfWeek: 4, - location: 'Fjärr', - teacher: 'HRr', - timeEnd: '13:10:00', - timeStart: '12:35:00', - dateStart: '2021-04-15T12:35:00.000+02:00', - dateEnd: '2021-04-15T13:10:00.000+02:00', - }, - { - id: 'YTA0ZTA2NTktYTU5MS0wMTFmLTVlYWYtNWM1MTgxNDJlMDcy', - code: 'EN', - name: 'Engelska', - category: '', - comment: 'a)', - blockName: '', - dayOfWeek: 4, - location: 'Fjärr', - teacher: 'TPe', - timeEnd: '14:20:00', - timeStart: '13:35:00', - dateStart: '2021-04-15T13:35:00.000+02:00', - dateEnd: '2021-04-15T14:20:00.000+02:00', - }, - { - id: 'OGJhN2MxYTYtMDQ4NS0wNWNhLTUwZWEtZDQ5YzQyMzFhYzc5', - code: 'Lunch', - name: 'Lunch', - category: 'Diverse', - blockName: '', - dayOfWeek: 5, - location: 'Ö5', - teacher: '', - timeEnd: '12:05:00', - timeStart: '11:40:00', - dateStart: '2021-04-16T11:40:00.000+02:00', - dateEnd: '2021-04-16T12:05:00.000+02:00', - }, - { - id: 'ZmUwMGEwM2QtNTExMy0wODliLTY1ZGEtODM0YmRjNjc1NDIw', - code: 'MA', - name: 'Matematik', - category: '', - comment: 'a)', - blockName: '', - dayOfWeek: 5, - location: '303', - teacher: 'CBr', - timeEnd: '14:00:00', - timeStart: '13:15:00', - dateStart: '2021-04-16T13:15:00.000+02:00', - dateEnd: '2021-04-16T14:00:00.000+02:00', - }, - { - id: 'Y2IwYjYzZDEtODAxYi0wMTNjLTRjNDMtMDFlODgzMmY4MWEy', - code: 'MU', - name: 'Musik', - category: '', - comment: 'a)', - blockName: '', - dayOfWeek: 5, - location: '510', - teacher: 'KBj', - timeEnd: '13:05:00', - timeStart: '12:20:00', - dateStart: '2021-04-16T12:20:00.000+02:00', - dateEnd: '2021-04-16T13:05:00.000+02:00', - }, - { - id: 'N2JkMGFiOTYtMjI5OC0wMjZiLTc3OGEtN2JkN2Q4MDZkNTEy', - code: 'SL', - name: 'Slöjd', - category: '', - comment: 'tmtx)', - blockName: '', - dayOfWeek: 5, - location: '860', - teacher: 'EAl', - timeEnd: '15:10:00', - timeStart: '14:10:00', - dateStart: '2021-04-16T14:10:00.000+02:00', - dateEnd: '2021-04-16T15:10:00.000+02:00', - }, - { - id: 'NzkxMjE3MDctMWExNS0wN2RmLTQwMzQtNTEyZTczZjQyZTUw', - code: 'SV', - name: 'Svenska', - category: '', - blockName: '', - dayOfWeek: 5, - location: '303', - teacher: 'JCa', - timeEnd: '10:35:00', - timeStart: '09:20:00', - dateStart: '2021-04-16T09:20:00.000+02:00', - dateEnd: '2021-04-16T10:35:00.000+02:00', - }, - { - id: 'ZTU1ZDQxNzQtN2Q3Yy0wMDMxLTY2ZmYtZmIyNGM5MjM3ZTRj', - code: 'MA', - name: 'Matematik', - category: '', - blockName: '', - dayOfWeek: 5, - location: '303', - teacher: 'CBr', - timeEnd: '11:35:00', - timeStart: '10:40:00', - dateStart: '2021-04-16T10:40:00.000+02:00', - dateEnd: '2021-04-16T11:35:00.000+02:00', - } - ] -} From 5c477e1cf151f0bca3f6de25ed5cdfcab1137c81 Mon Sep 17 00:00:00 2001 From: Emil Lindqvist Date: Sun, 5 Dec 2021 15:31:43 +0100 Subject: [PATCH 15/41] Add support for running api-test-app with api-hjarntorget --- apps/api-test-app/src/main.js | 23 +++++++++++++--------- libs/api-hjarntorget/lib/apiHjarntorget.ts | 11 ++++------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/apps/api-test-app/src/main.js b/apps/api-test-app/src/main.js index 24f282b6..6bd0599d 100644 --- a/apps/api-test-app/src/main.js +++ b/apps/api-test-app/src/main.js @@ -14,9 +14,13 @@ const path = require('path') const fs = require('fs') const HttpProxyAgent = require('https-proxy-agent') const agentWrapper = require('./app/agentFetchWrapper') -const init = require('@skolplattformen/api-skolplattformen').default +const initSkolplattformen = require('@skolplattformen/api-skolplattformen').default +const initHjarntorget = require('@skolplattformen/api-hjarntorget').default + +const [, , personalNumber, platform] = process.argv +const isHjarntorget = platform && platform.startsWith('hj') +const init = isHjarntorget ? initHjarntorget : initSkolplattformen; -const [, , personalNumber] = process.argv process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0' const cookieJar = new CookieJar() let bankIdUsed = false @@ -136,10 +140,9 @@ async function Login(api) { try { console.log('Attempt to use saved session cookie to login') const rawContent = await readFile(`${recordFolder}/latestSessionCookie.txt`) - const sessionCookie = JSON.parse(rawContent) - - await api.setSessionCookie(`${sessionCookie.key}=${sessionCookie.value}`) - + const sessionCookies = JSON.parse(rawContent) + await api.setSessionCookie(`${sessionCookies[0].key}=${sessionCookies[0].value}`) + useBankId = false console.log('Login with old cookie succeeded') } catch (error) { @@ -177,10 +180,12 @@ function ensureDirectoryExistence(filePath) { fs.mkdirSync(dirname) } + function getSessionCookieFromCookieJar() { - const cookies = cookieJar.getCookiesSync('https://etjanst.stockholm.se') - const sessionCookie = cookies.find((c) => c.key === 'SMSESSION') - return sessionCookie + const cookieUrl = isHjarntorget ? 'https://hjarntorget.goteborg.se' : 'https://etjanst.stockholm.se' + const cookies = cookieJar.getCookiesSync(cookieUrl) + const sessionCookieKey = isHjarntorget ? 'JSESSIONID' : 'SMSESSION' + return cookies.find(c => c.key === sessionCookieKey) } const record = async (info, data) => { diff --git a/libs/api-hjarntorget/lib/apiHjarntorget.ts b/libs/api-hjarntorget/lib/apiHjarntorget.ts index 6ab43814..1bebf739 100644 --- a/libs/api-hjarntorget/lib/apiHjarntorget.ts +++ b/libs/api-hjarntorget/lib/apiHjarntorget.ts @@ -147,13 +147,8 @@ export class ApiHjarntorget extends EventEmitter implements Api { } async setSessionCookie(sessionCookie: string): Promise { - await this.fetch('login-cookie', hjarntorgetUrl, { - headers: { - cookie: sessionCookie, - }, - redirect: 'manual', - }) - + this.cookieManager.setCookieString(sessionCookie, hjarntorgetUrl) + const user = await this.getUser() if (!user.isAuthenticated) { throw new Error('Session cookie is expired') @@ -167,9 +162,11 @@ export class ApiHjarntorget extends EventEmitter implements Api { console.log('fetching user') const currentUserResponse = await this.fetch('current-user', currentUserUrl) if (currentUserResponse.status !== 200) { + console.log('is not authenticated!') return { isAuthenticated: false } } + console.log('fetching user worked...') const retrivedUser = await currentUserResponse.json() return { ...retrivedUser, isAuthenticated: true } } From 601e92b230eaf81ad08a83dbaee69b3c57807a3a Mon Sep 17 00:00:00 2001 From: Emil Lindqvist Date: Sun, 5 Dec 2021 16:48:03 +0100 Subject: [PATCH 16/41] Remove unncessary console.log statements --- libs/api-hjarntorget/lib/apiHjarntorget.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/libs/api-hjarntorget/lib/apiHjarntorget.ts b/libs/api-hjarntorget/lib/apiHjarntorget.ts index 1bebf739..104009f3 100644 --- a/libs/api-hjarntorget/lib/apiHjarntorget.ts +++ b/libs/api-hjarntorget/lib/apiHjarntorget.ts @@ -162,11 +162,9 @@ export class ApiHjarntorget extends EventEmitter implements Api { console.log('fetching user') const currentUserResponse = await this.fetch('current-user', currentUserUrl) if (currentUserResponse.status !== 200) { - console.log('is not authenticated!') return { isAuthenticated: false } } - console.log('fetching user worked...') const retrivedUser = await currentUserResponse.json() return { ...retrivedUser, isAuthenticated: true } } From 3b39c47230404bc8edb598a95f732f3fd13dc85b Mon Sep 17 00:00:00 2001 From: Andreas Eriksson Date: Sun, 5 Dec 2021 18:31:34 +0100 Subject: [PATCH 17/41] Hide lunch menu on weekends The menu for next week are not available until monday morrning (with current api implementation) --- .../components/childListItem.component.tsx | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/apps/skolplattformen-app/components/childListItem.component.tsx b/apps/skolplattformen-app/components/childListItem.component.tsx index 76e6c67b..8ca199f5 100644 --- a/apps/skolplattformen-app/components/childListItem.component.tsx +++ b/apps/skolplattformen-app/components/childListItem.component.tsx @@ -146,6 +146,16 @@ export const ChildListItem = ({ const styles = useStyleSheet(themeStyles) const isDarkMode = useColorScheme() === 'dark' const meaningfulStartingDate = getMeaningfulStartingDate(currentDate) + + // Hide menu if we want to show monday but it is not monday yet. + // The menu for next week is not available until monday + const shouldShowLunchMenu = + menu[meaningfulStartingDate.isoWeekday() - 1] && + !( + meaningfulStartingDate.isoWeekday() === 1 && + currentDate.isoWeekday() !== 1 + ) + return ( navigation.navigate('Child', { child, color })} @@ -200,14 +210,18 @@ export const ChildListItem = ({ {t('news.noNewNewsItemsThisWeek')}
)} - {!menu[currentDate.isoWeekday() - 1] ? null : ( + {shouldShowLunchMenu ? ( <> - {t('schedule.lunch')} + {meaningfulStartingDate.format( + '[' + t('schedule.lunch') + '] dddd' + )} + + + {menu[meaningfulStartingDate.isoWeekday() - 1]?.description} - {menu[currentDate.isoWeekday() - 1]?.description} - )} + ) : null}