import React from 'react' ; import { parse } from 'query-string' ; import PageSwitcher , { IPageLoadingSpec } from 'common/lib/components/PageSwitcher' ; import { SCRIPT_URLS } from 'common/lib/constants' ; import { OFFICE_JS_URL_QUERY_PARAMETER_KEY } from 'common/lib/utilities/script-loader/constants' ; import { PATHS } from '../constants' ; import CustomFunctionsRunner from './CustomFunctionsRunner' ; import Runner from './Runner' ; const pages = { [ PATHS . CustomFunctionsRunner ] : { component : CustomFunctionsRunner , officeJs : null , } , [ PATHS . Runner ] : { component : Runner , officeJs : getOfficeJsUrlToLoad ( ) , } , } ; export default ( ) => < PageSwitcher pages = { pages } defaultPath = { PATHS . Runner } / > ; function getOfficeJsUrlToLoad ( ) { const params = parse ( window . location . search ) as { [ OFFICE_JS_URL_QUERY_PARAMETER_KEY ] : string ; } ; return ( params [ OFFICE_JS_URL_QUERY_PARAMETER_KEY ] || '' ) . trim ( ) . length > 0 ? params [ OFFICE_JS_URL_QUERY_PARAMETER_KEY ] : SCRIPT_URLS . DEFAULT_OFFICE_JS ; }