|
@@ -1,378 +1,384 @@
|
1
|
1
|
// @flow
|
2
|
2
|
|
3
|
|
-import i18n from "i18n-js";
|
4
|
|
-import AvailableWebsites from "../constants/AvailableWebsites";
|
5
|
|
-import {StackNavigationProp} from "@react-navigation/stack";
|
6
|
|
-import ConnectionManager from "./ConnectionManager";
|
7
|
|
-import type {fullDashboard} from "../screens/Home/HomeScreen";
|
|
3
|
+import i18n from 'i18n-js';
|
|
4
|
+import {StackNavigationProp} from '@react-navigation/stack';
|
|
5
|
+import AvailableWebsites from '../constants/AvailableWebsites';
|
|
6
|
+import ConnectionManager from './ConnectionManager';
|
|
7
|
+import type {FullDashboardType} from '../screens/Home/HomeScreen';
|
|
8
|
+import getStrippedServicesList from '../utils/Services';
|
8
|
9
|
|
9
|
10
|
// AMICALE
|
10
|
|
-const CLUBS_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/Clubs.png";
|
11
|
|
-const PROFILE_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/ProfilAmicaliste.png";
|
12
|
|
-const EQUIPMENT_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/Materiel.png";
|
13
|
|
-const VOTE_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/Vote.png";
|
14
|
|
-const AMICALE_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/WebsiteAmicale.png";
|
|
11
|
+const CLUBS_IMAGE =
|
|
12
|
+ 'https://etud.insa-toulouse.fr/~amicale_app/images/Clubs.png';
|
|
13
|
+const PROFILE_IMAGE =
|
|
14
|
+ 'https://etud.insa-toulouse.fr/~amicale_app/images/ProfilAmicaliste.png';
|
|
15
|
+const EQUIPMENT_IMAGE =
|
|
16
|
+ 'https://etud.insa-toulouse.fr/~amicale_app/images/Materiel.png';
|
|
17
|
+const VOTE_IMAGE = 'https://etud.insa-toulouse.fr/~amicale_app/images/Vote.png';
|
|
18
|
+const AMICALE_IMAGE =
|
|
19
|
+ 'https://etud.insa-toulouse.fr/~amicale_app/images/WebsiteAmicale.png';
|
15
|
20
|
|
16
|
21
|
// STUDENTS
|
17
|
|
-const PROXIMO_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/Proximo.png"
|
18
|
|
-const WIKETUD_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/Wiketud.png";
|
19
|
|
-const EE_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/EEC.png";
|
20
|
|
-const TUTORINSA_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/TutorINSA.png";
|
|
22
|
+const PROXIMO_IMAGE =
|
|
23
|
+ 'https://etud.insa-toulouse.fr/~amicale_app/images/Proximo.png';
|
|
24
|
+const WIKETUD_IMAGE =
|
|
25
|
+ 'https://etud.insa-toulouse.fr/~amicale_app/images/Wiketud.png';
|
|
26
|
+const EE_IMAGE = 'https://etud.insa-toulouse.fr/~amicale_app/images/EEC.png';
|
|
27
|
+const TUTORINSA_IMAGE =
|
|
28
|
+ 'https://etud.insa-toulouse.fr/~amicale_app/images/TutorINSA.png';
|
21
|
29
|
|
22
|
30
|
// INSA
|
23
|
|
-const BIB_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/Bib.png";
|
24
|
|
-const RU_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/RU.png";
|
25
|
|
-const ROOM_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/Salles.png";
|
26
|
|
-const EMAIL_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/Bluemind.png";
|
27
|
|
-const ENT_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/ENT.png";
|
28
|
|
-const ACCOUNT_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/Account.png";
|
|
31
|
+const BIB_IMAGE = 'https://etud.insa-toulouse.fr/~amicale_app/images/Bib.png';
|
|
32
|
+const RU_IMAGE = 'https://etud.insa-toulouse.fr/~amicale_app/images/RU.png';
|
|
33
|
+const ROOM_IMAGE =
|
|
34
|
+ 'https://etud.insa-toulouse.fr/~amicale_app/images/Salles.png';
|
|
35
|
+const EMAIL_IMAGE =
|
|
36
|
+ 'https://etud.insa-toulouse.fr/~amicale_app/images/Bluemind.png';
|
|
37
|
+const ENT_IMAGE = 'https://etud.insa-toulouse.fr/~amicale_app/images/ENT.png';
|
|
38
|
+const ACCOUNT_IMAGE =
|
|
39
|
+ 'https://etud.insa-toulouse.fr/~amicale_app/images/Account.png';
|
29
|
40
|
|
30
|
41
|
// SPECIAL
|
31
|
|
-const WASHER_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/ProxiwashLaveLinge.png";
|
32
|
|
-const DRYER_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/ProxiwashSecheLinge.png";
|
|
42
|
+const WASHER_IMAGE =
|
|
43
|
+ 'https://etud.insa-toulouse.fr/~amicale_app/images/ProxiwashLaveLinge.png';
|
|
44
|
+const DRYER_IMAGE =
|
|
45
|
+ 'https://etud.insa-toulouse.fr/~amicale_app/images/ProxiwashSecheLinge.png';
|
33
|
46
|
|
34
|
|
-const AMICALE_LOGO = require("../../assets/amicale.png");
|
|
47
|
+const AMICALE_LOGO = require('../../assets/amicale.png');
|
35
|
48
|
|
36
|
49
|
export const SERVICES_KEY = {
|
37
|
|
- CLUBS: "clubs",
|
38
|
|
- PROFILE: "profile",
|
39
|
|
- EQUIPMENT: "equipment",
|
40
|
|
- AMICALE_WEBSITE: "amicale_website",
|
41
|
|
- VOTE: "vote",
|
42
|
|
- PROXIMO: "proximo",
|
43
|
|
- WIKETUD: "wiketud",
|
44
|
|
- ELUS_ETUDIANTS: "elus_etudiants",
|
45
|
|
- TUTOR_INSA: "tutor_insa",
|
46
|
|
- RU: "ru",
|
47
|
|
- AVAILABLE_ROOMS: "available_rooms",
|
48
|
|
- BIB: "bib",
|
49
|
|
- EMAIL: "email",
|
50
|
|
- ENT: "ent",
|
51
|
|
- INSA_ACCOUNT: "insa_account",
|
52
|
|
- WASHERS: "washers",
|
53
|
|
- DRYERS: "dryers",
|
54
|
|
-}
|
|
50
|
+ CLUBS: 'clubs',
|
|
51
|
+ PROFILE: 'profile',
|
|
52
|
+ EQUIPMENT: 'equipment',
|
|
53
|
+ AMICALE_WEBSITE: 'amicale_website',
|
|
54
|
+ VOTE: 'vote',
|
|
55
|
+ PROXIMO: 'proximo',
|
|
56
|
+ WIKETUD: 'wiketud',
|
|
57
|
+ ELUS_ETUDIANTS: 'elus_etudiants',
|
|
58
|
+ TUTOR_INSA: 'tutor_insa',
|
|
59
|
+ RU: 'ru',
|
|
60
|
+ AVAILABLE_ROOMS: 'available_rooms',
|
|
61
|
+ BIB: 'bib',
|
|
62
|
+ EMAIL: 'email',
|
|
63
|
+ ENT: 'ent',
|
|
64
|
+ INSA_ACCOUNT: 'insa_account',
|
|
65
|
+ WASHERS: 'washers',
|
|
66
|
+ DRYERS: 'dryers',
|
|
67
|
+};
|
55
|
68
|
|
56
|
69
|
export const SERVICES_CATEGORIES_KEY = {
|
57
|
|
- AMICALE: "amicale",
|
58
|
|
- STUDENTS: "students",
|
59
|
|
- INSA: "insa",
|
60
|
|
- SPECIAL: "special",
|
61
|
|
-}
|
62
|
|
-
|
|
70
|
+ AMICALE: 'amicale',
|
|
71
|
+ STUDENTS: 'students',
|
|
72
|
+ INSA: 'insa',
|
|
73
|
+ SPECIAL: 'special',
|
|
74
|
+};
|
63
|
75
|
|
64
|
|
-export type ServiceItem = {
|
65
|
|
- key: string,
|
66
|
|
- title: string,
|
67
|
|
- subtitle: string,
|
68
|
|
- image: string,
|
69
|
|
- onPress: () => void,
|
70
|
|
- badgeFunction?: (dashboard: fullDashboard) => number,
|
71
|
|
-}
|
72
|
|
-
|
73
|
|
-export type ServiceCategory = {
|
74
|
|
- key: string,
|
75
|
|
- title: string,
|
76
|
|
- subtitle: string,
|
77
|
|
- image: string | number,
|
78
|
|
- content: Array<ServiceItem>
|
79
|
|
-}
|
|
76
|
+export type ServiceItemType = {
|
|
77
|
+ key: string,
|
|
78
|
+ title: string,
|
|
79
|
+ subtitle: string,
|
|
80
|
+ image: string,
|
|
81
|
+ onPress: () => void,
|
|
82
|
+ badgeFunction?: (dashboard: FullDashboardType) => number,
|
|
83
|
+};
|
80
|
84
|
|
|
85
|
+export type ServiceCategoryType = {
|
|
86
|
+ key: string,
|
|
87
|
+ title: string,
|
|
88
|
+ subtitle: string,
|
|
89
|
+ image: string | number,
|
|
90
|
+ content: Array<ServiceItemType>,
|
|
91
|
+};
|
81
|
92
|
|
82
|
93
|
export default class ServicesManager {
|
|
94
|
+ navigation: StackNavigationProp;
|
83
|
95
|
|
84
|
|
- navigation: StackNavigationProp;
|
|
96
|
+ amicaleDataset: Array<ServiceItemType>;
|
85
|
97
|
|
86
|
|
- amicaleDataset: Array<ServiceItem>;
|
87
|
|
- studentsDataset: Array<ServiceItem>;
|
88
|
|
- insaDataset: Array<ServiceItem>;
|
89
|
|
- specialDataset: Array<ServiceItem>;
|
|
98
|
+ studentsDataset: Array<ServiceItemType>;
|
90
|
99
|
|
91
|
|
- categoriesDataset: Array<ServiceCategory>;
|
|
100
|
+ insaDataset: Array<ServiceItemType>;
|
92
|
101
|
|
93
|
|
- constructor(nav: StackNavigationProp) {
|
94
|
|
- this.navigation = nav;
|
95
|
|
- this.amicaleDataset = [
|
96
|
|
- {
|
97
|
|
- key: SERVICES_KEY.CLUBS,
|
98
|
|
- title: i18n.t('screens.clubs.title'),
|
99
|
|
- subtitle: i18n.t('screens.services.descriptions.clubs'),
|
100
|
|
- image: CLUBS_IMAGE,
|
101
|
|
- onPress: () => this.onAmicaleServicePress("club-list"),
|
102
|
|
- },
|
103
|
|
- {
|
104
|
|
- key: SERVICES_KEY.PROFILE,
|
105
|
|
- title: i18n.t('screens.profile.title'),
|
106
|
|
- subtitle: i18n.t('screens.services.descriptions.profile'),
|
107
|
|
- image: PROFILE_IMAGE,
|
108
|
|
- onPress: () => this.onAmicaleServicePress("profile"),
|
109
|
|
- },
|
110
|
|
- {
|
111
|
|
- key: SERVICES_KEY.EQUIPMENT,
|
112
|
|
- title: i18n.t('screens.equipment.title'),
|
113
|
|
- subtitle: i18n.t('screens.services.descriptions.equipment'),
|
114
|
|
- image: EQUIPMENT_IMAGE,
|
115
|
|
- onPress: () => this.onAmicaleServicePress("equipment-list"),
|
116
|
|
- },
|
117
|
|
- {
|
118
|
|
- key: SERVICES_KEY.AMICALE_WEBSITE,
|
119
|
|
- title: i18n.t('screens.websites.amicale'),
|
120
|
|
- subtitle: i18n.t('screens.services.descriptions.amicaleWebsite'),
|
121
|
|
- image: AMICALE_IMAGE,
|
122
|
|
- onPress: () => nav.navigate("website", {
|
123
|
|
- host: AvailableWebsites.websites.AMICALE,
|
124
|
|
- title: i18n.t('screens.websites.amicale')
|
125
|
|
- }),
|
126
|
|
- },
|
127
|
|
- {
|
128
|
|
- key: SERVICES_KEY.VOTE,
|
129
|
|
- title: i18n.t('screens.vote.title'),
|
130
|
|
- subtitle: i18n.t('screens.services.descriptions.vote'),
|
131
|
|
- image: VOTE_IMAGE,
|
132
|
|
- onPress: () => this.onAmicaleServicePress("vote"),
|
133
|
|
- },
|
134
|
|
- ];
|
135
|
|
- this.studentsDataset = [
|
136
|
|
- {
|
137
|
|
- key: SERVICES_KEY.PROXIMO,
|
138
|
|
- title: i18n.t('screens.proximo.title'),
|
139
|
|
- subtitle: i18n.t('screens.services.descriptions.proximo'),
|
140
|
|
- image: PROXIMO_IMAGE,
|
141
|
|
- onPress: () => nav.navigate("proximo"),
|
142
|
|
- badgeFunction: (dashboard: fullDashboard) => dashboard.proximo_articles
|
143
|
|
- },
|
144
|
|
- {
|
145
|
|
- key: SERVICES_KEY.WIKETUD,
|
146
|
|
- title: "Wiketud",
|
147
|
|
- subtitle: i18n.t('screens.services.descriptions.wiketud'),
|
148
|
|
- image: WIKETUD_IMAGE,
|
149
|
|
- onPress: () => nav.navigate("website", {host: AvailableWebsites.websites.WIKETUD, title: "Wiketud"}),
|
150
|
|
- },
|
151
|
|
- {
|
152
|
|
- key: SERVICES_KEY.ELUS_ETUDIANTS,
|
153
|
|
- title: "Élus Étudiants",
|
154
|
|
- subtitle: i18n.t('screens.services.descriptions.elusEtudiants'),
|
155
|
|
- image: EE_IMAGE,
|
156
|
|
- onPress: () => nav.navigate("website", {
|
157
|
|
- host: AvailableWebsites.websites.ELUS_ETUDIANTS,
|
158
|
|
- title: "Élus Étudiants"
|
159
|
|
- }),
|
160
|
|
- },
|
161
|
|
- {
|
162
|
|
- key: SERVICES_KEY.TUTOR_INSA,
|
163
|
|
- title: "Tutor'INSA",
|
164
|
|
- subtitle: i18n.t('screens.services.descriptions.tutorInsa'),
|
165
|
|
- image: TUTORINSA_IMAGE,
|
166
|
|
- onPress: () => nav.navigate("website", {
|
167
|
|
- host: AvailableWebsites.websites.TUTOR_INSA,
|
168
|
|
- title: "Tutor'INSA"
|
169
|
|
- }),
|
170
|
|
- badgeFunction: (dashboard: fullDashboard) => dashboard.available_tutorials
|
171
|
|
- },
|
172
|
|
- ];
|
173
|
|
- this.insaDataset = [
|
174
|
|
- {
|
175
|
|
- key: SERVICES_KEY.RU,
|
176
|
|
- title: i18n.t('screens.menu.title'),
|
177
|
|
- subtitle: i18n.t('screens.services.descriptions.self'),
|
178
|
|
- image: RU_IMAGE,
|
179
|
|
- onPress: () => nav.navigate("self-menu"),
|
180
|
|
- badgeFunction: (dashboard: fullDashboard) => dashboard.today_menu.length
|
181
|
|
- },
|
182
|
|
- {
|
183
|
|
- key: SERVICES_KEY.AVAILABLE_ROOMS,
|
184
|
|
- title: i18n.t('screens.websites.rooms'),
|
185
|
|
- subtitle: i18n.t('screens.services.descriptions.availableRooms'),
|
186
|
|
- image: ROOM_IMAGE,
|
187
|
|
- onPress: () => nav.navigate("website", {
|
188
|
|
- host: AvailableWebsites.websites.AVAILABLE_ROOMS,
|
189
|
|
- title: i18n.t('screens.websites.rooms')
|
190
|
|
- }),
|
191
|
|
- },
|
192
|
|
- {
|
193
|
|
- key: SERVICES_KEY.BIB,
|
194
|
|
- title: i18n.t('screens.websites.bib'),
|
195
|
|
- subtitle: i18n.t('screens.services.descriptions.bib'),
|
196
|
|
- image: BIB_IMAGE,
|
197
|
|
- onPress: () => nav.navigate("website", {
|
198
|
|
- host: AvailableWebsites.websites.BIB,
|
199
|
|
- title: i18n.t('screens.websites.bib')
|
200
|
|
- }),
|
201
|
|
- },
|
202
|
|
- {
|
203
|
|
- key: SERVICES_KEY.EMAIL,
|
204
|
|
- title: i18n.t('screens.websites.mails'),
|
205
|
|
- subtitle: i18n.t('screens.services.descriptions.mails'),
|
206
|
|
- image: EMAIL_IMAGE,
|
207
|
|
- onPress: () => nav.navigate("website", {
|
208
|
|
- host: AvailableWebsites.websites.BLUEMIND,
|
209
|
|
- title: i18n.t('screens.websites.mails')
|
210
|
|
- }),
|
211
|
|
- },
|
212
|
|
- {
|
213
|
|
- key: SERVICES_KEY.ENT,
|
214
|
|
- title: i18n.t('screens.websites.ent'),
|
215
|
|
- subtitle: i18n.t('screens.services.descriptions.ent'),
|
216
|
|
- image: ENT_IMAGE,
|
217
|
|
- onPress: () => nav.navigate("website", {
|
218
|
|
- host: AvailableWebsites.websites.ENT,
|
219
|
|
- title: i18n.t('screens.websites.ent')
|
220
|
|
- }),
|
221
|
|
- },
|
222
|
|
- {
|
223
|
|
- key: SERVICES_KEY.INSA_ACCOUNT,
|
224
|
|
- title: i18n.t('screens.insaAccount.title'),
|
225
|
|
- subtitle: i18n.t('screens.services.descriptions.insaAccount'),
|
226
|
|
- image: ACCOUNT_IMAGE,
|
227
|
|
- onPress: () => nav.navigate("website", {
|
228
|
|
- host: AvailableWebsites.websites.INSA_ACCOUNT,
|
229
|
|
- title: i18n.t('screens.insaAccount.title')
|
230
|
|
- }),
|
231
|
|
- },
|
232
|
|
- ];
|
233
|
|
- this.specialDataset = [
|
234
|
|
- {
|
235
|
|
- key: SERVICES_KEY.WASHERS,
|
236
|
|
- title: i18n.t('screens.proxiwash.washers'),
|
237
|
|
- subtitle: i18n.t('screens.services.descriptions.washers'),
|
238
|
|
- image: WASHER_IMAGE,
|
239
|
|
- onPress: () => nav.navigate("proxiwash"),
|
240
|
|
- badgeFunction: (dashboard: fullDashboard) => dashboard.available_washers
|
241
|
|
- },
|
242
|
|
- {
|
243
|
|
- key: SERVICES_KEY.DRYERS,
|
244
|
|
- title: i18n.t('screens.proxiwash.dryers'),
|
245
|
|
- subtitle: i18n.t('screens.services.descriptions.washers'),
|
246
|
|
- image: DRYER_IMAGE,
|
247
|
|
- onPress: () => nav.navigate("proxiwash"),
|
248
|
|
- badgeFunction: (dashboard: fullDashboard) => dashboard.available_dryers
|
249
|
|
- }
|
250
|
|
- ];
|
251
|
|
- this.categoriesDataset = [
|
252
|
|
- {
|
253
|
|
- key: SERVICES_CATEGORIES_KEY.AMICALE,
|
254
|
|
- title: i18n.t("screens.services.categories.amicale"),
|
255
|
|
- subtitle: i18n.t("screens.services.more"),
|
256
|
|
- image: AMICALE_LOGO,
|
257
|
|
- content: this.amicaleDataset
|
258
|
|
- },
|
259
|
|
- {
|
260
|
|
- key: SERVICES_CATEGORIES_KEY.STUDENTS,
|
261
|
|
- title: i18n.t("screens.services.categories.students"),
|
262
|
|
- subtitle: i18n.t("screens.services.more"),
|
263
|
|
- image: 'account-group',
|
264
|
|
- content: this.studentsDataset
|
265
|
|
- },
|
266
|
|
- {
|
267
|
|
- key: SERVICES_CATEGORIES_KEY.INSA,
|
268
|
|
- title: i18n.t("screens.services.categories.insa"),
|
269
|
|
- subtitle: i18n.t("screens.services.more"),
|
270
|
|
- image: 'school',
|
271
|
|
- content: this.insaDataset
|
272
|
|
- },
|
273
|
|
- {
|
274
|
|
- key: SERVICES_CATEGORIES_KEY.SPECIAL,
|
275
|
|
- title: i18n.t("screens.services.categories.special"),
|
276
|
|
- subtitle: i18n.t("screens.services.categories.special"),
|
277
|
|
- image: 'star',
|
278
|
|
- content: this.specialDataset
|
279
|
|
- },
|
280
|
|
- ];
|
281
|
|
- }
|
|
102
|
+ specialDataset: Array<ServiceItemType>;
|
282
|
103
|
|
283
|
|
- /**
|
284
|
|
- * Redirects the user to the login screen if he is not logged in
|
285
|
|
- *
|
286
|
|
- * @param route
|
287
|
|
- * @returns {null}
|
288
|
|
- */
|
289
|
|
- onAmicaleServicePress(route: string) {
|
290
|
|
- if (ConnectionManager.getInstance().isLoggedIn())
|
291
|
|
- this.navigation.navigate(route);
|
292
|
|
- else
|
293
|
|
- this.navigation.navigate("login", {nextScreen: route});
|
294
|
|
- }
|
|
104
|
+ categoriesDataset: Array<ServiceCategoryType>;
|
295
|
105
|
|
296
|
|
- /**
|
297
|
|
- * Gets the given services list without items of the given ids
|
298
|
|
- *
|
299
|
|
- * @param idList The ids of items to remove
|
300
|
|
- * @param sourceList The item list to use as source
|
301
|
|
- * @returns {[]}
|
302
|
|
- */
|
303
|
|
- getStrippedList(idList: Array<string>, sourceList: Array<{key: string, [key: string]: any}>) {
|
304
|
|
- let newArray = [];
|
305
|
|
- for (let i = 0; i < sourceList.length; i++) {
|
306
|
|
- const item = sourceList[i];
|
307
|
|
- if (!(idList.includes(item.key)))
|
308
|
|
- newArray.push(item);
|
309
|
|
- }
|
310
|
|
- return newArray;
|
311
|
|
- }
|
|
106
|
+ constructor(nav: StackNavigationProp) {
|
|
107
|
+ this.navigation = nav;
|
|
108
|
+ this.amicaleDataset = [
|
|
109
|
+ {
|
|
110
|
+ key: SERVICES_KEY.CLUBS,
|
|
111
|
+ title: i18n.t('screens.clubs.title'),
|
|
112
|
+ subtitle: i18n.t('screens.services.descriptions.clubs'),
|
|
113
|
+ image: CLUBS_IMAGE,
|
|
114
|
+ onPress: (): void => this.onAmicaleServicePress('club-list'),
|
|
115
|
+ },
|
|
116
|
+ {
|
|
117
|
+ key: SERVICES_KEY.PROFILE,
|
|
118
|
+ title: i18n.t('screens.profile.title'),
|
|
119
|
+ subtitle: i18n.t('screens.services.descriptions.profile'),
|
|
120
|
+ image: PROFILE_IMAGE,
|
|
121
|
+ onPress: (): void => this.onAmicaleServicePress('profile'),
|
|
122
|
+ },
|
|
123
|
+ {
|
|
124
|
+ key: SERVICES_KEY.EQUIPMENT,
|
|
125
|
+ title: i18n.t('screens.equipment.title'),
|
|
126
|
+ subtitle: i18n.t('screens.services.descriptions.equipment'),
|
|
127
|
+ image: EQUIPMENT_IMAGE,
|
|
128
|
+ onPress: (): void => this.onAmicaleServicePress('equipment-list'),
|
|
129
|
+ },
|
|
130
|
+ {
|
|
131
|
+ key: SERVICES_KEY.AMICALE_WEBSITE,
|
|
132
|
+ title: i18n.t('screens.websites.amicale'),
|
|
133
|
+ subtitle: i18n.t('screens.services.descriptions.amicaleWebsite'),
|
|
134
|
+ image: AMICALE_IMAGE,
|
|
135
|
+ onPress: (): void =>
|
|
136
|
+ nav.navigate('website', {
|
|
137
|
+ host: AvailableWebsites.websites.AMICALE,
|
|
138
|
+ title: i18n.t('screens.websites.amicale'),
|
|
139
|
+ }),
|
|
140
|
+ },
|
|
141
|
+ {
|
|
142
|
+ key: SERVICES_KEY.VOTE,
|
|
143
|
+ title: i18n.t('screens.vote.title'),
|
|
144
|
+ subtitle: i18n.t('screens.services.descriptions.vote'),
|
|
145
|
+ image: VOTE_IMAGE,
|
|
146
|
+ onPress: (): void => this.onAmicaleServicePress('vote'),
|
|
147
|
+ },
|
|
148
|
+ ];
|
|
149
|
+ this.studentsDataset = [
|
|
150
|
+ {
|
|
151
|
+ key: SERVICES_KEY.PROXIMO,
|
|
152
|
+ title: i18n.t('screens.proximo.title'),
|
|
153
|
+ subtitle: i18n.t('screens.services.descriptions.proximo'),
|
|
154
|
+ image: PROXIMO_IMAGE,
|
|
155
|
+ onPress: (): void => nav.navigate('proximo'),
|
|
156
|
+ badgeFunction: (dashboard: FullDashboardType): number =>
|
|
157
|
+ dashboard.proximo_articles,
|
|
158
|
+ },
|
|
159
|
+ {
|
|
160
|
+ key: SERVICES_KEY.WIKETUD,
|
|
161
|
+ title: 'Wiketud',
|
|
162
|
+ subtitle: i18n.t('screens.services.descriptions.wiketud'),
|
|
163
|
+ image: WIKETUD_IMAGE,
|
|
164
|
+ onPress: (): void =>
|
|
165
|
+ nav.navigate('website', {
|
|
166
|
+ host: AvailableWebsites.websites.WIKETUD,
|
|
167
|
+ title: 'Wiketud',
|
|
168
|
+ }),
|
|
169
|
+ },
|
|
170
|
+ {
|
|
171
|
+ key: SERVICES_KEY.ELUS_ETUDIANTS,
|
|
172
|
+ title: 'Élus Étudiants',
|
|
173
|
+ subtitle: i18n.t('screens.services.descriptions.elusEtudiants'),
|
|
174
|
+ image: EE_IMAGE,
|
|
175
|
+ onPress: (): void =>
|
|
176
|
+ nav.navigate('website', {
|
|
177
|
+ host: AvailableWebsites.websites.ELUS_ETUDIANTS,
|
|
178
|
+ title: 'Élus Étudiants',
|
|
179
|
+ }),
|
|
180
|
+ },
|
|
181
|
+ {
|
|
182
|
+ key: SERVICES_KEY.TUTOR_INSA,
|
|
183
|
+ title: "Tutor'INSA",
|
|
184
|
+ subtitle: i18n.t('screens.services.descriptions.tutorInsa'),
|
|
185
|
+ image: TUTORINSA_IMAGE,
|
|
186
|
+ onPress: (): void =>
|
|
187
|
+ nav.navigate('website', {
|
|
188
|
+ host: AvailableWebsites.websites.TUTOR_INSA,
|
|
189
|
+ title: "Tutor'INSA",
|
|
190
|
+ }),
|
|
191
|
+ badgeFunction: (dashboard: FullDashboardType): number =>
|
|
192
|
+ dashboard.available_tutorials,
|
|
193
|
+ },
|
|
194
|
+ ];
|
|
195
|
+ this.insaDataset = [
|
|
196
|
+ {
|
|
197
|
+ key: SERVICES_KEY.RU,
|
|
198
|
+ title: i18n.t('screens.menu.title'),
|
|
199
|
+ subtitle: i18n.t('screens.services.descriptions.self'),
|
|
200
|
+ image: RU_IMAGE,
|
|
201
|
+ onPress: (): void => nav.navigate('self-menu'),
|
|
202
|
+ badgeFunction: (dashboard: FullDashboardType): number =>
|
|
203
|
+ dashboard.today_menu.length,
|
|
204
|
+ },
|
|
205
|
+ {
|
|
206
|
+ key: SERVICES_KEY.AVAILABLE_ROOMS,
|
|
207
|
+ title: i18n.t('screens.websites.rooms'),
|
|
208
|
+ subtitle: i18n.t('screens.services.descriptions.availableRooms'),
|
|
209
|
+ image: ROOM_IMAGE,
|
|
210
|
+ onPress: (): void =>
|
|
211
|
+ nav.navigate('website', {
|
|
212
|
+ host: AvailableWebsites.websites.AVAILABLE_ROOMS,
|
|
213
|
+ title: i18n.t('screens.websites.rooms'),
|
|
214
|
+ }),
|
|
215
|
+ },
|
|
216
|
+ {
|
|
217
|
+ key: SERVICES_KEY.BIB,
|
|
218
|
+ title: i18n.t('screens.websites.bib'),
|
|
219
|
+ subtitle: i18n.t('screens.services.descriptions.bib'),
|
|
220
|
+ image: BIB_IMAGE,
|
|
221
|
+ onPress: (): void =>
|
|
222
|
+ nav.navigate('website', {
|
|
223
|
+ host: AvailableWebsites.websites.BIB,
|
|
224
|
+ title: i18n.t('screens.websites.bib'),
|
|
225
|
+ }),
|
|
226
|
+ },
|
|
227
|
+ {
|
|
228
|
+ key: SERVICES_KEY.EMAIL,
|
|
229
|
+ title: i18n.t('screens.websites.mails'),
|
|
230
|
+ subtitle: i18n.t('screens.services.descriptions.mails'),
|
|
231
|
+ image: EMAIL_IMAGE,
|
|
232
|
+ onPress: (): void =>
|
|
233
|
+ nav.navigate('website', {
|
|
234
|
+ host: AvailableWebsites.websites.BLUEMIND,
|
|
235
|
+ title: i18n.t('screens.websites.mails'),
|
|
236
|
+ }),
|
|
237
|
+ },
|
|
238
|
+ {
|
|
239
|
+ key: SERVICES_KEY.ENT,
|
|
240
|
+ title: i18n.t('screens.websites.ent'),
|
|
241
|
+ subtitle: i18n.t('screens.services.descriptions.ent'),
|
|
242
|
+ image: ENT_IMAGE,
|
|
243
|
+ onPress: (): void =>
|
|
244
|
+ nav.navigate('website', {
|
|
245
|
+ host: AvailableWebsites.websites.ENT,
|
|
246
|
+ title: i18n.t('screens.websites.ent'),
|
|
247
|
+ }),
|
|
248
|
+ },
|
|
249
|
+ {
|
|
250
|
+ key: SERVICES_KEY.INSA_ACCOUNT,
|
|
251
|
+ title: i18n.t('screens.insaAccount.title'),
|
|
252
|
+ subtitle: i18n.t('screens.services.descriptions.insaAccount'),
|
|
253
|
+ image: ACCOUNT_IMAGE,
|
|
254
|
+ onPress: (): void =>
|
|
255
|
+ nav.navigate('website', {
|
|
256
|
+ host: AvailableWebsites.websites.INSA_ACCOUNT,
|
|
257
|
+ title: i18n.t('screens.insaAccount.title'),
|
|
258
|
+ }),
|
|
259
|
+ },
|
|
260
|
+ ];
|
|
261
|
+ this.specialDataset = [
|
|
262
|
+ {
|
|
263
|
+ key: SERVICES_KEY.WASHERS,
|
|
264
|
+ title: i18n.t('screens.proxiwash.washers'),
|
|
265
|
+ subtitle: i18n.t('screens.services.descriptions.washers'),
|
|
266
|
+ image: WASHER_IMAGE,
|
|
267
|
+ onPress: (): void => nav.navigate('proxiwash'),
|
|
268
|
+ badgeFunction: (dashboard: FullDashboardType): number =>
|
|
269
|
+ dashboard.available_washers,
|
|
270
|
+ },
|
|
271
|
+ {
|
|
272
|
+ key: SERVICES_KEY.DRYERS,
|
|
273
|
+ title: i18n.t('screens.proxiwash.dryers'),
|
|
274
|
+ subtitle: i18n.t('screens.services.descriptions.washers'),
|
|
275
|
+ image: DRYER_IMAGE,
|
|
276
|
+ onPress: (): void => nav.navigate('proxiwash'),
|
|
277
|
+ badgeFunction: (dashboard: FullDashboardType): number =>
|
|
278
|
+ dashboard.available_dryers,
|
|
279
|
+ },
|
|
280
|
+ ];
|
|
281
|
+ this.categoriesDataset = [
|
|
282
|
+ {
|
|
283
|
+ key: SERVICES_CATEGORIES_KEY.AMICALE,
|
|
284
|
+ title: i18n.t('screens.services.categories.amicale'),
|
|
285
|
+ subtitle: i18n.t('screens.services.more'),
|
|
286
|
+ image: AMICALE_LOGO,
|
|
287
|
+ content: this.amicaleDataset,
|
|
288
|
+ },
|
|
289
|
+ {
|
|
290
|
+ key: SERVICES_CATEGORIES_KEY.STUDENTS,
|
|
291
|
+ title: i18n.t('screens.services.categories.students'),
|
|
292
|
+ subtitle: i18n.t('screens.services.more'),
|
|
293
|
+ image: 'account-group',
|
|
294
|
+ content: this.studentsDataset,
|
|
295
|
+ },
|
|
296
|
+ {
|
|
297
|
+ key: SERVICES_CATEGORIES_KEY.INSA,
|
|
298
|
+ title: i18n.t('screens.services.categories.insa'),
|
|
299
|
+ subtitle: i18n.t('screens.services.more'),
|
|
300
|
+ image: 'school',
|
|
301
|
+ content: this.insaDataset,
|
|
302
|
+ },
|
|
303
|
+ {
|
|
304
|
+ key: SERVICES_CATEGORIES_KEY.SPECIAL,
|
|
305
|
+ title: i18n.t('screens.services.categories.special'),
|
|
306
|
+ subtitle: i18n.t('screens.services.categories.special'),
|
|
307
|
+ image: 'star',
|
|
308
|
+ content: this.specialDataset,
|
|
309
|
+ },
|
|
310
|
+ ];
|
|
311
|
+ }
|
312
|
312
|
|
313
|
|
- /**
|
314
|
|
- * Gets the list of amicale's services
|
315
|
|
- *
|
316
|
|
- * @param excludedItems Ids of items to exclude from the returned list
|
317
|
|
- * @returns {Array<ServiceItem>}
|
318
|
|
- */
|
319
|
|
- getAmicaleServices(excludedItems?: Array<string>) {
|
320
|
|
- if (excludedItems != null)
|
321
|
|
- return this.getStrippedList(excludedItems, this.amicaleDataset)
|
322
|
|
- else
|
323
|
|
- return this.amicaleDataset;
|
324
|
|
- }
|
|
313
|
+ /**
|
|
314
|
+ * Redirects the user to the login screen if he is not logged in
|
|
315
|
+ *
|
|
316
|
+ * @param route
|
|
317
|
+ * @returns {null}
|
|
318
|
+ */
|
|
319
|
+ onAmicaleServicePress(route: string) {
|
|
320
|
+ if (ConnectionManager.getInstance().isLoggedIn())
|
|
321
|
+ this.navigation.navigate(route);
|
|
322
|
+ else this.navigation.navigate('login', {nextScreen: route});
|
|
323
|
+ }
|
325
|
324
|
|
326
|
|
- /**
|
327
|
|
- * Gets the list of students' services
|
328
|
|
- *
|
329
|
|
- * @param excludedItems Ids of items to exclude from the returned list
|
330
|
|
- * @returns {Array<ServiceItem>}
|
331
|
|
- */
|
332
|
|
- getStudentServices(excludedItems?: Array<string>) {
|
333
|
|
- if (excludedItems != null)
|
334
|
|
- return this.getStrippedList(excludedItems, this.studentsDataset)
|
335
|
|
- else
|
336
|
|
- return this.studentsDataset;
|
337
|
|
- }
|
|
325
|
+ /**
|
|
326
|
+ * Gets the list of amicale's services
|
|
327
|
+ *
|
|
328
|
+ * @param excludedItems Ids of items to exclude from the returned list
|
|
329
|
+ * @returns {Array<ServiceItemType>}
|
|
330
|
+ */
|
|
331
|
+ getAmicaleServices(excludedItems?: Array<string>): Array<ServiceItemType> {
|
|
332
|
+ if (excludedItems != null)
|
|
333
|
+ return getStrippedServicesList(excludedItems, this.amicaleDataset);
|
|
334
|
+ return this.amicaleDataset;
|
|
335
|
+ }
|
338
|
336
|
|
339
|
|
- /**
|
340
|
|
- * Gets the list of INSA's services
|
341
|
|
- *
|
342
|
|
- * @param excludedItems Ids of items to exclude from the returned list
|
343
|
|
- * @returns {Array<ServiceItem>}
|
344
|
|
- */
|
345
|
|
- getINSAServices(excludedItems?: Array<string>) {
|
346
|
|
- if (excludedItems != null)
|
347
|
|
- return this.getStrippedList(excludedItems, this.insaDataset)
|
348
|
|
- else
|
349
|
|
- return this.insaDataset;
|
350
|
|
- }
|
|
337
|
+ /**
|
|
338
|
+ * Gets the list of students' services
|
|
339
|
+ *
|
|
340
|
+ * @param excludedItems Ids of items to exclude from the returned list
|
|
341
|
+ * @returns {Array<ServiceItemType>}
|
|
342
|
+ */
|
|
343
|
+ getStudentServices(excludedItems?: Array<string>): Array<ServiceItemType> {
|
|
344
|
+ if (excludedItems != null)
|
|
345
|
+ return getStrippedServicesList(excludedItems, this.studentsDataset);
|
|
346
|
+ return this.studentsDataset;
|
|
347
|
+ }
|
351
|
348
|
|
352
|
|
- /**
|
353
|
|
- * Gets the list of special services
|
354
|
|
- *
|
355
|
|
- * @param excludedItems Ids of items to exclude from the returned list
|
356
|
|
- * @returns {Array<ServiceItem>}
|
357
|
|
- */
|
358
|
|
- getSpecialServices(excludedItems?: Array<string>) {
|
359
|
|
- if (excludedItems != null)
|
360
|
|
- return this.getStrippedList(excludedItems, this.specialDataset)
|
361
|
|
- else
|
362
|
|
- return this.specialDataset;
|
363
|
|
- }
|
|
349
|
+ /**
|
|
350
|
+ * Gets the list of INSA's services
|
|
351
|
+ *
|
|
352
|
+ * @param excludedItems Ids of items to exclude from the returned list
|
|
353
|
+ * @returns {Array<ServiceItemType>}
|
|
354
|
+ */
|
|
355
|
+ getINSAServices(excludedItems?: Array<string>): Array<ServiceItemType> {
|
|
356
|
+ if (excludedItems != null)
|
|
357
|
+ return getStrippedServicesList(excludedItems, this.insaDataset);
|
|
358
|
+ return this.insaDataset;
|
|
359
|
+ }
|
364
|
360
|
|
365
|
|
- /**
|
366
|
|
- * Gets all services sorted by category
|
367
|
|
- *
|
368
|
|
- * @param excludedItems Ids of categories to exclude from the returned list
|
369
|
|
- * @returns {Array<ServiceCategory>}
|
370
|
|
- */
|
371
|
|
- getCategories(excludedItems?: Array<string>) {
|
372
|
|
- if (excludedItems != null)
|
373
|
|
- return this.getStrippedList(excludedItems, this.categoriesDataset)
|
374
|
|
- else
|
375
|
|
- return this.categoriesDataset;
|
376
|
|
- }
|
|
361
|
+ /**
|
|
362
|
+ * Gets the list of special services
|
|
363
|
+ *
|
|
364
|
+ * @param excludedItems Ids of items to exclude from the returned list
|
|
365
|
+ * @returns {Array<ServiceItemType>}
|
|
366
|
+ */
|
|
367
|
+ getSpecialServices(excludedItems?: Array<string>): Array<ServiceItemType> {
|
|
368
|
+ if (excludedItems != null)
|
|
369
|
+ return getStrippedServicesList(excludedItems, this.specialDataset);
|
|
370
|
+ return this.specialDataset;
|
|
371
|
+ }
|
377
|
372
|
|
|
373
|
+ /**
|
|
374
|
+ * Gets all services sorted by category
|
|
375
|
+ *
|
|
376
|
+ * @param excludedItems Ids of categories to exclude from the returned list
|
|
377
|
+ * @returns {Array<ServiceCategoryType>}
|
|
378
|
+ */
|
|
379
|
+ getCategories(excludedItems?: Array<string>): Array<ServiceCategoryType> {
|
|
380
|
+ if (excludedItems != null)
|
|
381
|
+ return getStrippedServicesList(excludedItems, this.categoriesDataset);
|
|
382
|
+ return this.categoriesDataset;
|
|
383
|
+ }
|
378
|
384
|
}
|