import moment from 'moment'

import {
  USER_REFERRAL_VC_REWARD
} from '../constants'

class Globals {
  constructor () {
    this.raised = 490100.00
    this.raisedUpdateTime = moment('2018-02-28 16:00:00')
    this.dollarsPerDayRate = 600.00
  }
}

function isGlobalCampaignLive () {
  return process.env.IS_GLOBAL_CAMPAIGN_LIVE === 'true' || false
}

/**
 * Get an estimate of how much we've raised, using a combination of
 * the most recent manual entry and the estimated rate of money
 * raised over time.
 * @return {number}  A decimal rounded to two decimal places
 */
function getMoneyRaised () {
  const globals = new Globals()
  const secsInDay = 60 * 60 * 24

  const totalRaised = globals.raised
  const datetimeOfLastEntry = globals.raisedUpdateTime
  const moneyRaisedRate = globals.dollarsPerDayRate
  const now = moment()
  const diff = now.diff(datetimeOfLastEntry, 'seconds')
  const secondsToDays = diff / secsInDay
  const finalRaised = totalRaised + (secondsToDays * moneyRaisedRate)
  return finalRaised.toFixed(2)
}

function getDollarsPerDayRate () {
  const globals = new Globals()
  return globals.dollarsPerDayRate
}

function getReferralVcReward () {
  return USER_REFERRAL_VC_REWARD
}

export {
  Globals,
  getMoneyRaised,
  getDollarsPerDayRate,
  getReferralVcReward,
  isGlobalCampaignLive
}

@@ -135,18 +135,18 @@
 sed = 49
-01
+58
 00.00%0A  
@@ -189,15 +189,15 @@
 18-0
-2-28 16
+3-09 18
 :00:
@@ -234,11 +234,11 @@
 e = 
-600
+433
 .00%0A

Tweak money raised rate