Feature/33 api fails when no pilots or logbook entries #35
@@ -12,36 +12,36 @@ const App: React.FC<unknown> = () => {
|
||||
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 (
|
||||
<div>
|
||||
<SiteNav />
|
||||
<Routes>
|
||||
{/* {useFeatureFlag('flying-pilots')?.enabled && ( */}
|
||||
<Route path="/pilots" element={<Pilots />} />
|
||||
{/* )} */}
|
||||
{useFeatureFlag('flying-pilots')?.enabled && (
|
||||
<Route path="/pilots" element={<Pilots />} />
|
||||
)}
|
||||
<Route path="/" element={<Logbook />} />
|
||||
</Routes>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user