fix: 🐛 Hide lunch in timetable if not showing current week (#613)

 Closes: #599
This commit is contained in:
Kajetan Kazimierczak 2022-01-31 23:32:44 +01:00 committed by GitHub
parent 9e9833bc8a
commit a40af3e94d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -121,7 +121,17 @@ export const Week = ({ child }: WeekProps) => {
year,
LanguageService.getLanguageCode()
)
const { data: menu } = useMenu(child)
let { data: menu } = useMenu(child)
// Hide menu if we want to show next week but it is not monday yet.
// The menu for next week is not available until monday
const currentDate = moment()
const shouldShowLunchMenu =
menu[displayDate.isoWeekday() - 1] &&
!(displayDate.isoWeekday() === 1 && currentDate.isoWeekday() !== 1)
if (!shouldShowLunchMenu) {
menu = []
}
const styles = useStyleSheet(themedStyles)

View File

@ -82,7 +82,8 @@
"@formatjs/intl-pluralrules": "*",
"@formatjs/intl-datetimeformat": "*",
"jest": "*",
"react-native-clean-project": "*"
"react-native-clean-project": "*",
"mockdate": "*"
},
"devDependencies": {
"react-native-clean-project": "*"