Browse Source

Merge branch 'master' of gogs.dyne.org:DECODE/decode-prototype

Jordi Coscolla 1 year ago
parent
commit
8a723e48eb

+ 1 - 2
apps/credential-issuer/src/client/components/Verify.jsx

@@ -41,7 +41,7 @@ const SubTitle = styled.div`
41 41
 const TextInput = styled.input`
42 42
   display: block;
43 43
   font-size: 20px;
44
-  padding: 10px; 
44
+  padding: 10px;
45 45
   border: 1px solid #13A398;
46 46
   border-radius: 3px;
47 47
   margin-bottom: 18px;
@@ -92,4 +92,3 @@ Verify.defaultProps = {
92 92
 };
93 93
 
94 94
 export default Verify;
95
-

+ 2 - 2
apps/credential-issuer/src/server/index.js

@@ -2,8 +2,8 @@ const express = require('express');
2 2
 
3 3
 const app = express();
4 4
 
5
-console.log(`${__dirname}./../../build`);
5
+console.log(`${__dirname}/../../build`);
6 6
 
7
-app.use(express.static(`${__dirname}./../../build`)); // serves the index.html
7
+app.use(express.static(`${__dirname}/../../build`)); // serves the index.html
8 8
 app.listen(3010);
9 9
 // listens on port 3010 -> http://localhost:3010/

+ 1 - 1
apps/petitions/decode-app/data/petitions.json

@@ -6,7 +6,7 @@
6 6
     "closingDate": "2018-12-28",
7 7
     "submittedTo": "Ayuntamiento de Barcelona",
8 8
     "createdBy": "Citizens for Data",
9
-    "id": "59f888c8ce33c76884e8cf16",
9
+    "id": "40",
10 10
     "cs_id": null,
11 11
     "images": {
12 12
       "square": "images/square-city-red.png",

+ 1 - 1
apps/petitions/decode-app/go.sh

@@ -9,7 +9,7 @@ DECODE_APP_HOST="http://localhost:3040"
9 9
 CLUSTER_NAME="petitions-app"
10 10
 
11 11
 start_mongo() {
12
-  exec `docker-compose -f docker-compose.mongo.yml up -d`
12
+  exec `docker-compose --verbose -f docker-compose.mongo.yml up -d`
13 13
 }
14 14
 
15 15
 stop_mongo() {

+ 1 - 0
apps/petitions/petitions-app/.eslintrc.json

@@ -16,6 +16,7 @@
16 16
     "expect": true,
17 17
     "API": true,
18 18
     "expoLink": true,
19
+    "walletLink": true,
19 20
     "$": true,
20 21
     "neptuneUrl": true,
21 22
     "atlantisUrl": true

+ 4 - 2
apps/petitions/petitions-app/config.json

@@ -1,10 +1,12 @@
1 1
 {
2 2
   "development": {
3 3
     "api": "http://localhost:3040",
4
-    "expoLink": "exp://localhost:19000?"
4
+    "expoLink": "exp://localhost:19000?",
5
+    "walletLink": "decodewallet://localhost:19000?"
5 6
   },
6 7
   "production": {
7 8
     "api" : "http://ec2-34-253-207-49.eu-west-1.compute.amazonaws.com",
8
-    "expoLink" : "exp://exp.host/@decode-barcelona/wallet?release-channel=production"
9
+    "expoLink" : "exp://exp.host/@decode-barcelona/decode-walletapp?release-channel=production",
10
+    "walletLink": "decodewallet://exp.host/@decode-barcelona/decode-walletapp?release-channel=production"
9 11
   }
10 12
 }

+ 2 - 1
apps/petitions/petitions-app/package.json

@@ -57,7 +57,8 @@
57 57
   "jest": {
58 58
     "globals": {
59 59
       "API": "blah",
60
-      "expoLink": "foo"
60
+      "expoLink": "foo",
61
+      "walletLink": "foo"
61 62
     }
62 63
   }
63 64
 }

+ 8 - 21
apps/petitions/petitions-app/src/components/PetitionDetails.jsx

@@ -1,7 +1,6 @@
1 1
 import React, { Component } from 'react';
2 2
 import 'whatwg-fetch';
3 3
 import styled from 'styled-components';
4
-import QRCode from 'qrcode.react';
5 4
 import { string } from 'prop-types';
6 5
 import { Loading, ErrorMessage } from './Messages';
7 6
 import { Main, PageTitle, SubTitle, SubTitleInline, Button, Paragraph } from './common/Elements';
@@ -63,18 +62,6 @@ const AppLink = styled.a`
63 62
     text-decoration: none;
64 63
 `;
65 64
 
66
-const QRContainer = styled.div`
67
-    display: flex;
68
-    flex-direction: column;
69
-    align-items: center;
70
-`;
71
-
72
-const ScanInstructions = styled.p`
73
-  text-align: center;
74
-  padding-top: 1rem;
75
-`;
76
-
77
-
78 65
 const handleErrors = (response) => {
79 66
   if (!response.ok) {
80 67
     throw Error(response.statusText);
@@ -83,15 +70,14 @@ const handleErrors = (response) => {
83 70
 };
84 71
 
85 72
 class PetitionDetails extends Component {
86
-  static renderSignButton(petitionLink) {
73
+  static renderSignButton(petitionLink, id) {
87 74
     return (<div>
88
-      <AppLink href={`${expoLink}&mobile=true&petitionLink=${petitionLink}`}>
89
-        <SignPetitionButton1>Sign with Wallet</SignPetitionButton1>
75
+      <AppLink href={`${expoLink}&mobile=true&petitionLink=${petitionLink}&decidimAPIUrl=https://meta.decidim.org/api&petitionId=${id}`}>
76
+        <SignPetitionButton1>Sign with Expo<image src="" /></SignPetitionButton1>
77
+      </AppLink>
78
+      <AppLink href={`${walletLink}&mobile=true&petitionLink=${petitionLink}&decidimAPIUrl=https://meta.decidim.org/api&petitionId=${id}`}>
79
+        <SignPetitionButton1>Sign with Decode App<image src="" /></SignPetitionButton1>
90 80
       </AppLink>
91
-      <QRContainer>
92
-        <ScanInstructions>Use wallet to scan QR code</ScanInstructions>
93
-        <QRCode value={`${expoLink}&petitionLink=${petitionLink}`} />
94
-      </QRContainer>
95 81
     </div>);
96 82
   }
97 83
 
@@ -142,7 +128,8 @@ class PetitionDetails extends Component {
142 128
                 {petition.createdBy}<br />
143 129
               </PetitionDetailsContent>
144 130
               <SignPetition>
145
-                {petition && petition.isOpen && PetitionDetails.renderSignButton(petitionLink)}
131
+                {petition && petition.isOpen &&
132
+                PetitionDetails.renderSignButton(petitionLink, this.props.id)}
146 133
                 {petition && !petition.isOpen && this.renderResults()}
147 134
               </SignPetition>
148 135
             </PetitionDetailsCard>

+ 13 - 0
apps/petitions/petitions-app/webpack.config.js

@@ -29,6 +29,18 @@ const getExpoLink = () => {
29 29
   }
30 30
 };
31 31
 
32
+const getWalletLink = () => {
33
+  if (process.env.IP) {
34
+    return config.development.walletLink.replace('localhost', process.env.IP);
35
+  }
36
+  switch (process.env.NODE_ENV) {
37
+    case 'production':
38
+      return config.production.walletLink;
39
+    default:
40
+      return config.development.walletLink;
41
+  }
42
+};
43
+
32 44
 module.exports = {
33 45
   entry: ['whatwg-fetch', 'babel-polyfill', './src/index.jsx'],
34 46
   output: {
@@ -55,6 +67,7 @@ module.exports = {
55 67
     new webpack.DefinePlugin({
56 68
       API: JSON.stringify(getAPIEndpoint()),
57 69
       expoLink: JSON.stringify(getExpoLink()),
70
+      walletLink: JSON.stringify(getWalletLink()),
58 71
     }),
59 72
     new CopyWebpackPlugin([
60 73
       // {output}/to/file.txt