aboutsummaryrefslogtreecommitdiff
path: root/pages/confirm-contract.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'pages/confirm-contract.tsx')
-rw-r--r--pages/confirm-contract.tsx30
1 files changed, 28 insertions, 2 deletions
diff --git a/pages/confirm-contract.tsx b/pages/confirm-contract.tsx
index 9e15841e9..2e055d4f1 100644
--- a/pages/confirm-contract.tsx
+++ b/pages/confirm-contract.tsx
@@ -72,6 +72,7 @@ export function main() {
console.dir(offer);
let contract = offer.contract;
let error = null;
+ let payDisabled = true;
var Contract = {
view(ctrl) {
@@ -87,8 +88,8 @@ export function main() {
_.map(contract.products,
(p: any) => m("li",
`${p.description}: ${prettyAmount(p.price)}`))),
- m("button.accept", {onclick: doPayment}, i18n`Confirm Payment`),
- m("p", error ? error : []),
+ m("button.accept", {onclick: doPayment, disabled: payDisabled}, i18n`Confirm Payment`),
+ (error ? m("p.errorbox", error) : []),
m(Details, contract)
];
}
@@ -96,6 +97,31 @@ export function main() {
m.mount(document.getElementById("contract"), Contract);
+ function checkPayment() {
+ chrome.runtime.sendMessage({type: 'check-pay', detail: {offer}}, (resp) => {
+ if (resp.error) {
+ console.log("check-pay error", JSON.stringify(resp));
+ switch (resp.error) {
+ case "coins-insufficient":
+ error = "You do not have enough coins of the requested currency.";
+ break;
+ default:
+ error = `Error: ${resp.error}`;
+ break;
+ }
+ payDisabled = true;
+ } else {
+ payDisabled = false;
+ error = null;
+ }
+ m.redraw();
+ window.setTimeout(checkPayment, 300);
+ });
+ }
+
+ checkPayment();
+
+
function doPayment() {
let d = {offer};
chrome.runtime.sendMessage({type: 'confirm-pay', detail: d}, (resp) => {