Add context to newsletters entrypoint

[MAILPOET-2389]
This commit is contained in:
Amine Ben hammou
2019-11-27 13:46:53 +01:00
committed by Jack Kitterhing
parent 41697e1580
commit 89d0362f13

View File

@ -20,6 +20,7 @@ import NewsletterListNotification from 'newsletters/listings/notification.jsx';
import NewsletterListNotificationHistory from 'newsletters/listings/notification_history.jsx'; import NewsletterListNotificationHistory from 'newsletters/listings/notification_history.jsx';
import NewsletterSendingStatus from 'newsletters/sending_status.jsx'; import NewsletterSendingStatus from 'newsletters/sending_status.jsx';
import CampaignStatsPage from 'newsletters/campaign_stats/page.jsx'; import CampaignStatsPage from 'newsletters/campaign_stats/page.jsx';
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
const getAutomaticEmailsRoutes = () => { const getAutomaticEmailsRoutes = () => {
if (!window.mailpoet_automatic_emails) return null; if (!window.mailpoet_automatic_emails) return null;
@ -98,21 +99,23 @@ const routes = Hooks.applyFilters('mailpoet_newsletters_before_router', [
]); ]);
const App = () => ( const App = () => (
<HashRouter> <GlobalContext.Provider value={useGlobalContextValue(window)}>
<Switch> <HashRouter>
<Route exact path="/" render={() => <Redirect to="/standard" />} /> <Switch>
{routes.map((route) => ( <Route exact path="/" render={() => <Redirect to="/standard" />} />
<Route {routes.map((route) => (
key={route.path} <Route
path={route.path} key={route.path}
component={route.component} path={route.path}
name={route.name || null} component={route.component}
data={route.data || null} name={route.name || null}
render={route.render} data={route.data || null}
/> render={route.render}
))} />
</Switch> ))}
</HashRouter> </Switch>
</HashRouter>
</GlobalContext.Provider>
); );
const container = document.getElementById('newsletters_container'); const container = document.getElementById('newsletters_container');