-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
43 lines (39 loc) · 1.09 KB
/
utils.js
File metadata and controls
43 lines (39 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
export const filterParams = ({ location, category }, filtCategory, filtLocation) => {
if (filtLocation) {
if (filtCategory)
return (category == filtCategory && location == filtLocation)
else
return (location == filtLocation)
}
else {
return true
}
}
export const onlyUnique = (value, index, self) => self.indexOf(value) === index
export const sanitizeItem = (item) => {
return {
location: item.location,
category: getHumanReadableCategory(item.category),
code: item.code,
quota: getIntFromString(item.quota),
first: item.first,
second: item.second,
invitations: getIntFromString(item.invitations),
candidates: getIntFromString(item.candidates),
spots: getIntFromString(item.spots),
chances: getIntFromString(item.chances)
}
}
const getHumanReadableCategory = (cat) => {
switch(cat) {
case 'coop':
return 'Stage coop'
case 'wh':
return 'PVT'
case 'yp':
return 'JP'
}
}
const getIntFromString = (str) => {
return parseInt(str.replace(/\s/g, ''))
}