Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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