-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43e40c5
commit cb3f4f5
Showing
8 changed files
with
272 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
.mood-logging-container { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
min-height: 100vh; | ||
font-family: 'Arial', sans-serif; | ||
|
||
} | ||
|
||
.mood-logging { | ||
width: 90%; | ||
max-width: 500px; | ||
|
||
padding: 25px; | ||
border-radius: 10px; | ||
box-shadow: 0 10px 25px rgba(0,0,0,0.1); | ||
transition: box-shadow 0.3s ease-in-out; | ||
} | ||
|
||
.mood-logging:hover { | ||
box-shadow: 0 20px 45px rgba(0,0,0,0.15); | ||
} | ||
|
||
.input-group { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
input[type="text"] { | ||
padding: 12px 20px; | ||
margin: 10px 0; | ||
border: 2px solid #ccc; | ||
border-radius: 5px; | ||
box-sizing: border-box; | ||
font-size: 16px; | ||
transition: border-color 0.3s ease-in-out; | ||
} | ||
|
||
input[type="text"]:focus { | ||
border-color: #007BFF; | ||
outline: none; | ||
} | ||
|
||
.submit-button { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
width: 100%; | ||
background-color: #007BFF; | ||
color: white; | ||
padding: 12px 20px; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
font-size: 18px; | ||
margin-top: 20px; | ||
transition: background-color 0.3s ease-in-out; | ||
} | ||
|
||
.submit-button:hover { | ||
background-color: #0056b3; | ||
} | ||
|
||
|
||
.message { | ||
text-align: center; | ||
margin-top: 15px; | ||
padding: 10px; | ||
font-size: 16px; | ||
color: #2c3e50; | ||
border-radius: 5px; | ||
background-color: #e0e0e0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
.mood-logs { | ||
max-width: 600px; | ||
margin: 50px auto; | ||
padding: 20px; | ||
box-shadow: 0 4px 8px rgba(0,0,0,0.1); | ||
border-radius: 8px; | ||
background-color: white; | ||
} | ||
|
||
h2 { | ||
display: flex; | ||
align-items: center; /* This aligns the icon with the text vertically */ | ||
font-size: 24px; /* Adjust text size as needed */ | ||
} | ||
|
||
.icon-large { | ||
font-size: 40px; /* or any other size */ | ||
margin-right: 7px; /* Adds space between the icon and the text */ | ||
} | ||
|
||
.mood-logs h2 { | ||
text-align: center; | ||
color: #333; | ||
} | ||
|
||
ul { | ||
list-style-type: none; | ||
padding: 0; | ||
} | ||
|
||
li { | ||
padding: 10px; | ||
border-bottom: 1px solid #ccc; | ||
} | ||
|
||
li:last-child { | ||
border-bottom: none; | ||
} | ||
|
||
.error { | ||
color: red; | ||
text-align: center; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, { useState } from 'react'; | ||
import axios from 'axios'; | ||
import { Button } from '@mui/material'; | ||
import MoodIcon from '@mui/icons-material/Mood'; | ||
import SendIcon from '@mui/icons-material/Send'; | ||
import '../Assets/Styles/MoodLogging.css'; | ||
|
||
function MoodLogging() { | ||
const [mood, setMood] = useState(''); | ||
const [activities, setActivities] = useState(''); | ||
const [message, setMessage] = useState(''); | ||
|
||
const handleLogMood = async () => { | ||
const token = localStorage.getItem('token'); | ||
if (!mood || !activities) { | ||
setMessage("Both mood and activities are required."); | ||
return; | ||
}if (!token) { | ||
setMessage("You are not logged in."); | ||
return; | ||
} | ||
|
||
try { | ||
const response = await axios.post('/api/user/log_mood', { mood, activities }, { | ||
headers: { | ||
Authorization: `Bearer ${token}` | ||
} | ||
}); | ||
setMessage(response.data.message); | ||
} catch (error) { | ||
setMessage(error.response.data.error); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="mood-logging-container"> | ||
<h1><MoodIcon fontSize="large" /> Track Your Vibes </h1> | ||
<div className="mood-logging"> | ||
<div className="input-group"> | ||
<label htmlFor="mood-input">Mood:</label> | ||
<input id="mood-input" type="text" value={mood} onChange={(e) => setMood(e.target.value)} placeholder="Enter your current mood" /> | ||
|
||
<label htmlFor="activities-input">Activities:</label> | ||
<input id="activities-input" type="text" value={activities} onChange={(e) => setActivities(e.target.value)} placeholder="What are you doing?" /> | ||
</div> | ||
<Button variant="contained" className="submit-button" onClick={handleLogMood} startIcon={<SendIcon />}> | ||
Log Mood | ||
</Button> | ||
{message && <div className="message">{message}</div>} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default MoodLogging; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import axios from 'axios'; | ||
import '../Assets/Styles/MoodLogs.css'; | ||
import ListAltIcon from '@mui/icons-material/ListAlt'; // Icon for mood logs | ||
|
||
function MoodLogs() { | ||
const [moodLogs, setMoodLogs] = useState([]); | ||
const [error, setError] = useState(''); | ||
|
||
useEffect(() => { | ||
const fetchMoodLogs = async () => { | ||
const token = localStorage.getItem('token'); | ||
if (!token) { | ||
setError("You are not logged in."); | ||
return; | ||
} | ||
|
||
try { | ||
const response = await axios.get('/api/user/get_mood_logs', { | ||
headers: { | ||
Authorization: `Bearer ${token}` | ||
} | ||
}); | ||
console.log("Received data:", response.data); // Check what's being received | ||
setMoodLogs(response.data.mood_logs || []); | ||
} catch (error) { | ||
setError(error.response.data.error); | ||
} | ||
}; | ||
|
||
fetchMoodLogs(); | ||
}, []); | ||
const formatDateTime = (dateObject) => { | ||
const options = { year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit' }; | ||
try { | ||
// Extract the date string from the date object | ||
const dateString = dateObject['$date']; | ||
const date = new Date(dateString); | ||
return date.toLocaleDateString("en-US", options) ; | ||
} catch (error) { | ||
console.error("Date parsing error:", error); | ||
return "Invalid Date"; | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="mood-logs"> | ||
<h2><ListAltIcon className="icon-large" />Your Mood Journey</h2> | ||
{error ?<div className="error">{error}</div> : ( | ||
<ul> | ||
{moodLogs.map((log, index) => ( | ||
<li key={index}><div><strong>Mood:</strong> {log.mood}</div> | ||
<div><strong>Activities:</strong> {log.activities}</div> | ||
<div><strong>Timestamp:</strong> {formatDateTime(log.timestamp)}</div></li> | ||
))} | ||
</ul> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default MoodLogs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters