From 82f2b76e25a4a67e01ec67e5ebe39d14ad771ea8 Mon Sep 17 00:00:00 2001
From: Florian Dold <florian.dold@gmail.com>
Date: Thu, 20 Apr 2017 03:09:25 +0200
Subject: Reorganize module loading.

We now use webpack instead of SystemJS, effectively bundling modules
into one file (plus commons chunks) for every entry point.  This results
in a much smaller extension size (almost half).  Furthermore we use
yarn/npm even for extension run-time dependencies.  This relieves us
from manually vendoring and building dependencies.  It's also easier to
understand for new developers familiar with node.
---
 src/pages/confirm-contract.tsx | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

(limited to 'src/pages/confirm-contract.tsx')

diff --git a/src/pages/confirm-contract.tsx b/src/pages/confirm-contract.tsx
index 3a0712a8c..d8f72ba01 100644
--- a/src/pages/confirm-contract.tsx
+++ b/src/pages/confirm-contract.tsx
@@ -23,12 +23,15 @@
 
 "use strict";
 
-import {substituteFulfillmentUrl} from "src/helpers";
-import {Contract, AmountJson, ExchangeRecord} from "src/types";
-import {OfferRecord} from "src/wallet";
-import {renderContract, prettyAmount} from "src/renderHtml";
-import {getExchanges} from "src/wxApi";
-import * as i18n from "src/i18n";
+import {substituteFulfillmentUrl} from "../helpers";
+import {Contract, AmountJson, ExchangeRecord} from "../types";
+import {OfferRecord} from "../wallet";
+import {renderContract, prettyAmount} from "../renderHtml";
+import {getExchanges} from "../wxApi";
+import * as i18n from "../i18n";
+import * as React from "react";
+import * as ReactDOM from "react-dom";
+import URI = require("urijs");
 
 
 interface DetailState {
@@ -129,7 +132,7 @@ class ContractPrompt extends React.Component<ContractPromptProps, ContractPrompt
   }
 
   getOffer(): Promise<OfferRecord> {
-    return new Promise((resolve, reject) => {
+    return new Promise<OfferRecord>((resolve, reject) => {
       let msg = {
         type: 'get-offer',
         detail: {
@@ -160,22 +163,21 @@ class ContractPrompt extends React.Component<ContractPromptProps, ContractPrompt
               let acceptedExchangePubs = this.state.offer.contract.exchanges.map((e) => e.master_pub);
               let ex = this.state.exchanges.find((e) => acceptedExchangePubs.indexOf(e.masterPublicKey) >= 0);
               if (ex) {
-                this.state.error = msgInsufficient;
+                this.setState({error: msgInsufficient});
               } else {
-                this.state.error = msgNoMatch;
+                this.setState({error: msgNoMatch});
               }
             } else {
-              this.state.error = msgInsufficient;
+              this.setState({error: msgInsufficient});
             }
             break;
           default:
-            this.state.error = `Error: ${resp.error}`;
+            this.setState({error: `Error: ${resp.error}`});
             break;
         }
-        this.state.payDisabled = true;
+        this.setState({payDisabled: true});
       } else {
-        this.state.payDisabled = false;
-        this.state.error = null;
+        this.setState({payDisabled: false, error: null});
       }
       this.setState({} as any);
       window.setTimeout(() => this.checkPayment(), 500);
@@ -189,14 +191,12 @@ class ContractPrompt extends React.Component<ContractPromptProps, ContractPrompt
         console.log("confirm-pay error", JSON.stringify(resp));
         switch (resp.error) {
           case "coins-insufficient":
-            this.state.error = "You do not have enough coins of the" +
-              " requested currency.";
+            this.setState({error: "You do not have enough coins of the requested currency."});
             break;
           default:
-            this.state.error = `Error: ${resp.error}`;
+            this.setState({error: `Error: ${resp.error}`});
             break;
         }
-        this.setState({} as any);
         return;
       }
       let c = d.offer!.contract;
@@ -232,11 +232,11 @@ class ContractPrompt extends React.Component<ContractPromptProps, ContractPrompt
 }
 
 
-export function main() {
-  let url = URI(document.location.href);
+document.addEventListener("DOMContentLoaded", () => {
+  let url = new URI(document.location.href);
   let query: any = URI.parseQuery(url.query());
   let offerId = JSON.parse(query.offerId);
 
   ReactDOM.render(<ContractPrompt offerId={offerId}/>, document.getElementById(
     "contract")!);
-}
+});
-- 
cgit v1.2.3

