Skip to content

Commit

Permalink
fix: 🐛 Hide lunch in timetable if not showing current week (kolplattf…
Browse files Browse the repository at this point in the history
  • Loading branch information
kajetan-kazimierczak authored Jan 31, 2022
1 parent 9e9833b commit a40af3e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion apps/skolplattformen-app/components/week.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion apps/skolplattformen-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*"
Expand Down

0 comments on commit a40af3e

Please sign in to comment.