enable data saving
This commit is contained in:
@@ -118,7 +118,30 @@
|
||||
}
|
||||
|
||||
const sendForm = () => {
|
||||
alert( 'Data submitted. Remember: Stop smoking! Smoking hurts your health!' );
|
||||
fetch( localStorage.getItem( 'url' ) + '/update', {
|
||||
method: 'post',
|
||||
body: JSON.stringify( {
|
||||
day: date.value?.toISOString(),
|
||||
count: cigaretCount.value,
|
||||
difficulty: difficulty.value,
|
||||
sleep: sleepHours.value,
|
||||
rest: rest.value,
|
||||
freeTime: freeTime.value,
|
||||
stress: stress.value
|
||||
} ),
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'charset': 'utf-8'
|
||||
}
|
||||
} ).then( res => {
|
||||
if ( res.status === 200 ) {
|
||||
alert( 'Data submitted. Remember: Stop smoking! Smoking hurts your health!' );
|
||||
} else {
|
||||
alert( `Failed to save data (${ res.status })` );
|
||||
}
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
const dateUpdatedHandler = () => {
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
transform-origin: center;
|
||||
transform: scale(0);
|
||||
transition: all 0.5s;
|
||||
z-index: 50;
|
||||
}
|
||||
|
||||
.stats-view-shown {
|
||||
|
||||
Reference in New Issue
Block a user