import React from 'react';
import { View, Text, TextInput, StyleSheet, Button, ScrollView } from 'react-native';
import Axios from 'axios'
import { connect } from 'react-redux'
class MenuConfirmation extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            kasproBalance: '',
            kasproPoint: '',
            checkedBalance: false,
            checkedPoint: false,
            checkedBalancePoint: false,
            balanceused: 0,
            pointsused: 0,
            ongkir: 0,
            diskon: 0,
            isDelivery: false,
            isPickUp: false
            // dummyBalance : 155000,
            // dummyPoint : 20000
        }
    }

    render() {
        console.log(this.props)
        return (
            <ScrollView style={styles.container}>
                {
                    this.props.order_item.map((item, index) => {

                        return (
                            <View style={{ margin: 10 }} key={index}>
                                <View style={{ flex: 1, margin: 10, flexDirection: 'row', justifyContent: 'space-around' }}>
                                    <View style={{ flex: 0.3, alignItems: 'center' }}>
                                        <Text>{item.quantity}</Text>
                                    </View>
                                    <View style={{ flex: 0.1, alignItems: 'flex-start' }}>
                                        <Text>x</Text>
                                    </View>
                                    <View style={{ flex: 0.3, alignItems: 'baseline' }}>
                                        <Text>{item.name} </Text>
                                    </View>
                                    <View style={{ flex: 0.3, alignItems: 'flex-end' }}>
                                        <Text>{item.quantity * item.price} </Text>
                                    </View>
                                </View>
                            </View>
                        )
                    })
                }
                <View style={{ alignItems: 'flex-end', borderTopWidth: 1, margin: 10, padding: 10 }}>
                    <Text>0</Text>
                </View>
                <View style={{ flexDirection: 'row', margin: 10, justifyContent: 'space-between' }}>
                    <View style={{ margin: 10 }}>
                        <Text>Voucher Discount</Text>
                    </View>
                    <View style={{ margin: 10 }}>
                        <Text>0</Text>
                    </View>
                </View>
                <View style={{ flexDirection: 'row', margin: 10, justifyContent: 'space-between' }}>
                    <View style={{ margin: 10 }}>
                        <Text>Delivery Charge</Text>
                    </View>
                    <View style={{ margin: 10 }}>
                        <Text>0</Text>
                    </View>
                </View>
                <View style={{ flexDirection: 'row', margin: 10, justifyContent: 'space-between', borderTopWidth: 1 }}>
                    <View style={{ margin: 10 }}>
                        <Text>Total</Text>
                    </View>
                    <View style={{ margin: 10 }}>
                        <Text>0</Text>
                    </View>
                </View>
                <View style={{ flexDirection: 'row', margin: 10, justifyContent: 'space-between', borderTopWidth: 1 }}>
                    <View style={{ margin: 10 }}>
                        <Text>Balance Used</Text>
                    </View>
                    <View style={{ margin: 10 }}>
                        <Text>{this.props.route.params.balanceUsed}</Text>
                    </View>
                </View>
                <View style={{ flexDirection: 'row', margin: 10, justifyContent: 'space-between'}}>
                    <View style={{ margin: 10 }}>
                        <Text>Point Used</Text>
                    </View>
                    <View style={{ margin: 10 }}>
                        <Text>{this.props.route.params.pointused}</Text>
                    </View>
                </View>
            </ScrollView>
        )
    }
}

const styles = StyleSheet.create({

    container: {
        flex: 1,
        backgroundColor: 'white',
    },
    header: {

        flex: 0.5,
    },
    images: {
        margin: 10,
        flex: 2,
        backgroundColor: 'green'
    },
    content: {
        flex: 2,
    },
    body: {
        flex: 3,
    },

})

const mapStateToProps = (state) => {
    console.log(state)
    return {
        session_id: state.session_id,
        outlet_id: state.outlet_id,
        order_quantity: state.order_quantity,
        order_total: state.order_total,
        order_item: state.order_item,
        quantity: state.quantity,
        address: state.address
    }
}


export default connect(mapStateToProps)(MenuConfirmation)
