Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
render () {
if (!this.props.crowdfunding) {
return null
}
const {crowdfunding: {goals, status, endDate}, t} = this.props
const now = new Date()
const nextMinute = timeMinute.ceil(new Date())
// end date is expected to be an exact minute
// timeMinute.round is used to ensure that and
// support end dates like '2017-05-31 19:59:59.999+02'
const end = timeMinute.round(new Date(endDate))
const totalMinutes = timeMinute.count(nextMinute, end)
const minutes = totalMinutes % 60
const hours = Math.floor(totalMinutes / 60) % 24
const days = Math.floor(totalMinutes / 60 / 24)
if (!goals.length) {
return
}
const goalsByPeople = [].concat(goals)
.sort((a, b) => ascending(a.people, b.people))
const goal = goalsByPeople[goalsByPeople.length - 1]
const peopleLabel = t.elements('status/goal/people', {
count: (
<a> {</a>
crowdfundingName,
crowdfunding: { goals, status },
t,
money,
people,
memberships
} = this.props
const now = new Date()
const nextMinute = timeMinute.ceil(new Date())
// end date is expected to be an exact minute
// timeMinute.round is used to ensure that and
// support end dates like '2017-05-31 19:59:59.999+02'
const end = timeMinute.round(new Date(endDate))
const totalMinutes = timeMinute.count(nextMinute, end)
const minutes = totalMinutes % 60
const hours = Math.floor(totalMinutes / 60) % 24
const days = Math.floor(totalMinutes / 60 / 24)
if (!goals.length) {
return null
}
const goalsByPeople = []
.concat(goals)
.sort((a, b) => ascending(a.people, b.people))
const goal = goalsByPeople[goalsByPeople.length - 1]
const createHoverGoalCount = (format, value) => (
isEditing: false
})
}} />
<a href="#"> {
e.preventDefault()
this.setState({
isEditing: false
})
}}>{t('discuss/comment/editCancel')}</a>
)
}
const createdAt = new Date(data.createdAt)
const updatedAt = new Date(data.updatedAt)
const updateOffset = timeMinute.count(createdAt, updatedAt)
let updateNote
if (updateOffset > 2) {
updateNote = t('discuss/comment/updateNote', {
updateDate: dateTimeFormat(updatedAt)
})
}
const commentColor = pollColors[tags[0]]
return (
<div data-comment="">
{!!id && (
<div>
</div></div>
tick() {
const now = new Date()
const msLeft = 1000 - now.getMilliseconds() + 50
let msToNextTick = (60 - now.getSeconds()) * 1000 + msLeft
const endDate = this.props.endDate || this.props.crowdfunding.endDate
if (endDate) {
const end = new Date(endDate)
if (end < now) {
return
}
const totalMinutes = timeMinute.count(now, end)
const hours = Math.floor(totalMinutes / 60) % 24
if (hours === 0) {
msToNextTick = msLeft
}
}
clearTimeout(this.timeout)
this.timeout = setTimeout(() => {
this.setState({
now: new Date()
})
this.tick()
}, msToNextTick)
}
componentDidMount() {
render () {
if ((this.props.loading || this.props.error) && !this.props.crowdfunding) {
return null
}
const {crowdfunding: {goals, status, endDate}, t} = this.props
const now = new Date()
const end = new Date(endDate)
const totalMinutes = timeMinute.count(now, end)
const minutes = totalMinutes % 60
const hours = Math.floor(totalMinutes / 60) % 24
const days = Math.floor(totalMinutes / 60 / 24)
if (!goals.length) {
return
}
const goalsByPeople = [].concat(goals)
.sort((a, b) => ascending(a.people, b.people))
const goal = goalsByPeople[goalsByPeople.length - 1]
const peopleLabel = t.elements('status/goal/people', {
count: (
<a> {</a>
render () {
const {to} = this.props
const now = new Date()
if (now > to) {
return (<div style="{{margin:">
Es ist Zeit.
</div>)
}
const totalMinutes = timeMinute.count(now, to)
const minutes = totalMinutes % 60
const hours = Math.floor(totalMinutes / 60) % 24
const days = Math.floor(totalMinutes / 60 / 24)
return (
<div style="{{textAlign:">
<div>
<figure>
<div>{days}</div>
<figcaption>
{days === 1 ? 'Tag' : 'Tage'}
</figcaption>
</figure>
<figure>
<div>{hours}</div>
<figcaption></figcaption></figure></div></div>
tick () {
const now = new Date()
const msLeft = 1000 - now.getMilliseconds() + 50
let msToNextTick = (60 - now.getSeconds()) * 1000 + msLeft
const {crowdfunding: {endDate}} = this.props
if (endDate) {
const end = new Date(endDate)
if (end < now) {
return
}
const totalMinutes = timeMinute.count(now, end)
const hours = Math.floor(totalMinutes / 60) % 24
if (hours === 0) {
msToNextTick = msLeft
}
}
clearTimeout(this.timeout)
this.timeout = setTimeout(
() => {
this.setState({
now: new Date()
})
this.tick()
},
msToNextTick
)
{
const endDate = new Date(voting.endDate)
const reachedEndDate = now > endDate
const minutes = timeMinute.count(now, endDate)
let timeLeft
if (minutes > 60 * 24) {
timeLeft = {
unit: 'days',
count: Math.floor(minutes / 60 / 24)
}
} else if (minutes > 60) {
timeLeft = {
unit: 'hours',
count: Math.floor(minutes / 60)
}
} else {
timeLeft = {
unit: 'minutes',
count: minutes