Skip to content

Commit eb87dad

Browse files
authored
Feature - Added temporary database connection (#40)
* 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
1 parent 917d5f4 commit eb87dad

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

fitness_tracker/src/components/GraphDisplay.jsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ function GraphDisplay() {
1818
<Fragment>
1919
<GenerateGraph data={data} />
2020
<input id="dateSelector" type="date" max={endDate} />
21-
<select id="exercise">
22-
<option>Exercise 1</option>
23-
<option>Exercise 2</option>
24-
<option>Exercise 3</option>
25-
<option>Exercise 4</option>
21+
<select id="muscleGroup">
22+
<option>Muscle Group 1</option>
23+
<option>Muscle Group 2</option>
24+
<option>Muscle Group 3</option>
25+
<option>Muscle Group 4</option>
2626
</select>
2727
<select id="periodDropDown">
2828
<option value="7">Week</option>
@@ -99,6 +99,10 @@ function UpdateGraph(startDate, endDate, setData) {
9999
endDate: A JavaScript Date object corresponding with the period end date.
100100
*/
101101
function FetchPeriod(startDate, endDate) {
102+
103+
/* Temporary get request */
104+
console.log(getData('/exercises/score/' + '2022-01-01', 'GET'));
105+
102106
let data = [];
103107
for (
104108
let nextDate = startDate;
@@ -107,10 +111,15 @@ function FetchPeriod(startDate, endDate) {
107111
) {
108112
data.push({
109113
date: DateToString(nextDate),
110-
score: Math.floor(Math.random() * 2400)
114+
/* Temp score, to be connected to database */
115+
score: Math.floor(Math.random() * 2000)
111116
});
112117
}
113118
return data;
114119
}
115120

121+
async function getData(path, method) {
122+
return await fetch('http://localhost:4001' + path, {method: method});
123+
}
124+
116125
export default GraphDisplay;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default async function getData(path, method) {
2+
const response = await fetch('http://localhost:4001' + path, {method: method});
3+
return response;
4+
}

0 commit comments

Comments
 (0)