@app.route('/cart', methods=['POST'])
@cross_origin(supports_credentials=True)
@token_required
def create_cart(current_user):
    data = request.get_json()
    cart = Cart(total_amount=data['total'], user_id=data['clientId'])
    db.session.add(cart)
    db.session.commit()
    if (not cart):
        return (jsonify({'message': 'Problema na inclusão do carrinho'}), 400)
    for product in data['products']:
        if (not product):
            return (jsonify({'message': 'Problema na inclusão do produto'}), 400)
        add_product = CP(product_id=product['id'], cart_id=cart.cart_id, quantity=product['quantity'], size=product['size'])
        db.session.add(add_product)
    db.session.commit()
    return (jsonify({'message': 'Carrinho salvo com sucesso!'}), 200)
@app.route('/cart', methods=['POST'])
@cross_origin(supports_credentials=True)
@token_required
def create_cart(current_user):
    data = request.get_json()
    cart = Cart(total_amount=data['total'], user_id=data['clientId'])
    db.session.add(cart)
    db.session.commit()
    if (not cart):
        return (jsonify({'message': 'Problema na inclusão do carrinho'}), 400)
    for product in data['products']:
        if (not product):
            return (jsonify({'message': 'Problema na inclusão do produto'}), 400)
        add_product = CP(product_id=product['id'], cart_id=cart.cart_id, quantity=product['quantity'], size=product['size'])
        db.session.add(add_product)
    db.session.commit()
    return (jsonify({'message': 'Carrinho salvo com sucesso!'}), 200)