Skip to content

Commit

Permalink
Group order confirmation page code by file types
Browse files Browse the repository at this point in the history
  • Loading branch information
Starotitorov committed Nov 13, 2018
1 parent 1fbbf74 commit feaa419
Show file tree
Hide file tree
Showing 32 changed files with 9,866 additions and 2,881 deletions.
1,879 changes: 935 additions & 944 deletions package-lock.json

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions packages/peregrine/src/Peregrine/Peregrine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';
import { Provider as ReduxProvider } from 'react-redux';
import createStore from '../store';
import MagentoRouter from '../Router';

/**
*
* @param {string} apiBase Absolute URL pointing to the GraphQL endpoint
* @param {string} __tmp_webpack_public_path__ Temporary hack. Expects the `__webpack_public_path__` value
* @returns {{ store: Store, Provider: () => JSX.Element }}
*/
export default function bootstrap({
apiBase,
renderRoutes,
__tmp_webpack_public_path__
}) {
// Remove deprecation warning after 2 version bumps
if (process.env.NODE_ENV !== 'production' && this instanceof bootstrap) {
throw new Error(
'The API for Peregrine has changed. ' +
'Please see the Release Notes on Github ' +
'for instructions to update your application'
);
}

const store = createStore();
const routerProps = {
apiBase,
renderRoutes,
__tmp_webpack_public_path__: ensureDirURI(__tmp_webpack_public_path__)
};
const Provider = () => (
<ReduxProvider store={store}>
<MagentoRouter {...routerProps} />
</ReduxProvider>
);

return { store, Provider };
}

/**
* Given a URI, will always return the same URI with a trailing slash
* @param {string} uri
*/
function ensureDirURI(uri) {
return uri.endsWith('/') ? uri : uri + '/';
}
Loading

0 comments on commit feaa419

Please sign in to comment.