Add context to import entrypoint

[MAILPOET-2389]
This commit is contained in:
Amine Ben hammou
2019-11-27 13:57:24 +01:00
committed by Jack Kitterhing
parent 8dba06f8b9
commit 6ce548ef1b

View File

@@ -5,6 +5,7 @@ import {
} from 'react-router-dom'; } from 'react-router-dom';
import ScrollToTop from 'common/scroll_to_top.jsx'; import ScrollToTop from 'common/scroll_to_top.jsx';
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
import StepMethodSelection from './import/step_method_selection.jsx'; import StepMethodSelection from './import/step_method_selection.jsx';
import StepInputValidation from './import/step_input_validation.jsx'; import StepInputValidation from './import/step_input_validation.jsx';
import StepDataManipulation from './import/step_data_manipulation.jsx'; import StepDataManipulation from './import/step_data_manipulation.jsx';
@@ -17,62 +18,65 @@ const subscribersLimitForValidation = 200;
const ImportSubscribers = () => { const ImportSubscribers = () => {
const [stepMethodSelectionData, setStepMethodSelectionData] = useState(undefined); const [stepMethodSelectionData, setStepMethodSelectionData] = useState(undefined);
const [stepDataManipulationData, setStepDataManipulationData] = useState({}); const [stepDataManipulationData, setStepDataManipulationData] = useState({});
const contextValue = useGlobalContextValue(window);
return ( return (
<HashRouter> <GlobalContext.Provider value={contextValue}>
<ScrollToTop> <HashRouter>
<Switch> <ScrollToTop>
<Route <Switch>
path="/step_method_selection" <Route
render={(props) => ( path="/step_method_selection"
<StepMethodSelection render={(props) => (
{...props} <StepMethodSelection
setStepMethodSelectionData={setStepMethodSelectionData} {...props}
subscribersLimitForValidation={subscribersLimitForValidation} setStepMethodSelectionData={setStepMethodSelectionData}
/> subscribersLimitForValidation={subscribersLimitForValidation}
)} />
/> )}
<Route />
path="/step_input_validation" <Route
render={(props) => ( path="/step_input_validation"
<StepInputValidation render={(props) => (
{...props} <StepInputValidation
stepMethodSelectionData={stepMethodSelectionData} {...props}
/> stepMethodSelectionData={stepMethodSelectionData}
)} />
/> )}
<Route />
path="/step_data_manipulation" <Route
render={(props) => ( path="/step_data_manipulation"
<StepDataManipulation render={(props) => (
{...props} <StepDataManipulation
stepMethodSelectionData={stepMethodSelectionData} {...props}
subscribersLimitForValidation={subscribersLimitForValidation} stepMethodSelectionData={stepMethodSelectionData}
setStepDataManipulationData={setStepDataManipulationData} subscribersLimitForValidation={subscribersLimitForValidation}
/> setStepDataManipulationData={setStepDataManipulationData}
)} />
/> )}
<Route />
path="/step_results" <Route
render={(props) => ( path="/step_results"
<StepResults render={(props) => (
{...props} <StepResults
errors={stepDataManipulationData.errors} {...props}
createdSubscribers={stepDataManipulationData.created} errors={stepDataManipulationData.errors}
updatedSubscribers={stepDataManipulationData.updated} createdSubscribers={stepDataManipulationData.created}
segments={stepDataManipulationData.segments} updatedSubscribers={stepDataManipulationData.updated}
addedToSegmentWithWelcomeNotification={ segments={stepDataManipulationData.segments}
addedToSegmentWithWelcomeNotification={
stepDataManipulationData.added_to_segment_with_welcome_notification stepDataManipulationData.added_to_segment_with_welcome_notification
} }
/> />
)} )}
/> />
<Route <Route
path="*" path="*"
render={() => <Redirect to="/step_method_selection" />} render={() => <Redirect to="/step_method_selection" />}
/> />
</Switch> </Switch>
</ScrollToTop> </ScrollToTop>
</HashRouter> </HashRouter>
</GlobalContext.Provider>
); );
}; };