Skip to content
Permalink
Browse files

#610 claim counter should change to button when counter is 0 (#672)

* Claim counter should change to button when counter is 0 #610

* add new condition

* get entitlement from contract

* add variable to env for testing

* fixed snapshot

* fixed snapshot

* add global var. window.nextTimeClaim for testing
  • Loading branch information...
StanislavShevchenko authored and sirpy committed Oct 3, 2019
1 parent d1c690a commit 93b9aac63531f124fdf365e7b8b73e4045814635
Showing with 24 additions and 6 deletions.
  1. +3 −0 .env.example
  2. +19 −5 src/components/dashboard/Claim.js
  3. +1 −0 src/config/config.js
  4. +1 −1 src/lib/wallet/GoodWalletClass.js
@@ -41,5 +41,8 @@ REACT_APP_ROLLBAR_API_KEY=
# Should or should not throw errors when saving profile fails
REACT_APP_THROW_SAVE_PROFILE_ERRORS=true

# Next claim time
REACT_APP_NEXT_TIME_CLAIM=86400

REACT_APP_RECEIVE_URL=
REACT_APP_SEND_URL=
@@ -80,19 +80,33 @@ const Claim = props => {
evaluateFRValidity()
}, [])

const getNextClaim = date => new Date(date - new Date().getTime()).toISOString().substr(11, 8)
const getNextClaim = async date => {
let nextClaimTime = date - new Date().getTime()
if (nextClaimTime < 0 && state.entitlement <= 0) {
const entitlement = await goodWallet.checkEntitlement()
setState({
nextClaim: '--:--:--',
entitlement: entitlement.toNumber() > 0 ? entitlement.toNumber() : 100,
claimedToday: {
people: '--',
amount: '--',
},
})
}
return new Date(nextClaimTime).toISOString().substr(11, 8)
}

const gatherStats = async () => {
const [claimedToday, nextClaimDate] = await Promise.all([
wrappedGoodWallet.getAmountAndQuantityClaimedToday(),
wrappedGoodWallet.getNextClaimTime(),
])

setState(prevState => ({ ...prevState, claimedToday, nextClaim: getNextClaim(nextClaimDate) }))
const nextClaim = await getNextClaim(nextClaimDate)
setState( prevState => ({ ...prevState, claimedToday, nextClaim }))

setClaimInterval(
setInterval(() => {
const nextClaim = getNextClaim(nextClaimDate)
setInterval(async () => {
const nextClaim = await getNextClaim(nextClaimDate)
setState(prevState => ({ ...prevState, nextClaim }))
}, 1000)
)
@@ -24,6 +24,7 @@ const Config = {
safariMobileKeyboardGuidedSize: process.env.REACT_APP_SAFARI_MOBILE_KEYBOARD_GUIDED_SIZE === 'true',
receiveUrl: process.env.REACT_APP_RECEIVE_URL || `${publicUrl}`,
sendUrl: process.env.REACT_APP_SEND_URL || `${publicUrl}`,
nextTimeClaim: process.env.REACT_APP_NEXT_TIME_CLAIM || 86400,
ethereum: {
'42': {
network_id: 42,
@@ -19,7 +19,7 @@ import WalletFactory from './WalletFactory'

const log = logger.child({ from: 'GoodWallet' })

const DAY_IN_SECONDS = 86400
const DAY_IN_SECONDS = window.nextTimeClaim ? Number(window.nextTimeClaim) : Number(Config.nextTimeClaim)
const MILLISECONDS = 1000
const ZERO = new BN('0')

0 comments on commit 93b9aac

Please sign in to comment.
You can’t perform that action at this time.