From 34aac62ec8816003d19ff44f2cb8b0002cd9b381 Mon Sep 17 00:00:00 2001 From: Noah Spannbauer Date: Sun, 1 Dec 2024 19:29:02 -0600 Subject: [PATCH] api no longer fails when no pilots or logbook entries --- app/src/App.tsx | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/app/src/App.tsx b/app/src/App.tsx index 39743c8..b1a4034 100644 --- a/app/src/App.tsx +++ b/app/src/App.tsx @@ -12,36 +12,36 @@ const App: React.FC = () => { const httpClient: AxiosInstance = useHttpClient(); const appContext = useAppContext(); - // useEffect(() => { - // const getFeatureFlags = async () => { - // try { - // const featureFlagKeys: string = 'flying-pilots'; - // const response: AxiosResponse = await httpClient.get( - // `api/featureFlags?keys=${featureFlagKeys}&label=${import.meta.env.MODE}` - // ); - // const featureFlags: { key: string; enabled: boolean }[] = response.data; + useEffect(() => { + const getFeatureFlags = async () => { + try { + const featureFlagKeys: string = 'flying-pilots'; + const response: AxiosResponse = await httpClient.get( + `api/featureFlags?keys=${featureFlagKeys}&label=${import.meta.env.MODE}` + ); + const featureFlags: { key: string; enabled: boolean }[] = response.data; - // if (featureFlags.length > 0) { - // appContext.dispatch({ - // type: 'SET_FEATURE_FLAGS', - // payload: featureFlags - // }); - // } - // } catch (error) { - // console.log(error); - // } - // }; + if (featureFlags.length > 0) { + appContext.dispatch({ + type: 'SET_FEATURE_FLAGS', + payload: featureFlags + }); + } + } catch (error) { + console.log(error); + } + }; - // getFeatureFlags(); - // }, []); + getFeatureFlags(); + }, []); return (
- {/* {useFeatureFlag('flying-pilots')?.enabled && ( */} - } /> - {/* )} */} + {useFeatureFlag('flying-pilots')?.enabled && ( + } /> + )} } />