increasing test coverage to 20 percent
[aai/sparky-fe.git] / src / app / configurableViews / ConfigurableViewManager.js
1 import React from 'react';
2 import {
3   Route
4 } from 'react-router-dom';
5 import { fetchConfigurableViewRequest } from 'app/networking/NetworkCalls';
6
7 export function getConfigurableRoutes(config, components) {
8   let routes = [];
9   if (config && Object.keys(config).length > 0 && components && Object.keys(components).length > 0) {
10     config.layouts.forEach( (viewConfig) => {
11       let ConfigurableView = components[viewConfig.viewType];
12       if (ConfigurableView) {
13         routes.push(
14           <Route key={viewConfig.id} path={`/${viewConfig.id}`} render={ () => {
15             return (
16               <ConfigurableView
17                 config={ viewConfig }
18                 networkAPI={ fetchConfigurableViewRequest }/>
19             );
20           }}/>
21         );
22       }
23     });
24   }
25
26   return routes;
27 }