Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Telemedicine_App_Development
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashini Thilakarathne
Telemedicine_App_Development
Commits
78a3ce6b
Commit
78a3ce6b
authored
Mar 18, 2024
by
Shashini Thilakarathne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update DB configurations
parent
f6d14975
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
10 deletions
+26
-10
StressPrediction/src/newJournalEntry.js
StressPrediction/src/newJournalEntry.js
+26
-10
No files found.
StressPrediction/src/newJournalEntry.js
View file @
78a3ce6b
...
@@ -15,19 +15,35 @@ const AddData = () => {
...
@@ -15,19 +15,35 @@ const AddData = () => {
const
updateData
=
()
=>
{
const
updateData
=
()
=>
{
const
jobSatisfactionValue
=
Job_Satisfaction
===
'
Yes
'
?
0
:
1
;
const
jobSatisfactionValue
=
Job_Satisfaction
===
'
Yes
'
?
0
:
1
;
cons
t
sleepHoursValue
=
parseInt
(
selectedHours
);
le
t
sleepHoursValue
=
parseInt
(
selectedHours
);
// Applying the logic to set sleep hours value
if
(
!
isNaN
(
sleepHoursValue
))
{
if
(
!
isNaN
(
sleepHoursValue
))
{
sleepHoursValue
=
sleepHoursValue
>
8
?
0
:
1
;
}
else
{
console
.
error
(
"
Invalid input for Sleep Hours. Please enter a valid number.
"
);
return
;
// Exit the function if sleep hours is invalid
}
const
postData
=
{
const
postData
=
{
Job_Satisfaction
:
jobSatisfactionValue
,
Job_Satisfaction
:
jobSatisfactionValue
,
Sleep_Hours
:
sleepHoursValue
,
Sleep_Hours
:
sleepHoursValue
,
Text
:
Additional_Text
,
Text
:
Additional_Text
,
isNew
:
false
isNew
:
true
// Set isNew to true initially
};
};
set
(
ref
(
db
,
'
live_data
'
),
postData
);
}
else
{
set
(
ref
(
db
,
'
live_data
'
),
postData
)
console
.
error
(
"
Invalid input for Sleep Hours. Please enter a valid number.
"
);
.
then
(()
=>
{
}
console
.
log
(
"
Data updated successfully
"
);
// After some time or event, update isNew to false
setTimeout
(()
=>
{
set
(
ref
(
db
,
'
live_data/isNew
'
),
false
);
},
5000
);
// Example: Set isNew to false after 5 seconds
})
.
catch
(
error
=>
{
console
.
error
(
"
Error updating data:
"
,
error
);
});
setModalVisible
(
false
);
// Close the modal after updating data
setModalVisible
(
false
);
// Close the modal after updating data
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment