Browse Source

[+Elisa] #211 - created link to login with dashboard

Raul Vega del Valle 1 year ago
parent
commit
39d4fed8ab

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

@@ -2,11 +2,13 @@
2 2
   "development": {
3 3
     "api": "http://localhost:3040",
4 4
     "expoLink": "exp://localhost:19000?",
5
-    "walletLink": "decodewallet://localhost:19000?"
5
+    "walletLink": "decodewallet://localhost:19000?",
6
+    "expoLoginLink": "exp://localhost:19000?header={predicate:\"schema:iotCommunity\"}&sessionId=9876&callback=http://bcnnow.decodeproject.eu/wallet-login&action=login"
6 7
   },
7 8
   "production": {
8 9
     "api" : "http://ec2-34-253-207-49.eu-west-1.compute.amazonaws.com",
9 10
     "expoLink" : "exp://exp.host/@decode-barcelona/decode-walletapp?release-channel=production",
10
-    "walletLink": "decodewallet://exp.host/@decode-barcelona/decode-walletapp?release-channel=production"
11
+    "walletLink": "decodewallet://exp.host/@decode-barcelona/decode-walletapp?release-channel=production",
12
+    "expoLoginLink": "exp://login?header={predicate:\"schema:iotCommunity\"}&sessionId=9876&callback=http://bcnnow.decodeproject.eu/wallet-login"
11 13
   }
12 14
 }

+ 1 - 1
apps/petitions/petitions-app/src/components/PetitionList.jsx

@@ -54,7 +54,7 @@ class PetitionList extends Component {
54 54
       <div>
55 55
         <Header />
56 56
         <Main>
57
-          <a href={'decodewallet://login?header={predicate:"schema:iotCommunity"}&sessionId=9876&callback=http://bcnnow.decodeproject.eu/wallet-login'}>Login to Dashboard</a>
57
+          <a href={`${expoLoginLink}`}>Login to Dashboard</a>
58 58
           {this.state.serverError ?
59 59
             <ErrorMessage>Sorry, there was an error loading the page</ErrorMessage> :
60 60
             <div>

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

@@ -41,6 +41,18 @@ const getWalletLink = () => {
41 41
   }
42 42
 };
43 43
 
44
+const getExpoLoginLink = () => {
45
+  if (process.env.IP) {
46
+    return config.development.expoLoginLink.replace('localhost', process.env.IP);
47
+  }
48
+  switch (process.env.NODE_ENV) {
49
+    case 'production':
50
+      return config.production.expoLoginLink;
51
+    default:
52
+      return config.development.expoLoginLink;
53
+  }
54
+};
55
+
44 56
 module.exports = {
45 57
   entry: ['whatwg-fetch', 'babel-polyfill', './src/index.jsx'],
46 58
   output: {
@@ -68,6 +80,7 @@ module.exports = {
68 80
       API: JSON.stringify(getAPIEndpoint()),
69 81
       expoLink: JSON.stringify(getExpoLink()),
70 82
       walletLink: JSON.stringify(getWalletLink()),
83
+      expoLoginLink: JSON.stringify(getExpoLoginLink()),
71 84
     }),
72 85
     new CopyWebpackPlugin([
73 86
       // {output}/to/file.txt