show sales & subscriptions
This commit is contained in:
		@ -381,7 +381,25 @@ func (app *application) AllSubscriptions(w http.ResponseWriter, r *http.Request)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (app *application) ShowSale(w http.ResponseWriter, r *http.Request) {
 | 
					func (app *application) ShowSale(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
	if err := app.renderTemplate(w, r, "sale", &templateData{}); err != nil {
 | 
						stringMap := make(map[string]string)
 | 
				
			||||||
 | 
						stringMap["title"] = "Sale"
 | 
				
			||||||
 | 
						stringMap["cancel"] = "/admin/all-sales"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if err := app.renderTemplate(w, r, "sale", &templateData{
 | 
				
			||||||
 | 
							StringMap: stringMap,
 | 
				
			||||||
 | 
						}); err != nil {
 | 
				
			||||||
 | 
							app.errorLog.Println(err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (app *application) ShowSubscriptions(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
 | 
						stringMap := make(map[string]string)
 | 
				
			||||||
 | 
						stringMap["title"] = "Subscriptions"
 | 
				
			||||||
 | 
						stringMap["cancel"] = "/admin/all-subscriptions"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if err := app.renderTemplate(w, r, "sale", &templateData{
 | 
				
			||||||
 | 
							StringMap: stringMap,
 | 
				
			||||||
 | 
						}); err != nil {
 | 
				
			||||||
		app.errorLog.Println(err)
 | 
							app.errorLog.Println(err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -18,6 +18,7 @@ func (app *application) routes() http.Handler {
 | 
				
			|||||||
		mux.Get("/all-sales", app.AllSales)
 | 
							mux.Get("/all-sales", app.AllSales)
 | 
				
			||||||
		mux.Get("/all-subscriptions", app.AllSubscriptions)
 | 
							mux.Get("/all-subscriptions", app.AllSubscriptions)
 | 
				
			||||||
		mux.Get("/sales/{id}", app.ShowSale)
 | 
							mux.Get("/sales/{id}", app.ShowSale)
 | 
				
			||||||
 | 
							mux.Get("/subscriptions/{id}", app.ShowSubscriptions)
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// mux.Post("/virtual-terminal-payment-succeeded", app.VirtualTerminalPaymentSucceeded)
 | 
						// mux.Post("/virtual-terminal-payment-succeeded", app.VirtualTerminalPaymentSucceeded)
 | 
				
			||||||
 | 
				
			|||||||
@ -1,11 +1,21 @@
 | 
				
			|||||||
{{template "base" .}}
 | 
					{{template "base" .}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{{define "title"}}
 | 
					{{define "title"}}
 | 
				
			||||||
Sale
 | 
					{{index .StringMap "title"}}
 | 
				
			||||||
{{end}}
 | 
					{{end}}
 | 
				
			||||||
{{define "content"}}
 | 
					{{define "content"}}
 | 
				
			||||||
<h2 class="mt-5">Sale</h2>
 | 
					<h2 class="mt-5">Sale</h2>
 | 
				
			||||||
<hr>
 | 
					<hr>
 | 
				
			||||||
 | 
					<div>
 | 
				
			||||||
 | 
					    <strong>Order No:</strong> <span id="order-no"></span><br>
 | 
				
			||||||
 | 
					    <strong>Customer:</strong> <span id="customer"></span><br>
 | 
				
			||||||
 | 
					    <strong>Product:</strong> <span id="product"></span><br>
 | 
				
			||||||
 | 
					    <strong>Quantity:</strong> <span id="quantity"></span><br>
 | 
				
			||||||
 | 
					    <strong>Total Sale:</strong> <span id="amount"></span><br>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
 | 
					<hr>
 | 
				
			||||||
 | 
					<a href='{{index .StringMap "cancel"}}' class="btn btn-info">Cancel</a>
 | 
				
			||||||
 | 
					<a href="#!" class="btn btn-warning">Refund Order</a>
 | 
				
			||||||
{{end}}
 | 
					{{end}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{{define "js"}}
 | 
					{{define "js"}}
 | 
				
			||||||
 | 
				
			|||||||
@ -15,6 +15,13 @@ export function showInfo(api) {
 | 
				
			|||||||
        .then(response => response.json())
 | 
					        .then(response => response.json())
 | 
				
			||||||
        .then(function (data) {
 | 
					        .then(function (data) {
 | 
				
			||||||
            console.log(data);
 | 
					            console.log(data);
 | 
				
			||||||
 | 
					            if (data) {
 | 
				
			||||||
 | 
					                document.getElementById("order-no").innerHTML = data.id
 | 
				
			||||||
 | 
					                document.getElementById("customer").innerHTML = data.customer.first_name + " " + data.customer.last_name
 | 
				
			||||||
 | 
					                document.getElementById("product").innerHTML = data.widget.name
 | 
				
			||||||
 | 
					                document.getElementById("quantity").innerHTML = data.quantity
 | 
				
			||||||
 | 
					                document.getElementById("amount").innerHTML = formatCurrency(data.transaction.amount)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user