axios-utils-lts 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +191 -0
- package/package.json +12 -0
package/index.js
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
module.exports = `
|
|
2
|
+
|
|
3
|
+
path:
|
|
4
|
+
receptkonyv\frontend\src\components\KategoriaSelect.js
|
|
5
|
+
|
|
6
|
+
components mappa:
|
|
7
|
+
1. kategoriaSelect.js
|
|
8
|
+
function KategoriaSelect(props) {
|
|
9
|
+
return (
|
|
10
|
+
<select onChange={e => props.onChange(e.target.value)}>
|
|
11
|
+
<option value="">Összes kategória</option>
|
|
12
|
+
{props.kategoriak.map(k => (
|
|
13
|
+
<option key={k.id} value={k.id}>
|
|
14
|
+
{k.nev}
|
|
15
|
+
</option>
|
|
16
|
+
))}
|
|
17
|
+
</select>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default KategoriaSelect;
|
|
22
|
+
|
|
23
|
+
2. ReceptReszlet.js
|
|
24
|
+
function ReceptReszlet(props) {
|
|
25
|
+
if (!props.recept) return null;
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div className="details">
|
|
29
|
+
<h2>{props.recept.nev}</h2>
|
|
30
|
+
<p>{props.recept.leiras}</p>
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default ReceptReszlet;
|
|
36
|
+
|
|
37
|
+
3. ReceptTabla.js
|
|
38
|
+
function ReceptTabla(props) {
|
|
39
|
+
return (
|
|
40
|
+
<table border="1" width="100%">
|
|
41
|
+
<thead>
|
|
42
|
+
<tr>
|
|
43
|
+
<th>Név</th>
|
|
44
|
+
<th>Kategória</th>
|
|
45
|
+
</tr>
|
|
46
|
+
</thead>
|
|
47
|
+
<tbody>
|
|
48
|
+
{props.receptek.map(r => (
|
|
49
|
+
<tr key={r.id} onClick={() => props.onSelect(r)}>
|
|
50
|
+
<td>{r.nev}</td>
|
|
51
|
+
<td>{r.kategoria ? r.kategoria.nev : ""}</td>
|
|
52
|
+
</tr>
|
|
53
|
+
))}
|
|
54
|
+
</tbody>
|
|
55
|
+
</table>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default ReceptTabla;
|
|
60
|
+
|
|
61
|
+
services mappa:
|
|
62
|
+
1. api.js
|
|
63
|
+
const API_URL = "http://127.0.0.1:8000/api";
|
|
64
|
+
|
|
65
|
+
export async function getKategoriak() {
|
|
66
|
+
const res = await fetch(`/**${API_URL}/kategoriak*/`);
|
|
67
|
+
return res.json();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export async function getReceptek() {
|
|
71
|
+
const res = await fetch(`/*${API_URL}/receptek*/`);
|
|
72
|
+
return res.json();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export async function getReceptekKategoriaval(katId) {
|
|
76
|
+
const res = await fetch(`/*${API_URL}/receptek/kategoria/${katId}*/`);
|
|
77
|
+
return res.json();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
App.css
|
|
81
|
+
/* ===== Alap konténer ===== */
|
|
82
|
+
.container {
|
|
83
|
+
width: 95%;
|
|
84
|
+
max-width: 900px;
|
|
85
|
+
margin: auto;
|
|
86
|
+
font-family: Arial, sans-serif;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* ===== Táblázat ===== */
|
|
90
|
+
table {
|
|
91
|
+
width: 100%;
|
|
92
|
+
border-collapse: collapse;
|
|
93
|
+
margin-top: 10px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
th, td {
|
|
97
|
+
border: 1px solid #ccc;
|
|
98
|
+
padding: 8px;
|
|
99
|
+
text-align: left;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* váltott sorok */
|
|
103
|
+
tbody tr:nth-child(even) {
|
|
104
|
+
background-color: #f2f2f2;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
tbody tr {
|
|
108
|
+
cursor: pointer;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* ===== Recept részletek ===== */
|
|
112
|
+
.details {
|
|
113
|
+
margin-top: 20px;
|
|
114
|
+
padding: 10px;
|
|
115
|
+
border: 1px solid #ccc;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* ===== Mobil nézet ===== */
|
|
119
|
+
@media (max-width: 600px) {
|
|
120
|
+
|
|
121
|
+
table {
|
|
122
|
+
font-size: 14px;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
th:nth-child(2),
|
|
126
|
+
td:nth-child(2) {
|
|
127
|
+
display: none;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.details {
|
|
131
|
+
font-size: 14px;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
App.js
|
|
137
|
+
import { useEffect, useState } from "react";
|
|
138
|
+
import "./App.css";
|
|
139
|
+
|
|
140
|
+
import {
|
|
141
|
+
getKategoriak,
|
|
142
|
+
getReceptek,
|
|
143
|
+
getReceptekKategoriaval
|
|
144
|
+
} from "./services/api";
|
|
145
|
+
|
|
146
|
+
import KategoriaSelect from "./components/KategoriaSelect";
|
|
147
|
+
import ReceptTabla from "./components/ReceptTabla";
|
|
148
|
+
import ReceptReszlet from "./components/ReceptReszlet";
|
|
149
|
+
|
|
150
|
+
function App() {
|
|
151
|
+
const [kategoriak, setKategoriak] = useState([]);
|
|
152
|
+
const [receptek, setReceptek] = useState([]);
|
|
153
|
+
const [kivalasztott, setKivalasztott] = useState(null);
|
|
154
|
+
|
|
155
|
+
useEffect(() => {
|
|
156
|
+
getKategoriak().then(setKategoriak);
|
|
157
|
+
getReceptek().then(setReceptek);
|
|
158
|
+
}, []);
|
|
159
|
+
|
|
160
|
+
function handleSzures(katId) {
|
|
161
|
+
setKivalasztott(null);
|
|
162
|
+
|
|
163
|
+
if (katId === "") {
|
|
164
|
+
getReceptek().then(setReceptek);
|
|
165
|
+
} else {
|
|
166
|
+
getReceptekKategoriaval(katId).then(setReceptek);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
<div className="container">
|
|
172
|
+
<h1>Receptkönyv</h1>
|
|
173
|
+
|
|
174
|
+
<KategoriaSelect
|
|
175
|
+
kategoriak={kategoriak}
|
|
176
|
+
onChange={handleSzures}
|
|
177
|
+
/>
|
|
178
|
+
|
|
179
|
+
<ReceptTabla
|
|
180
|
+
receptek={receptek}
|
|
181
|
+
onSelect={setKivalasztott}
|
|
182
|
+
/>
|
|
183
|
+
|
|
184
|
+
<ReceptReszlet recept={kivalasztott} />
|
|
185
|
+
</div>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export default App;
|
|
190
|
+
|
|
191
|
+
`;
|
package/package.json
ADDED