Issues (5)

src/utils/utils.js (2 issues)

1
const utils = {
2
  /**
3
   * Returns color for each state
4
   * @param {string} state
5
   * @returns
6
   */
7
  sateColor: function stateColor(state) {
8
    switch (state) {
9
      case "Available":
10
        return "#22c55e";
11
      case "Unavailable":
12
        return "#dc2626";
13
      case "Off":
14
        return "#94a3b8";
15
      case "In use":
16
        return "#facc15";
17
      case "Maintenance":
18
        return "#ea580c";
19
    }
0 ignored issues
show
Comprehensibility introduced by
There is no default case in this switch, so nothing gets returned when all cases fail. You might want to consider adding a default or return undefined explicitly.
Loading history...
20
  },
21
22
  /**
23
   * Translate zone reference name to a more readble state
24
   *
25
   * @param {string} name
26
   * @returns
27
   */
28
  zoneNameTranslate: function zoneNameTranslate(name) {
29
    switch (name) {
30
      case "noParkingZone":
31
        return "No Parking Zone";
32
      case "bonusParkingZone":
33
        return "Bonus Parking Zone";
34
      case "parkingZone":
35
        return "Parking Zone";
36
      case "chargingZone":
37
        return "Charging Zone";
38
    }
0 ignored issues
show
Comprehensibility introduced by
There is no default case in this switch, so nothing gets returned when all cases fail. You might want to consider adding a default or return undefined explicitly.
Loading history...
39
  },
40
41
  /**
42
   * Returns objects with amount of zones
43
   * @param {object} selected
44
   * @returns zones
45
   */
46
  zoneCount: function zoneCount(selected) {
47
    let zones = {
48
      noParkingZone: 0,
49
      bonusParkingZone: 0,
50
      parkingZone: 0,
51
      chargingZone: 0,
52
      total: 0,
53
    };
54
    selected.map((item) => {
55
      zones[item.zoneType] += 1;
56
      zones["total"] += 1;
57
    });
58
    return zones;
59
  },
60
};
61
62
export default utils;
63