enable data saving

This commit is contained in:
2024-10-03 09:37:04 +02:00
parent 9f2a51b911
commit 5ecdf3adb7
5 changed files with 44 additions and 13 deletions

View File

@@ -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 = () => {

View File

@@ -43,6 +43,7 @@
transform-origin: center;
transform: scale(0);
transition: all 0.5s;
z-index: 50;
}
.stats-view-shown {