frontend: order result screen
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
parent
19aeb032b5
commit
91493bf0a3
4 changed files with 57 additions and 9 deletions
|
@ -288,14 +288,24 @@ func (fe *frontendServer) placeOrderHandler(w http.ResponseWriter, r *http.Reque
|
||||||
order.GetOrder().GetItems()
|
order.GetOrder().GetItems()
|
||||||
recommendations, _ := fe.getRecommendations(r.Context(), sessionID(r), nil)
|
recommendations, _ := fe.getRecommendations(r.Context(), sessionID(r), nil)
|
||||||
|
|
||||||
|
totalPaid := *order.GetOrder().GetShippingCost()
|
||||||
|
for _, v := range order.GetOrder().GetItems() {
|
||||||
|
totalPaid = money.Must(money.Sum(totalPaid, *v.GetCost()))
|
||||||
|
}
|
||||||
|
|
||||||
if err := templates.ExecuteTemplate(w, "order", map[string]interface{}{
|
if err := templates.ExecuteTemplate(w, "order", map[string]interface{}{
|
||||||
"session_id": sessionID(r),
|
"session_id": sessionID(r),
|
||||||
"user_currency": currentCurrency(r),
|
"user_currency": currentCurrency(r),
|
||||||
"order": order.GetOrder(),
|
"order": order.GetOrder(),
|
||||||
|
"total_paid": &totalPaid,
|
||||||
"recommendations": recommendations,
|
"recommendations": recommendations,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := fe.emptyCart(r.Context(), sessionID(r)); err != nil {
|
||||||
|
log.Printf("WARN: failed to empty user (%s) cart after checkout: %+v", sessionID(r), err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fe *frontendServer) prepareCheckoutHandler(w http.ResponseWriter, r *http.Request) {
|
func (fe *frontendServer) prepareCheckoutHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
|
@ -123,7 +123,11 @@
|
||||||
<label for="credit_card_expiration_year">Year</label>
|
<label for="credit_card_expiration_year">Year</label>
|
||||||
<select name="credit_card_expiration_year" id="credit_card_expiration_year"
|
<select name="credit_card_expiration_year" id="credit_card_expiration_year"
|
||||||
class="form-control">
|
class="form-control">
|
||||||
{{range $.expiration_years}}<option value="{{.}}">{{.}}</option>{{end}}
|
{{ range $i, $y := $.expiration_years}}<option value="{{$y}}"
|
||||||
|
{{if eq $i 1 -}}
|
||||||
|
selected="selected"
|
||||||
|
{{- end}}
|
||||||
|
>{{$y}}</option>{{end}}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2 mb-3">
|
<div class="col-md-2 mb-3">
|
||||||
|
|
17
src/frontend/templates/error.html
Normal file
17
src/frontend/templates/error.html
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{{ define "error" }}
|
||||||
|
{{ template "header" }}
|
||||||
|
|
||||||
|
<main role="main">
|
||||||
|
<div class="py-5">
|
||||||
|
<div class="container bg-light py-3 px-lg-5 py-lg-5">
|
||||||
|
<h1>Uh, oh!</h1>
|
||||||
|
<p>Something has failed. Below are some details for debugging.</p>
|
||||||
|
<pre>
|
||||||
|
{{.errorMsg}}
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
{{ template "footer" }}
|
||||||
|
{{ end }}
|
|
@ -3,16 +3,33 @@
|
||||||
|
|
||||||
<main role="main">
|
<main role="main">
|
||||||
<div class="py-5">
|
<div class="py-5">
|
||||||
<div class="container bg-light py-3 px-lg-5 py-lg-5">
|
<div class="container bg-light py-3 px-lg-5">
|
||||||
|
<div class="row mt-5 py-2">
|
||||||
|
<div class="col">
|
||||||
<h3>
|
<h3>
|
||||||
Your order is complete!
|
Your order is complete!
|
||||||
</h3>
|
</h3>
|
||||||
<p>
|
<p>
|
||||||
Order Confirmation ID: {{ $.order }}
|
Order Confirmation ID: <strong>{{.order.OrderId}}</strong>
|
||||||
|
<br>
|
||||||
|
Shipping Tracking ID: <strong>{{.order.ShippingTrackingId}}</strong>
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
Shipping Cost: <strong>{{renderMoney .order.ShippingCost}}</strong>
|
||||||
|
<br>
|
||||||
|
Total Paid: <strong>{{renderMoney .total_paid}}</strong>
|
||||||
|
</p>
|
||||||
|
<a class="btn btn-primary" href="/" role="button">Browse other products → </a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
{{ if $.recommendations }}
|
||||||
|
<div class="row mt-5 py-2">
|
||||||
{{ template "recommendations" $.recommendations }}
|
{{ template "recommendations" $.recommendations }}
|
||||||
</div>
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue