Commit f2f91942 authored by Denis Sedura's avatar Denis Sedura

[RNA-822] Add Cart, Order, PaymentRecept, AddCard, PaymentDetails, PaymentMethods

parent 124b653c
import React, { Component } from 'react'
export default function enhanceAddCard(ComposedComponent) {
return class Wrapper extends Component {
render() {
return (
<ComposedComponent {...this.props} />
)
}
}
}
export { default as enhanceAddCard } from './AddCard'
import React, { Component } from 'react'
export default function enhanceAddShipping(ComposedComponent) {
return class Wrapper extends Component {
render() {
return (
<ComposedComponent {...this.props} />
)
}
}
}
export { default as enhanceAddShipping } from './AddShipping'
import React, { Component } from 'react'
export default function enhanceCart(ComposedComponent) {
return class Wrapper extends Component {
render() {
return (
<ComposedComponent {...this.props} />
)
}
}
}
export { default as enhanceCart } from './Cart'
......@@ -3,9 +3,15 @@ import { Router } from 'tipsi-router'
export default function enhanceLogin(ComposedComponent) {
return class Wrapper extends Component {
dismissModal = () => (
dismissModal = (user, route = { params: {} }) => {
Router.dismissModal()
)
if (route.params.redirect) {
Router.push(
null,
Router.routes[route.params.redirect], { ...route.params.redirectParams, user }
)
}
}
render() {
return (
<ComposedComponent {...this.props} dismissModal={this.dismissModal} />
......
import React, { Component } from 'react'
export default function enhanceOrder(ComposedComponent) {
return class Wrapper extends Component {
render() {
return (
<ComposedComponent {...this.props} />
)
}
}
}
export { default as enhanceOrder } from './Order'
import React, { Component } from 'react'
export default function enhancePaymentDetails(ComposedComponent) {
return class Wrapper extends Component {
render() {
return (
<ComposedComponent {...this.props} />
)
}
}
}
export { default as enhancePaymentDetails } from './PaymentDetails'
import React, { Component } from 'react'
export default function enhancePaymentMethods(ComposedComponent) {
return class Wrapper extends Component {
render() {
return (
<ComposedComponent {...this.props} />
)
}
}
}
export { default as enhancePaymentMethods } from './PaymentMethods'
import React, { Component } from 'react'
export default function enhancePaymentReceipt(ComposedComponent) {
return class Wrapper extends Component {
render() {
return (
<ComposedComponent {...this.props} />
)
}
}
}
export { default as enhancePaymentReceipt } from './PaymentReceipt'
import React, { Component } from 'react'
import { Router } from 'tipsi-router'
export default function enhanceLogoutButton(ComposedComponent) {
return class Wrapper extends Component {
handleLogout = () => {
Router.replace(null, Router.routes.home)
}
render() {
return (
<ComposedComponent {...this.props} handleLogout={this.handleLogout} />
)
}
}
}
import React, { Component } from 'react'
import { Router } from 'tipsi-router'
import { default as enhanceLogoutButton } from './LogoutButton'
export default function enhanceProfile(ComposedComponent, LogoutButton) {
const LogoutButtonHOC = enhanceLogoutButton(LogoutButton)
return class Wrapper extends Component {
componentWillMount() {
Router.config({
navigationBar: {
renderRight: () => (
<LogoutButtonHOC eventName="ui_profile_logout_click" />
),
},
})
}
setTitle = title => (
Router.config({ navigationBar: { title } })
)
render() {
return (
<ComposedComponent {...this.props} setTitle={this.setTitle} />
)
}
}
}
export { default as enhanceProfile } from './Profile'
import React, { Component } from 'react'
export default function enhanceSelectShipping(ComposedComponent) {
return class Wrapper extends Component {
render() {
return (
<ComposedComponent {...this.props} />
)
}
}
}
export { default as enhanceSelectShipping } from './SelectShipping'
......@@ -2,10 +2,19 @@ export { enhanceAppComponent } from './App'
export { enhanceInitialComponent } from './InitialScreen'
export { enhanceAgeConfirmation } from './AgeConfirmation'
export { enhanceMain } from './Main'
export { enhanceProfile } from './Profile'
export { enhanceItemDetails } from './ItemDetails'
export { enhanceLabelPreview } from './LabelPreview'
export { enhanceMangeReview } from './ManageReview'
export { enhanceItemReviews } from './ItemReviews'
export { enhanceStore } from './Store'
export { enhanceCart } from './Cart'
export { enhanceAddCard } from './AddCard'
export { enhanceOrder } from './Order'
export { enhancePaymentReceipt } from './PaymentReceipt'
export { enhancePaymentMethods } from './PaymentMethods'
export { enhancePaymentDetails } from './PaymentDetails'
export { enhanceAddShipping } from './AddShipping'
export { enhanceSelectShipping } from './SelectShipping'
export { default as enhanceWineList } from './Store/WineList'
export { default as enhanceStoreTabView } from './Store/StoreTabView'
......@@ -3,6 +3,7 @@ import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { userSelector } from 'tipsi_api/selectors'
import { isEqual } from 'lodash'
import { Router } from 'tipsi-router'
// import Router from '../../navigation/Router'
import { openSidebarMenu, closeSidebarMenu } from '../../actions'
......@@ -23,7 +24,7 @@ function enhanceSidebarMenu(ComposedComponent) {
}
handleNavigate = ({ route, type, props, requireLoggedIn }) => {
const { navigation, user } = this.props
const { user } = this.props
// const navigatorApp = navigation.getNavigator('app')
// // const navigatorMaster = navigation.getNavigator('master')
// const { routeName } = navigatorApp.getCurrentRoute()
......@@ -33,19 +34,21 @@ function enhanceSidebarMenu(ComposedComponent) {
// if (routeName === route) {
// // Do nothing
// } else
if (requireLoggedIn && !user) {
if (requireLoggedIn && !user.id) {
// navigatorMaster.push(Router.getRoute('Login', { redirect: route }))
console.log('Show login')
Router.showModal(null, Router.routes.login, {
config: { navigationBar: { visible: false } },
redirect: route,
})
} else if (type === 'push') {
// navigatorApp.push(Router.getRoute(route, props))
console.log('Push to ', route)
} else if (type === 'reset') {
// navigatorApp.immediatelyResetStack([Router.getRoute(route, props)])
console.log('Reset stack')
console.log('Reset stack', route)
} else if (type === 'popToTop') {
// navigatorApp.popToTop()
// navigatorApp.push(Router.getRoute(route, { ...props, user }))
console.log('Go to top of stack')
Router.popToTop()
Router.push(null, Router.routes[route], { ...props, user })
} else {
throw new Error(`Wrong navigation type: ${type}`)
}
......
import { reduce, keys } from 'lodash'
import {
enhanceAppComponent,
enhanceProfile,
enhanceStore,
enhanceStoreTabView,
enhanceWineList,
enhanceCart,
enhanceAddCard,
enhanceOrder,
enhanceItemDetails,
enhanceLabelPreview,
enhanceMangeReview,
enhanceItemReviews,
enhancePaymentReceipt,
enhancePaymentDetails,
enhancePaymentMethods,
enhanceAddShipping,
enhanceSelectShipping,
} from './Screens'
import { enhanceSearch } from './Screens/Search'
import { enhanceLogin } from './Screens/Login'
......@@ -18,10 +26,38 @@ const routesMap = {
path: '/',
component: enhanceAppComponent,
},
profile: {
path: 'profile',
component: enhanceProfile,
},
store: {
path: 'store',
component: enhanceStore,
},
cart: {
path: 'cart',
component: enhanceCart,
},
addCard: {
path: 'addCard',
component: enhanceAddCard,
},
order: {
path: 'order',
component: enhanceOrder,
},
paymentReceipt: {
path: 'paymentReceipt',
component: enhancePaymentReceipt,
},
paymentDetails: {
path: 'paymentDetails',
component: enhancePaymentDetails,
},
paymentMethods: {
path: 'paymentMethods',
component: enhancePaymentMethods,
},
storeTabView: {
path: 'storeTabView',
component: enhanceStoreTabView,
......@@ -54,6 +90,14 @@ const routesMap = {
path: 'itemReviews',
component: enhanceItemReviews,
},
addShipping: {
path: 'addShipping',
component: enhanceAddShipping,
},
selectShipping: {
path: 'selectShipping',
component: enhanceSelectShipping,
},
}
export function createRoutes(routes = {}) {
......
......@@ -28,7 +28,7 @@ const tipsiMiddleware = createApiMiddleware({
}),
})
const middleware = [tipsiMiddleware, thunk, analyticsMiddleware] // ,logger]
const middleware = [tipsiMiddleware, thunk, analyticsMiddleware]// ,logger]
// if (__DEV__) {
// middleware.push(require('redux-logger')())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment