Módosítás
This commit is contained in:
1 parent
909e756d7b
commit
0dfccd43d5
4 files changed
+38
-4
No files matched your search
@@ -101,6 +101,18 @@
|
|||||||
"name": "kotyogós",
|
"name": "kotyogós",
|
||||||
"roast": "dark",
|
"roast": "dark",
|
||||||
"price": "720"
|
"price": "720"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "0koPruoTLf4",
|
||||||
|
"name": "kotyogós22",
|
||||||
|
"roast": "light",
|
||||||
|
"price": "420"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "2_AY_0pvaU0",
|
||||||
|
"name": "kotyogós33",
|
||||||
|
"roast": "dark",
|
||||||
|
"price": "500"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"$schema": "./node_modules/json-server/schema.json"
|
"$schema": "./node_modules/json-server/schema.json"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import Main from "./components/Main"
|
|||||||
import Menu from "./components/Menu"
|
import Menu from "./components/Menu"
|
||||||
import Coffees from "./components/Coffees"
|
import Coffees from "./components/Coffees"
|
||||||
import CoffeeForm from "./components/CoffeeForm"
|
import CoffeeForm from "./components/CoffeeForm"
|
||||||
|
import CoffeeForm2 from "./components/CoffeeForm2"
|
||||||
|
|
||||||
import {BrowserRouter,Routes,Route,Navigate} from 'react-router-dom'
|
import {BrowserRouter,Routes,Route,Navigate} from 'react-router-dom'
|
||||||
|
|
||||||
@@ -14,7 +15,7 @@ function App() {
|
|||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<Main />} />
|
<Route path="/" element={<Main />} />
|
||||||
<Route path="/coffees" element={<Coffees />} />
|
<Route path="/coffees" element={<Coffees />} />
|
||||||
<Route path="/coffeeform" element={<CoffeeForm />} />
|
<Route path="/coffeeform" element={<CoffeeForm2 />} />
|
||||||
<Route path="*" element={<Navigate to="/" />} />
|
<Route path="*" element={<Navigate to="/" />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
|
|||||||
@@ -1,6 +1,17 @@
|
|||||||
|
import { useNavigate } from "react-router-dom"
|
||||||
|
|
||||||
function Coffee({ coffee }) {
|
function Coffee({ coffee }) {
|
||||||
|
|
||||||
|
const navigate=useNavigate();
|
||||||
|
|
||||||
|
const modositas=(coffee)=>{
|
||||||
|
navigate("/coffeeform",{state:{coffee}});
|
||||||
|
}
|
||||||
|
|
||||||
|
const torles=(coffee)=>{
|
||||||
|
//fetch, delete metódussal
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="card w-96 bg-blue-200 card-md shadow-sm m-2">
|
<div className="card w-96 bg-blue-200 card-md shadow-sm m-2">
|
||||||
<div className="card-body">
|
<div className="card-body">
|
||||||
@@ -8,8 +19,8 @@ function Coffee({ coffee }) {
|
|||||||
<p>Roast:{coffee.roast}</p>
|
<p>Roast:{coffee.roast}</p>
|
||||||
<p>Price:{coffee.price}</p>
|
<p>Price:{coffee.price}</p>
|
||||||
<div className="justify-end card-actions">
|
<div className="justify-end card-actions">
|
||||||
<button className="btn btn-primary">Módosítás</button>
|
<button onClick={()=>modositas(coffee)} className="btn btn-primary">Módosítás</button>
|
||||||
<button className="btn btn-primary">Törlés</button>
|
<button onClick={()=>torles(coffee)} className="btn btn-primary">Törlés</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -36,6 +36,16 @@ function CoffeeForm2() {
|
|||||||
const[formData,setFormData]=useState(formObj);
|
const[formData,setFormData]=useState(formObj);
|
||||||
|
|
||||||
const adatkuldes=(adat)=>{
|
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