Browse Source

Centralized urls

Arnaud Vergnet 6 months ago
parent
commit
128af0b813

+ 1
- 1
src/components/Collapsible/CollapsibleComponent.tsx View File

@@ -34,7 +34,7 @@ export type CollapsibleComponentPropsType = {
34 34
   hasTab?: boolean;
35 35
   onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
36 36
   paddedProps?: (paddingTop: number) => Record<string, any>;
37
-  headerColors: string;
37
+  headerColors?: string;
38 38
 };
39 39
 
40 40
 type Props = CollapsibleComponentPropsType & {

+ 1
- 2
src/components/Screens/WebSectionList.tsx View File

@@ -54,9 +54,8 @@ type PropsType<ItemT, RawData> = {
54 54
     data: RawData | null,
55 55
     isLoading?: boolean
56 56
   ) => SectionListDataType<ItemT>;
57
-  onScroll: (event: NativeSyntheticEvent<EventTarget>) => void;
58
-  collapsibleStack: Collapsible;
59 57
 
58
+  onScroll?: (event: NativeSyntheticEvent<EventTarget>) => void;
60 59
   showError?: boolean;
61 60
   itemHeight?: number | null;
62 61
   updateData?: number;

+ 0
- 32
src/constants/AvailableWebsites.ts View File

@@ -1,32 +0,0 @@
1
-/*
2
- * Copyright (c) 2019 - 2020 Arnaud Vergnet.
3
- *
4
- * This file is part of Campus INSAT.
5
- *
6
- * Campus INSAT is free software: you can redistribute it and/or modify
7
- *  it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * Campus INSAT is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with Campus INSAT.  If not, see <https://www.gnu.org/licenses/>.
18
- */
19
-
20
-export default {
21
-  websites: {
22
-    AMICALE: 'https://www.amicale-insat.fr/',
23
-    AVAILABLE_ROOMS: 'http://planex.insa-toulouse.fr/salles.php',
24
-    BIB: 'https://bibbox.insa-toulouse.fr/',
25
-    BLUEMIND: 'https://etud-mel.insa-toulouse.fr/webmail/',
26
-    ELUS_ETUDIANTS: 'https://etud.insa-toulouse.fr/~eeinsat/',
27
-    ENT: 'https://ent.insa-toulouse.fr/',
28
-    INSA_ACCOUNT: 'https://moncompte.insa-toulouse.fr/',
29
-    TUTOR_INSA: 'https://www.etud.insa-toulouse.fr/~tutorinsa/',
30
-    WIKETUD: 'https://wiki.etud.insa-toulouse.fr/',
31
-  },
32
-};

+ 4
- 4
src/constants/ProxiwashConstants.ts View File

@@ -17,6 +17,8 @@
17 17
  * along with Campus INSAT.  If not, see <https://www.gnu.org/licenses/>.
18 18
  */
19 19
 
20
+import Urls from './Urls';
21
+
20 22
 export enum MachineStates {
21 23
   AVAILABLE,
22 24
   RUNNING,
@@ -45,8 +47,7 @@ export default {
45 47
     tarif: 'screens.proxiwash.washinsa.tariff',
46 48
     paymentMethods: 'screens.proxiwash.washinsa.paymentMethods',
47 49
     icon: 'school-outline',
48
-    url:
49
-      'https://etud.insa-toulouse.fr/~amicale_app/v2/washinsa/washinsa_data.json',
50
+    url: Urls.app.api + 'washinsa/washinsa_data.json',
50 51
   },
51 52
   tripodeB: {
52 53
     id: 'tripodeB',
@@ -56,7 +57,6 @@ export default {
56 57
     tarif: 'screens.proxiwash.tripodeB.tariff',
57 58
     paymentMethods: 'screens.proxiwash.tripodeB.paymentMethods',
58 59
     icon: 'domain',
59
-    url:
60
-      'https://etud.insa-toulouse.fr/~amicale_app/v2/washinsa/tripode_b_data.json',
60
+    url: Urls.app.api + 'washinsa/tripode_b_data.json',
61 61
   },
62 62
 };

+ 91
- 0
src/constants/Urls.tsx View File

@@ -0,0 +1,91 @@
1
+/*
2
+ * Copyright (c) 2019 - 2020 Arnaud Vergnet.
3
+ *
4
+ * This file is part of Campus INSAT.
5
+ *
6
+ * Campus INSAT is free software: you can redistribute it and/or modify
7
+ *  it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * Campus INSAT is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with Campus INSAT.  If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+const STUDENT_SERVER = 'https://etud.insa-toulouse.fr/';
21
+const AMICALE_SERVER = 'https://www.amicale-insat.fr/';
22
+const GIT_SERVER =
23
+  'https://git.etud.insa-toulouse.fr/vergnet/application-amicale/';
24
+
25
+const AMICALE_ENDPOINT = AMICALE_SERVER + 'api/';
26
+
27
+const APP_ENDPOINT = STUDENT_SERVER + '~amicale_app/v2/';
28
+const PROXIMO_ENDPOINT = STUDENT_SERVER + '~proximo/data/stock-v2.json';
29
+const APP_IMAGES_ENDPOINT = STUDENT_SERVER + '~amicale_app/images/';
30
+
31
+export default {
32
+  amicale: {
33
+    api: APP_ENDPOINT,
34
+    resetPassword: AMICALE_SERVER + 'password/reset',
35
+    events: AMICALE_ENDPOINT + 'event/list',
36
+  },
37
+  app: {
38
+    api: APP_ENDPOINT,
39
+    dashboard: APP_ENDPOINT + 'dashboard/dashboard_data.json',
40
+    menu: APP_ENDPOINT + 'menu/menu_data.json',
41
+  },
42
+  proximo: PROXIMO_ENDPOINT,
43
+  images: {
44
+    proxiwash: APP_IMAGES_ENDPOINT + 'Proxiwash.png',
45
+    washer: APP_IMAGES_ENDPOINT + 'ProxiwashLaveLinge.png',
46
+    dryer: APP_IMAGES_ENDPOINT + 'ProxiwashSecheLinge.png',
47
+    proximo: APP_IMAGES_ENDPOINT + 'Proximo.png',
48
+    clubs: APP_IMAGES_ENDPOINT + 'Clubs.png',
49
+    profile: APP_IMAGES_ENDPOINT + 'ProfilAmicaliste.png',
50
+    equipment: APP_IMAGES_ENDPOINT + 'Materiel.png',
51
+    vote: APP_IMAGES_ENDPOINT + 'Vote.png',
52
+    amicale: APP_IMAGES_ENDPOINT + 'WebsiteAmicale.png',
53
+    wiketud: APP_IMAGES_ENDPOINT + 'Wiketud.png',
54
+    elusEtudiants: APP_IMAGES_ENDPOINT + 'EEC.png',
55
+    tutorInsa: APP_IMAGES_ENDPOINT + 'TutorINSA.png',
56
+    bib: APP_IMAGES_ENDPOINT + 'Bib.png',
57
+    menu: APP_IMAGES_ENDPOINT + 'RU.png',
58
+    availableRooms: APP_IMAGES_ENDPOINT + 'Salles.png',
59
+    bluemind: APP_IMAGES_ENDPOINT + 'Bluemind.png',
60
+    ent: APP_IMAGES_ENDPOINT + 'ENT.png',
61
+    insaAccount: APP_IMAGES_ENDPOINT + 'Account.png',
62
+  },
63
+  websites: {
64
+    amicale: AMICALE_SERVER,
65
+    availableRooms: 'http://planex.insa-toulouse.fr/salles.php',
66
+    bib: 'https://bibbox.insa-toulouse.fr/',
67
+    bluemind: 'https://etud-mel.insa-toulouse.fr/webmail/',
68
+    elusEtudiants: STUDENT_SERVER + '~eeinsat/',
69
+    ent: 'https://ent.insa-toulouse.fr/',
70
+    insaAccount: 'https://moncompte.insa-toulouse.fr/',
71
+    tutorInsa: STUDENT_SERVER + '~tutorinsa/',
72
+    wiketud: 'https://wiki.etud.insa-toulouse.fr/',
73
+  },
74
+  about: {
75
+    appstore: 'https://apps.apple.com/us/app/campus-amicale-insat/id1477722148',
76
+    playstore:
77
+      'https://play.google.com/store/apps/details?id=fr.amicaleinsat.application',
78
+    react: 'https://facebook.github.io/react-native/',
79
+    git: GIT_SERVER + 'src/branch/master/README.md',
80
+    changelog: GIT_SERVER + 'src/branch/master/Changelog.md',
81
+    license: GIT_SERVER + 'src/branch/master/LICENSE',
82
+  },
83
+  feedback: {
84
+    git: GIT_SERVER,
85
+    trello: 'https://trello.com/b/RMej49Uq/application-campus-insa',
86
+    facebook: 'https://www.facebook.com/campus.insat',
87
+    mail: `mailto:app@amicale-insat.fr?subject=[FEEDBACK] Application CAMPUS
88
+&body=Coucou Arnaud j'ai du feedback\n\n\n\nBien cordialement.`,
89
+    discord: 'https://discord.gg/W8MeTec',
90
+  },
91
+};

+ 27
- 64
src/managers/ServicesManager.ts View File

@@ -19,47 +19,10 @@
19 19
 
20 20
 import i18n from 'i18n-js';
21 21
 import { StackNavigationProp } from '@react-navigation/stack';
22
-import AvailableWebsites from '../constants/AvailableWebsites';
23 22
 import ConnectionManager from './ConnectionManager';
24 23
 import type { FullDashboardType } from '../screens/Home/HomeScreen';
25 24
 import getStrippedServicesList from '../utils/Services';
26
-
27
-// AMICALE
28
-const CLUBS_IMAGE =
29
-  'https://etud.insa-toulouse.fr/~amicale_app/images/Clubs.png';
30
-const PROFILE_IMAGE =
31
-  'https://etud.insa-toulouse.fr/~amicale_app/images/ProfilAmicaliste.png';
32
-const EQUIPMENT_IMAGE =
33
-  'https://etud.insa-toulouse.fr/~amicale_app/images/Materiel.png';
34
-const VOTE_IMAGE = 'https://etud.insa-toulouse.fr/~amicale_app/images/Vote.png';
35
-const AMICALE_IMAGE =
36
-  'https://etud.insa-toulouse.fr/~amicale_app/images/WebsiteAmicale.png';
37
-
38
-// STUDENTS
39
-const PROXIMO_IMAGE =
40
-  'https://etud.insa-toulouse.fr/~amicale_app/images/Proximo.png';
41
-const WIKETUD_IMAGE =
42
-  'https://etud.insa-toulouse.fr/~amicale_app/images/Wiketud.png';
43
-const EE_IMAGE = 'https://etud.insa-toulouse.fr/~amicale_app/images/EEC.png';
44
-const TUTORINSA_IMAGE =
45
-  'https://etud.insa-toulouse.fr/~amicale_app/images/TutorINSA.png';
46
-
47
-// INSA
48
-const BIB_IMAGE = 'https://etud.insa-toulouse.fr/~amicale_app/images/Bib.png';
49
-const RU_IMAGE = 'https://etud.insa-toulouse.fr/~amicale_app/images/RU.png';
50
-const ROOM_IMAGE =
51
-  'https://etud.insa-toulouse.fr/~amicale_app/images/Salles.png';
52
-const EMAIL_IMAGE =
53
-  'https://etud.insa-toulouse.fr/~amicale_app/images/Bluemind.png';
54
-const ENT_IMAGE = 'https://etud.insa-toulouse.fr/~amicale_app/images/ENT.png';
55
-const ACCOUNT_IMAGE =
56
-  'https://etud.insa-toulouse.fr/~amicale_app/images/Account.png';
57
-
58
-// SPECIAL
59
-const WASHER_IMAGE =
60
-  'https://etud.insa-toulouse.fr/~amicale_app/images/ProxiwashLaveLinge.png';
61
-const DRYER_IMAGE =
62
-  'https://etud.insa-toulouse.fr/~amicale_app/images/ProxiwashSecheLinge.png';
25
+import Urls from '../constants/Urls';
63 26
 
64 27
 const AMICALE_LOGO = require('../../assets/amicale.png');
65 28
 
@@ -127,31 +90,31 @@ export default class ServicesManager {
127 90
         key: SERVICES_KEY.CLUBS,
128 91
         title: i18n.t('screens.clubs.title'),
129 92
         subtitle: i18n.t('screens.services.descriptions.clubs'),
130
-        image: CLUBS_IMAGE,
93
+        image: Urls.images.clubs,
131 94
         onPress: (): void => this.onAmicaleServicePress('club-list'),
132 95
       },
133 96
       {
134 97
         key: SERVICES_KEY.PROFILE,
135 98
         title: i18n.t('screens.profile.title'),
136 99
         subtitle: i18n.t('screens.services.descriptions.profile'),
137
-        image: PROFILE_IMAGE,
100
+        image: Urls.images.profile,
138 101
         onPress: (): void => this.onAmicaleServicePress('profile'),
139 102
       },
140 103
       {
141 104
         key: SERVICES_KEY.EQUIPMENT,
142 105
         title: i18n.t('screens.equipment.title'),
143 106
         subtitle: i18n.t('screens.services.descriptions.equipment'),
144
-        image: EQUIPMENT_IMAGE,
107
+        image: Urls.images.equipment,
145 108
         onPress: (): void => this.onAmicaleServicePress('equipment-list'),
146 109
       },
147 110
       {
148 111
         key: SERVICES_KEY.AMICALE_WEBSITE,
149 112
         title: i18n.t('screens.websites.amicale'),
150 113
         subtitle: i18n.t('screens.services.descriptions.amicaleWebsite'),
151
-        image: AMICALE_IMAGE,
114
+        image: Urls.images.amicale,
152 115
         onPress: (): void =>
153 116
           nav.navigate('website', {
154
-            host: AvailableWebsites.websites.AMICALE,
117
+            host: Urls.websites.amicale,
155 118
             title: i18n.t('screens.websites.amicale'),
156 119
           }),
157 120
       },
@@ -159,7 +122,7 @@ export default class ServicesManager {
159 122
         key: SERVICES_KEY.VOTE,
160 123
         title: i18n.t('screens.vote.title'),
161 124
         subtitle: i18n.t('screens.services.descriptions.vote'),
162
-        image: VOTE_IMAGE,
125
+        image: Urls.images.vote,
163 126
         onPress: (): void => this.onAmicaleServicePress('vote'),
164 127
       },
165 128
     ];
@@ -168,7 +131,7 @@ export default class ServicesManager {
168 131
         key: SERVICES_KEY.PROXIMO,
169 132
         title: i18n.t('screens.proximo.title'),
170 133
         subtitle: i18n.t('screens.services.descriptions.proximo'),
171
-        image: PROXIMO_IMAGE,
134
+        image: Urls.images.proximo,
172 135
         onPress: (): void => nav.navigate('proximo'),
173 136
         badgeFunction: (dashboard: FullDashboardType): number =>
174 137
           dashboard.proximo_articles,
@@ -177,10 +140,10 @@ export default class ServicesManager {
177 140
         key: SERVICES_KEY.WIKETUD,
178 141
         title: 'Wiketud',
179 142
         subtitle: i18n.t('screens.services.descriptions.wiketud'),
180
-        image: WIKETUD_IMAGE,
143
+        image: Urls.images.wiketud,
181 144
         onPress: (): void =>
182 145
           nav.navigate('website', {
183
-            host: AvailableWebsites.websites.WIKETUD,
146
+            host: Urls.websites.wiketud,
184 147
             title: 'Wiketud',
185 148
           }),
186 149
       },
@@ -188,10 +151,10 @@ export default class ServicesManager {
188 151
         key: SERVICES_KEY.ELUS_ETUDIANTS,
189 152
         title: 'Élus Étudiants',
190 153
         subtitle: i18n.t('screens.services.descriptions.elusEtudiants'),
191
-        image: EE_IMAGE,
154
+        image: Urls.images.elusEtudiants,
192 155
         onPress: (): void =>
193 156
           nav.navigate('website', {
194
-            host: AvailableWebsites.websites.ELUS_ETUDIANTS,
157
+            host: Urls.websites.elusEtudiants,
195 158
             title: 'Élus Étudiants',
196 159
           }),
197 160
       },
@@ -199,10 +162,10 @@ export default class ServicesManager {
199 162
         key: SERVICES_KEY.TUTOR_INSA,
200 163
         title: "Tutor'INSA",
201 164
         subtitle: i18n.t('screens.services.descriptions.tutorInsa'),
202
-        image: TUTORINSA_IMAGE,
165
+        image: Urls.images.tutorInsa,
203 166
         onPress: (): void =>
204 167
           nav.navigate('website', {
205
-            host: AvailableWebsites.websites.TUTOR_INSA,
168
+            host: Urls.websites.tutorInsa,
206 169
             title: "Tutor'INSA",
207 170
           }),
208 171
         badgeFunction: (dashboard: FullDashboardType): number =>
@@ -214,7 +177,7 @@ export default class ServicesManager {
214 177
         key: SERVICES_KEY.RU,
215 178
         title: i18n.t('screens.menu.title'),
216 179
         subtitle: i18n.t('screens.services.descriptions.self'),
217
-        image: RU_IMAGE,
180
+        image: Urls.images.menu,
218 181
         onPress: (): void => nav.navigate('self-menu'),
219 182
         badgeFunction: (dashboard: FullDashboardType): number =>
220 183
           dashboard.today_menu.length,
@@ -223,10 +186,10 @@ export default class ServicesManager {
223 186
         key: SERVICES_KEY.AVAILABLE_ROOMS,
224 187
         title: i18n.t('screens.websites.rooms'),
225 188
         subtitle: i18n.t('screens.services.descriptions.availableRooms'),
226
-        image: ROOM_IMAGE,
189
+        image: Urls.images.availableRooms,
227 190
         onPress: (): void =>
228 191
           nav.navigate('website', {
229
-            host: AvailableWebsites.websites.AVAILABLE_ROOMS,
192
+            host: Urls.websites.availableRooms,
230 193
             title: i18n.t('screens.websites.rooms'),
231 194
           }),
232 195
       },
@@ -234,10 +197,10 @@ export default class ServicesManager {
234 197
         key: SERVICES_KEY.BIB,
235 198
         title: i18n.t('screens.websites.bib'),
236 199
         subtitle: i18n.t('screens.services.descriptions.bib'),
237
-        image: BIB_IMAGE,
200
+        image: Urls.images.bib,
238 201
         onPress: (): void =>
239 202
           nav.navigate('website', {
240
-            host: AvailableWebsites.websites.BIB,
203
+            host: Urls.websites.bib,
241 204
             title: i18n.t('screens.websites.bib'),
242 205
           }),
243 206
       },
@@ -245,10 +208,10 @@ export default class ServicesManager {
245 208
         key: SERVICES_KEY.EMAIL,
246 209
         title: i18n.t('screens.websites.mails'),
247 210
         subtitle: i18n.t('screens.services.descriptions.mails'),
248
-        image: EMAIL_IMAGE,
211
+        image: Urls.images.bluemind,
249 212
         onPress: (): void =>
250 213
           nav.navigate('website', {
251
-            host: AvailableWebsites.websites.BLUEMIND,
214
+            host: Urls.websites.bluemind,
252 215
             title: i18n.t('screens.websites.mails'),
253 216
           }),
254 217
       },
@@ -256,10 +219,10 @@ export default class ServicesManager {
256 219
         key: SERVICES_KEY.ENT,
257 220
         title: i18n.t('screens.websites.ent'),
258 221
         subtitle: i18n.t('screens.services.descriptions.ent'),
259
-        image: ENT_IMAGE,
222
+        image: Urls.images.ent,
260 223
         onPress: (): void =>
261 224
           nav.navigate('website', {
262
-            host: AvailableWebsites.websites.ENT,
225
+            host: Urls.websites.ent,
263 226
             title: i18n.t('screens.websites.ent'),
264 227
           }),
265 228
       },
@@ -267,10 +230,10 @@ export default class ServicesManager {
267 230
         key: SERVICES_KEY.INSA_ACCOUNT,
268 231
         title: i18n.t('screens.insaAccount.title'),
269 232
         subtitle: i18n.t('screens.services.descriptions.insaAccount'),
270
-        image: ACCOUNT_IMAGE,
233
+        image: Urls.images.insaAccount,
271 234
         onPress: (): void =>
272 235
           nav.navigate('website', {
273
-            host: AvailableWebsites.websites.INSA_ACCOUNT,
236
+            host: Urls.websites.insaAccount,
274 237
             title: i18n.t('screens.insaAccount.title'),
275 238
           }),
276 239
       },
@@ -280,7 +243,7 @@ export default class ServicesManager {
280 243
         key: SERVICES_KEY.WASHERS,
281 244
         title: i18n.t('screens.proxiwash.washers'),
282 245
         subtitle: i18n.t('screens.services.descriptions.washers'),
283
-        image: WASHER_IMAGE,
246
+        image: Urls.images.washer,
284 247
         onPress: (): void => nav.navigate('proxiwash'),
285 248
         badgeFunction: (dashboard: FullDashboardType): number =>
286 249
           dashboard.available_washers,
@@ -289,7 +252,7 @@ export default class ServicesManager {
289 252
         key: SERVICES_KEY.DRYERS,
290 253
         title: i18n.t('screens.proxiwash.dryers'),
291 254
         subtitle: i18n.t('screens.services.descriptions.washers'),
292
-        image: DRYER_IMAGE,
255
+        image: Urls.images.dryer,
293 256
         onPress: (): void => nav.navigate('proxiwash'),
294 257
         badgeFunction: (dashboard: FullDashboardType): number =>
295 258
           dashboard.available_dryers,

+ 8
- 18
src/screens/About/AboutScreen.tsx View File

@@ -34,6 +34,7 @@ import CollapsibleFlatList from '../../components/Collapsible/CollapsibleFlatLis
34 34
 import OptionsDialog from '../../components/Dialogs/OptionsDialog';
35 35
 import type { OptionsDialogButtonType } from '../../components/Dialogs/OptionsDialog';
36 36
 import GENERAL_STYLES from '../../constants/Styles';
37
+import Urls from '../../constants/Urls';
37 38
 
38 39
 const APP_LOGO = require('../../../assets/android.icon.round.png');
39 40
 
@@ -53,19 +54,6 @@ type MemberItemType = {
53 54
   mail?: string;
54 55
 };
55 56
 
56
-const links = {
57
-  appstore: 'https://apps.apple.com/us/app/campus-amicale-insat/id1477722148',
58
-  playstore:
59
-    'https://play.google.com/store/apps/details?id=fr.amicaleinsat.application',
60
-  git:
61
-    'https://git.etud.insa-toulouse.fr/vergnet/application-amicale/src/branch/master/README.md',
62
-  changelog:
63
-    'https://git.etud.insa-toulouse.fr/vergnet/application-amicale/src/branch/master/Changelog.md',
64
-  license:
65
-    'https://git.etud.insa-toulouse.fr/vergnet/application-amicale/src/branch/master/LICENSE',
66
-  react: 'https://facebook.github.io/react-native/',
67
-};
68
-
69 57
 type PropsType = {
70 58
   navigation: StackNavigationProp<any>;
71 59
 };
@@ -177,7 +165,9 @@ class AboutScreen extends React.Component<PropsType, StateType> {
177 165
   appData: Array<ListItemType> = [
178 166
     {
179 167
       onPressCallback: () => {
180
-        openWebLink(Platform.OS === 'ios' ? links.appstore : links.playstore);
168
+        openWebLink(
169
+          Platform.OS === 'ios' ? Urls.about.appstore : Urls.about.playstore
170
+        );
181 171
       },
182 172
       icon: Platform.OS === 'ios' ? 'apple' : 'google-play',
183 173
       text:
@@ -197,7 +187,7 @@ class AboutScreen extends React.Component<PropsType, StateType> {
197 187
     },
198 188
     {
199 189
       onPressCallback: () => {
200
-        openWebLink(links.git);
190
+        openWebLink(Urls.about.git);
201 191
       },
202 192
       icon: 'git',
203 193
       text: 'Git',
@@ -205,7 +195,7 @@ class AboutScreen extends React.Component<PropsType, StateType> {
205 195
     },
206 196
     {
207 197
       onPressCallback: () => {
208
-        openWebLink(links.changelog);
198
+        openWebLink(Urls.about.changelog);
209 199
       },
210 200
       icon: 'refresh',
211 201
       text: i18n.t('screens.about.changelog'),
@@ -213,7 +203,7 @@ class AboutScreen extends React.Component<PropsType, StateType> {
213 203
     },
214 204
     {
215 205
       onPressCallback: () => {
216
-        openWebLink(links.license);
206
+        openWebLink(Urls.about.license);
217 207
       },
218 208
       icon: 'file-document',
219 209
       text: i18n.t('screens.about.license'),
@@ -237,7 +227,7 @@ class AboutScreen extends React.Component<PropsType, StateType> {
237 227
   technoData = [
238 228
     {
239 229
       onPressCallback: () => {
240
-        openWebLink(links.react);
230
+        openWebLink(Urls.about.react);
241 231
       },
242 232
       icon: 'react',
243 233
       text: i18n.t('screens.about.reactNative'),

+ 3
- 5
src/screens/Amicale/LoginScreen.tsx View File

@@ -32,12 +32,12 @@ import LinearGradient from 'react-native-linear-gradient';
32 32
 import ConnectionManager from '../../managers/ConnectionManager';
33 33
 import ErrorDialog from '../../components/Dialogs/ErrorDialog';
34 34
 import AsyncStorageManager from '../../managers/AsyncStorageManager';
35
-import AvailableWebsites from '../../constants/AvailableWebsites';
36 35
 import { MASCOT_STYLE } from '../../components/Mascot/Mascot';
37 36
 import MascotPopup from '../../components/Mascot/MascotPopup';
38 37
 import CollapsibleScrollView from '../../components/Collapsible/CollapsibleScrollView';
39 38
 import { MainStackParamsList } from '../../navigation/MainNavigator';
40 39
 import GENERAL_STYLES from '../../constants/Styles';
40
+import Urls from '../../constants/Urls';
41 41
 
42 42
 type LoginScreenNavigationProp = StackScreenProps<MainStackParamsList, 'login'>;
43 43
 
@@ -59,8 +59,6 @@ type StateType = {
59 59
 
60 60
 const ICON_AMICALE = require('../../../assets/amicale.png');
61 61
 
62
-const RESET_PASSWORD_PATH = 'https://www.amicale-insat.fr/password/reset';
63
-
64 62
 const emailRegex = /^.+@.+\..+$/;
65 63
 
66 64
 const styles = StyleSheet.create({
@@ -134,8 +132,8 @@ class LoginScreen extends React.Component<Props, StateType> {
134 132
   onResetPasswordClick = () => {
135 133
     const { navigation } = this.props;
136 134
     navigation.navigate('website', {
137
-      host: AvailableWebsites.websites.AMICALE,
138
-      path: RESET_PASSWORD_PATH,
135
+      host: Urls.websites.amicale,
136
+      path: Urls.amicale.resetPassword,
139 137
       title: i18n.t('screens.websites.amicale'),
140 138
     });
141 139
   };

+ 2
- 2
src/screens/Amicale/ProfileScreen.tsx View File

@@ -36,12 +36,12 @@ import MaterialHeaderButtons, {
36 36
   Item,
37 37
 } from '../../components/Overrides/CustomHeaderButton';
38 38
 import CardList from '../../components/Lists/CardList/CardList';
39
-import AvailableWebsites from '../../constants/AvailableWebsites';
40 39
 import Mascot, { MASCOT_STYLE } from '../../components/Mascot/Mascot';
41 40
 import ServicesManager, { SERVICES_KEY } from '../../managers/ServicesManager';
42 41
 import CollapsibleFlatList from '../../components/Collapsible/CollapsibleFlatList';
43 42
 import type { ServiceItemType } from '../../managers/ServicesManager';
44 43
 import GENERAL_STYLES from '../../constants/Styles';
44
+import Urls from '../../constants/Urls';
45 45
 
46 46
 type PropsType = {
47 47
   navigation: StackNavigationProp<any>;
@@ -298,7 +298,7 @@ class ProfileScreen extends React.Component<PropsType, StateType> {
298 298
               mode="contained"
299 299
               onPress={() => {
300 300
                 navigation.navigate('website', {
301
-                  host: AvailableWebsites.websites.AMICALE,
301
+                  host: Urls.websites.amicale,
302 302
                   path: this.data?.link,
303 303
                   title: i18n.t('screens.websites.amicale'),
304 304
                 });

+ 2
- 4
src/screens/Home/HomeScreen.tsx View File

@@ -51,10 +51,8 @@ import type { ServiceItemType } from '../../managers/ServicesManager';
51 51
 import { getDisplayEvent, getFutureEvents } from '../../utils/Home';
52 52
 import type { PlanningEventType } from '../../utils/Planning';
53 53
 import GENERAL_STYLES from '../../constants/Styles';
54
-// import DATA from "../dashboard_data.json";
54
+import Urls from '../../constants/Urls';
55 55
 
56
-const DATA_URL =
57
-  'https://etud.insa-toulouse.fr/~amicale_app/v2/dashboard/dashboard_data.json';
58 56
 const FEED_ITEM_HEIGHT = 500;
59 57
 
60 58
 const SECTIONS_ID = ['dashboard', 'news_feed'];
@@ -476,7 +474,7 @@ class HomeScreen extends React.Component<PropsType, StateType> {
476 474
             createDataset={this.createDataset}
477 475
             autoRefreshTime={REFRESH_TIME}
478 476
             refreshOnFocus
479
-            fetchUrl={DATA_URL}
477
+            fetchUrl={Urls.app.dashboard}
480 478
             renderItem={this.getRenderItem}
481 479
             itemHeight={FEED_ITEM_HEIGHT}
482 480
             onScroll={this.onScroll}

+ 6
- 14
src/screens/Other/FeedbackScreen.tsx View File

@@ -22,15 +22,7 @@ import { Avatar, Button, Card, Paragraph, withTheme } from 'react-native-paper';
22 22
 import i18n from 'i18n-js';
23 23
 import { Linking, StyleSheet, View } from 'react-native';
24 24
 import CollapsibleScrollView from '../../components/Collapsible/CollapsibleScrollView';
25
-
26
-const links = {
27
-  bugsGit: 'https://git.etud.insa-toulouse.fr/vergnet/application-amicale/',
28
-  trello: 'https://trello.com/b/RMej49Uq/application-campus-insa',
29
-  facebook: 'https://www.facebook.com/campus.insat',
30
-  feedbackMail: `mailto:app@amicale-insat.fr?subject=[FEEDBACK] Application CAMPUS
31
-&body=Coucou Arnaud j'ai du feedback\n\n\n\nBien cordialement.`,
32
-  feedbackDiscord: 'https://discord.gg/W8MeTec',
33
-};
25
+import Urls from '../../constants/Urls';
34 26
 
35 27
 const styles = StyleSheet.create({
36 28
   container: {
@@ -63,7 +55,7 @@ function getButtons(isFeedback: boolean) {
63 55
             mode="contained"
64 56
             style={styles.button}
65 57
             onPress={() => {
66
-              Linking.openURL(links.feedbackMail);
58
+              Linking.openURL(Urls.feedback.mail);
67 59
             }}
68 60
           >
69 61
             MAIL
@@ -74,7 +66,7 @@ function getButtons(isFeedback: boolean) {
74 66
             color="#2e88fe"
75 67
             style={styles.button}
76 68
             onPress={() => {
77
-              Linking.openURL(links.facebook);
69
+              Linking.openURL(Urls.feedback.facebook);
78 70
             }}
79 71
           >
80 72
             Facebook
@@ -85,7 +77,7 @@ function getButtons(isFeedback: boolean) {
85 77
             color="#7289da"
86 78
             style={styles.button}
87 79
             onPress={() => {
88
-              Linking.openURL(links.feedbackDiscord);
80
+              Linking.openURL(Urls.feedback.discord);
89 81
             }}
90 82
           >
91 83
             Discord
@@ -99,7 +91,7 @@ function getButtons(isFeedback: boolean) {
99 91
             color="#609927"
100 92
             style={styles.button}
101 93
             onPress={() => {
102
-              Linking.openURL(links.bugsGit);
94
+              Linking.openURL(Urls.feedback.git);
103 95
             }}
104 96
           >
105 97
             GITETUD
@@ -110,7 +102,7 @@ function getButtons(isFeedback: boolean) {
110 102
             color="#026AA7"
111 103
             style={styles.button}
112 104
             onPress={() => {
113
-              Linking.openURL(links.trello);
105
+              Linking.openURL(Urls.feedback.trello);
114 106
             }}
115 107
           >
116 108
             TRELLO

+ 2
- 2
src/screens/Planning/PlanningScreen.tsx View File

@@ -36,6 +36,7 @@ import { MASCOT_STYLE } from '../../components/Mascot/Mascot';
36 36
 import MascotPopup from '../../components/Mascot/MascotPopup';
37 37
 import AsyncStorageManager from '../../managers/AsyncStorageManager';
38 38
 import GENERAL_STYLES from '../../constants/Styles';
39
+import Urls from '../../constants/Urls';
39 40
 
40 41
 LocaleConfig.locales.fr = {
41 42
   monthNames: [
@@ -88,7 +89,6 @@ type StateType = {
88 89
   calendarShowing: boolean;
89 90
 };
90 91
 
91
-const FETCH_URL = 'https://www.amicale-insat.fr/api/event/list';
92 92
 const AGENDA_MONTH_SPAN = 3;
93 93
 
94 94
 const styles = StyleSheet.create({
@@ -174,7 +174,7 @@ class PlanningScreen extends React.Component<PropsType, StateType> {
174 174
 
175 175
     if (canRefresh) {
176 176
       this.setState({ refreshing: true });
177
-      readData(FETCH_URL)
177
+      readData(Urls.amicale.events)
178 178
         .then((fetchedData: Array<PlanningEventType>) => {
179 179
           this.setState({
180 180
             refreshing: false,

+ 3
- 4
src/screens/Proxiwash/ProxiwashAboutScreen.tsx View File

@@ -23,8 +23,7 @@ import i18n from 'i18n-js';
23 23
 import { Card, Avatar, Paragraph, Title } from 'react-native-paper';
24 24
 import CollapsibleScrollView from '../../components/Collapsible/CollapsibleScrollView';
25 25
 import ProxiwashConstants from '../../constants/ProxiwashConstants';
26
-
27
-const LOGO = 'https://etud.insa-toulouse.fr/~amicale_app/images/Proxiwash.png';
26
+import Urls from '../../constants/Urls';
28 27
 
29 28
 export type LaundromatType = {
30 29
   id: string;
@@ -85,9 +84,9 @@ function getCardItem(item: LaundromatType) {
85 84
  */
86 85
 export default function ProxiwashAboutScreen() {
87 86
   return (
88
-    <CollapsibleScrollView style={styles.container} hasTab>
87
+    <CollapsibleScrollView style={styles.container} hasTab={true}>
89 88
       <View style={styles.imageContainer}>
90
-        <Image source={{ uri: LOGO }} style={styles.image} />
89
+        <Image source={{ uri: Urls.images.proxiwash }} style={styles.image} />
91 90
       </View>
92 91
 
93 92
       {getCardItem(ProxiwashConstants.washinsa)}

+ 3
- 6
src/screens/Services/Proximo/ProximoAboutScreen.tsx View File

@@ -21,12 +21,9 @@ import * as React from 'react';
21 21
 import { Image, StyleSheet, View } from 'react-native';
22 22
 import i18n from 'i18n-js';
23 23
 import { Card, Avatar, Paragraph, Text } from 'react-native-paper';
24
-import CustomTabBar, {
25
-  TAB_BAR_HEIGHT,
26
-} from '../../../components/Tabbar/CustomTabBar';
24
+import { TAB_BAR_HEIGHT } from '../../../components/Tabbar/CustomTabBar';
27 25
 import CollapsibleScrollView from '../../../components/Collapsible/CollapsibleScrollView';
28
-
29
-const LOGO = 'https://etud.insa-toulouse.fr/~amicale_app/images/Proximo.png';
26
+import Urls from '../../../constants/Urls';
30 27
 
31 28
 const styles = StyleSheet.create({
32 29
   container: {
@@ -57,7 +54,7 @@ export default function ProximoAboutScreen() {
57 54
   return (
58 55
     <CollapsibleScrollView style={styles.container}>
59 56
       <View style={styles.imageContainer}>
60
-        <Image source={{ uri: LOGO }} style={styles.image} />
57
+        <Image source={{ uri: Urls.images.proximo }} style={styles.image} />
61 58
       </View>
62 59
       <Text>{i18n.t('screens.proximo.description')}</Text>
63 60
       <Card style={styles.card}>

+ 2
- 2
src/screens/Services/Proximo/ProximoMainScreen.tsx View File

@@ -27,8 +27,8 @@ import MaterialHeaderButtons, {
27 27
 } from '../../../components/Overrides/CustomHeaderButton';
28 28
 import type { SectionListDataType } from '../../../components/Screens/WebSectionList';
29 29
 import { StyleSheet } from 'react-native';
30
+import Urls from '../../../constants/Urls';
30 31
 
31
-const DATA_URL = 'https://etud.insa-toulouse.fr/~proximo/data/stock-v2.json';
32 32
 const LIST_ITEM_HEIGHT = 84;
33 33
 
34 34
 export type ProximoCategoryType = {
@@ -320,7 +320,7 @@ class ProximoMainScreen extends React.Component<PropsType> {
320 320
         navigation={navigation}
321 321
         autoRefreshTime={0}
322 322
         refreshOnFocus={false}
323
-        fetchUrl={DATA_URL}
323
+        fetchUrl={Urls.proximo}
324 324
         renderItem={this.getRenderItem}
325 325
       />
326 326
     );

+ 2
- 4
src/screens/Services/SelfMenuScreen.tsx View File

@@ -25,9 +25,7 @@ import i18n from 'i18n-js';
25 25
 import DateManager from '../../managers/DateManager';
26 26
 import WebSectionList from '../../components/Screens/WebSectionList';
27 27
 import type { SectionListDataType } from '../../components/Screens/WebSectionList';
28
-
29
-const DATA_URL =
30
-  'https://etud.insa-toulouse.fr/~amicale_app/menu/menu_data.json';
28
+import Urls from '../../constants/Urls';
31 29
 
32 30
 type PropsType = {
33 31
   navigation: StackNavigationProp<any>;
@@ -198,7 +196,7 @@ class SelfMenuScreen extends React.Component<PropsType> {
198 196
         navigation={navigation}
199 197
         autoRefreshTime={0}
200 198
         refreshOnFocus={false}
201
-        fetchUrl={DATA_URL}
199
+        fetchUrl={Urls.app.menu}
202 200
         renderItem={this.getRenderItem}
203 201
         renderSectionHeader={this.getRenderSectionHeader}
204 202
         stickyHeader

+ 6
- 6
src/screens/Services/WebsiteScreen.tsx View File

@@ -20,8 +20,8 @@
20 20
 import * as React from 'react';
21 21
 import { StackNavigationProp } from '@react-navigation/stack';
22 22
 import WebViewScreen from '../../components/Screens/WebViewScreen';
23
-import AvailableWebsites from '../../constants/AvailableWebsites';
24 23
 import BasicLoadingScreen from '../../components/Screens/BasicLoadingScreen';
24
+import Urls from '../../constants/Urls';
25 25
 
26 26
 type Props = {
27 27
   navigation: StackNavigationProp<any>;
@@ -42,7 +42,7 @@ const BIB_STYLE =
42 42
 
43 43
 const BIB_BACK_BUTTON =
44 44
   "<div style='width: 100%; display: flex'>" +
45
-  `<a style='margin: auto' href='${AvailableWebsites.websites.BIB}'>` +
45
+  `<a style='margin: auto' href='${Urls.websites.bib}'>` +
46 46
   "<button id='customBackButton' class='btn btn-primary'>Retour</button>" +
47 47
   '</a>' +
48 48
   '</div>';
@@ -63,17 +63,17 @@ class WebsiteScreen extends React.Component<Props, State> {
63 63
     props.navigation.addListener('focus', this.onScreenFocus);
64 64
     this.injectedJS = {};
65 65
     this.customPaddingFunctions = {};
66
-    this.injectedJS[AvailableWebsites.websites.AVAILABLE_ROOMS] =
66
+    this.injectedJS[Urls.websites.availableRooms] =
67 67
       `document.querySelector('head').innerHTML += '${ENABLE_MOBILE_STRING}';` +
68 68
       `document.querySelector('head').innerHTML += '${AVAILABLE_ROOMS_STYLE}'; true;`;
69 69
 
70
-    this.injectedJS[AvailableWebsites.websites.BIB] =
70
+    this.injectedJS[Urls.websites.bib] =
71 71
       `document.querySelector('head').innerHTML += '${ENABLE_MOBILE_STRING}';` +
72 72
       `document.querySelector('head').innerHTML += '${BIB_STYLE}';` +
73 73
       'if ($(".hero-unit-form").length > 0 && $("#customBackButton").length === 0)' +
74 74
       `$(".hero-unit-form").append("${BIB_BACK_BUTTON}");true;`;
75 75
 
76
-    this.customPaddingFunctions[AvailableWebsites.websites.BLUEMIND] = (
76
+    this.customPaddingFunctions[Urls.websites.bluemind] = (
77 77
       padding: number
78 78
     ): string => {
79 79
       return (
@@ -82,7 +82,7 @@ class WebsiteScreen extends React.Component<Props, State> {
82 82
         "$('#mailview-bottom').css('min-height', 500);"
83 83
       );
84 84
     };
85
-    this.customPaddingFunctions[AvailableWebsites.websites.WIKETUD] = (
85
+    this.customPaddingFunctions[Urls.websites.wiketud] = (
86 86
       padding: number
87 87
     ): string => {
88 88
       return (

+ 3
- 3
src/utils/WebData.ts View File

@@ -17,6 +17,8 @@
17 17
  * along with Campus INSAT.  If not, see <https://www.gnu.org/licenses/>.
18 18
  */
19 19
 
20
+import Urls from '../constants/Urls';
21
+
20 22
 export const ERROR_TYPE = {
21 23
   SUCCESS: 0,
22 24
   BAD_CREDENTIALS: 1,
@@ -40,8 +42,6 @@ type ApiResponseType<T> = {
40 42
   data: T;
41 43
 };
42 44
 
43
-const API_ENDPOINT = 'https://www.amicale-insat.fr/api/';
44
-
45 45
 /**
46 46
  * Checks if the given API response is valid.
47 47
  *
@@ -81,7 +81,7 @@ export async function apiRequest<T>(
81 81
       if (params != null) {
82 82
         requestParams = { ...params };
83 83
       }
84
-      fetch(API_ENDPOINT + path, {
84
+      fetch(Urls.amicale.api + path, {
85 85
         method,
86 86
         headers: new Headers({
87 87
           'Accept': 'application/json',

Loading…
Cancel
Save