const User = require('../models/GPS.User');
const InstalledDevice = require('../models/GPS.InstalledDevice');
const Withdraw = require('../models/GPS.Withdraw');


module.exports.mainPage = async(req, res)=>{
    const device = await InstalledDevice.countDocuments({userId:req.user_id})
    const user = await User.findById(req.user_id).select('walletBalance dollarBalance score')
    res.status(200).json({installedDevice:device, user})
}

module.exports.walletPage = async(req, res)=>{
    const withdraw = await Withdraw.findOne({userId: req.user_id, status:0})
    const user = await User.findById(req.user_id).select('walletBalance dollarBalance score')
    let pending;
   
    if(withdraw){
         pending = true
    }else{
         pending = false
    }
    res.status(200).json({user, pending })
}