Browse Source

[+Jordi, + Elena] #87 - Fixed link to decidim from results page

Elisa Cutrin 1 year ago
parent
commit
83ea63dffc

+ 6 - 0
apps/wallet/application/utils/index.js

@@ -0,0 +1,6 @@
1
+import { Linking } from 'react-native';
2
+
3
+export default (petitionId) => {
4
+  const petitionUrl = `http://secure-petitions.s3-website-eu-west-1.amazonaws.com/#/${petitionId}`;
5
+  Linking.openURL(petitionUrl);
6
+};

+ 2 - 6
apps/wallet/screens/AttributesSummary.js

@@ -7,6 +7,7 @@ import { goToPetitionSummary } from '../application/redux/actions/navigation';
7 7
 import Button from '../application/components/Button/Button';
8 8
 import { addCredential } from '../application/redux/actions/attributes';
9 9
 import { getPetition } from '../application/redux/actions/petition';
10
+import openPetitionInBrowser from '../application/utils';
10 11
 import styles from './styles';
11 12
 
12 13
 const decodeUser = require('../assets/images/decode-user.png');
@@ -36,11 +37,6 @@ class AttributesSummary extends React.Component {
36 37
     WebBrowser.dismissBrowser();
37 38
   };
38 39
 
39
-  openPetitionInBrowser = () => {
40
-    const petitionUrl = `http://secure-petitions.s3-website-eu-west-1.amazonaws.com/#/${this.props.petition.id}`;
41
-    Linking.openURL(petitionUrl);
42
-  };
43
-
44 40
   openWebBrowserAsync = async () => {
45 41
     const queryParam = encodeURIComponent(Constants.linkingUri);
46 42
     const url = `http://atlantis-decode.s3-website-eu-west-1.amazonaws.com/#/?linkingUri=${queryParam}`;
@@ -120,7 +116,7 @@ class AttributesSummary extends React.Component {
120 116
         <View style={{ flex: 1 }}>
121 117
           <Text
122 118
             style={styles.cancelSigningPetition}
123
-            onPress={this.openPetitionInBrowser}
119
+            onPress={() => openPetitionInBrowser(this.props.petition.id)}
124 120
           >Or, cancel signing this petition
125 121
           </Text>
126 122
         </View>

+ 3 - 7
apps/wallet/screens/PetitionSummary.js

@@ -1,7 +1,7 @@
1 1
 import React from 'react';
2 2
 import { Constants } from 'expo';
3 3
 import Spinner from 'react-native-loading-spinner-overlay';
4
-import { Text, View, Linking, ScrollView } from 'react-native';
4
+import { Text, View, ScrollView } from 'react-native';
5 5
 import { connect } from 'react-redux';
6 6
 import PropTypes from 'prop-types';
7 7
 import { getPetition, signPetition } from '../application/redux/actions/petition';
@@ -11,6 +11,7 @@ import Button from '../application/components/Button/Button';
11 11
 import { goToSignOutcome } from '../application/redux/actions/navigation';
12 12
 import AttributeComponent from '../application/components/Attribute/Attribute';
13 13
 import getWalletProxyUrl from '../config';
14
+import openPetitionInBrowser from '../application/utils';
14 15
 import styles from './styles';
15 16
 
16 17
 
@@ -38,11 +39,6 @@ class PetitionSummary extends React.Component {
38 39
     this.props.getPetition(this.props.petitionLink);
39 40
   }
40 41
 
41
-  openPetitionInBrowser = () => {
42
-    const petitionUrl = `http://secure-petitions.s3-website-eu-west-1.amazonaws.com/#/${this.props.petition.id}`;
43
-    Linking.openURL(petitionUrl);
44
-  };
45
-
46 42
   async sign(petition, walletId, vote) {
47 43
     this.setState({
48 44
       loading: true,
@@ -133,7 +129,7 @@ class PetitionSummary extends React.Component {
133 129
         </View>
134 130
         <Text
135 131
           style={styles.cancelSigningPetition}
136
-          onPress={this.openPetitionInBrowser}
132
+          onPress={() => openPetitionInBrowser(this.props.petition.id)}
137 133
         >Or, cancel signing this petition
138 134
         </Text>
139 135
       </View>);

+ 5 - 8
apps/wallet/screens/SignOutcome.js

@@ -1,10 +1,10 @@
1
-/* eslint-disable max-len */
2 1
 import React from 'react';
3
-import { Text, View, Linking, Image } from 'react-native';
2
+import { Text, View, Image } from 'react-native';
4 3
 import PropTypes from 'prop-types';
5 4
 import { connect } from 'react-redux';
6 5
 import ImageOverlay from 'react-native-image-overlay';
7 6
 import { goToAuthorization } from '../application/redux/actions/navigation';
7
+import openPetitionInBrowser from '../application/utils';
8 8
 import styles from './styles';
9 9
 import Button from '../application/components/Button/Button';
10 10
 
@@ -27,11 +27,7 @@ class SignOutcome extends React.Component {
27 27
       tintColor: 'rgb(0,163,158)',
28 28
       title: 'Outcome',
29 29
     },
30
-  }
31
-
32
-  static handlePress() {
33
-    Linking.openURL('http://secure-petitions.s3-website-eu-west-1.amazonaws.com/#/results/59f888c8ce33c76884e8cf16');
34
-  }
30
+  };
35 31
 
36 32
   static createLink(linkText, index) {
37 33
     return (
@@ -94,7 +90,7 @@ class SignOutcome extends React.Component {
94 90
         </View>
95 91
         <Button
96 92
           name="Back to Decidim"
97
-          onPress={SignOutcome.handlePress}
93
+          onPress={() => openPetitionInBrowser(this.props.petition.id)}
98 94
           style={{
99 95
             width: 200,
100 96
             alignSelf: 'center',
@@ -142,6 +138,7 @@ SignOutcome.propTypes = {
142 138
     title: PropTypes.string,
143 139
     description: PropTypes.string,
144 140
     closingDate: PropTypes.string,
141
+    id: PropTypes.string,
145 142
   }),
146 143
   petitionError: PropTypes.string,
147 144
   links: PropTypes.arrayOf(PropTypes.string),