Cron implementation 2: Untested
This commit is contained in:
parent
04f207db5d
commit
af3b2fe53b
1 changed files with 12 additions and 10 deletions
|
|
@ -28,20 +28,20 @@ class App extends React.Component<any,any> {
|
||||||
dailys: [],
|
dailys: [],
|
||||||
habits: [],
|
habits: [],
|
||||||
}
|
}
|
||||||
this.handleChangeTodos = this.handleChangeTodos.bind(this)
|
this.handleChangeTodos = this.handleChangeTodos.bind(this);
|
||||||
this.handleChangeDailys = this.handleChangeDailys.bind(this)
|
this.handleChangeDailys = this.handleChangeDailys.bind(this);
|
||||||
this.handleChangeHabits = this.handleChangeHabits.bind(this)
|
this.handleChangeHabits = this.handleChangeHabits.bind(this);
|
||||||
|
this.runCron = this.runCron.bind(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
CheckCron(props: any) {
|
CheckCron(lastCron: string) {
|
||||||
let cronDate = new Date(props.lastCron).getTime();
|
let cronDate = new Date(lastCron).getDate();
|
||||||
let now = new Date().getTime();
|
let now = new Date().getDate();
|
||||||
if (now > cronDate + 86400000) {
|
if (cronDate < now) {
|
||||||
return(
|
return(
|
||||||
<div className="cron">
|
<div className="cron">
|
||||||
<div id="cronMessage"> Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards. </div>
|
<div id="cronMessage"> Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards. </div>
|
||||||
<button onClick={() => {this.runCron()}}>Continue</button>
|
<button onClick={() => {this.runCron}}>Continue</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -51,6 +51,7 @@ class App extends React.Component<any,any> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
runCron() {
|
runCron() {
|
||||||
|
console.log("running cron");
|
||||||
makeCronReq(this.username, this.credentials)
|
makeCronReq(this.username, this.credentials)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|
@ -143,6 +144,7 @@ class App extends React.Component<any,any> {
|
||||||
}
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
|
let content = this.CheckCron(this.state.user_data.lastCron);
|
||||||
if(this.state.error)
|
if(this.state.error)
|
||||||
return(<div className="loading">Loading....</div>)
|
return(<div className="loading">Loading....</div>)
|
||||||
else if(!this.state.isLoaded)
|
else if(!this.state.isLoaded)
|
||||||
|
|
@ -152,7 +154,7 @@ class App extends React.Component<any,any> {
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
|
||||||
<Statsview user_data={this.state.user_data} />
|
<Statsview user_data={this.state.user_data} />
|
||||||
<Taskview data={this.state.tasks} handleChangeTodos={this.handleChangeTodos} handleChangeDailys={this.handleChangeDailys} handleChangeHabits={this.handleChangeHabits}/>
|
<Taskview data={this.state.tasks} handleChangeTodos={this.handleChangeTodos} handleChangeDailys={this.handleChangeDailys} handleChangeHabits={this.handleChangeHabits}/>
|
||||||
<this.CheckCron lastCron={this.state.user_data.lastCron}/>
|
{content}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue