@smartico/public-api 0.0.348 → 0.0.349

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.
@@ -1931,7 +1931,8 @@ const getLeaderBoardTransform = board => {
1931
1931
  };
1932
1932
 
1933
1933
  const GetLevelMapResponseTransform = levels => {
1934
- return levels == null ? void 0 : levels.levels.map(l => {
1934
+ if (!(levels != null && levels.levels)) return [];
1935
+ const mapped = levels.levels.map(l => {
1935
1936
  var _l$level_public_meta;
1936
1937
  return {
1937
1938
  id: l.level_id,
@@ -1942,9 +1943,15 @@ const GetLevelMapResponseTransform = levels => {
1942
1943
  visibility_points: l.level_public_meta.visibility_points ? parseInt(l.level_public_meta.visibility_points) : null,
1943
1944
  required_level_counter_1: l.required_level_counter_1,
1944
1945
  required_level_counter_2: l.required_level_counter_2,
1945
- custom_data: IntUtils.JsonOrText((_l$level_public_meta = l.level_public_meta) == null ? void 0 : _l$level_public_meta.custom_data)
1946
+ custom_data: IntUtils.JsonOrText((_l$level_public_meta = l.level_public_meta) == null ? void 0 : _l$level_public_meta.custom_data),
1947
+ ordinal_position: 0
1946
1948
  };
1947
1949
  });
1950
+ const ordinalById = new Map();
1951
+ [...mapped].sort((a, b) => a.required_points - b.required_points).forEach((l, index) => ordinalById.set(l.id, index + 1));
1952
+ return mapped.map(l => _extends({}, l, {
1953
+ ordinal_position: ordinalById.get(l.id)
1954
+ }));
1948
1955
  };
1949
1956
 
1950
1957
  /** @hidden */
@@ -4182,7 +4189,6 @@ class SmarticoAPI {
4182
4189
  const userPointsEver = (_userInfo$points_ever2 = userInfo.points_ever) != null ? _userInfo$points_ever2 : 0;
4183
4190
  const progress = nextLevel ? (userPointsEver - currentLevel.required_points) / (nextLevel.required_points - currentLevel.required_points) * 100 : 100;
4184
4191
  return _extends({}, currentLevel, {
4185
- ordinal_position: currentLevelIndex + 1,
4186
4192
  progress: Math.min(Math.max(progress, 0), 100)
4187
4193
  });
4188
4194
  }