@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.
@@ -47,6 +47,7 @@ declare enum PublicLabelSettings {
47
47
  GAMIFICATION_WIDGET_BG_OPACITY = "GAMIFICATION_WIDGET_BG_OPACITY",
48
48
  GAMIFICATION_POPUP_BG_OPACITY = "GAMIFICATION_POPUP_BG_OPACITY",
49
49
  GAMIFICATION_POPUP_BG_BLUR = "GAMIFICATION_POPUP_BG_BLUR",
50
+ FRONT_DISABLE_POPUP_INBOX_ON_URLS = "FRONT_DISABLE_POPUP_INBOX_ON_URLS",
50
51
  GAMIFICATION_LEVELS_LOGIC2 = "GAMIFICATION_LEVELS_LOGIC2",
51
52
  GAMIFICATION_LEVELS_LOGIC3 = "GAMIFICATION_LEVELS_LOGIC3",
52
53
  AVATAR_CUSTOM_IMAGE_MAX_ID = "AVATAR_CUSTOM_IMAGE_MAX_ID",
@@ -260,13 +260,13 @@ export interface TLevel {
260
260
  * Read more here - https://help.smartico.ai/welcome/products/general-concepts/custom-fields-attributes
261
261
  */
262
262
  custom_data: string;
263
+ /** The ordinal position of the level */
264
+ ordinal_position: number;
263
265
  }
264
266
  /**
265
267
  * TLevelCurrent describes the information of each level defined in the system along with ordinal position and progress of the current level
266
268
  */
267
269
  export interface TLevelCurrent extends TLevel {
268
- /** The ordinal position of the level */
269
- ordinal_position: number;
270
270
  /** The progress of the user towards next level in the percents to complete */
271
271
  progress: number;
272
272
  }
package/dist/index.js CHANGED
@@ -1925,7 +1925,8 @@ var getLeaderBoardTransform = function getLeaderBoardTransform(board) {
1925
1925
  };
1926
1926
 
1927
1927
  var GetLevelMapResponseTransform = function GetLevelMapResponseTransform(levels) {
1928
- return levels == null ? void 0 : levels.levels.map(function (l) {
1928
+ if (!(levels != null && levels.levels)) return [];
1929
+ var mapped = levels.levels.map(function (l) {
1929
1930
  var _l$level_public_meta;
1930
1931
  return {
1931
1932
  id: l.level_id,
@@ -1936,9 +1937,21 @@ var GetLevelMapResponseTransform = function GetLevelMapResponseTransform(levels)
1936
1937
  visibility_points: l.level_public_meta.visibility_points ? parseInt(l.level_public_meta.visibility_points) : null,
1937
1938
  required_level_counter_1: l.required_level_counter_1,
1938
1939
  required_level_counter_2: l.required_level_counter_2,
1939
- custom_data: IntUtils.JsonOrText((_l$level_public_meta = l.level_public_meta) == null ? void 0 : _l$level_public_meta.custom_data)
1940
+ custom_data: IntUtils.JsonOrText((_l$level_public_meta = l.level_public_meta) == null ? void 0 : _l$level_public_meta.custom_data),
1941
+ ordinal_position: 0
1940
1942
  };
1941
1943
  });
1944
+ var ordinalById = new Map();
1945
+ [].concat(mapped).sort(function (a, b) {
1946
+ return a.required_points - b.required_points;
1947
+ }).forEach(function (l, index) {
1948
+ return ordinalById.set(l.id, index + 1);
1949
+ });
1950
+ return mapped.map(function (l) {
1951
+ return _extends({}, l, {
1952
+ ordinal_position: ordinalById.get(l.id)
1953
+ });
1954
+ });
1942
1955
  };
1943
1956
 
1944
1957
  /** @hidden */
@@ -5041,7 +5054,6 @@ var SmarticoAPI = /*#__PURE__*/function () {
5041
5054
  var userPointsEver = (_userInfo$points_ever2 = userInfo.points_ever) != null ? _userInfo$points_ever2 : 0;
5042
5055
  var progress = nextLevel ? (userPointsEver - currentLevel.required_points) / (nextLevel.required_points - currentLevel.required_points) * 100 : 100;
5043
5056
  return _extends({}, currentLevel, {
5044
- ordinal_position: currentLevelIndex + 1,
5045
5057
  progress: Math.min(Math.max(progress, 0), 100)
5046
5058
  });
5047
5059
  });