Autók kész
This commit is contained in:
1 parent
ff1db69b85
commit
0ea7fe28b2
8 files changed
+216
-2
No files matched your search
Generated
+58
@@ -12,6 +12,7 @@
|
||||
"daisyui": "^5.7.47",
|
||||
"react": "^19.2.8",
|
||||
"react-dom": "^19.2.8",
|
||||
"react-router-dom": "^7.18.5",
|
||||
"tailwindcss": "^4.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -1537,6 +1538,19 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/cookie": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz",
|
||||
"integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "7.0.6",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
||||
@@ -2656,6 +2670,44 @@
|
||||
"react": "^19.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react-router": {
|
||||
"version": "7.18.5",
|
||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.18.5.tgz",
|
||||
"integrity": "sha512-dTgvcXDOrLPrlLHrcZAqWveiK1hMSqN+rGAJzegP8HtmNkfRxOoshGWBNX3ZJ0cZjOHkRdlUJtaIhZMLLyGyPw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cookie": "^1.0.1",
|
||||
"set-cookie-parser": "^2.6.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=18",
|
||||
"react-dom": ">=18"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"react-dom": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/react-router-dom": {
|
||||
"version": "7.18.5",
|
||||
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.18.5.tgz",
|
||||
"integrity": "sha512-9HcfDMU6JJ/fp6gJZYGwNE6RknVGS4kBjH1HkNw959mCJi70TVwdipQWv2FEol9uGpi+SZTFtVpJPtEQfayeOw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"react-router": "7.18.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=18",
|
||||
"react-dom": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/rolldown": {
|
||||
"version": "1.2.12",
|
||||
"resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.12.tgz",
|
||||
@@ -2705,6 +2757,12 @@
|
||||
"semver": "bin/semver.js"
|
||||
}
|
||||
},
|
||||
"node_modules/set-cookie-parser": {
|
||||
"version": "2.7.3",
|
||||
"resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.3.tgz",
|
||||
"integrity": "sha512-irZHtTqurLna57KQG/s+fzOwv/J6XSH4cs8M/vsrY3uCaQ3S6+QJguAH0WdN47SXlk82voMZ4naWMQf8fdEoIg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/shebang-command": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
"daisyui": "^5.7.47",
|
||||
"react": "^19.2.8",
|
||||
"react-dom": "^19.2.8",
|
||||
"react-router-dom": "^7.18.5",
|
||||
"tailwindcss": "^4.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,11 +1,24 @@
|
||||
import Menu from "./components/Menu";
|
||||
import Main from "./components/Main";
|
||||
import Autok from "./components/Autok";
|
||||
import AutoForm from "./components/AutoForm";
|
||||
|
||||
import {BrowserRouter,Routes,Route,Navigate} from 'react-router-dom';
|
||||
|
||||
|
||||
function App() {
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<BrowserRouter>
|
||||
<Menu/>
|
||||
<Routes>
|
||||
<Route path="/" element={<Main />} />
|
||||
<Route path="/autok" element={<Autok />}/>
|
||||
<Route path="/autoform" element={<AutoForm />}/>
|
||||
<Route path="*" element={<Navigate to="/" />} />
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
|
||||
function Auto({ auto }) {
|
||||
return (
|
||||
<div className="card w-96 bg-emerald-300 card-md shadow-sm m-2">
|
||||
<div className="card-body">
|
||||
<h2 className="card-title">{auto.marka} {auto.tipus}</h2>
|
||||
<p>{auto.kor}</p>
|
||||
<p>{auto.rendszam}</p>
|
||||
<p>{auto.szin}</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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Auto
|
||||
@@ -0,0 +1,44 @@
|
||||
import { useState } from "react"
|
||||
import { useNavigate } from "react-router-dom"
|
||||
|
||||
function AutoForm() {
|
||||
const navigate=useNavigate();
|
||||
|
||||
const[marka,setMarka]=useState("");
|
||||
const[tipus,setTipus]=useState("");
|
||||
const[kor,setKor]=useState(0);
|
||||
const[rendszam,setRendszam]=useState("");
|
||||
const[szin,setSzin]=useState("");
|
||||
|
||||
const adatkuldes=(adat)=>{
|
||||
fetch('http://localhost:3000/autok',{
|
||||
method:"POST",
|
||||
headers:{
|
||||
"Content-type":"application/json"
|
||||
},
|
||||
body:JSON.stringify(adat)
|
||||
})
|
||||
.then(res=>res.text())
|
||||
.then(valasz=>alert(valasz))
|
||||
.catch(err=>alert(err));
|
||||
|
||||
}
|
||||
|
||||
const onSubmit=(e)=>{
|
||||
e.preventDefault();
|
||||
adatkuldes({marka,tipus,kor,rendszam,szin});
|
||||
navigate("/autok");
|
||||
}
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<form onSubmit={onSubmit}>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default AutoForm
|
||||
@@ -0,0 +1,34 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import Auto from "./Auto";
|
||||
|
||||
function Autok() {
|
||||
const[autok,setAutok]=useState([]);
|
||||
const letolt=async ()=>{
|
||||
try {
|
||||
let keres=await fetch('http://localhost:3000/autok');
|
||||
let valasz=await keres.json();
|
||||
|
||||
setAutok(valasz);
|
||||
|
||||
} catch (error) {
|
||||
alert(err);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
useEffect(()=>{
|
||||
letolt();
|
||||
},[])
|
||||
return (
|
||||
<div>
|
||||
<h2 className="text-center font-bold">Autóink</h2>
|
||||
<div className="flex flex-row flex-wrap items-center justify-center">
|
||||
{
|
||||
autok.map((auto)=>(<Auto key={auto.id} auto={auto} />))
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Autok
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
|
||||
function Main() {
|
||||
return (
|
||||
<div className="hero bg-emerald-200 min-h-screen">
|
||||
<div className="hero-content flex-col lg:flex-row-reverse">
|
||||
<img
|
||||
alt="Tailwind CSS hero component"
|
||||
src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fimages.pexels.com%2Fphotos%2F810357%2Fpexels-photo-810357.jpeg%3Fcs%3Dsrgb%26dl%3Dpexels-mike-b-810357.jpg%26fm%3Djpg&f=1&nofb=1&ipt=6b05ccac34f3b594d8185fbedeea4ae957224bdbfd2e9edd1b1392945a885b24&ipo=images"
|
||||
className="max-w-sm rounded-lg shadow-2xl"
|
||||
/>
|
||||
<div>
|
||||
<h1 className="text-5xl font-bold">Box Office News!</h1>
|
||||
<p className="py-6">
|
||||
Provident cupiditate voluptatem et in. Quaerat fugiat ut assumenda excepturi exercitationem
|
||||
quasi. In deleniti eaque aut repudiandae et a id nisi.
|
||||
</p>
|
||||
<button className="btn btn-primary">Get Started</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Main
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Link } from "react-router-dom"
|
||||
|
||||
function Menu() {
|
||||
return (
|
||||
<div className="navbar bg-emerald-300 text-emerald-900 shadow-sm">
|
||||
<div className="flex-1">
|
||||
<Link to="/" className="btn btn-ghost text-xl">Főoldal</Link>
|
||||
</div>
|
||||
<div className="flex-none">
|
||||
<ul className="menu menu-horizontal px-1">
|
||||
<li><Link to="/autok">Autóink</Link></li>
|
||||
<li><Link to="/autoform">Új autó felvitele</Link></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Menu
|
||||
Reference in new issue
Block a user