Skip to content

Commit

Permalink
Feature - Added temporary database connection (#40)
Browse files Browse the repository at this point in the history
* feat - Added date selector elements

* refactor - Moved graph generation code into seperate jsx file

* feat - Added dynamic graph generation

* feat - Implemented responsive progress graph, does not currently fetch information from database

* feat - Added data utils class

* feat - Added temporary get request
  • Loading branch information
Ben-G-Man authored Aug 22, 2024
1 parent 917d5f4 commit eb87dad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
21 changes: 15 additions & 6 deletions fitness_tracker/src/components/GraphDisplay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ function GraphDisplay() {
<Fragment>
<GenerateGraph data={data} />
<input id="dateSelector" type="date" max={endDate} />
<select id="exercise">
<option>Exercise 1</option>
<option>Exercise 2</option>
<option>Exercise 3</option>
<option>Exercise 4</option>
<select id="muscleGroup">
<option>Muscle Group 1</option>
<option>Muscle Group 2</option>
<option>Muscle Group 3</option>
<option>Muscle Group 4</option>
</select>
<select id="periodDropDown">
<option value="7">Week</option>
Expand Down Expand Up @@ -99,6 +99,10 @@ function UpdateGraph(startDate, endDate, setData) {
endDate: A JavaScript Date object corresponding with the period end date.
*/
function FetchPeriod(startDate, endDate) {

/* Temporary get request */
console.log(getData('/exercises/score/' + '2022-01-01', 'GET'));

let data = [];
for (
let nextDate = startDate;
Expand All @@ -107,10 +111,15 @@ function FetchPeriod(startDate, endDate) {
) {
data.push({
date: DateToString(nextDate),
score: Math.floor(Math.random() * 2400)
/* Temp score, to be connected to database */
score: Math.floor(Math.random() * 2000)
});
}
return data;
}

async function getData(path, method) {
return await fetch('http://localhost:4001' + path, {method: method});
}

export default GraphDisplay;
4 changes: 4 additions & 0 deletions fitness_tracker/src/utils/dataUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default async function getData(path, method) {
const response = await fetch('http://localhost:4001' + path, {method: method});
return response;
}

0 comments on commit eb87dad

Please sign in to comment.