diff --git a/Interface.tsx b/Interface.tsx
index e4dfb22..e4a09c0 100644
--- a/Interface.tsx
+++ b/Interface.tsx
@@ -76,13 +76,20 @@ const Interface = ({ children }) => {
};
const fetchUserInformation = async (username) => {
- const userinformation = await requestGet(`userinformation/?username=${username}`, false);
- if (!userinformation) {
- console.log("Using Demoinformation");
- showToast(ToastType.Info, "You are using a DEMOUSER", 5000);
- return await requestGet(`demoinformation/`);
+ try {
+ return await requestGet(`userinformation/?username=${username}`, false);
+ } catch (error) {
+ if (error.response.status === 404) {
+ const demoinformation = await requestGet(`demoinformation/`);
+ if (demoinformation) {
+ console.log("Using Demoinformation");
+ showToast(ToastType.Info, "You are using a DEMOUSER", 5000);
+ }
+ return demoinformation;
+ }
+ console.error("Error fetching user information:", error);
+ return Null;
}
- return userinformation;
};
const fetchTimes = async () => {
@@ -127,7 +134,7 @@ const Interface = ({ children }) => {
}
} catch (error) {
if (!handleError) {
- return null
+ throw(error);
} else if (error.response) {
if (error.response.data.message) {
throw new NetworkError(error.response.status + ": " + error.response.data.message, url);
diff --git a/screens/Calendar.tsx b/screens/Calendar.tsx
index bdf0d2a..d21d710 100644
--- a/screens/Calendar.tsx
+++ b/screens/Calendar.tsx
@@ -1,6 +1,6 @@
import { addMonths, addDays, format, isSameDay, isWithinInterval, parseISO, getDay, parse, differenceInDays } from 'date-fns';
import React, { useContext, useEffect, useState, useMemo, useCallback } from 'react';
-import { FlatList, ScrollView, StyleSheet, View, Text, TouchableOpacity, Modal } from 'react-native';
+import { FlatList, ScrollView, StyleSheet, View, Text, TouchableOpacity, Modal, Linking } from 'react-native';
import ErrorBoundary from 'react-native-error-boundary';
import { RefreshControl } from 'react-native-web-refresh-control';
import { InterfaceContext } from '../Interface';
@@ -107,34 +107,39 @@ const Calendar = () => {
);
} else if (selectedView === 'tests') {
return (
- }
- data={calendarData.tests}
- keyExtractor={(item) => item.date + item.hourFrom + item.hourUntil + item.subject}
+
+ Linking.openURL('https://ux4.edvschule-plattling.de/~hthaler/tests-calendar/')}>
+ Prüfungen in einen Kalender importieren (.ics)
+
+ }
+ data={calendarData.tests}
+ keyExtractor={(item) => item.date + item.hourFrom + item.hourUntil + item.subject}
renderItem={({ item }) => (
-
-
- {format(item.date, 'dd.MM.yyyy')}
- {`${item.timeFrom}-${item.timeUntil}`}
-
-
- {item.subject}
- {item.type}
- {userInformation.usertype === 'teacher' && (
- {item.class}
- )}
- {userInformation.usertype === 'pupil' && (
- {item.teacher}
- )}
- {item.room}
- {`${item.hourFrom||'n'}-${item.hourUntil||'n'}`}
-
-
- )}
- getItemLayout={(data, index) => (
- { length: 70, offset: 70 * index, index }
- )}
- />
+
+
+ {format(item.date, 'dd.MM.yyyy')}
+ {`${item.timeFrom}-${item.timeUntil}`}
+
+
+ {item.subject}
+ {item.type}
+ {userInformation.usertype === 'teacher' && (
+ {item.class}
+ )}
+ {userInformation.usertype === 'pupil' && (
+ {item.teacher}
+ )}
+ {item.room}
+ {`${item.hourFrom||'n'}-${item.hourUntil||'n'}`}
+
+
+ )}
+ getItemLayout={(data, index) => (
+ { length: 70, offset: 70 * index, index }
+ )}
+ />
+
);
} else if (selectedView === 'appointments') {
// Group appointments by day
@@ -401,7 +406,6 @@ const getDayType = (date, calendarData) => {
return fromDate <= targetDate && targetDate <= untilDate;
});
- console.log(targetDate, dayType);
return dayType ? dayType.type : "schultag";
};