mirror of
https://codeberg.org/andyscott/ExerciseTracker.git
synced 2024-12-21 11:43:10 -05:00
Correction to function param and added redirect to home after edit
This commit is contained in:
parent
ec4f910562
commit
552187d53e
1 changed files with 6 additions and 4 deletions
|
@ -4,9 +4,11 @@ import { Link } from "react-router-dom";
|
||||||
import { useHistory } from "react-router-dom";
|
import { useHistory } from "react-router-dom";
|
||||||
import "../App.css";
|
import "../App.css";
|
||||||
|
|
||||||
function HomePage() {
|
function HomePage({ setExerciseToEdit }) {
|
||||||
const [exercises, setExercises] = useState([]);
|
const [exercises, setExercises] = useState([]);
|
||||||
|
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
const onDelete = async (_id) => {
|
const onDelete = async (_id) => {
|
||||||
const response = await fetch(`/exercises/${_id}`, { method: "DELETE" });
|
const response = await fetch(`/exercises/${_id}`, { method: "DELETE" });
|
||||||
if (response.status === 204) {
|
if (response.status === 204) {
|
||||||
|
@ -19,8 +21,8 @@ function HomePage() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onEdit = async (exerciseToEdit) => {
|
const onEdit = async (exerciseToEdit) => {
|
||||||
//setExerciseToEdit(exerciseToEdit);
|
setExerciseToEdit(exerciseToEdit);
|
||||||
//history.push("/edit");
|
history.push("/edit");
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadExercises = async () => {
|
const loadExercises = async () => {
|
||||||
|
@ -41,7 +43,7 @@ function HomePage() {
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
onEdit={onEdit}
|
onEdit={onEdit}
|
||||||
></ExerciseList>
|
></ExerciseList>
|
||||||
<div className="App-link">
|
<div>
|
||||||
<Link to="/create">Create</Link>
|
<Link to="/create">Create</Link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue