ExerciseTracker/exercises-ui/src/App.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-06-04 01:22:40 -04:00
import "./App.css";
import React from "react";
import { BrowserRouter as Router, Route } from "react-router-dom";
import HomePage from "./pages/HomePage";
import CreatePage from "./pages/CreatePage";
import EditPage from "./pages/EditPage";
2022-06-04 03:18:04 -04:00
import { useState } from "react";
import { Link } from "react-router-dom";
2022-06-04 01:22:40 -04:00
function App() {
2022-06-04 03:18:04 -04:00
const [exerciseToEdit, setExerciseToEdit] = useState();
2022-06-04 01:22:40 -04:00
return (
<div className="App">
<Router>
<div className="App-header">
2022-06-04 03:18:04 -04:00
<header>
<h1>Exercise Tracker</h1>
<p>Create, edit, and delete exercises</p>
</header>
2022-06-04 01:22:40 -04:00
<Route path="/" exact>
2022-06-04 03:18:04 -04:00
<HomePage setExerciseToEdit={setExerciseToEdit} />
2022-06-04 01:22:40 -04:00
</Route>
<Route path="/create">
<CreatePage />
</Route>
<Route path="/edit">
2022-06-04 03:18:04 -04:00
<EditPage exerciseToEdit={exerciseToEdit} />
2022-06-04 01:22:40 -04:00
</Route>
</div>
2022-06-04 03:18:04 -04:00
<nav>
<div>
<Link to="/">Home </Link>
</div>
<div>
<Link to="/create">Create</Link>
</div>
</nav>
<footer>© 2022 Andrew Scott</footer>
2022-06-04 01:22:40 -04:00
</Router>
</div>
);
}
export default App;