This commit is contained in:
Martin Quarda 2024-10-15 07:54:47 +02:00
parent 6ae1d3740c
commit b086f576a8
2 changed files with 8 additions and 4 deletions

View File

@ -385,7 +385,9 @@ def select_delivery(request):
def delivery(request): def delivery(request):
try: 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: except AttributeError:
return HttpResponse("undefined", status=200, content_type='application/json') return HttpResponse("undefined", status=200, content_type='application/json')

View File

@ -204,7 +204,7 @@ class Main extends Component {
}; };
selectDeliveryCallback(point){ selectDeliveryCallback(point){
if(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"){ if(json.status == "failed"){
this.setState({ this.setState({
status_text: json.reason, status_text: json.reason,
@ -214,7 +214,7 @@ class Main extends Component {
this.setState({ this.setState({
cart: [ cart: [
...this.state.cart.filter(product => !product.name.startsWith("Doprava na ")), ...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, delivery: point.name,
status_text: json.reason, status_text: json.reason,
@ -225,7 +225,9 @@ class Main extends Component {
} }
} }
selectDelivery = () => { selectDelivery = () => {
Packeta.Widget.pick("8599115769fd895b", this.selectDeliveryCallback.bind(this)) Packeta.Widget.pick("8599115769fd895b", this.selectDeliveryCallback.bind(this), {
language: "cs",
})
} }
togglefaq(){ togglefaq(){
this.setState({faq: !this.state.faq}); this.setState({faq: !this.state.faq});