From 4a824d9d6553d6e9e780201d7a0bb0cc92172a9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid?= Date: Wed, 18 Feb 2026 13:08:10 +0100 Subject: [PATCH] Initial commit --- backend/autoszalon.db | Bin 12288 -> 12288 bytes package-lock.json | 2 +- package.json | 2 +- src/App.jsx | 39 ++++++++++++++++++++++++++++++- src/components/AutoKartya.jsx | 10 ++++---- src/components/AutoLista.jsx | 3 ++- src/components/FoMenu.jsx | 6 ++--- src/components/Osszefoglalas.jsx | 5 ++-- src/components/UjAutoForm.jsx | 37 +++++++++++++++++++++++------ 9 files changed, 83 insertions(+), 21 deletions(-) diff --git a/backend/autoszalon.db b/backend/autoszalon.db index d76cce00d00a9fbf66bc80a907a40630732247ba..308d662e51deef7a8a4337d6d889ac5dbaced0aa 100644 GIT binary patch delta 211 zcmZojXh@hK&B!rP#+i|0W5N=CE=K+}4E$^Op7K52EGTfDFCvJUi-A{=NtA`x)6>V9 z{X+KPmD#MZUJXVDMrOJOM!JR;3WkPOrj}MlCVCc@CJNdH237_J_+=Rw7>-Z2mCyGL aVjnU&^9ozGBCg)yZNU) In*bvd0RCzp5C8xG 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." />