price check and display flex

This commit is contained in:
Martin Quarda 2024-10-14 11:56:55 +02:00
parent 1c4ab9527e
commit 88b3f25afe
2 changed files with 5 additions and 2 deletions

View File

@ -388,7 +388,7 @@ def cart_buy(request):
for cp in cart_products: for cp in cart_products:
if cp.quantity > cp.product.quantity: if cp.quantity > cp.product.quantity:
return HttpResponse('{"status": "failed", "reason": "Nemáme dostatek ' + cp.product.name + ' na skladě!"}', status=400) return HttpResponse('{"status": "failed", "reason": "Nemáme dostatek ' + cp.product.name + ' na skladě!"}', status=400, content_type='application/json')
invoice = Invoice( invoice = Invoice(
user=user, user=user,
@ -411,6 +411,9 @@ def cart_buy(request):
total_price += cp.quantity * cp.product.price total_price += cp.quantity * cp.product.price
ip.save() ip.save()
if total_price <= 0:
return HttpResponse('{"status": "failed", "reason": "Prosím přidejte svoje položky do košíku!"}', status=400, content_type='application/json')
payment_data = { payment_data = {
'merchant': COMGATE_MERCHANT, 'merchant': COMGATE_MERCHANT,
'test': 'true' if COMGATE_TEST else 'false', 'test': 'true' if COMGATE_TEST else 'false',

View File

@ -344,7 +344,7 @@ class Main extends Component {
</table> </table>
</div>} </div>}
{this.state.page == "#eshop" && {this.state.page == "#eshop" &&
<div class="container"> <div class="container" style={{display: "flex"}}>
{this.state.products.map(product => {this.state.products.map(product =>
<div class="card" style={{width: "18rem"}}> <div class="card" style={{width: "18rem"}}>
<img src={product.img} class="card-img-top" alt="..." /> <img src={product.img} class="card-img-top" alt="..." />