-
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.
Add useEffect and useContext to fetch and update goals
- Loading branch information
Showing
6 changed files
with
134 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"id": 2, | ||
"details": "Backend", | ||
"frequency": 1, | ||
"period": "día", | ||
"icon": "📚", | ||
"finish": 52, | ||
"limitDate": "2030-12-31", | ||
"completed": 5 | ||
} |
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,52 @@ | ||
[ | ||
{ | ||
"id": 1, | ||
"details": "Correr por 30 minutos", | ||
"frequency": 1, | ||
"period": "día", | ||
"icon": "🏃♂️", | ||
"finish": 52, | ||
"limitDate": "2030-12-31", | ||
"completed": 5 | ||
}, | ||
{ | ||
"id": 2, | ||
"details": "Leer 30 minutos", | ||
"frequency": 1, | ||
"period": "día", | ||
"icon": "📚", | ||
"finish": 52, | ||
"limitDate": "2030-12-31", | ||
"completed": 5 | ||
}, | ||
{ | ||
"id": 3, | ||
"details": "Hacer 30 minutos de meditación", | ||
"frequency": 1, | ||
"period": "día", | ||
"icon": "🧘♂️", | ||
"finish": 52, | ||
"limitDate": "2030-12-31", | ||
"completed": 5 | ||
}, | ||
{ | ||
"id": 4, | ||
"details": "Hacer 30 minutos de ejercicio", | ||
"frequency": 1, | ||
"period": "día", | ||
"icon": "🏋️♂️", | ||
"finish": 52, | ||
"limitDate": "2030-12-31", | ||
"completed": 5 | ||
}, | ||
{ | ||
"id": 5, | ||
"details": "Hacer 30 minutos de yoga", | ||
"frequency": 1, | ||
"period": "día", | ||
"icon": "🧘♂️", | ||
"finish": 52, | ||
"limitDate": "2030-12-31", | ||
"completed": 5 | ||
} | ||
] |
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
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,32 @@ | ||
export async function requestGoals() { | ||
const response = await fetch('/goals.json'); | ||
const goals = await response.json(); | ||
return goals; | ||
} | ||
|
||
export async function requestGoal() { | ||
const response = await fetch('/goal.json'); | ||
const goal = await response.json(); | ||
return goal; | ||
} | ||
|
||
export async function createGoal() { | ||
const response = await fetch('/goal.json'); | ||
const newGoal = await response.json(); | ||
console.log('Meta creada: ',newGoal); | ||
return newGoal; | ||
} | ||
|
||
export async function updateGoal(goal) { | ||
const response = await fetch('/goal.json'); | ||
const updatedGoal = await response.json(); | ||
console.log('Meta actualizada: ',updatedGoal); | ||
return updatedGoal; | ||
} | ||
|
||
export async function deleteGoal() { | ||
const response = await fetch('/goal.json'); | ||
const deletedGoal = await response.json(); | ||
console.log('Meta eliminada: ',deletedGoal.id); | ||
return deletedGoal.id; | ||
} |