diff --git a/backend/autoszalon.db b/backend/autoszalon.db index d76cce0..308d662 100644 Binary files a/backend/autoszalon.db and b/backend/autoszalon.db differ diff --git a/package-lock.json b/package-lock.json index 503f10c..05fb87e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "eslint-plugin-react-hooks": "^7.0.1", "eslint-plugin-react-refresh": "^0.4.24", "globals": "^16.5.0", - "vite": "^7.2.4" + "vite": "^7.3.1" } }, "node_modules/@babel/code-frame": { diff --git a/package.json b/package.json index c3eed43..c721055 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,6 @@ "eslint-plugin-react-hooks": "^7.0.1", "eslint-plugin-react-refresh": "^0.4.24", "globals": "^16.5.0", - "vite": "^7.2.4" + "vite": "^7.3.1" } } diff --git a/src/App.jsx b/src/App.jsx index f3bd7ca..542bfac 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -11,7 +11,40 @@ import UjAutoForm from './components/UjAutoForm' function App() { const [autok, setAutok] = useState([]) - + useEffect(() => { + fetch('http://localhost:3000/api/autok') + .then(res => res.json()) + .then(data => setAutok(data)) + .catch(error => console.error('Hiba', error)); + }, []) + + const hozzaAdas = (auto) => { + const requestOptions = { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(auto) + }; + fetch('http://localhost:3000/api/autok', requestOptions) + .then(response => response.json()) + .then(() => { + fetch('http://localhost:3000/api/autok') + .then(res => res.json()) + .then(data => setAutok(data)); + }); + } + + const elemTorles = (id) => { + const requestOptions = { + method: 'DELETE', + }; + fetch(`http://localhost:3000/api/autok/${id}`, requestOptions) + .then(response => response.json()) + .then(() => { + fetch('http://localhost:3000/api/autok') + .then(res => res.json()) + .then(data => setAutok(data)); + }); + } return ( @@ -27,6 +60,10 @@ function App() { }> + }/> + }/> + }/> + }/> {/* 3 alútvonal létrehozása: -összefoglalás (alapértelmezett legyen) -autók listája diff --git a/src/components/AutoKartya.jsx b/src/components/AutoKartya.jsx index 5c87c16..b3c237e 100644 --- a/src/components/AutoKartya.jsx +++ b/src/components/AutoKartya.jsx @@ -6,11 +6,11 @@ const AutoKartya = ({ auto, torles }) => { return (
-
Márka
-
Típus
-

Évjárat - Szín - Uzemanyag

-
Ár: xxxxxxxxxxxx Ft.
- {/* Törlés gomb */} +
{auto.marka}
+
{auto.tipus}
+

{auto.evjarat} - {auto.szin} - {auto.uzemanyag}

+
Ár: {auto.ar} Ft.
+
) diff --git a/src/components/AutoLista.jsx b/src/components/AutoLista.jsx index 8ec8888..ac5646b 100644 --- a/src/components/AutoLista.jsx +++ b/src/components/AutoLista.jsx @@ -4,7 +4,8 @@ import AutoKartya from './AutoKartya' const AutoLista = ({autok, torles}) => { return (
- {/* Az autókat megjelenítő komponensek */} + {autok.map(auto => ())} +
) } diff --git a/src/components/FoMenu.jsx b/src/components/FoMenu.jsx index 8f6b61c..5f6e364 100644 --- a/src/components/FoMenu.jsx +++ b/src/components/FoMenu.jsx @@ -5,9 +5,9 @@ const FoMenu = () => { return ( ) diff --git a/src/components/Osszefoglalas.jsx b/src/components/Osszefoglalas.jsx index c021dc5..c0f42b5 100644 --- a/src/components/Osszefoglalas.jsx +++ b/src/components/Osszefoglalas.jsx @@ -2,8 +2,9 @@ import React from 'react' const Osszefoglalas = () => { return ( -
Összefoglalas - egy rövid statisztika tetszőleges formátumban az autók számáról, azok összértékéröl, - a legrégebbi és a legújabb évjáratról. +
+ Autók száma: +
) } diff --git a/src/components/UjAutoForm.jsx b/src/components/UjAutoForm.jsx index 07828ce..3676466 100644 --- a/src/components/UjAutoForm.jsx +++ b/src/components/UjAutoForm.jsx @@ -1,17 +1,40 @@ import React from 'react' +import { use } from 'react'; import { useState } from 'react' const UjAutoForm = ({hozzaad}) => { + const [marka, setMarka] = useState(""); + const [tipus, setTipus] = useState(""); + const [evjarat, setEvjarat] = useState(""); + const [szin, setSzin] = useState(""); + const [ar, setAr] = useState(""); + const [uzemanyag, setUzemanyag] = useState(""); + + const formSubmit = (sub) => { + sub.preventDefault(); + + const hozzaadAuto = { marka, tipus, evjarat, szin, ar, uzemanyag }; + hozzaad(hozzaadAuto); + + setMarka(""); + setTipus(""); + setEvjarat(""); + setSzin(""); + setAr(""); + setUzemanyag(""); + }; + + return (
-
+
- setMarka(sub.target.value)} required > @@ -24,23 +47,23 @@ const UjAutoForm = ({hozzaad}) => {
- + setTipus(sub.target.value)} required />
- + setEvjarat(sub.target.value)} required />
- + setSzin(sub.target.value)} />
- + setAr(sub.target.value)} required />
- + setUzemanyag(sub.target.value)} placeholder="benzin, dízel, elektromos stb." />