-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
298 lines (274 loc) · 14.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<!DOCTYPE html>
<html lang="cs">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>POS Systém pro Vily</title>
<!-- Tailwind CSS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.js"></script>
<!-- React -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.production.min.js"></script>
<!-- Babel pro JSX -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
<!-- Lucide ikony -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/lucide/0.263.1/lucide.min.js"></script>
</head>
<body>
<div id="root"></div>
<script type="text/babel">
const { useState } = React;
const { Euro, DollarSign, Home, ShoppingCart, Trash2 } = lucide;
// Definice konstant
const VILLAS = {
OH_YEAH: {
name: 'OH YEAH vila',
theme: 'bg-pink-500',
textTheme: 'text-pink-500'
},
AMAZING_POOL: {
name: 'Amazing Pool vila',
theme: 'bg-cyan-500',
textTheme: 'text-cyan-500'
},
LITTLE_CASTLE: {
name: 'Little Castle vila',
theme: 'bg-indigo-500',
textTheme: 'text-indigo-500'
}
};
const PRODUCTS = {
DRINKS_CZK: [
{ id: 'budvar', name: 'Budvar', price: 59, currency: 'CZK', image: 'budvar.png' },
{ id: 'malibu', name: 'Malibu', price: 99, currency: 'CZK', image: 'malibu.png' },
{ id: 'jack', name: 'Jack s colou', price: 99, currency: 'CZK', image: 'jack.png' },
{ id: 'moscow', name: 'Moscow Mule', price: 99, currency: 'CZK', image: 'moscow.png' },
{ id: 'gin', name: 'Gin-Tonic', price: 99, currency: 'CZK', image: 'gin.png' },
{ id: 'mojito', name: 'Mojito', price: 99, currency: 'CZK', image: 'mojito.png' },
{ id: 'prosecco', name: 'Prosecco', price: 390, currency: 'CZK', image: 'prosecco.png' },
],
AMAZING_POOL_EXTRA: [
{ id: 'cola', name: 'Coca-Cola', price: 32, currency: 'CZK', image: 'cola.png' },
{ id: 'sprite', name: 'Sprite', price: 32, currency: 'CZK', image: 'sprite.png' },
{ id: 'redbull', name: 'Red Bull', price: 59, currency: 'CZK', image: 'redbull.png' },
],
ITEMS_EUR: [
{ id: 'beer30', name: 'Sud piva 30l', price: 125, currency: 'EUR', image: 'keg30.png' },
{ id: 'beer50', name: 'Sud piva 50l', price: 175, currency: 'EUR', image: 'pivo50.png' },
{ id: 'gas', name: 'Plyn', price: 12, currency: 'EUR', image: 'Plyn.png' },
{ id: 'grill', name: 'Gril', price: 20, currency: 'EUR', image: 'grill.png' },
]
};
const EXCHANGE_RATE = 25;
function POSSystem() {
const [selectedVilla, setSelectedVilla] = useState(VILLAS.OH_YEAH);
const [cart, setCart] = useState([]);
const [showQuantityModal, setShowQuantityModal] = useState(false);
const [selectedProduct, setSelectedProduct] = useState(null);
const [displayCurrency, setDisplayCurrency] = useState('CZK');
const [cityTax, setCityTax] = useState({ guests: 0, nights: 0 });
const [wellness, setWellness] = useState(0);
const [discount, setDiscount] = useState(false);
const addToCart = (product, quantity) => {
const existingItem = cart.find(item => item.product.id === product.id);
if (existingItem) {
setCart(cart.map(item =>
item.product.id === product.id
? { ...item, quantity: item.quantity + quantity }
: item
));
} else {
setCart([...cart, { product, quantity }]);
}
};
const removeFromCart = (productId) => {
setCart(cart.filter(item => item.product.id !== productId));
};
const calculateTotal = () => {
let total = cart.reduce((sum, item) => {
const price = item.product.currency === 'EUR'
? item.product.price * EXCHANGE_RATE
: item.product.price;
return sum + (price * item.quantity);
}, 0);
total += wellness * EXCHANGE_RATE;
if (discount) {
total = total * 0.9;
}
const cityTaxAmount = cityTax.guests * cityTax.nights * 2 * EXCHANGE_RATE;
total += cityTaxAmount;
return displayCurrency === 'EUR' ? total / EXCHANGE_RATE : total;
};
const getAvailableProducts = () => {
let products = [...PRODUCTS.DRINKS_CZK, ...PRODUCTS.ITEMS_EUR];
if (selectedVilla.name === VILLAS.AMAZING_POOL.name) {
products = [...products, ...PRODUCTS.AMAZING_POOL_EXTRA];
}
return products;
};
return (
<div className="max-w-lg mx-auto p-4 bg-gray-50 pb-32">
{/* Villa Selection */}
<div className="mb-6 space-y-2">
<h1 className="text-2xl font-bold mb-4">Výběr vily</h1>
<div className="grid grid-cols-1 gap-2">
{Object.values(VILLAS).map(villa => (
<button
key={villa.name}
onClick={() => setSelectedVilla(villa)}
className={`p-4 text-white rounded-lg ${villa.theme} ${
selectedVilla.name === villa.name ? 'ring-2 ring-offset-2' : ''
}`}
>
{villa.name}
</button>
))}
</div>
</div>
{/* Products Grid */}
<div className="mb-6">
<h2 className="text-xl font-bold mb-4">Produkty</h2>
<div className="grid grid-cols-2 gap-4">
{getAvailableProducts().map(product => (
<button
key={product.id}
onClick={() => {
setSelectedProduct(product);
setShowQuantityModal(true);
}}
className="p-4 bg-white border rounded-lg hover:shadow-md transition-shadow"
>
<div className="aspect-square mb-2">
<img
src={product.image}
alt={product.name}
className="w-full h-full object-contain"
/>
</div>
<div className={`font-bold ${selectedVilla.textTheme}`}>
{product.price} {product.currency}
</div>
</button>
))}
</div>
</div>
{/* Cart */}
<div className="mb-6 p-4 bg-white border rounded-lg">
<h2 className="text-xl font-bold mb-4">Košík</h2>
{cart.map(item => (
<div key={item.product.id} className="flex items-center mb-2 p-2 bg-gray-50 rounded">
<img
src={item.product.image}
alt={item.product.name}
className="w-12 h-12 object-contain mr-2"
/>
<div className="flex-grow">
<div className="font-medium">{item.product.name}</div>
<div className="text-sm text-gray-600">x {item.quantity}</div>
</div>
<div className="flex items-center space-x-2">
<div className="font-medium">
{(item.product.currency === 'EUR'
? item.product.price * item.quantity
: item.product.price * item.quantity / (displayCurrency === 'EUR' ? EXCHANGE_RATE : 1)
).toFixed(2)} {displayCurrency}
</div>
<button
onClick={() => removeFromCart(item.product.id)}
className="p-1 text-red-500 hover:bg-red-50 rounded"
>
<Trash2 size={16} />
</button>
</div>
</div>
))}
</div>
{/* City Tax Calculator */}
<div className="mb-6 p-4 bg-white border rounded-lg">
<h2 className="text-xl font-bold mb-4">City Tax</h2>
<div className="grid grid-cols-2 gap-4">
<input
type="number"
placeholder="Počet hostů"
min="0"
value={cityTax.guests}
onChange={e => setCityTax({ ...cityTax, guests: parseInt(e.target.value) || 0 })}
className="p-2 border rounded"
/>
<input
type="number"
placeholder="Počet nocí"
min="0"
value={cityTax.nights}
onChange={e => setCityTax({ ...cityTax, nights: parseInt(e.target.value) || 0 })}
className="p-2 border rounded"
/>
</div>
</div>
{/* Wellness */}
<div className="mb-6 p-4 bg-white border rounded-lg">
<h2 className="text-xl font-bold mb-4">Wellness</h2>
<div className="flex items-center">
<img src="wellness.png" alt="Wellness" className="w-12 h-12 object-contain mr-4" />
<input
type="number"
placeholder="Cena wellness (EUR)"
min="0"
value={wellness}
onChange={e => setWellness(parseInt(e.target.value) || 0)}
className="flex-grow p-2 border rounded"
/>
</div>
</div>
{/* Controls */}
<div className="fixed bottom-0 left-0 right-0 p-4 bg-white border-t">
<div className="max-w-lg mx-auto">
<div className="flex justify-between items-center mb-4">
<button
onClick={() => setDisplayCurrency(curr => curr === 'CZK' ? 'EUR' : 'CZK')}
className="p-2 border rounded-lg hover:bg-gray-50"
>
{displayCurrency === 'CZK' ? <DollarSign size={20} /> : <Euro size={20} />}
</button>
<button
onClick={() => setDiscount(!discount)}
className={`p-2 border rounded-lg ${discount ? 'bg-green-500 text-white' : 'hover:bg-gray-50'}`}
>
10% Sleva
</button>
</div>
<div className="text-xl font-bold text-right">
Celkem: {calculateTotal().toFixed(2)} {displayCurrency}
</div>
</div>
</div>
{/* Quantity Modal */}
{showQuantityModal && selectedProduct && (
<div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center">
<div className="bg-white p-4 rounded-lg max-w-sm w-full">
<h3 className="text-lg font-bold mb-4">Zvolte množství</h3>
<div className="grid grid-cols-3 gap-2">
{[1, 2, 3, 4, 5, 6, 7, 8, 9].map(num => (
<button
key={num}
onClick={() => {
addToCart(selectedProduct, num);
setShowQuantityModal(false);
}}
className="p-4 border rounded-lg hover:bg-gray-50"
>
{num}
</button>
))}
</div>
<button
onClick={() => setShowQuantityModal(false)}
className="w-full mt-4 p-2 border rounded-lg hover:bg-gray-50"
>
Zrušit
</button>
</div>
</div>
)}
</div>
);