From a40af3e94d236bd61272319f0b1e8e5e19cd3a2c Mon Sep 17 00:00:00 2001 From: Kajetan Kazimierczak Date: Mon, 31 Jan 2022 23:32:44 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Hide=20lunch=20in=20timet?= =?UTF-8?q?able=20if=20not=20showing=20current=20week=20(#613)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: #599 --- .../components/week.component.tsx | 12 +++++++++++- apps/skolplattformen-app/package.json | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/skolplattformen-app/components/week.component.tsx b/apps/skolplattformen-app/components/week.component.tsx index 4b525fbb..01c3e174 100644 --- a/apps/skolplattformen-app/components/week.component.tsx +++ b/apps/skolplattformen-app/components/week.component.tsx @@ -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) diff --git a/apps/skolplattformen-app/package.json b/apps/skolplattformen-app/package.json index b228791d..c41f0927 100644 --- a/apps/skolplattformen-app/package.json +++ b/apps/skolplattformen-app/package.json @@ -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": "*"