-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
date can be passed in, weekly stats, journal
- Loading branch information
1 parent
6c78a98
commit 19a69da
Showing
10 changed files
with
180 additions
and
6 deletions.
There are no files selected for viewing
Binary file not shown.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,38 @@ | ||
.journal-container { | ||
max-width: 600px; | ||
margin: auto; | ||
background-color: #f5f5f5; | ||
padding: 20px; | ||
border-radius: 5px; | ||
box-shadow: 0 0 10px rgba(0,0,0,0.1); | ||
} | ||
|
||
.exercise-journal-data { | ||
margin-bottom: 10px; | ||
padding-top: 20px; | ||
} | ||
|
||
.date-range { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 10px; | ||
margin-bottom: 20px; | ||
} | ||
|
||
ul { | ||
padding-left: 0; | ||
} | ||
|
||
li { | ||
list-style-type: none; | ||
background: #e0e0e0; | ||
margin-bottom: 5px; | ||
padding: 10px; | ||
border-radius: 3px; | ||
} | ||
|
||
.button-small { | ||
padding: 5px 10px; | ||
font-size: 0.8rem; | ||
} |
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,57 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import axios from 'axios'; | ||
import { Button } from 'react-bootstrap'; | ||
import moment from 'moment'; | ||
import './journal.css'; | ||
|
||
const Journal = ({ currentUser }) => { | ||
const [startDate, setStartDate] = useState(moment().startOf('week').toDate()); | ||
const [endDate, setEndDate] = useState(moment().endOf('week').toDate()); | ||
const [exercises, setExercises] = useState([]); | ||
|
||
const fetchExercises = async () => { | ||
try { | ||
const url = `http://localhost:5050/api/stats/weekly/?user=${currentUser}&start=${moment(startDate).format('YYYY-MM-DD')}&end=${moment(endDate).format('YYYY-MM-DD')}`; | ||
const response = await axios.get(url); | ||
console.log('API Response:', response.data); | ||
setExercises(response.data.stats); // Updated this line | ||
} catch (error) { | ||
console.error('Failed to fetch exercises', error); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
fetchExercises(); | ||
}, [currentUser, startDate, endDate]); | ||
|
||
const goToPreviousWeek = () => { | ||
setStartDate(moment(startDate).subtract(1, 'weeks').startOf('week').toDate()); | ||
setEndDate(moment(endDate).subtract(1, 'weeks').endOf('week').toDate()); | ||
}; | ||
|
||
const goToNextWeek = () => { | ||
setStartDate(moment(startDate).add(1, 'weeks').startOf('week').toDate()); | ||
setEndDate(moment(endDate).add(1, 'weeks').endOf('week').toDate()); | ||
}; | ||
|
||
return ( | ||
<div className="journal-container"> | ||
<h4>Weekly Exercise Journal</h4> | ||
<br></br> | ||
<div className="date-range"> | ||
<Button className="button-small" onClick={goToPreviousWeek}>← Previous</Button> | ||
<span>{moment(startDate).format('YYYY-MM-DD')} to {moment(endDate).format('YYYY-MM-DD')}</span> | ||
<Button className="button-small" onClick={goToNextWeek}>Next →</Button> | ||
</div> | ||
<ul> | ||
{exercises && exercises.length > 0 && exercises[0].exercises.map((exercise, index) => ( | ||
<li key={index} className="exercise-journal-data"> | ||
{exercise.exerciseType} - {exercise.totalDuration} minutes | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Journal; |
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
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