From 88b3f25afe6999abcce6446c03caea85465a18c1 Mon Sep 17 00:00:00 2001 From: Martin Quarda Date: Mon, 14 Oct 2024 11:56:55 +0200 Subject: [PATCH] price check and display flex --- alkatorapi/views.py | 5 ++++- frontend/src/scripts/index.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/alkatorapi/views.py b/alkatorapi/views.py index ad6fa8c..7088bc1 100644 --- a/alkatorapi/views.py +++ b/alkatorapi/views.py @@ -388,7 +388,7 @@ def cart_buy(request): for cp in cart_products: 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( user=user, @@ -411,6 +411,9 @@ def cart_buy(request): total_price += cp.quantity * cp.product.price 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 = { 'merchant': COMGATE_MERCHANT, 'test': 'true' if COMGATE_TEST else 'false', diff --git a/frontend/src/scripts/index.js b/frontend/src/scripts/index.js index c536f20..2e27ec7 100644 --- a/frontend/src/scripts/index.js +++ b/frontend/src/scripts/index.js @@ -344,7 +344,7 @@ class Main extends Component { } {this.state.page == "#eshop" && -
+
{this.state.products.map(product =>
...