Skip to content

Instantly share code, notes, and snippets.

@SomtoUgeh
Last active June 18, 2020 14:04
Show Gist options
  • Save SomtoUgeh/29a6331192fc3c33a2232905ddb73f50 to your computer and use it in GitHub Desktop.
Save SomtoUgeh/29a6331192fc3c33a2232905ddb73f50 to your computer and use it in GitHub Desktop.
/* Add new identifiers here */
enum AppModuleView {
DASHBOARD = "DASHBOARD",
PROFILE = "PROFILE",
FAQ = "FAQ",
SETTINGS = "SETTINGS"
}
/* .env, pass in completed/availble feature identifier here */
COMPLETED_MODULES=[DASHBOARD, PROFILE, FAQ, SETTINGS]
/* APP_ROUTES, pass identifier to routes */
const AppRoutes = [
{
path: "/",
exact: true,
component: Dashboard,
module: AppModuleView.DASHBOARD
},
{
path: "/faqs",
exact: true,
component: FAQs,
module: AppModuleView.FAQ
},
{
path: "/profile",
exact: true,
component: Profile,
module: AppModuleView.PROFILE
}
];
/* RENDERED ROUTES, only available features indicated in .env will be rendered */
const APP_MODULES = process.env.COMPLETED_MODULES;
const Routes = AppRoutes.filter(
({ module }) => {
if (module && APP_MODULES) return APP_MODULES.includes(module);
else return;
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment