Kalender ics link und Bugfix
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 (
|
||||
<FlatList
|
||||
refreshControl={<RefreshControl refreshing={loading} onRefresh={refresh} colors={[colors.primary]} />}
|
||||
data={calendarData.tests}
|
||||
keyExtractor={(item) => item.date + item.hourFrom + item.hourUntil + item.subject}
|
||||
<View style={{ marginLeft: 5 }}>
|
||||
<TouchableOpacity onPress={() => Linking.openURL('https://ux4.edvschule-plattling.de/~hthaler/tests-calendar/')}>
|
||||
<Text style={{ color: colors.primary }}>Prüfungen in einen Kalender importieren (.ics)</Text>
|
||||
</TouchableOpacity>
|
||||
<FlatList
|
||||
refreshControl={<RefreshControl refreshing={loading} onRefresh={refresh} colors={[colors.primary]} />}
|
||||
data={calendarData.tests}
|
||||
keyExtractor={(item) => item.date + item.hourFrom + item.hourUntil + item.subject}
|
||||
renderItem={({ item }) => (
|
||||
<View style={{ marginLeft: 5, marginBottom: 5, borderBottomWidth: 1, borderColor: '#ccc' }}>
|
||||
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 3 }}>
|
||||
<ThemeText style={{ fontWeight: 'bold', marginRight: 5 }}>{format(item.date, 'dd.MM.yyyy')}</ThemeText>
|
||||
<ThemeText>{`${item.timeFrom}-${item.timeUntil}`}</ThemeText>
|
||||
</View>
|
||||
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 5 }}>
|
||||
<ThemeText style={{ marginRight: 5 }}>{item.subject}</ThemeText>
|
||||
<ThemeText style={{ marginRight: 5 }}>{item.type}</ThemeText>
|
||||
{userInformation.usertype === 'teacher' && (
|
||||
<ThemeText style={{ marginRight: 5 }}>{item.class}</ThemeText>
|
||||
)}
|
||||
{userInformation.usertype === 'pupil' && (
|
||||
<ThemeText style={{ marginRight: 5 }}>{item.teacher}</ThemeText>
|
||||
)}
|
||||
<ThemeText style={{ marginRight: 5 }}>{item.room}</ThemeText>
|
||||
<ThemeText style={{ marginRight: 5 }}>{`${item.hourFrom||'n'}-${item.hourUntil||'n'}`}</ThemeText>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
getItemLayout={(data, index) => (
|
||||
{ length: 70, offset: 70 * index, index }
|
||||
)}
|
||||
/>
|
||||
<View style={{ marginTop: 5, borderBottomWidth: 1, borderColor: '#ccc', flexDirection: 'row', flexWrap: 'wrap' }}>
|
||||
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 5, marginRight: 20 }}>
|
||||
<ThemeText style={{ fontWeight: 'bold', marginRight: 5 }}>{format(item.date, 'dd.MM.yyyy')}</ThemeText>
|
||||
<ThemeText>{`${item.timeFrom}-${item.timeUntil}`}</ThemeText>
|
||||
</View>
|
||||
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 5 }}>
|
||||
<ThemeText style={{ marginRight: 5 }}>{item.subject}</ThemeText>
|
||||
<ThemeText style={{ marginRight: 5 }}>{item.type}</ThemeText>
|
||||
{userInformation.usertype === 'teacher' && (
|
||||
<ThemeText style={{ marginRight: 5 }}>{item.class}</ThemeText>
|
||||
)}
|
||||
{userInformation.usertype === 'pupil' && (
|
||||
<ThemeText style={{ marginRight: 5 }}>{item.teacher}</ThemeText>
|
||||
)}
|
||||
<ThemeText style={{ marginRight: 5 }}>{item.room}</ThemeText>
|
||||
<ThemeText style={{ marginRight: 5 }}>{`${item.hourFrom||'n'}-${item.hourUntil||'n'}`}</ThemeText>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
getItemLayout={(data, index) => (
|
||||
{ length: 70, offset: 70 * index, index }
|
||||
)}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
} 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";
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user