diff --git a/apps/skolplattformen-app/.eslintrc.json b/apps/skolplattformen-app/.eslintrc.json
index 952b9695a..a7fd39f60 100644
--- a/apps/skolplattformen-app/.eslintrc.json
+++ b/apps/skolplattformen-app/.eslintrc.json
@@ -9,7 +9,7 @@
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
- "rules": {}
+ "rules": {"no-console":"warn"}
},
{
"files": ["*.ts", "*.tsx"],
diff --git a/apps/skolplattformen-app/components/childListItem.component.tsx b/apps/skolplattformen-app/components/childListItem.component.tsx
index f718a7c7c..b259457c8 100644
--- a/apps/skolplattformen-app/components/childListItem.component.tsx
+++ b/apps/skolplattformen-app/components/childListItem.component.tsx
@@ -16,7 +16,7 @@ import {
Text,
useStyleSheet,
} from '@ui-kitten/components'
-import moment from 'moment'
+import moment, { Moment } from 'moment'
import React, { useEffect } from 'react'
import { TouchableOpacity, useColorScheme, View } from 'react-native'
import { useTranslation } from '../hooks/useTranslation'
@@ -31,6 +31,7 @@ interface ChildListItemProps {
child: Child
color: string
updated: string
+ currentDate?: Moment
}
type ChildListItemNavigationProp = StackNavigationProp<
RootStackParamList,
@@ -41,6 +42,7 @@ export const ChildListItem = ({
child,
color,
updated,
+ currentDate = moment(),
}: ChildListItemProps) => {
// Forces rerender when child.id changes
React.useEffect(() => {
@@ -57,16 +59,14 @@ export const ChildListItem = ({
const { data: menu, reload: menuReload } = useMenu(child)
const { data: schedule, reload: scheduleReload } = useSchedule(
child,
- moment().toISOString(),
- moment().add(7, 'days').toISOString()
+ moment(currentDate).toISOString(),
+ moment(currentDate).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()
@@ -89,8 +89,8 @@ export const ChildListItem = ({
)
const newsThisWeek = news.filter(({ modified, published }) => {
- const date = modified || published
- return date ? moment(date).isSame(moment(), 'week') : false
+ const newsDate = modified || published
+ return newsDate ? moment(newsDate).isSame(currentDate, 'week') : false
})
const scheduleAndCalendarThisWeek = [
@@ -99,14 +99,18 @@ export const ChildListItem = ({
].filter(({ startDate }) =>
startDate
? moment(startDate).isBetween(
- moment().startOf('day'),
- moment().add(7, 'days')
+ moment(currentDate).startOf('day'),
+ moment(currentDate).add(7, 'days')
)
: false
)
- const displayDate = (date: moment.MomentInput) => {
- return moment(date).fromNow()
+ const displayDate = (inputDate: moment.MomentInput) => {
+ return moment(inputDate).fromNow()
+ }
+
+ const capitalizeFirstLetter = (string) => {
+ return string.charAt(0).toUpperCase() + string.slice(1)
}
const getClassName = () => {
@@ -168,12 +172,19 @@ export const ChildListItem = ({
/>
-
+ {currentDate.hour() > 17 && currentDate.hour() <= 23 ? (
+
+ {capitalizeFirstLetter(currentDate.format('dddd'))}
+
+ ) : null}
+
+
{scheduleAndCalendarThisWeek.slice(0, 3).map((calendarItem, i) => (
{`${calendarItem.title} (${displayDate(calendarItem.startDate)})`}
))}
+
{t('navigation.news')}
@@ -182,11 +193,13 @@ export const ChildListItem = ({
{notification.message}
))}
+
{newsThisWeek.slice(0, 3).map((newsItem, i) => (
{newsItem.header ?? ''}
))}
+
{scheduleAndCalendarThisWeek.length ||
notificationsThisWeek.length ||
newsThisWeek.length ? null : (
@@ -194,14 +207,15 @@ export const ChildListItem = ({
{t('news.noNewNewsItemsThisWeek')}
)}
- {!menu[moment().isoWeekday() - 1] ? null : (
+ {!menu[currentDate.isoWeekday() - 1] ? null : (
<>
{t('schedule.lunch')}
- {menu[moment().isoWeekday() - 1]?.description}
+ {menu[currentDate.isoWeekday() - 1]?.description}
>
)}
+
- }
- renderItem={({ item: child, index }: ListRenderItemInfo) => (
-
- )}
- />
- ) : (
-
+ return status === 'loaded' ? (
+
+ {translate('children.noKids_title')}
+
+ {translate('children.noKids_description')}
+
- {status === 'error' ? (
-
-
- {translate('children.loadingErrorHeading')}
-
-
- {translate('children.loadingErrorInformationText')}
-
-
-
-
-
-
-
- ) : (
-
-
-
- {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 8c908c09b..a9b93dfb3 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 3eab8ee23..e7b07ffb0 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 d85f7932b..188a51d60 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 1a7846cbf..1fd886251 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 000000000..335d74d9d
--- /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 9be35042e..3719245eb 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)
)