import React from 'react';
import style from './controls.module.sass';
import {userCabinetGoodsElement} from "../../../../../constants/typesComponents";
import ButtonBuy from "../../../../buttons/buttonBuy/buttonBuy";
import {orderStatus} from "../../../../../constants/orders";
import ButtonDeleteOrder from '../../../../buttons/buttonDeleteOrder/buttonDeleteOrder';
import ButtonFavourite from '../../../../buttons/buttonFavourite/buttonFavourite';

const Controls = (props) => {
    const {typeElement, goodsData} = props;
    const selectedGoodsAttribute = goodsData.GoodsAttributes[0];


    if( typeElement == userCabinetGoodsElement.FAVOURITE_GOODS_ELEMENT ) {
        return (
            <div className={style.mainContainer}>
                <ButtonBuy
                    simpleGoodsData={goodsData}
                    changedPrice={selectedGoodsAttribute.price}
                    changedValueAttributes={selectedGoodsAttribute.valueAttribute}
                />
                <ButtonFavourite
                    idAttribute={selectedGoodsAttribute.id}
                />
            </div>
        );
    }else if(typeElement == userCabinetGoodsElement.HISTORY_ORDERS_ELEMENT) {
        if(goodsData.orderStatus == orderStatus.NOT_CONFIRMED ) {

            return (
                <div className={style.mainContainer}>
                    <ButtonDeleteOrder
                        goodId={selectedGoodsAttribute.id}
                    />
                </div>
            )
        }else if(goodsData.orderStatus == orderStatus.CONFIRMED) {

            return (
                <div className={style.mainContainer}>
                    <h2>Подтверждено</h2>
                </div>
            );
        }else if(goodsData.orderStatus == orderStatus.DELIVERED) {

            return (
                <div className={style.mainContainer}>
                    <h3>Доставлено</h3>
                </div>
            )
        }
    }
};


export default Controls;
