diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-02-15 15:53:59 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-02-15 15:53:59 +0100 |
commit | 0c760bc2a1459cc7ec7fd22ae39ca0a8201df9b5 (patch) | |
tree | 5f36206aff29a0204527550ebeebe0c8eaafbb6b /extension/pages/confirm-contract.tsx | |
parent | 526e88695f6c8a2b3dea4b9befeb2a85ba00b66b (diff) |
UI improvements and error handling
Diffstat (limited to 'extension/pages/confirm-contract.tsx')
-rw-r--r-- | extension/pages/confirm-contract.tsx | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/extension/pages/confirm-contract.tsx b/extension/pages/confirm-contract.tsx index 055490175..ff6ffba64 100644 --- a/extension/pages/confirm-contract.tsx +++ b/extension/pages/confirm-contract.tsx @@ -39,16 +39,17 @@ export function main() { view(ctrl) { return [ m("p", - i18n`Hello, this is the wallet. The merchant "${contract.merchant.name}" - wants to enter a contract over ${prettyAmount(contract.amount)} + i18n.parts`${m("strong", contract.merchant.name)} + wants to enter a contract over ${m("strong", + prettyAmount(contract.amount))} with you.`), m("p", - i18n`The contract contains the following products:`), + i18n`You are about to purchase:`), m('ul', _.map(contract.products, (p: any) => m("li", `${p.description}: ${prettyAmount(p.price)}`))), - m("button", {onclick: doPayment}, i18n`Confirm Payment`), + m("button.confirm-pay", {onclick: doPayment}, i18n`Confirm Payment`), m("p", error ? error : []), ]; } @@ -56,21 +57,26 @@ export function main() { m.mount(document.getElementById("contract"), Contract); - function doPayment() { - let d = { - offer - }; + let d = {offer}; chrome.runtime.sendMessage({type: 'confirm-pay', detail: d}, (resp) => { - if (!resp.success) { + if (resp.error) { console.log("confirm-pay error", JSON.stringify(resp)); - error = resp.message; + switch (resp.error) { + case "coins-insufficient": + error = "You do not have enough coins of the requested currency."; + break; + default: + error = `Error: ${resp.error}`; + break; + } m.redraw(); return; } let c = d.offer.contract; console.log("contract", c); - document.location.href = substituteFulfillmentUrl(c.fulfillment_url, offer); + document.location.href = substituteFulfillmentUrl(c.fulfillment_url, + offer); }); } -} +}
\ No newline at end of file |