@olea-bps/base 1.1.9 → 1.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/ComponentJobsFilter/index.js +136 -135
- package/components/CourseDetailDialog/index.js +100 -100
- package/components/NewsDetail/index.js +229 -289
- package/components/NewsDetail/styles.js +3 -4
- package/components/RoomDetail/index.js +240 -212
- package/components/TimetableDay/index.js +211 -212
- package/components/TimetableMonth/index.js +57 -60
- package/components/TimetableWeek/index.js +72 -75
- package/package.json +10 -8
|
@@ -12,26 +12,25 @@
|
|
|
12
12
|
* limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import React, {
|
|
16
|
-
import { View, Text, TouchableOpacity, StyleSheet, useWindowDimensions } from 'react-native'
|
|
17
|
-
import { connect } from 'react-redux'
|
|
18
|
-
import { withTheme } from 'react-native-paper'
|
|
19
|
-
import { withTranslation } from 'react-i18next'
|
|
20
|
-
import { onUpdateRefreshing } from '../../libraries/core'
|
|
21
|
-
import componentStyles from
|
|
22
|
-
import { Calendar } from 'react-native-big-calendar'
|
|
23
|
-
import { useCourses } from '../../context/context-timetable'
|
|
24
|
-
import CalendarStrip from 'react-native-calendar-strip'
|
|
25
|
-
import
|
|
26
|
-
import {
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import 'moment/locale/de';
|
|
15
|
+
import React, { useMemo, useCallback } from 'react'
|
|
16
|
+
import { View, Text, TouchableOpacity, StyleSheet, useWindowDimensions } from 'react-native'
|
|
17
|
+
import { connect } from 'react-redux'
|
|
18
|
+
import { withTheme } from 'react-native-paper'
|
|
19
|
+
import { withTranslation } from 'react-i18next'
|
|
20
|
+
import { onUpdateRefreshing } from '../../libraries/core'
|
|
21
|
+
import componentStyles from './styles'
|
|
22
|
+
import { Calendar } from 'react-native-big-calendar'
|
|
23
|
+
import { useCourses } from '../../context/context-timetable'
|
|
24
|
+
import CalendarStrip from 'react-native-calendar-strip'
|
|
25
|
+
import { DateTime, Duration } from 'luxon'
|
|
26
|
+
import { TabView } from 'react-native-tab-view'
|
|
27
|
+
import moment from 'moment'
|
|
28
|
+
import 'moment/locale/de'
|
|
30
29
|
|
|
31
30
|
/**
|
|
32
31
|
* Die Zeitspanne, welche vor und nach heute angezeigt werden soll.
|
|
33
32
|
*/
|
|
34
|
-
const daysTabDuration = Duration.fromISO('P6M')
|
|
33
|
+
const daysTabDuration = Duration.fromISO('P6M')
|
|
35
34
|
|
|
36
35
|
/**
|
|
37
36
|
*
|
|
@@ -39,214 +38,214 @@ const daysTabDuration = Duration.fromISO('P6M');
|
|
|
39
38
|
* @param {(DateTime) => void} props.onDateChanged Callback, welche aufgerufen wird, wenn der Tag in der Ansicht wechselt
|
|
40
39
|
* @returns
|
|
41
40
|
*/
|
|
42
|
-
function CalendarDay({ selectedDate, theme, settings, calendarScrollOffsetMinutes, calendarHeight, onDateChanged, onCourseSelected }) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
41
|
+
function CalendarDay ({ selectedDate, theme, settings, calendarScrollOffsetMinutes, calendarHeight, onDateChanged, onCourseSelected }) {
|
|
42
|
+
const { appSettings: { modules: { timetable: { showDetails } } } } = theme
|
|
43
|
+
const today = DateTime.now().toISODate()
|
|
44
|
+
|
|
45
|
+
const { width } = useWindowDimensions()
|
|
46
|
+
|
|
47
|
+
const [courses] = useCourses()
|
|
48
|
+
|
|
49
|
+
const language = settings?.settingsGeneral?.language
|
|
50
|
+
|
|
51
|
+
const styles = useMemo(
|
|
52
|
+
() => StyleSheet.create(componentStyles(theme)),
|
|
53
|
+
[theme]
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
const calendarStripMinDate = useMemo(
|
|
57
|
+
() => DateTime.fromISO(today).minus(daysTabDuration).toJSDate(),
|
|
58
|
+
[today, daysTabDuration]
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
const calendarStripMaxDate = useMemo(
|
|
62
|
+
() => DateTime.fromISO(today).plus(daysTabDuration).toJSDate(),
|
|
63
|
+
[today, daysTabDuration]
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
const daysTabViewRoutes = useMemo(
|
|
67
|
+
() => {
|
|
68
|
+
const dateRoutes = []
|
|
69
|
+
const todayDateTime = DateTime.fromISO(today)
|
|
70
|
+
const beginDateTime = todayDateTime.minus(daysTabDuration)
|
|
71
|
+
const endDateTime = todayDateTime.plus(daysTabDuration)
|
|
72
|
+
let currentDateTime = DateTime.fromObject(beginDateTime.toObject())
|
|
73
|
+
|
|
74
|
+
const eventColor = theme.colors.eventContainerSidebar
|
|
75
|
+
|
|
76
|
+
while (currentDateTime <= endDateTime) {
|
|
77
|
+
const currentISODate = currentDateTime.toISODate()
|
|
78
|
+
const currentDateTimeCourses = courses?.[currentISODate]
|
|
79
|
+
?.map(
|
|
80
|
+
course => (
|
|
81
|
+
{
|
|
82
|
+
title: course.title.data,
|
|
83
|
+
start: new Date(Date.parse(course.startDateTime)),
|
|
84
|
+
end: new Date(Date.parse(course.endDateTime)),
|
|
85
|
+
color: eventColor,
|
|
86
|
+
type: course.type?.data,
|
|
87
|
+
professor: course.lecturer[0]?.data,
|
|
88
|
+
room: course.room.data,
|
|
89
|
+
// Anfügen des Ürsprügnlichen Vorlesungsobjektes, damit es beim Klick zur Verfügung steht
|
|
90
|
+
origine: course
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
) ?? []
|
|
94
|
+
|
|
95
|
+
dateRoutes.push(
|
|
96
|
+
{
|
|
97
|
+
key: currentISODate,
|
|
98
|
+
date: currentDateTime,
|
|
99
|
+
events: currentDateTimeCourses
|
|
100
|
+
}
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
currentDateTime = currentDateTime.plus({ day: 1 })
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return dateRoutes
|
|
107
|
+
},
|
|
108
|
+
[today, courses, language]
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
const daysTabViewIndexes = useMemo(
|
|
112
|
+
() => daysTabViewRoutes
|
|
113
|
+
.reduce(
|
|
114
|
+
(accumulator, currentRoute, currentIndex) =>
|
|
115
|
+
(
|
|
116
|
+
{
|
|
117
|
+
...accumulator,
|
|
118
|
+
[currentRoute.key]: currentIndex
|
|
105
119
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
120
|
+
),
|
|
121
|
+
{}
|
|
122
|
+
),
|
|
123
|
+
[daysTabViewRoutes]
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
const daysTabViewIndex = useMemo(
|
|
127
|
+
() => {
|
|
128
|
+
const selectedISODate = selectedDate.toISODate()
|
|
129
|
+
return daysTabViewIndexes[selectedISODate]
|
|
130
|
+
},
|
|
131
|
+
[daysTabViewIndexes, selectedDate]
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
const renderEvent = useCallback((event, touchableOpacityProps) => {
|
|
135
|
+
const { key, style, ...restTouchableOpacityProps } = touchableOpacityProps
|
|
136
|
+
return (
|
|
137
|
+
<TouchableOpacity key={key} {...restTouchableOpacityProps} style={[style, styles.eventContainer, { borderLeftColor: event.color || '#000' }]}>
|
|
138
|
+
<View style={styles.eventHeader}>
|
|
139
|
+
<Text style={styles.eventTitle} numberOfLines={1} ellipsizeMode='tail'>
|
|
140
|
+
{event.title}
|
|
141
|
+
</Text>
|
|
142
|
+
<Text style={styles.eventType} numberOfLines={1} ellipsizeMode='tail'>
|
|
143
|
+
{event.type}
|
|
144
|
+
</Text>
|
|
145
|
+
</View>
|
|
146
|
+
<Text style={styles.eventProfessor} numberOfLines={1} ellipsizeMode='head'>
|
|
147
|
+
{event.professor}
|
|
148
|
+
</Text>
|
|
149
|
+
<View style={styles.eventFooter}>
|
|
150
|
+
<Text style={styles.eventTime} numberOfLines={1} ellipsizeMode='tail'>
|
|
151
|
+
{`${event.start.toLocaleTimeString('de-DE', { hour: '2-digit', minute: '2-digit' })} - ${event.end.toLocaleTimeString('de-DE', { hour: '2-digit', minute: '2-digit' })}`}
|
|
152
|
+
</Text>
|
|
153
|
+
<Text style={styles.eventRoom} numberOfLines={1} ellipsizeMode='tail'>
|
|
154
|
+
{event.room}
|
|
155
|
+
</Text>
|
|
156
|
+
</View>
|
|
157
|
+
</TouchableOpacity>
|
|
133
158
|
)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
{`${event.start.toLocaleTimeString('de-DE', { hour: '2-digit', minute: '2-digit' })} - ${event.end.toLocaleTimeString('de-DE', { hour: '2-digit', minute: '2-digit' })}`}
|
|
153
|
-
</Text>
|
|
154
|
-
<Text style={styles.eventRoom} numberOfLines={1} ellipsizeMode="tail">
|
|
155
|
-
{event.room}
|
|
156
|
-
</Text>
|
|
157
|
-
</View>
|
|
158
|
-
</TouchableOpacity>
|
|
159
|
-
);
|
|
160
|
-
}, [styles]);
|
|
161
|
-
|
|
162
|
-
const renderScene = useCallback(
|
|
163
|
-
({ route }) => {
|
|
164
|
-
return (
|
|
165
|
-
<View style={{ flex: 1, width: width }}>
|
|
166
|
-
<Calendar
|
|
167
|
-
events={route.events}
|
|
168
|
-
renderEvent={renderEvent}
|
|
169
|
-
renderHeader={() => null}
|
|
170
|
-
overlapOffset={95}
|
|
171
|
-
mode={'day'}
|
|
172
|
-
height={calendarHeight}
|
|
173
|
-
headerContentStyle={{ backgroundColor: 'transparent' }}
|
|
174
|
-
weekStartsOn={1}
|
|
175
|
-
date={route.key}
|
|
176
|
-
swipeEnabled={false}
|
|
177
|
-
onPressEvent={
|
|
159
|
+
}, [styles])
|
|
160
|
+
|
|
161
|
+
const renderScene = useCallback(
|
|
162
|
+
({ route }) => {
|
|
163
|
+
return (
|
|
164
|
+
<View style={{ flex: 1, width }}>
|
|
165
|
+
<Calendar
|
|
166
|
+
events={route.events}
|
|
167
|
+
renderEvent={renderEvent}
|
|
168
|
+
renderHeader={() => null}
|
|
169
|
+
overlapOffset={95}
|
|
170
|
+
mode='day'
|
|
171
|
+
height={calendarHeight}
|
|
172
|
+
headerContentStyle={{ backgroundColor: 'transparent' }}
|
|
173
|
+
weekStartsOn={1}
|
|
174
|
+
date={route.key}
|
|
175
|
+
swipeEnabled={false}
|
|
176
|
+
onPressEvent={
|
|
178
177
|
showDetails
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
// Wenn eine Vorlesung im Kalender angeklickt wird, wird die ursprüngliche Vorlesung ausgelesen und selektiert
|
|
179
|
+
? (event) => onCourseSelected(event.origine)
|
|
180
|
+
: null
|
|
182
181
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
182
|
+
scrollOffsetMinutes={calendarScrollOffsetMinutes}
|
|
183
|
+
hourStyle={styles.hourStyle}
|
|
184
|
+
/>
|
|
185
|
+
</View>
|
|
186
|
+
)
|
|
187
|
+
},
|
|
188
|
+
[styles, calendarScrollOffsetMinutes, courses, width, renderEvent]
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
return (
|
|
192
|
+
<>
|
|
193
|
+
<View style={styles.stripShadow}>
|
|
194
|
+
<CalendarStrip
|
|
195
|
+
style={styles.strip}
|
|
196
|
+
locale={{
|
|
197
|
+
name: language,
|
|
198
|
+
config: moment.localeData(language)
|
|
199
|
+
}}
|
|
200
|
+
selectedDate={selectedDate.toJSDate()}
|
|
201
|
+
onDateSelected={
|
|
203
202
|
(date) =>
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
)
|
|
203
|
+
onDateChanged?.(
|
|
204
|
+
DateTime.fromObject(
|
|
205
|
+
{
|
|
206
|
+
year: date.year(),
|
|
207
|
+
month: date.month() + 1,
|
|
208
|
+
day: date.date()
|
|
209
|
+
}
|
|
212
210
|
)
|
|
211
|
+
)
|
|
213
212
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
213
|
+
highlightDateContainerStyle={styles.highlightDateContainer}
|
|
214
|
+
showMonth={false}
|
|
215
|
+
iconStyle={{ display: 'none' }}
|
|
216
|
+
scrollable
|
|
217
|
+
minDate={calendarStripMinDate}
|
|
218
|
+
maxDate={calendarStripMaxDate}
|
|
219
|
+
/>
|
|
220
|
+
</View>
|
|
221
|
+
|
|
222
|
+
<TabView
|
|
223
|
+
navigationState={{ index: daysTabViewIndex, routes: daysTabViewRoutes }}
|
|
224
|
+
renderTabBar={() => null}
|
|
225
|
+
lazy
|
|
226
|
+
lazyPreloadDistance={1}
|
|
227
|
+
onIndexChange={
|
|
229
228
|
(index) => {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
229
|
+
const currentDateTime = daysTabViewRoutes?.[daysTabViewIndex].date
|
|
230
|
+
const indexDelta = index - daysTabViewIndex
|
|
231
|
+
const deltaDateTime = currentDateTime.plus({ days: indexDelta })
|
|
232
|
+
onDateChanged?.(deltaDateTime)
|
|
234
233
|
}
|
|
235
234
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
235
|
+
renderScene={renderScene}
|
|
236
|
+
/>
|
|
237
|
+
</>
|
|
238
|
+
)
|
|
240
239
|
}
|
|
241
240
|
|
|
242
241
|
const mapStateToProps = (state) => {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
242
|
+
return {
|
|
243
|
+
pluginComponent: state.pluginReducer.timetable.component,
|
|
244
|
+
pluginStyles: state.pluginReducer.timetable.styles,
|
|
245
|
+
settings: state.settingReducer,
|
|
246
|
+
refreshing: state.stateReducer.refreshing
|
|
248
247
|
|
|
249
|
-
|
|
250
|
-
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
251
250
|
|
|
252
|
-
export default connect(mapStateToProps, { onUpdateRefreshing })(withTranslation()(withTheme(CalendarDay)))
|
|
251
|
+
export default connect(mapStateToProps, { onUpdateRefreshing })(withTranslation()(withTheme(CalendarDay)))
|
|
@@ -12,50 +12,50 @@
|
|
|
12
12
|
* limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import React, { useState, useMemo, useEffect, useRef, useCallback } from 'react'
|
|
16
|
-
import { Text, TouchableOpacity, StyleSheet, View } from 'react-native'
|
|
17
|
-
import { connect } from 'react-redux'
|
|
18
|
-
import { withTheme } from 'react-native-paper'
|
|
19
|
-
import { withTranslation } from 'react-i18next'
|
|
20
|
-
import { onUpdateRefreshing } from '../../libraries/core'
|
|
21
|
-
import componentStyles from
|
|
22
|
-
import { Calendar } from 'react-native-big-calendar'
|
|
23
|
-
import { useCourses } from '../../context/context-timetable'
|
|
24
|
-
import CourseDetailDialog from '../CourseDetailDialog'
|
|
25
|
-
import CalendarStrip from 'react-native-calendar-strip'
|
|
26
|
-
import { DateTime } from 'luxon'
|
|
27
|
-
|
|
28
|
-
function CalendarMonth(props) {
|
|
29
|
-
const { theme, setMonth, today, locale,
|
|
15
|
+
import React, { useState, useMemo, useEffect, useRef, useCallback } from 'react'
|
|
16
|
+
import { Text, TouchableOpacity, StyleSheet, View } from 'react-native'
|
|
17
|
+
import { connect } from 'react-redux'
|
|
18
|
+
import { withTheme } from 'react-native-paper'
|
|
19
|
+
import { withTranslation } from 'react-i18next'
|
|
20
|
+
import { onUpdateRefreshing } from '../../libraries/core'
|
|
21
|
+
import componentStyles from './styles'
|
|
22
|
+
import { Calendar } from 'react-native-big-calendar'
|
|
23
|
+
import { useCourses } from '../../context/context-timetable'
|
|
24
|
+
import CourseDetailDialog from '../CourseDetailDialog'
|
|
25
|
+
import CalendarStrip from 'react-native-calendar-strip'
|
|
26
|
+
import { DateTime } from 'luxon'
|
|
27
|
+
|
|
28
|
+
function CalendarMonth (props) {
|
|
29
|
+
const { theme, setMonth, today, locale, calendarHeight } = props
|
|
30
30
|
const styles = useMemo(
|
|
31
31
|
() => StyleSheet.create(componentStyles(theme)),
|
|
32
32
|
[theme]
|
|
33
|
-
)
|
|
33
|
+
)
|
|
34
34
|
|
|
35
|
-
const [courses, refreshCourses] = useCourses()
|
|
36
|
-
const selectedDate = useRef(new Date())
|
|
37
|
-
const [
|
|
38
|
-
const [dialogVisible, setDialogVisible] = useState(false)
|
|
39
|
-
const [selectedEvent, setSelectedEvent] = useState(null)
|
|
35
|
+
const [courses, refreshCourses] = useCourses()
|
|
36
|
+
const selectedDate = useRef(new Date())
|
|
37
|
+
const [, setSelectedDateState] = useState(selectedDate.current)
|
|
38
|
+
const [dialogVisible, setDialogVisible] = useState(false)
|
|
39
|
+
const [selectedEvent, setSelectedEvent] = useState(null)
|
|
40
40
|
|
|
41
|
-
const selectedDateStartISO = DateTime.fromISO(JSON.stringify(selectedDate.current).slice(1, -1)).startOf('month').toISODate()
|
|
42
|
-
const selectedDateEndISO = DateTime.fromISO(JSON.stringify(selectedDate.current).slice(1, -1)).endOf('month').toISODate()
|
|
41
|
+
const selectedDateStartISO = DateTime.fromISO(JSON.stringify(selectedDate.current).slice(1, -1)).startOf('month').toISODate()
|
|
42
|
+
const selectedDateEndISO = DateTime.fromISO(JSON.stringify(selectedDate.current).slice(1, -1)).endOf('month').toISODate()
|
|
43
43
|
|
|
44
44
|
useEffect(() => {
|
|
45
|
-
refreshCourses(selectedDateStartISO, selectedDateEndISO)
|
|
46
|
-
}, [selectedDateStartISO, selectedDateEndISO])
|
|
45
|
+
refreshCourses(selectedDateStartISO, selectedDateEndISO)
|
|
46
|
+
}, [selectedDateStartISO, selectedDateEndISO])
|
|
47
47
|
|
|
48
48
|
const handleDateChange = (date) => {
|
|
49
|
-
selectedDate.current = date
|
|
50
|
-
setSelectedDateState(date)
|
|
51
|
-
}
|
|
49
|
+
selectedDate.current = date
|
|
50
|
+
setSelectedDateState(date)
|
|
51
|
+
}
|
|
52
52
|
|
|
53
53
|
const monthCourses = useMemo(() => {
|
|
54
|
-
const startDate = DateTime.fromISO(selectedDateStartISO)
|
|
55
|
-
const daysInMonth = startDate.daysInMonth
|
|
56
|
-
const daysArray = Array.from({ length: daysInMonth }, (_, index) => startDate.plus({ days: index }).toISODate())
|
|
57
|
-
return daysArray.reduce((acc, date) => acc.concat(courses?.[date] ?? []), [])
|
|
58
|
-
}, [selectedDateStartISO, courses])
|
|
54
|
+
const startDate = DateTime.fromISO(selectedDateStartISO)
|
|
55
|
+
const daysInMonth = startDate.daysInMonth
|
|
56
|
+
const daysArray = Array.from({ length: daysInMonth }, (_, index) => startDate.plus({ days: index }).toISODate())
|
|
57
|
+
return daysArray.reduce((acc, date) => acc.concat(courses?.[date] ?? []), [])
|
|
58
|
+
}, [selectedDateStartISO, courses])
|
|
59
59
|
|
|
60
60
|
const monthEvents = useMemo(() => {
|
|
61
61
|
try {
|
|
@@ -69,35 +69,32 @@ function CalendarMonth(props) {
|
|
|
69
69
|
type: course.type?.data,
|
|
70
70
|
professor: course.lecturer[0]?.data,
|
|
71
71
|
room: course.room.data
|
|
72
|
-
}
|
|
73
|
-
})
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
74
|
} catch (error) {
|
|
75
|
-
console.error('Error in useMemo for monthEvents:', error)
|
|
76
|
-
return []
|
|
75
|
+
console.error('Error in useMemo for monthEvents:', error)
|
|
76
|
+
return []
|
|
77
77
|
}
|
|
78
|
-
}, [monthCourses])
|
|
78
|
+
}, [monthCourses])
|
|
79
79
|
|
|
80
80
|
useEffect(() => {
|
|
81
|
-
handleDateChange(today)
|
|
82
|
-
setMonth(today.getMonth())
|
|
83
|
-
}, [today, setMonth])
|
|
81
|
+
handleDateChange(today)
|
|
82
|
+
setMonth(today.getMonth())
|
|
83
|
+
}, [today, setMonth])
|
|
84
84
|
|
|
85
85
|
const renderEvent = useCallback((event, touchableOpacityProps) => {
|
|
86
|
-
const { style, ...restTouchableOpacityProps } = touchableOpacityProps
|
|
87
|
-
|
|
86
|
+
const { key, style, ...restTouchableOpacityProps } = touchableOpacityProps
|
|
88
87
|
return (
|
|
89
|
-
<TouchableOpacity {...restTouchableOpacityProps}
|
|
90
|
-
style={[style, styles.event]}
|
|
91
|
-
>
|
|
88
|
+
<TouchableOpacity key={key} {...restTouchableOpacityProps} style={[style, styles.event]}>
|
|
92
89
|
<Text style={styles.eventTitle} numberOfLines={1}>
|
|
93
90
|
{event.title}
|
|
94
91
|
</Text>
|
|
95
92
|
</TouchableOpacity>
|
|
96
|
-
)
|
|
97
|
-
}, [styles])
|
|
93
|
+
)
|
|
94
|
+
}, [styles])
|
|
98
95
|
|
|
99
96
|
const renderHeader = useCallback(() => (
|
|
100
|
-
<View pointerEvents=
|
|
97
|
+
<View pointerEvents='none'>
|
|
101
98
|
<CalendarStrip
|
|
102
99
|
style={styles.strip}
|
|
103
100
|
locale={locale}
|
|
@@ -112,7 +109,7 @@ function CalendarMonth(props) {
|
|
|
112
109
|
/>
|
|
113
110
|
|
|
114
111
|
</View>
|
|
115
|
-
), [selectedDate])
|
|
112
|
+
), [selectedDate])
|
|
116
113
|
|
|
117
114
|
return (
|
|
118
115
|
<>
|
|
@@ -122,16 +119,16 @@ function CalendarMonth(props) {
|
|
|
122
119
|
renderHeaderForMonthView={renderHeader}
|
|
123
120
|
date={selectedDate.current}
|
|
124
121
|
height={calendarHeight}
|
|
125
|
-
mode=
|
|
122
|
+
mode='month'
|
|
126
123
|
headerContentStyle={{ backgroundColor: 'transparent' }}
|
|
127
124
|
weekStartsOn={1}
|
|
128
125
|
onSwipeEnd={(date) => {
|
|
129
|
-
handleDateChange(date)
|
|
130
|
-
setMonth(new Date(date).getMonth())
|
|
126
|
+
handleDateChange(date)
|
|
127
|
+
setMonth(new Date(date).getMonth())
|
|
131
128
|
}}
|
|
132
129
|
onPressEvent={(event) => {
|
|
133
|
-
setDialogVisible(true)
|
|
134
|
-
setSelectedEvent(event)
|
|
130
|
+
setDialogVisible(true)
|
|
131
|
+
setSelectedEvent(event)
|
|
135
132
|
}}
|
|
136
133
|
/>
|
|
137
134
|
{dialogVisible && selectedEvent && (
|
|
@@ -144,13 +141,13 @@ function CalendarMonth(props) {
|
|
|
144
141
|
/>
|
|
145
142
|
)}
|
|
146
143
|
</>
|
|
147
|
-
)
|
|
144
|
+
)
|
|
148
145
|
}
|
|
149
146
|
|
|
150
147
|
const mapStateToProps = (state) => {
|
|
151
148
|
return {
|
|
152
|
-
settings: state.settingReducer
|
|
153
|
-
}
|
|
154
|
-
}
|
|
149
|
+
settings: state.settingReducer
|
|
150
|
+
}
|
|
151
|
+
}
|
|
155
152
|
|
|
156
|
-
export default connect(mapStateToProps, { onUpdateRefreshing })(withTranslation()(withTheme(CalendarMonth)))
|
|
153
|
+
export default connect(mapStateToProps, { onUpdateRefreshing })(withTranslation()(withTheme(CalendarMonth)))
|