From bec62fa21b9503927b44ad956314a888fa6923e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sarstr=C3=B6m?= Date: Mon, 22 Nov 2021 13:00:32 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Added=20food=20menu=20to?= =?UTF-8?q?=20features?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/child.component.tsx | 81 +++++++++++++------ .../components/login.component.tsx | 2 +- .../context/feature/featureContext.tsx | 1 + libs/api-hjarntorget/lib/features.ts | 3 +- libs/api/lib/features.ts | 1 + 5 files changed, 60 insertions(+), 28 deletions(-) diff --git a/apps/skolplattformen-sthlm/components/child.component.tsx b/apps/skolplattformen-sthlm/components/child.component.tsx index 3b87597b..c61547af 100644 --- a/apps/skolplattformen-sthlm/components/child.component.tsx +++ b/apps/skolplattformen-sthlm/components/child.component.tsx @@ -22,6 +22,7 @@ import { NewsList } from './newsList.component' import { NotificationsList } from './notificationsList.component' import { Classmates } from './classmates.component' import { TabBarLabel } from './tabBarLabel.component' +import { useFeature } from '../hooks/useFeature' type ChildNavigationProp = StackNavigationProp type ChildRouteProps = RouteProp @@ -47,10 +48,20 @@ const CalendarScreen = () => const MenuScreen = () => const ClassmatesScreen = () => +interface ScreenSettings { + NEWS_SCREEN: boolean + NOTIFICATIONS_SCREEN: boolean + CALENDER_SCREEN: boolean + MENU_SCREEN: boolean + CLASSMATES_SCREEN: boolean +} + const TabNavigator = ({ initialRouteName = 'News', + screenSettings, }: { initialRouteName?: keyof ChildTabParamList + screenSettings: ScreenSettings }) => ( - - - - - + {screenSettings.NEWS_SCREEN && ( + + )} + {screenSettings.NOTIFICATIONS_SCREEN && ( + + )} + {screenSettings.CALENDER_SCREEN && ( + + )} + {screenSettings.MENU_SCREEN && ( + + )} + {screenSettings.CLASSMATES_SCREEN && ( + + )} ) @@ -151,16 +172,24 @@ export const childRouteOptions = export const Child = () => { const route = useRoute() const { child, initialRouteName } = route.params - + const useFoodMenu = useFeature('FOOD_MENU') const navigation = useNavigation() useEffect(() => { navigation.setOptions({ title: getHeaderTitle(route) }) }, [navigation, route]) + const screenSettings: ScreenSettings = { + NEWS_SCREEN: true, + NOTIFICATIONS_SCREEN: true, + CALENDER_SCREEN: true, + MENU_SCREEN: useFoodMenu, + CLASSMATES_SCREEN: true, + } return ( diff --git a/apps/skolplattformen-sthlm/components/login.component.tsx b/apps/skolplattformen-sthlm/components/login.component.tsx index abe77538..8083d6f8 100644 --- a/apps/skolplattformen-sthlm/components/login.component.tsx +++ b/apps/skolplattformen-sthlm/components/login.component.tsx @@ -157,7 +157,7 @@ export const Login = () => { return ( <> - {loginMethodIndex === 1 && ( + {loginMethodIndex === 0 && ( ({ LOGIN_BANK_ID_SAME_DEVICE: false, + FOOD_MENU: false, }) interface Props { diff --git a/libs/api-hjarntorget/lib/features.ts b/libs/api-hjarntorget/lib/features.ts index 471ad55c..4e79a8a8 100644 --- a/libs/api-hjarntorget/lib/features.ts +++ b/libs/api-hjarntorget/lib/features.ts @@ -1,5 +1,6 @@ import { Features } from '@skolplattformen/api' export const features: Features = { - LOGIN_BANK_ID_SAME_DEVICE: false + LOGIN_BANK_ID_SAME_DEVICE: false, + FOOD_MENU: false } \ No newline at end of file diff --git a/libs/api/lib/features.ts b/libs/api/lib/features.ts index c0b6392b..2a5af4a8 100644 --- a/libs/api/lib/features.ts +++ b/libs/api/lib/features.ts @@ -1,5 +1,6 @@ export interface Features { LOGIN_BANK_ID_SAME_DEVICE: boolean; + FOOD_MENU: boolean; } export type FeatureType = keyof Features;