delivery pre-loads
This commit is contained in:
parent
be6f57cf8b
commit
b52acd7b23
@ -25,6 +25,7 @@ from alkatorapi.views import (
|
|||||||
login_status, change_racer,
|
login_status, change_racer,
|
||||||
products, cart_add, cart, cart_delete,
|
products, cart_add, cart, cart_delete,
|
||||||
cart_decrease, cart_buy, select_delivery,
|
cart_decrease, cart_buy, select_delivery,
|
||||||
|
delivery,
|
||||||
)
|
)
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
@ -48,4 +49,5 @@ urlpatterns = [
|
|||||||
path('api/cart/decrease', cart_decrease),
|
path('api/cart/decrease', cart_decrease),
|
||||||
path('api/cart/buy', cart_buy),
|
path('api/cart/buy', cart_buy),
|
||||||
path('api/cart/select_delivery', select_delivery),
|
path('api/cart/select_delivery', select_delivery),
|
||||||
|
path('api/cart/delivery', delivery),
|
||||||
]
|
]
|
||||||
|
@ -382,6 +382,12 @@ def select_delivery(request):
|
|||||||
return HttpResponse('{"status":"success", "reason":"Úspěšně vybraná zásilkovna."}', status=200)
|
return HttpResponse('{"status":"success", "reason":"Úspěšně vybraná zásilkovna."}', status=200)
|
||||||
|
|
||||||
|
|
||||||
|
def delivery(request):
|
||||||
|
try:
|
||||||
|
return HttpResponse(request.user.cart.address, status=200, content_type='application/json')
|
||||||
|
except AttributeError:
|
||||||
|
return HttpResponse("undefined", status=200, content_type='application/json')
|
||||||
|
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
|
@ -50,6 +50,12 @@ class Main extends Component {
|
|||||||
fetch(addr_prefix + "/api/login_status").then(resp => resp.json()).then(json => {
|
fetch(addr_prefix + "/api/login_status").then(resp => resp.json()).then(json => {
|
||||||
this.setState({login_status: json})
|
this.setState({login_status: json})
|
||||||
})
|
})
|
||||||
|
fetch(addr_prefix + "/api/cart/delivery").then(resp => resp.json()).then(json => {
|
||||||
|
this.setState({
|
||||||
|
cart: [...this.state.cart, {"name": "Doprava na " + json, "id": 2, "price": delivery_cost, "locked": true, "quantity": 1}],
|
||||||
|
delivery: json,
|
||||||
|
})
|
||||||
|
})
|
||||||
if(window.location.search){
|
if(window.location.search){
|
||||||
let searchParams = new URLSearchParams(window.location.search);
|
let searchParams = new URLSearchParams(window.location.search);
|
||||||
for(const [key, value] of searchParams){
|
for(const [key, value] of searchParams){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user