import React , { useEffect } from 'react' ; import { Redirect , Route , Switch } from 'react-router-dom' ; import { useActions } from 'kea' ; import { ORG_SETTINGS_CUSTOMIZE_PATH , ORG_SETTINGS_CONNECTORS_PATH , ORG_SETTINGS_OAUTH_APPLICATION_PATH , } from '../../routes' ; import { staticSourceData } from '../content_sources/source_data' ; import { Connectors } from './components/connectors' ; import { Customize } from './components/customize' ; import { OauthApplication } from './components/oauth_application' ; import { SourceConfig } from './components/source_config' ; import { SettingsLogic } from './settings_logic' ; export const SettingsRouter = ( ) => { const { initializeSettings } = useActions ( SettingsLogic ) ; useEffect ( ( ) => { initializeSettings ( ) ; } , [ ] ) ; return ( < Switch > < Route exact path = { ORG_SETTINGS_CUSTOMIZE_PATH } > < Customize /> < /Route> < Route exact path = { ORG_SETTINGS_CONNECTORS_PATH } > < Connectors /> < /Route> < Route exact path = { ORG_SETTINGS_OAUTH_APPLICATION_PATH } > < OauthApplication /> < /Route> { staticSourceData . map ( ( { editPath } , i ) => ( < Route key = { i } exact path = { editPath } > < SourceConfig sourceIndex = { i } / > < /Route>))} < Route > < Redirect to = { ORG_SETTINGS_CUSTOMIZE_PATH } / > < /Route> < /Switch>); } ;