diff --git a/common/FilterModal.tsx b/common/FilterModal.tsx index cd08cca..e2fdf43 100644 --- a/common/FilterModal.tsx +++ b/common/FilterModal.tsx @@ -5,6 +5,7 @@ import { ThemeButton, ThemeText } from '../common/ThemeTypes'; import { Picker } from '@react-native-picker/picker'; import { FontAwesome } from '@expo/vector-icons'; import { Colors } from 'react-native/Libraries/NewAppScreen'; +import { getDefaultFilter } from '../utils/getDefaultFilter'; const categories = { class: 'Klasse', room: 'Raum', teacher: 'Lehrer' }; @@ -143,12 +144,4 @@ return ( ); }; -const getDefaultFilter = (userInformation) => { - if (!userInformation) return null; - let type = userInformation.usertype == 'pupil' ? 'class' : 'teacher'; - let value = userInformation.usertype == 'pupil' ? userInformation.classid : userInformation.id; - return { type: type, value: value, group: String(userInformation.group) }; -}; - - export default FilterModal; diff --git a/screens/Schedule.tsx b/screens/Schedule.tsx index 308a3a2..ec7f705 100644 --- a/screens/Schedule.tsx +++ b/screens/Schedule.tsx @@ -13,6 +13,7 @@ import { ThemeButton, ThemeText } from '../common/ThemeTypes'; import { useColors } from '../common/colors'; import { AntDesign } from '@expo/vector-icons'; import FilterModal from '../common/FilterModal'; +import { getDefaultFilter } from '../utils/getDefaultFilter'; let errorObject; let categories = { class: 'Klasse', room: 'Raum', teacher: 'Lehrer' }; @@ -124,10 +125,3 @@ const Schedule = () => { }; export default Schedule; - -const getDefaultFilter = (userInformation) => { - if (!userInformation) return null - let type = userInformation.usertype == 'pupil' ? 'class' : 'teacher'; - let value = userInformation.usertype == 'pupil' ? userInformation.classid : userInformation.id; - return { type: type, value: value, group: String(userInformation.group) } -} \ No newline at end of file diff --git a/utils/getDefaultFilter.ts b/utils/getDefaultFilter.ts new file mode 100644 index 0000000..26c8da7 --- /dev/null +++ b/utils/getDefaultFilter.ts @@ -0,0 +1,6 @@ +export const getDefaultFilter = (userInformation) => { + if (!userInformation) return null; + let type = userInformation.usertype == 'pupil' ? 'class' : 'teacher'; + let value = userInformation.usertype == 'pupil' ? userInformation.classid : userInformation.id; + return { type: type, value: value, group: String(userInformation.group) }; +}; \ No newline at end of file