const shared_consts = require('../tools/shared_nodejs');

const express = require('express');
const router = express.Router();

const tools = require('../tools/general');

var server_constants = require('../tools/server_constants');

var { Project } = require('../models/project');

var { authenticate, auth_default } = require('../middleware/authenticate');

var mongoose = require('mongoose').set('debug', false)
const Subscription = mongoose.model('subscribers');

const _ = require('lodash');

const { ObjectID } = require('mongodb');

const Product = require('../models/product');
const Order = require('../models/order');
const Variant = require('../models/variant');

const CartClass = require('../modules/Cart')
const Cart = require('../models/cart');
const OrdersCart = require('../models/orderscart');

//GET orders
router.get('/:userId', authenticate, function (req, res, next) {
  let userId = req.body.userId
  let idapp = req.body.idapp
  OrdersCart.getOrdersCartByUserId(userId, idapp, 0, function (err, cart) {
    if (err) return next(err)

    if (cart)
      res.send({ code: server_constants.RIS_CODE_OK, cart });
    else
      res.status(400).send(e);
  })
})

module.exports = router;
