turf-common 1.2.1-beta.45 → 1.2.1-beta.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,6 +20,11 @@ export declare class TurfAvailability implements ITurfAvailability {
20
20
  data: IGetAvailabilityByTurf;
21
21
  dateCodes: string[];
22
22
  timeSlotCodesDateWise: Record<string, string[]>;
23
+ startDateCode: string;
24
+ endDateCode: string;
25
+ fromTimeCode: string;
26
+ toTimeCode: string;
27
+ pitchIdCodes: string[];
23
28
  constructor(data: IGetAvailabilityByTurf);
24
29
  getTotalAvailablePrice(): number;
25
30
  getTotalNonAvailablePrice(): number;
@@ -37,5 +42,6 @@ export declare class TurfAvailability implements ITurfAvailability {
37
42
  static toJson(turfAvailability: TurfAvailability): IGetAvailabilityByTurf;
38
43
  getTotalTime(): number;
39
44
  getCode(): string;
45
+ parse(): void;
40
46
  }
41
47
  export {};
@@ -12,6 +12,7 @@ var TurfAvailability = /** @class */ (function () {
12
12
  var key = _a[0], value = _a[1];
13
13
  _this.timeSlotCodesDateWise[key] = Object.keys(value).sort();
14
14
  });
15
+ this.parse();
15
16
  }
16
17
  TurfAvailability.prototype.getTotalAvailablePrice = function () {
17
18
  var totalCost = 0;
@@ -173,6 +174,19 @@ var TurfAvailability = /** @class */ (function () {
173
174
  TurfAvailability.prototype.getCode = function () {
174
175
  return "event#".concat(this.dateCodes[0]).concat(this.dateCodes[this.dateCodes.length - 1], "#").concat(this.timeSlotCodesDateWise[this.dateCodes[0]][0].slice(0, 4)).concat(this.timeSlotCodesDateWise[this.dateCodes[0]][this.timeSlotCodesDateWise[this.dateCodes[0]].length - 1].slice(4, 8), "#").concat(this.getPitchIds());
175
176
  };
177
+ TurfAvailability.prototype.parse = function () {
178
+ var eventCode = this.getCode();
179
+ var eventCodes = eventCode.split("#");
180
+ var dateCodeRange = eventCodes[1];
181
+ var timeCodeRange = eventCodes[2];
182
+ this.pitchIdCodes = eventCodes[3]
183
+ .split(",")
184
+ .map(function (id) { return id.padStart(2, "0"); });
185
+ this.startDateCode = dateCodeRange.slice(0, 6);
186
+ this.endDateCode = dateCodeRange.slice(6, 12);
187
+ this.fromTimeCode = timeCodeRange.slice(0, 4);
188
+ this.toTimeCode = timeCodeRange.slice(4, 8);
189
+ };
176
190
  return TurfAvailability;
177
191
  }());
178
192
  exports.TurfAvailability = TurfAvailability;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turf-common",
3
- "version": "1.2.1-beta.45",
3
+ "version": "1.2.1-beta.47",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",