diff --git a/alkatorapi/views.py b/alkatorapi/views.py index 8ca7a63..f016f6f 100644 --- a/alkatorapi/views.py +++ b/alkatorapi/views.py @@ -385,7 +385,9 @@ def select_delivery(request): def delivery(request): try: - return HttpResponse('"'+request.user.cart.address+'"', status=200, content_type='application/json') + if request.user.cart.address: + return HttpResponse('"'+request.user.cart.address+'"', status=200, content_type='application/json') + return HttpResponse("undefined", status=200, content_type='application/json') except AttributeError: return HttpResponse("undefined", status=200, content_type='application/json') diff --git a/frontend/src/scripts/index.js b/frontend/src/scripts/index.js index e6439bd..b6bb54a 100644 --- a/frontend/src/scripts/index.js +++ b/frontend/src/scripts/index.js @@ -204,7 +204,7 @@ class Main extends Component { }; selectDeliveryCallback(point){ if(point){ - fetch(addr_prefix + '/api/cart/select_delivery?delivery='+point.name).then(resp => resp.json()).then(json => { + fetch(addr_prefix + '/api/cart/select_delivery?delivery=' + point.name).then(resp => resp.json()).then(json => { if(json.status == "failed"){ this.setState({ status_text: json.reason, @@ -214,7 +214,7 @@ class Main extends Component { this.setState({ cart: [ ...this.state.cart.filter(product => !product.name.startsWith("Doprava na ")), - {"name": "Doprava na " + point.name, "id": 2, "price": delivery_cost, "locked": true, "quantity": 1} + {"name": "Doprava na " + point.name, "id": 2, "price": delivery_cost, "locked": true, "quantity": 1} ], delivery: point.name, status_text: json.reason, @@ -225,7 +225,9 @@ class Main extends Component { } } selectDelivery = () => { - Packeta.Widget.pick("8599115769fd895b", this.selectDeliveryCallback.bind(this)) + Packeta.Widget.pick("8599115769fd895b", this.selectDeliveryCallback.bind(this), { + language: "cs", + }) } togglefaq(){ this.setState({faq: !this.state.faq});