Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. import React, { Component } from 'react'
  2. import { Provider } from 'react-contextual'
  3. import PropTypes from 'prop-types'
  4. import 'regenerator-runtime/runtime'
  5. import ErrorBoundary from '@argos/error-boundary'
  6.  
  7. import { BackDrop, Checkout, Logo } from '../../components'
  8. import { User, Navigation, Search, Suggestions, TopBar } from '../../containers'
  9. import { MegaNavService } from '../../services'
  10. import { NavigationStore, UserStore } from '../../stores'
  11.  
  12. import styles from './Header.scss'
  13.  
  14. export default class Header extends Component {
  15. static propTypes = {
  16. checkout: PropTypes.bool,
  17. routes: PropTypes.shape({
  18. help: PropTypes.func,
  19. stores: PropTypes.func,
  20. search: PropTypes.func,
  21. megabuttons: PropTypes.arrayOf(PropTypes.func)
  22. }),
  23. overrideSearchTerm: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
  24. overrideTrolleyCount: PropTypes.number,
  25. overrideWishlistCount: PropTypes.oneOfType([PropTypes.number, PropTypes.element]),
  26. overrideOnSearchSubmit: PropTypes.func,
  27. onUserInfoLoad: PropTypes.func,
  28.  
  29. /* legacy - to depcreate */
  30. config: PropTypes.string,
  31. catalogId: PropTypes.number,
  32. storeId: PropTypes.number,
  33. langId: PropTypes.number,
  34. domain: PropTypes.string,
  35. dynamicMegaButtons: PropTypes.bool,
  36. loadMegaNavSubcategories: PropTypes.bool,
  37. openSearchBarByDefault: PropTypes.bool,
  38. overrideMegaNavLocation: PropTypes.string
  39. }
  40.  
  41. static defaultProps = {
  42. checkout: false,
  43. routes: {},
  44. overrideTrolleyCount: null,
  45. overrideWishlistCount: null,
  46. onUserInfoLoad: () => ({}),
  47. storeId: 10151,
  48. langId: 110,
  49. catalogId: 10001
  50. }
  51.  
  52. static async getInitialProps() {
  53. const taxonomy = await MegaNavService({ lite: true, origin: 'https://www.argos.co.uk' })
  54. return { taxonomy }
  55. }
  56.  
  57. get store() {
  58. return { ...global.__INITIAL_HEADER_STATE__, ...this.props }
  59. }
  60.  
  61. render() {
  62. const {
  63. checkout,
  64. overrideTrolleyCount,
  65. overrideWishlistCount,
  66. onUserInfoLoad,
  67. skipToContentTag
  68. } = this.props
  69.  
  70. /* Stripped down header for checkout */
  71. if (checkout) {
  72. return (
  73. <ErrorBoundary>
  74. <Checkout skipToContentTag={skipToContentTag} />
  75. </ErrorBoundary>
  76. )
  77. }
  78.  
  79. return (
  80. <ErrorBoundary>
  81. <Provider {...this.store}>
  82. <Provider store={NavigationStore}>
  83. <Provider store={UserStore}>
  84. <header id="haas-v2" className={styles.header}>
  85. <TopBar />
  86. <div className={styles.main}>
  87. <div className={styles.container}>
  88. <Logo />
  89. <Navigation />
  90. <Suggestions>
  91. <Search />
  92. </Suggestions>
  93. <User
  94. onUserInfoLoad={onUserInfoLoad}
  95. overrideTrolleyCount={overrideTrolleyCount}
  96. overrideWishlistCount={overrideWishlistCount}
  97. />
  98. </div>
  99. </div>
  100. </header>
  101. <BackDrop />
  102. </Provider>
  103. </Provider>
  104. </Provider>
  105. </ErrorBoundary>
  106. )
  107. }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement