cancel subscription
This commit is contained in:
@ -384,9 +384,16 @@ func (app *application) ShowSale(w http.ResponseWriter, r *http.Request) {
|
||||
stringMap := make(map[string]string)
|
||||
stringMap["title"] = "Sale"
|
||||
stringMap["cancel"] = "/admin/all-sales"
|
||||
stringMap["refund-url"] = "/api/admin/refund"
|
||||
stringMap["refund-btn"] = "Refund Order"
|
||||
stringMap["refund-badge"] = "Refunded"
|
||||
|
||||
intMap := make(map[string]int)
|
||||
intMap["isRefund"] = 1
|
||||
|
||||
if err := app.renderTemplate(w, r, "sale", &templateData{
|
||||
StringMap: stringMap,
|
||||
IntMap: intMap,
|
||||
}); err != nil {
|
||||
app.errorLog.Println(err)
|
||||
}
|
||||
@ -396,9 +403,16 @@ func (app *application) ShowSubscriptions(w http.ResponseWriter, r *http.Request
|
||||
stringMap := make(map[string]string)
|
||||
stringMap["title"] = "Subscriptions"
|
||||
stringMap["cancel"] = "/admin/all-subscriptions"
|
||||
stringMap["refund-url"] = "/api/admin/cancel-subscription"
|
||||
stringMap["refund-btn"] = "Cancel Subscription"
|
||||
stringMap["refund-badge"] = "Cancelled"
|
||||
|
||||
intMap := make(map[string]int)
|
||||
intMap["is-refund"] = 0
|
||||
|
||||
if err := app.renderTemplate(w, r, "sale", &templateData{
|
||||
StringMap: stringMap,
|
||||
IntMap: intMap,
|
||||
}); err != nil {
|
||||
app.errorLog.Println(err)
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ All Subscriptions
|
||||
<th>Customer</th>
|
||||
<th>Product</th>
|
||||
<th>Amount</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -4,7 +4,7 @@
|
||||
{{ end }}
|
||||
{{ define "content" }}
|
||||
<h2 class="mt-5">Sale</h2>
|
||||
<span id="refunded" class="badge bg-danger d-none">Refunded</span>
|
||||
<span id="refunded" class="badge bg-danger d-none">{{index .StringMap "refund-badge"}}</span>
|
||||
<span id="charged" class="badge bg-success d-none">Charged</span>
|
||||
<hr>
|
||||
<div class="alert alert-danger text-center d-none" id="messages"></div>
|
||||
@ -22,7 +22,7 @@
|
||||
</div>
|
||||
<hr>
|
||||
<a href='{{ index .StringMap "cancel" }}' class="btn btn-info">Cancel</a>
|
||||
<a id="refund-btn" href="#!" class="btn btn-warning d-none">Refund Order</a>
|
||||
<a id="refund-btn" href="#!" class="btn btn-warning d-none">{{index .StringMap "refund-btn"}}</a>
|
||||
<input type="hidden" id="pi" value="">
|
||||
<input type="hidden" id="charge-amount" value="">
|
||||
<input type="hidden" id="currency" value="">
|
||||
@ -32,8 +32,10 @@
|
||||
<script type="module">
|
||||
import {showInfo, refund} from "/static/js/sale.js"
|
||||
showInfo({{.API}});
|
||||
|
||||
const api = {{.API}} + {{index .StringMap "refund-url"}}
|
||||
document.getElementById("refund-btn").addEventListener("click", function(event) {
|
||||
refund({{.API}});
|
||||
refund(api, {{index .IntMap "is-refund"}});
|
||||
});
|
||||
</script>
|
||||
{{ end }}
|
||||
|
Reference in New Issue
Block a user