Commit 227e780f authored by Dmytro Zavgorodniy's avatar Dmytro Zavgorodniy

[RNA-761] Update Screens/Cart

parent 2e9c4fa9
......@@ -9,7 +9,6 @@ import { get } from 'lodash'
import { requestPayment, finalizePayment } from '../../actions'
import { createPaymentSelector } from '../../selectors'
import { defaultDeliveryType } from '../../utils/deliveryTypes'
import getPaymentMethod from '../../utils/getPaymentMethod'
import { CREDIT_CARD } from '../../constants/paymentMethods'
import CartHOC from '../CartHOC'
......@@ -54,13 +53,11 @@ export default function enhanceCart(ComposedComponent) {
state = {
currentItemIndex: 0,
paymentMethod: CREDIT_CARD,
deliveryType: defaultDeliveryType,
}
componentWillMount() {
Router.setTitle('Shopping Cart')
this.updatePaymentMethod()
}
componentDidMount() {
......@@ -69,12 +66,6 @@ export default function enhanceCart(ComposedComponent) {
}
}
componentWillReceiveProps(nextProps) {
if (this.props.isFocused !== nextProps.isFocused && nextProps.isFocused) {
this.updatePaymentMethod()
}
}
getProductItem = () => {
const product = this.props.orderProducts[this.state.currentItemIndex] || {}
const inventoryId = product.inventory_id || get(product, 'inventory.id')
......@@ -84,11 +75,6 @@ export default function enhanceCart(ComposedComponent) {
return { product, inventoryId, currentCount }
}
updatePaymentMethod = async () => {
const paymentMethod = await getPaymentMethod()
this.setState({ paymentMethod })
}
itemIndexChanged = (index) => {
this.setState({ currentItemIndex: index })
}
......@@ -107,9 +93,9 @@ export default function enhanceCart(ComposedComponent) {
this.props.removeInventoryFromCart(inventoryId)
}
pay = async () => {
pay = async (paymentMethod) => {
const { storeId, order: { id: orderId, code }, isLoadingStoreCart } = this.props
const { deliveryType, paymentMethod } = this.state
const { deliveryType } = this.state
if (isLoadingStoreCart) {
return
......@@ -231,8 +217,8 @@ export default function enhanceCart(ComposedComponent) {
return (
<ComposedComponent
{...this.props}
isFocused={this.props.isFocused}
currentItemIndex={this.state.currentItemIndex}
paymentMethod={this.state.paymentMethod}
deliveryType={this.state.deliveryType}
order={this.props.order}
orderProducts={this.props.orderProducts}
......@@ -240,7 +226,6 @@ export default function enhanceCart(ComposedComponent) {
requestPaymentLoading={this.props.requestPaymentLoading}
finalizePaymentLoading={this.props.finalizePaymentLoading}
getProductItem={this.getProductItem}
updatePaymentMethod={this.updatePaymentMethod}
itemIndexChanged={this.itemIndexChanged}
deliveryTypeChanged={this.deliveryTypeChanged}
updateInventoryInCart={this.updateInventoryInCart}
......
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