Módosítás
This commit is contained in:
1 parent
909e756d7b
commit
0dfccd43d5
4 files changed
+38
-4
No files matched your search
@@ -2,6 +2,7 @@ import Main from "./components/Main"
|
||||
import Menu from "./components/Menu"
|
||||
import Coffees from "./components/Coffees"
|
||||
import CoffeeForm from "./components/CoffeeForm"
|
||||
import CoffeeForm2 from "./components/CoffeeForm2"
|
||||
|
||||
import {BrowserRouter,Routes,Route,Navigate} from 'react-router-dom'
|
||||
|
||||
@@ -14,7 +15,7 @@ function App() {
|
||||
<Routes>
|
||||
<Route path="/" element={<Main />} />
|
||||
<Route path="/coffees" element={<Coffees />} />
|
||||
<Route path="/coffeeform" element={<CoffeeForm />} />
|
||||
<Route path="/coffeeform" element={<CoffeeForm2 />} />
|
||||
<Route path="*" element={<Navigate to="/" />} />
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
|
||||
import { useNavigate } from "react-router-dom"
|
||||
|
||||
function Coffee({ coffee }) {
|
||||
|
||||
const navigate=useNavigate();
|
||||
|
||||
const modositas=(coffee)=>{
|
||||
navigate("/coffeeform",{state:{coffee}});
|
||||
}
|
||||
|
||||
const torles=(coffee)=>{
|
||||
//fetch, delete metódussal
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="card w-96 bg-blue-200 card-md shadow-sm m-2">
|
||||
<div className="card-body">
|
||||
@@ -8,8 +19,8 @@ function Coffee({ coffee }) {
|
||||
<p>Roast:{coffee.roast}</p>
|
||||
<p>Price:{coffee.price}</p>
|
||||
<div className="justify-end card-actions">
|
||||
<button className="btn btn-primary">Módosítás</button>
|
||||
<button className="btn btn-primary">Törlés</button>
|
||||
<button onClick={()=>modositas(coffee)} className="btn btn-primary">Módosítás</button>
|
||||
<button onClick={()=>torles(coffee)} className="btn btn-primary">Törlés</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -36,6 +36,16 @@ function CoffeeForm2() {
|
||||
const[formData,setFormData]=useState(formObj);
|
||||
|
||||
const adatkuldes=(adat)=>{
|
||||
fetch(url,{
|
||||
method:method,
|
||||
headers:{
|
||||
"Content-type":"application/json"
|
||||
},
|
||||
body:JSON.stringify(adat)
|
||||
})
|
||||
.then(res=>res.text())
|
||||
.then(valasz=>alert(valasz))
|
||||
.catch(err=>alert(err));
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user