import {Order} from "../../types/order";
import React from "react";
import {RFPercentage} from "react-native-responsive-fontsize";
import OrderProductsList from "../../components/OrderCard/OrderProductsList";
import {StyleSheet, View} from "react-native";
import {useAppDispatch} from "../../redux/store";
import {selectProduct} from "../../features/assembly/assemblySlice";

type Props = {
    order: Order;
}
const AssemblyProductSelect = (props: Props) => {
    const dispatch = useAppDispatch();
    const onSelected = (productId: number) => {
        dispatch(selectProduct(productId));
    }

    return (
        <View style={styles.wrapper}>

            <OrderProductsList
                products={props.order.products}
                onSelected={onSelected}
            />
        </View>

    )
}

const styles = StyleSheet.create({
    wrapper: {
        flex: 0.5,
        backgroundColor: "white",
        borderRadius: RFPercentage(3),
        padding: RFPercentage(2),
    },
})

export default AssemblyProductSelect;