|
@@ -1,22 +1,25 @@
|
1
|
1
|
// @flow
|
2
|
2
|
|
3
|
|
-import type {cardList} from "../components/Lists/CardList/CardList";
|
4
|
3
|
import i18n from "i18n-js";
|
5
|
4
|
import AvailableWebsites from "../constants/AvailableWebsites";
|
6
|
5
|
import {StackNavigationProp} from "@react-navigation/stack";
|
7
|
6
|
import ConnectionManager from "./ConnectionManager";
|
|
7
|
+import type {fullDashboard} from "../screens/Home/HomeScreen";
|
8
|
8
|
|
|
9
|
+// AMICALE
|
9
|
10
|
const CLUBS_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/Clubs.png";
|
10
|
11
|
const PROFILE_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/ProfilAmicaliste.png";
|
11
|
12
|
const EQUIPMENT_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/Materiel.png";
|
12
|
13
|
const VOTE_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/Vote.png";
|
13
|
14
|
const AMICALE_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/WebsiteAmicale.png";
|
14
|
15
|
|
|
16
|
+// STUDENTS
|
15
|
17
|
const PROXIMO_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/Proximo.png"
|
16
|
18
|
const WIKETUD_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/Wiketud.png";
|
17
|
19
|
const EE_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/EEC.png";
|
18
|
20
|
const TUTORINSA_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/TutorINSA.png";
|
19
|
21
|
|
|
22
|
+// INSA
|
20
|
23
|
const BIB_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/Bib.png";
|
21
|
24
|
const RU_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/RU.png";
|
22
|
25
|
const ROOM_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/Salles.png";
|
|
@@ -24,9 +27,13 @@ const EMAIL_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/Bluemind.
|
24
|
27
|
const ENT_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/ENT.png";
|
25
|
28
|
const ACCOUNT_IMAGE = "https://etud.insa-toulouse.fr/~amicale_app/images/Account.png";
|
26
|
29
|
|
|
30
|
+// 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";
|
|
33
|
+
|
27
|
34
|
export const SERVICES_KEY = {
|
28
|
35
|
CLUBS: "clubs",
|
29
|
|
- PROFILE:"profile",
|
|
36
|
+ PROFILE: "profile",
|
30
|
37
|
EQUIPMENT: "equipment",
|
31
|
38
|
AMICALE_WEBSITE: "amicale_website",
|
32
|
39
|
VOTE: "vote",
|
|
@@ -40,15 +47,27 @@ export const SERVICES_KEY = {
|
40
|
47
|
EMAIL: "email",
|
41
|
48
|
ENT: "ent",
|
42
|
49
|
INSA_ACCOUNT: "insa_account",
|
|
50
|
+ WASHERS: "washers",
|
|
51
|
+ DRYERS: "dryers",
|
|
52
|
+}
|
|
53
|
+
|
|
54
|
+export type ServiceItem = {
|
|
55
|
+ key: string,
|
|
56
|
+ title: string,
|
|
57
|
+ subtitle: string,
|
|
58
|
+ image: string,
|
|
59
|
+ onPress: () => void,
|
|
60
|
+ badgeFunction?: (dashboard: fullDashboard) => number,
|
43
|
61
|
}
|
44
|
62
|
|
45
|
63
|
export default class ServicesManager {
|
46
|
64
|
|
47
|
65
|
navigation: StackNavigationProp;
|
48
|
66
|
|
49
|
|
- amicaleDataset: cardList;
|
50
|
|
- studentsDataset: cardList;
|
51
|
|
- insaDataset: cardList;
|
|
67
|
+ amicaleDataset: Array<ServiceItem>;
|
|
68
|
+ studentsDataset: Array<ServiceItem>;
|
|
69
|
+ insaDataset: Array<ServiceItem>;
|
|
70
|
+ specialDataset: Array<ServiceItem>;
|
52
|
71
|
|
53
|
72
|
constructor(nav: StackNavigationProp) {
|
54
|
73
|
this.navigation = nav;
|
|
@@ -79,7 +98,10 @@ export default class ServicesManager {
|
79
|
98
|
title: i18n.t('screens.websites.amicale'),
|
80
|
99
|
subtitle: i18n.t('screens.services.descriptions.amicaleWebsite'),
|
81
|
100
|
image: AMICALE_IMAGE,
|
82
|
|
- onPress: () => nav.navigate("website", {host: AvailableWebsites.websites.AMICALE, title: i18n.t('screens.websites.amicale')}),
|
|
101
|
+ onPress: () => nav.navigate("website", {
|
|
102
|
+ host: AvailableWebsites.websites.AMICALE,
|
|
103
|
+ title: i18n.t('screens.websites.amicale')
|
|
104
|
+ }),
|
83
|
105
|
},
|
84
|
106
|
{
|
85
|
107
|
key: SERVICES_KEY.VOTE,
|
|
@@ -96,6 +118,7 @@ export default class ServicesManager {
|
96
|
118
|
subtitle: i18n.t('screens.services.descriptions.proximo'),
|
97
|
119
|
image: PROXIMO_IMAGE,
|
98
|
120
|
onPress: () => nav.navigate("proximo"),
|
|
121
|
+ badgeFunction: (dashboard: fullDashboard) => dashboard.proximo_articles
|
99
|
122
|
},
|
100
|
123
|
{
|
101
|
124
|
key: SERVICES_KEY.WIKETUD,
|
|
@@ -109,14 +132,21 @@ export default class ServicesManager {
|
109
|
132
|
title: "Élus Étudiants",
|
110
|
133
|
subtitle: i18n.t('screens.services.descriptions.elusEtudiants'),
|
111
|
134
|
image: EE_IMAGE,
|
112
|
|
- onPress: () => nav.navigate("website", {host: AvailableWebsites.websites.WIKETUD, title: "Wiketud"}),
|
|
135
|
+ onPress: () => nav.navigate("website", {
|
|
136
|
+ host: AvailableWebsites.websites.ELUS_ETUDIANTS,
|
|
137
|
+ title: "Élus Étudiants"
|
|
138
|
+ }),
|
113
|
139
|
},
|
114
|
140
|
{
|
115
|
141
|
key: SERVICES_KEY.TUTOR_INSA,
|
116
|
142
|
title: "Tutor'INSA",
|
117
|
143
|
subtitle: i18n.t('screens.services.descriptions.tutorInsa'),
|
118
|
144
|
image: TUTORINSA_IMAGE,
|
119
|
|
- onPress: () => nav.navigate("website", {host: AvailableWebsites.websites.TUTOR_INSA, title: "Tutor'INSA"})
|
|
145
|
+ onPress: () => nav.navigate("website", {
|
|
146
|
+ host: AvailableWebsites.websites.TUTOR_INSA,
|
|
147
|
+ title: "Tutor'INSA"
|
|
148
|
+ }),
|
|
149
|
+ badgeFunction: (dashboard: fullDashboard) => dashboard.available_tutorials
|
120
|
150
|
},
|
121
|
151
|
];
|
122
|
152
|
this.insaDataset = [
|
|
@@ -126,43 +156,77 @@ export default class ServicesManager {
|
126
|
156
|
subtitle: i18n.t('screens.services.descriptions.self'),
|
127
|
157
|
image: RU_IMAGE,
|
128
|
158
|
onPress: () => nav.navigate("self-menu"),
|
|
159
|
+ badgeFunction: (dashboard: fullDashboard) => dashboard.today_menu.length
|
129
|
160
|
},
|
130
|
161
|
{
|
131
|
162
|
key: SERVICES_KEY.AVAILABLE_ROOMS,
|
132
|
163
|
title: i18n.t('screens.websites.rooms'),
|
133
|
164
|
subtitle: i18n.t('screens.services.descriptions.availableRooms'),
|
134
|
165
|
image: ROOM_IMAGE,
|
135
|
|
- onPress: () => nav.navigate("website", {host: AvailableWebsites.websites.AVAILABLE_ROOMS, title: i18n.t('screens.websites.rooms')}),
|
|
166
|
+ onPress: () => nav.navigate("website", {
|
|
167
|
+ host: AvailableWebsites.websites.AVAILABLE_ROOMS,
|
|
168
|
+ title: i18n.t('screens.websites.rooms')
|
|
169
|
+ }),
|
136
|
170
|
},
|
137
|
171
|
{
|
138
|
172
|
key: SERVICES_KEY.BIB,
|
139
|
173
|
title: i18n.t('screens.websites.bib'),
|
140
|
174
|
subtitle: i18n.t('screens.services.descriptions.bib'),
|
141
|
175
|
image: BIB_IMAGE,
|
142
|
|
- onPress: () => nav.navigate("website", {host: AvailableWebsites.websites.BIB, title: i18n.t('screens.websites.bib')}),
|
|
176
|
+ onPress: () => nav.navigate("website", {
|
|
177
|
+ host: AvailableWebsites.websites.BIB,
|
|
178
|
+ title: i18n.t('screens.websites.bib')
|
|
179
|
+ }),
|
143
|
180
|
},
|
144
|
181
|
{
|
145
|
182
|
key: SERVICES_KEY.EMAIL,
|
146
|
183
|
title: i18n.t('screens.websites.mails'),
|
147
|
184
|
subtitle: i18n.t('screens.services.descriptions.mails'),
|
148
|
185
|
image: EMAIL_IMAGE,
|
149
|
|
- onPress: () => nav.navigate("website", {host: AvailableWebsites.websites.BLUEMIND, title: i18n.t('screens.websites.mails')}),
|
|
186
|
+ onPress: () => nav.navigate("website", {
|
|
187
|
+ host: AvailableWebsites.websites.BLUEMIND,
|
|
188
|
+ title: i18n.t('screens.websites.mails')
|
|
189
|
+ }),
|
150
|
190
|
},
|
151
|
191
|
{
|
152
|
192
|
key: SERVICES_KEY.ENT,
|
153
|
193
|
title: i18n.t('screens.websites.ent'),
|
154
|
194
|
subtitle: i18n.t('screens.services.descriptions.ent'),
|
155
|
195
|
image: ENT_IMAGE,
|
156
|
|
- onPress: () => nav.navigate("website", {host: AvailableWebsites.websites.ENT, title: i18n.t('screens.websites.ent')}),
|
|
196
|
+ onPress: () => nav.navigate("website", {
|
|
197
|
+ host: AvailableWebsites.websites.ENT,
|
|
198
|
+ title: i18n.t('screens.websites.ent')
|
|
199
|
+ }),
|
157
|
200
|
},
|
158
|
201
|
{
|
159
|
202
|
key: SERVICES_KEY.INSA_ACCOUNT,
|
160
|
203
|
title: i18n.t('screens.insaAccount.title'),
|
161
|
204
|
subtitle: i18n.t('screens.services.descriptions.insaAccount'),
|
162
|
205
|
image: ACCOUNT_IMAGE,
|
163
|
|
- onPress: () => nav.navigate("website", {host: AvailableWebsites.websites.INSA_ACCOUNT, title: i18n.t('screens.insaAccount.title')}),
|
|
206
|
+ onPress: () => nav.navigate("website", {
|
|
207
|
+ host: AvailableWebsites.websites.INSA_ACCOUNT,
|
|
208
|
+ title: i18n.t('screens.insaAccount.title')
|
|
209
|
+ }),
|
164
|
210
|
},
|
165
|
211
|
];
|
|
212
|
+ this.specialDataset = [
|
|
213
|
+ {
|
|
214
|
+ key: SERVICES_KEY.WASHERS,
|
|
215
|
+ title: i18n.t('screens.proxiwash.washers'),
|
|
216
|
+ subtitle: i18n.t('screens.proxiwash.title'), // TODO add description
|
|
217
|
+ image: WASHER_IMAGE,
|
|
218
|
+ onPress: () => nav.navigate("proxiwash"),
|
|
219
|
+ badgeFunction: (dashboard: fullDashboard) => dashboard.available_washers
|
|
220
|
+ },
|
|
221
|
+ {
|
|
222
|
+ key: SERVICES_KEY.DRYERS,
|
|
223
|
+ title: i18n.t('screens.proxiwash.dryers'),
|
|
224
|
+ subtitle: i18n.t('screens.proxiwash.title'), // TODO add description
|
|
225
|
+ image: DRYER_IMAGE,
|
|
226
|
+ onPress: () => nav.navigate("proxiwash"),
|
|
227
|
+ badgeFunction: (dashboard: fullDashboard) => dashboard.available_dryers
|
|
228
|
+ }
|
|
229
|
+ ]
|
166
|
230
|
}
|
167
|
231
|
|
168
|
232
|
/**
|
|
@@ -185,7 +249,7 @@ export default class ServicesManager {
|
185
|
249
|
* @param sourceList The item list to use as source
|
186
|
250
|
* @returns {[]}
|
187
|
251
|
*/
|
188
|
|
- getStrippedList(idList: Array<string>, sourceList: cardList) {
|
|
252
|
+ getStrippedList(idList: Array<string>, sourceList: Array<ServiceItem>) {
|
189
|
253
|
let newArray = [];
|
190
|
254
|
for (let i = 0; i < sourceList.length; i++) {
|
191
|
255
|
const item = sourceList[i];
|
|
@@ -196,34 +260,10 @@ export default class ServicesManager {
|
196
|
260
|
}
|
197
|
261
|
|
198
|
262
|
/**
|
199
|
|
- * Gets a services list of items with the given ids only
|
200
|
|
- *
|
201
|
|
- * @param idList The ids of items to find
|
202
|
|
- * @returns {[]}
|
203
|
|
- */
|
204
|
|
- getServicesOfId(idList: Array<string>) {
|
205
|
|
- const allServices = [
|
206
|
|
- ...this.amicaleDataset,
|
207
|
|
- ...this.studentsDataset,
|
208
|
|
- ...this.insaDataset,
|
209
|
|
- ]
|
210
|
|
- let servicesFound = [];
|
211
|
|
- for (let i = 0; i < allServices.length; i++) {
|
212
|
|
- const item = allServices[i];
|
213
|
|
- if (idList.includes(item.key)) {
|
214
|
|
- servicesFound.push(item);
|
215
|
|
- if (servicesFound.length === idList.length)
|
216
|
|
- break;
|
217
|
|
- }
|
218
|
|
- }
|
219
|
|
- return servicesFound;
|
220
|
|
- }
|
221
|
|
-
|
222
|
|
- /**
|
223
|
263
|
* Gets the list of amicale's services
|
224
|
264
|
*
|
225
|
265
|
* @param excludedItems Ids of items to exclude from the returned list
|
226
|
|
- * @returns {cardList|*[]}
|
|
266
|
+ * @returns {Array<ServiceItem>}
|
227
|
267
|
*/
|
228
|
268
|
getAmicaleServices(excludedItems?: Array<string>) {
|
229
|
269
|
if (excludedItems != null)
|
|
@@ -236,7 +276,7 @@ export default class ServicesManager {
|
236
|
276
|
* Gets the list of students' services
|
237
|
277
|
*
|
238
|
278
|
* @param excludedItems Ids of items to exclude from the returned list
|
239
|
|
- * @returns {cardList|*[]}
|
|
279
|
+ * @returns {Array<ServiceItem>}
|
240
|
280
|
*/
|
241
|
281
|
getStudentServices(excludedItems?: Array<string>) {
|
242
|
282
|
if (excludedItems != null)
|
|
@@ -249,7 +289,7 @@ export default class ServicesManager {
|
249
|
289
|
* Gets the list of INSA's services
|
250
|
290
|
*
|
251
|
291
|
* @param excludedItems Ids of items to exclude from the returned list
|
252
|
|
- * @returns {cardList|*[]}
|
|
292
|
+ * @returns {Array<ServiceItem>}
|
253
|
293
|
*/
|
254
|
294
|
getINSAServices(excludedItems?: Array<string>) {
|
255
|
295
|
if (excludedItems != null)
|
|
@@ -258,4 +298,17 @@ export default class ServicesManager {
|
258
|
298
|
return this.insaDataset;
|
259
|
299
|
}
|
260
|
300
|
|
|
301
|
+ /**
|
|
302
|
+ * Gets the list of special services
|
|
303
|
+ *
|
|
304
|
+ * @param excludedItems Ids of items to exclude from the returned list
|
|
305
|
+ * @returns {Array<ServiceItem>}
|
|
306
|
+ */
|
|
307
|
+ getSpecialServices(excludedItems?: Array<string>) {
|
|
308
|
+ if (excludedItems != null)
|
|
309
|
+ return this.getStrippedList(excludedItems, this.specialDataset)
|
|
310
|
+ else
|
|
311
|
+ return this.specialDataset;
|
|
312
|
+ }
|
|
313
|
+
|
261
|
314
|
}
|