robbyson-frontend-library 1.0.59 → 1.0.60

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.
@@ -33,7 +33,7 @@ var BaseAppPage = /** @class */ (function (_super) {
33
33
  var _this = _super.call(this, props) || this;
34
34
  _this.headerLocale = "Header Locale";
35
35
  _this._baseAppPageTitleRef = React.createRef();
36
- _this._baseAppPaseTitle = "";
36
+ _this._baseAppPageTitle = "";
37
37
  _this._profileHistoryService = IoC.GetInstance("ProfileService");
38
38
  _this.translate = _this.translate.bind(_this);
39
39
  _this.redirect = _this.redirect.bind(_this);
@@ -44,9 +44,9 @@ var BaseAppPage = /** @class */ (function (_super) {
44
44
  return _this;
45
45
  }
46
46
  BaseAppPage.prototype.redirect = function () {
47
- var state = RobbysonNavigate === null || RobbysonNavigate === void 0 ? void 0 : RobbysonNavigate.getHistoryState();
48
- if (state === null || state === void 0 ? void 0 : state.pathname) {
49
- var actualPathname = RobbysonNavigate.getPathname();
47
+ var actualPathname = RobbysonNavigate.getPathname();
48
+ var history = RobbysonNavigate.getLocationHistory();
49
+ if (history) {
50
50
  var restrictedRoutes = [
51
51
  "/terms-of-use",
52
52
  "/humor",
@@ -55,7 +55,9 @@ var BaseAppPage = /** @class */ (function (_super) {
55
55
  "/quiz",
56
56
  ];
57
57
  var isOperacaoPage = actualPathname.endsWith("/operacao/");
58
- var isRestrictedRoute = restrictedRoutes === null || restrictedRoutes === void 0 ? void 0 : restrictedRoutes.some(function (route) { var _a; return (_a = state === null || state === void 0 ? void 0 : state.pathname) === null || _a === void 0 ? void 0 : _a.includes(route); });
58
+ var isRestrictedRoute = restrictedRoutes === null || restrictedRoutes === void 0 ? void 0 : restrictedRoutes.some(function (route) {
59
+ return history === null || history === void 0 ? void 0 : history.includes(route);
60
+ });
59
61
  if (isOperacaoPage && isRestrictedRoute) {
60
62
  return;
61
63
  }
@@ -80,7 +82,7 @@ var BaseAppPage = /** @class */ (function (_super) {
80
82
  };
81
83
  BaseAppPage.prototype.focusOnTitle = function (title) {
82
84
  if (title) {
83
- this._baseAppPaseTitle = title;
85
+ this._baseAppPageTitle = title;
84
86
  }
85
87
  var route = RobbysonNavigate.getRouteId();
86
88
  var history = this._profileHistoryService.getSessionHistory();
@@ -99,8 +101,8 @@ var BaseAppPage = /** @class */ (function (_super) {
99
101
  React.createElement("div", null,
100
102
  React.createElement(GenericButton, { onClick: function () { return _this.redirect(); }, "aria-label": "Voltar para a tela anterior" },
101
103
  React.createElement(LeftArrowLarge, { src: this._themeService.getIconAssetUrl("left-arrow-large"), isOperacaoPage: isOperacaoPage })),
102
- React.createElement(Title, { tabIndex: 0, ref: this._baseAppPageTitleRef, "aria-label": this._baseAppPaseTitle
103
- ? this._baseAppPaseTitle
104
+ React.createElement(Title, { tabIndex: 0, ref: this._baseAppPageTitleRef, "aria-label": this._baseAppPageTitle
105
+ ? this._baseAppPageTitle
104
106
  : this.translate(this.headerLocale) }, this.translate(this.headerLocale))),
105
107
  !this._avoidContextMenu && (React.createElement(ContextMenu, { className: "body-2-book" }, this.contextMenu()))),
106
108
  React.createElement(Content, { contentMarginTop: this._contentMarginTop, usePageHeader: this._usePageHeader, avoidContextMenu: this._avoidContextMenu }, this.renderPage())));
@@ -20,9 +20,13 @@ var RobbysonNavigate = /** @class */ (function () {
20
20
  RobbysonNavigate._globalStore.GetGlobalState();
21
21
  var history = RobbysonNavigate._globalState.Global.RootApp.history;
22
22
  var routeState = __assign(__assign({}, state), { pathname: history.location.pathname });
23
+ this.setLocationHistory(history.location.pathname);
23
24
  // TODO: Usar a LIB PATH para concatenar a URL
24
25
  history.push("/operacao".concat(url), routeState);
25
26
  };
27
+ RobbysonNavigate.openInNewTab = function (url) {
28
+ window.open(url, '_blank');
29
+ };
26
30
  RobbysonNavigate.go = function (delta) {
27
31
  RobbysonNavigate._globalStore = GlobalStore.Get();
28
32
  RobbysonNavigate._globalState =
@@ -42,7 +46,9 @@ var RobbysonNavigate = /** @class */ (function () {
42
46
  RobbysonNavigate._globalState =
43
47
  RobbysonNavigate._globalStore.GetGlobalState();
44
48
  var history = RobbysonNavigate._globalState.Global.RootApp.history;
45
- history.replace(replace, state);
49
+ var routeState = __assign(__assign({}, state), { pathname: history.location.pathname });
50
+ this.setLocationHistory(history.location.pathname);
51
+ history.replace(replace, routeState);
46
52
  };
47
53
  RobbysonNavigate.getHistory = function () {
48
54
  RobbysonNavigate._globalStore = GlobalStore.Get();
@@ -82,6 +88,12 @@ var RobbysonNavigate = /** @class */ (function () {
82
88
  sort: false,
83
89
  });
84
90
  };
91
+ RobbysonNavigate.setLocationHistory = function (location) {
92
+ localStorage.setItem("location-history", location);
93
+ };
94
+ RobbysonNavigate.getLocationHistory = function () {
95
+ return localStorage.getItem("location-history");
96
+ };
85
97
  RobbysonNavigate.setQueryParams = function (key, value) {
86
98
  var queryString = new URLSearchParams(RobbysonNavigate.getQueryParams());
87
99
  if (Array.isArray(key) && Array.isArray(value)) {
@@ -2,8 +2,12 @@ import { ToWords } from "to-words";
2
2
  var StringUtils = /** @class */ (function () {
3
3
  function StringUtils() {
4
4
  }
5
- StringUtils.numberToWords = function (num) {
6
- return this._toWords.convert(num);
5
+ StringUtils.numberToWords = function (n) {
6
+ var numberToConvert = Number(n);
7
+ if (isNaN(numberToConvert)) {
8
+ return n;
9
+ }
10
+ return this._toWords.convert(numberToConvert);
7
11
  };
8
12
  StringUtils._toWords = new ToWords({
9
13
  localeCode: "pt-BR",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "robbyson-frontend-library",
3
- "version": "1.0.59",
3
+ "version": "1.0.60",
4
4
  "description": "Robbyson frontend Library",
5
5
  "main": "./dist/index.js",
6
6
  "license": "MIT",
@@ -25,7 +25,7 @@ export abstract class BaseAppPage<T, T1> extends React.Component<T, T1> {
25
25
  protected _usePageHeader?: boolean;
26
26
  protected _avoidContextMenu?: boolean;
27
27
  private _baseAppPageTitleRef = React.createRef<HTMLHeadingElement>();
28
- private _baseAppPaseTitle = "";
28
+ private _baseAppPageTitle = "";
29
29
  private _profileHistoryService =
30
30
  IoC.GetInstance<IProfileService>("ProfileService");
31
31
 
@@ -40,9 +40,9 @@ export abstract class BaseAppPage<T, T1> extends React.Component<T, T1> {
40
40
  IoC.GetInstance<IProfileService>("ProfileService");
41
41
  }
42
42
  private redirect(): void {
43
- const state = RobbysonNavigate?.getHistoryState() as any;
44
- if (state?.pathname) {
45
- const actualPathname = RobbysonNavigate.getPathname();
43
+ const actualPathname = RobbysonNavigate.getPathname();
44
+ const history = RobbysonNavigate.getLocationHistory();
45
+ if (history) {
46
46
  const restrictedRoutes = [
47
47
  "/terms-of-use",
48
48
  "/humor",
@@ -50,9 +50,10 @@ export abstract class BaseAppPage<T, T1> extends React.Component<T, T1> {
50
50
  "/login",
51
51
  "/quiz",
52
52
  ];
53
+
53
54
  const isOperacaoPage = actualPathname.endsWith("/operacao/");
54
55
  const isRestrictedRoute = restrictedRoutes?.some((route) =>
55
- state?.pathname?.includes(route)
56
+ history?.includes(route)
56
57
  );
57
58
 
58
59
  if (isOperacaoPage && isRestrictedRoute) {
@@ -74,7 +75,7 @@ export abstract class BaseAppPage<T, T1> extends React.Component<T, T1> {
74
75
 
75
76
  protected focusOnTitle(title?: string): void {
76
77
  if (title) {
77
- this._baseAppPaseTitle = title;
78
+ this._baseAppPageTitle = title;
78
79
  }
79
80
 
80
81
  const route = RobbysonNavigate.getRouteId();
@@ -118,8 +119,8 @@ export abstract class BaseAppPage<T, T1> extends React.Component<T, T1> {
118
119
  tabIndex={0}
119
120
  ref={this._baseAppPageTitleRef}
120
121
  aria-label={
121
- this._baseAppPaseTitle
122
- ? this._baseAppPaseTitle
122
+ this._baseAppPageTitle
123
+ ? this._baseAppPageTitle
123
124
  : this.translate(this.headerLocale)
124
125
  }
125
126
  >
@@ -65,6 +65,7 @@ export class UserSessionModel extends BaseRepositoryModel {
65
65
  // @TODO: this field is not completed filled as ClienteRobbyson and both needs to be the same, fix it at service-authentication
66
66
  _id: number;
67
67
  active: boolean;
68
+ authRoute: string;
68
69
  closingDay: number;
69
70
  coins_indicator_id: number;
70
71
  enableEAD: boolean;
@@ -14,9 +14,15 @@ export class RobbysonNavigate {
14
14
 
15
15
  const { history } = RobbysonNavigate._globalState.Global.RootApp;
16
16
  const routeState = { ...state, pathname: history.location.pathname };
17
+ this.setLocationHistory( history.location.pathname)
17
18
  // TODO: Usar a LIB PATH para concatenar a URL
18
19
  history.push(`/operacao${url}`, routeState);
19
20
  }
21
+
22
+ static openInNewTab(url: string) {
23
+ window.open(url, '_blank')
24
+ }
25
+
20
26
  static go(delta: number) {
21
27
  RobbysonNavigate._globalStore = GlobalStore.Get();
22
28
  RobbysonNavigate._globalState =
@@ -42,8 +48,10 @@ export class RobbysonNavigate {
42
48
  RobbysonNavigate._globalStore.GetGlobalState();
43
49
 
44
50
  const { history } = RobbysonNavigate._globalState.Global.RootApp;
51
+ const routeState = { ...state, pathname: history.location.pathname };
52
+ this.setLocationHistory( history.location.pathname)
45
53
 
46
- history.replace(replace, state);
54
+ history.replace(replace, routeState);
47
55
  }
48
56
 
49
57
  static getHistory(): BrowserHistory {
@@ -98,7 +106,12 @@ export class RobbysonNavigate {
98
106
  sort: false,
99
107
  }) as T;
100
108
  }
101
-
109
+ static setLocationHistory(location: string){
110
+ localStorage.setItem("location-history", location)
111
+ }
112
+ static getLocationHistory(): string | null {
113
+ return localStorage.getItem("location-history")
114
+ }
102
115
  static setQueryParams(
103
116
  key: string | string[],
104
117
  value: string | number | (string | number)[]
@@ -5,7 +5,13 @@ export class StringUtils {
5
5
  localeCode: "pt-BR",
6
6
  });
7
7
 
8
- public static numberToWords(num: number): string {
9
- return this._toWords.convert(num);
8
+ public static numberToWords(n: number): string | number {
9
+ const numberToConvert = Number(n);
10
+
11
+ if (isNaN(numberToConvert)) {
12
+ return n;
13
+ }
14
+
15
+ return this._toWords.convert(numberToConvert);
10
16
  }
11
17
  }