tycho-components 0.2.2-SNAPSHOT-4 → 0.2.2-SNAPSHOT-5

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.
@@ -1,8 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import logo from './logo.png';
3
2
  import { useState } from 'react';
4
3
  import { useTranslation } from 'react-i18next';
5
4
  import { useNavigate, useRouteError } from 'react-router-dom';
5
+ import { Button } from 'tycho-storybook';
6
+ import CookieStorage from '../configs/CookieStorage';
7
+ import logo from './logo.png';
6
8
  import './style.scss';
7
9
  export default function ErrorFound() {
8
10
  const navigate = useNavigate();
@@ -12,5 +14,9 @@ export default function ErrorFound() {
12
14
  const handleRedirect = () => {
13
15
  navigate(`${import.meta.env.VITE_APP_PUBLIC_URL}`, { replace: true });
14
16
  };
15
- return (_jsxs("div", { className: "box-container", children: [_jsxs("div", { className: "box", children: [_jsx("img", { src: logo }), _jsx("div", { className: "title", children: t('label.error.found') }), _jsx("div", { className: "subtitle", onClick: handleRedirect, children: t('label.redirect') }), _jsx("div", { className: "divider", children: t('label.divider') }), _jsx("div", { className: "error-details", onClick: () => setShow((prevState) => !prevState), children: t('label.error.details') })] }), show && (_jsx("pre", { className: "error-stack", children: JSON.stringify(error, null, 2) }))] }));
17
+ const handleRetry = () => {
18
+ const redirectUri = CookieStorage.getRedirectUri();
19
+ redirectUri ? (window.location.href = redirectUri) : handleRedirect();
20
+ };
21
+ return (_jsxs("div", { className: "box-container", children: [_jsxs("div", { className: "box", children: [_jsx("img", { src: logo }), _jsx("div", { className: "title", children: t('label.error.found') }), _jsxs("div", { className: "buttons", children: [_jsx(Button, { text: t('label.retry'), size: "small" }), _jsx(Button, { text: t('label.redirect'), size: "small" }), _jsx(Button, { text: t('label.error.details'), size: "small" })] })] }), show && (_jsx("pre", { className: "error-stack", children: JSON.stringify(error, null, 2) }))] }));
16
22
  }
@@ -28,8 +28,10 @@
28
28
  cursor: pointer;
29
29
  }
30
30
 
31
- .divider {
32
- margin: 16px 0px;
31
+ .buttons {
32
+ display: flex;
33
+ justify-content: center;
34
+ gap: 16px;
33
35
  }
34
36
 
35
37
  .error-details {
@@ -59,6 +61,14 @@
59
61
  .box {
60
62
  width: 90%;
61
63
  margin-top: 10%;
64
+
65
+ .buttons {
66
+ flex-direction: column;
67
+
68
+ > .ds-button {
69
+ margin: 0px auto;
70
+ }
71
+ }
62
72
  }
63
73
  }
64
74
  }
@@ -1,3 +1,4 @@
1
+ declare function getRedirectUri(): string | undefined;
1
2
  declare function setRedirectUri(uri: string): void;
2
3
  declare function removeRedirectUri(): void;
3
4
  declare const CookieStorage: {
@@ -5,6 +6,7 @@ declare const CookieStorage: {
5
6
  getJwtToken: () => string | undefined;
6
7
  removeJwtToken: () => void;
7
8
  setRedirectUri: typeof setRedirectUri;
9
+ getRedirectUri: typeof getRedirectUri;
8
10
  removeRedirectUri: typeof removeRedirectUri;
9
11
  };
10
12
  export default CookieStorage;
@@ -12,6 +12,9 @@ const getJwtToken = () => {
12
12
  const removeJwtToken = () => {
13
13
  return Cookies.remove(JWT_TOKEN);
14
14
  };
15
+ function getRedirectUri() {
16
+ return Cookies.get(REDIRECT_URI);
17
+ }
15
18
  function setRedirectUri(uri) {
16
19
  Cookies.set(REDIRECT_URI, uri);
17
20
  }
@@ -23,6 +26,7 @@ const CookieStorage = {
23
26
  getJwtToken,
24
27
  removeJwtToken,
25
28
  setRedirectUri,
29
+ getRedirectUri,
26
30
  removeRedirectUri,
27
31
  };
28
32
  export default CookieStorage;
@@ -10,9 +10,9 @@ export declare const commonResources: {
10
10
  'unauthorized.label.redirect': string;
11
11
  'notfound.label.disclaimer': string;
12
12
  'label.redirect': string;
13
- 'label.error.found': string;
13
+ 'label.retry': string;
14
14
  'label.error.details': string;
15
- 'label.divider': string;
15
+ 'label.error.found': string;
16
16
  };
17
17
  comments: {
18
18
  'label.title.comments': string;
@@ -189,9 +189,9 @@ export declare const commonResources: {
189
189
  'unauthorized.label.redirect': string;
190
190
  'notfound.label.disclaimer': string;
191
191
  'label.redirect': string;
192
+ 'label.retry': string;
192
193
  'label.error.details': string;
193
194
  'label.error.found': string;
194
- 'label.divider': string;
195
195
  };
196
196
  comments: {
197
197
  'label.title.comments': string;
@@ -366,9 +366,9 @@ export declare const commonResources: {
366
366
  'unauthorized.label.redirect': string;
367
367
  'notfound.label.disclaimer': string;
368
368
  'label.redirect': string;
369
+ 'label.retry': string;
369
370
  'label.error.details': string;
370
371
  'label.error.found': string;
371
- 'label.divider': string;
372
372
  };
373
373
  comments: {
374
374
  'label.title.comments': string;
@@ -9,9 +9,9 @@ export declare const BaseTexts: {
9
9
  'unauthorized.label.redirect': string;
10
10
  'notfound.label.disclaimer': string;
11
11
  'label.redirect': string;
12
- 'label.error.found': string;
12
+ 'label.retry': string;
13
13
  'label.error.details': string;
14
- 'label.divider': string;
14
+ 'label.error.found': string;
15
15
  };
16
16
  'pt-BR': {
17
17
  'text.title': string;
@@ -23,9 +23,9 @@ export declare const BaseTexts: {
23
23
  'unauthorized.label.redirect': string;
24
24
  'notfound.label.disclaimer': string;
25
25
  'label.redirect': string;
26
+ 'label.retry': string;
26
27
  'label.error.details': string;
27
28
  'label.error.found': string;
28
- 'label.divider': string;
29
29
  };
30
30
  it: {
31
31
  'text.title': string;
@@ -37,8 +37,8 @@ export declare const BaseTexts: {
37
37
  'unauthorized.label.redirect': string;
38
38
  'notfound.label.disclaimer': string;
39
39
  'label.redirect': string;
40
+ 'label.retry': string;
40
41
  'label.error.details': string;
41
42
  'label.error.found': string;
42
- 'label.divider': string;
43
43
  };
44
44
  };
@@ -8,10 +8,10 @@ export const BaseTexts = {
8
8
  'unauthorized.label.disclaimer': 'You are not authorized to access this content.',
9
9
  'unauthorized.label.redirect': 'Click here to be redirected to the login page',
10
10
  'notfound.label.disclaimer': 'Ops, page not found.',
11
- 'label.redirect': 'Click here to be redirected to the login page',
11
+ 'label.redirect': 'Go to login page',
12
+ 'label.retry': 'Retry',
13
+ 'label.error.details': 'Error details',
12
14
  'label.error.found': 'Ops, an error has occurred.',
13
- 'label.error.details': 'Click here for error details',
14
- 'label.divider': '-- or --',
15
15
  },
16
16
  'pt-BR': {
17
17
  'text.title': 'Bem-vindo à Plataforma Tycho Brahe',
@@ -22,10 +22,10 @@ export const BaseTexts = {
22
22
  'unauthorized.label.disclaimer': 'Você não está autorizado a acessar este conteúdo.',
23
23
  'unauthorized.label.redirect': 'Clique aqui para ser redirecionado para a página de login',
24
24
  'notfound.label.disclaimer': 'Ops, página não encontrada.',
25
- 'label.redirect': 'Clique aqui para ser redirecionado para a página de login',
26
- 'label.error.details': 'Clique aqui para ver os detalhes do erro',
25
+ 'label.redirect': 'Página de login',
26
+ 'label.retry': 'Tentar novamente',
27
+ 'label.error.details': 'Detalhes do erro',
27
28
  'label.error.found': 'Ops, ocorreu um erro.',
28
- 'label.divider': '-- ou --',
29
29
  },
30
30
  it: {
31
31
  'text.title': 'Benvenuto sulla Piattaforma Tycho Brahe',
@@ -36,9 +36,9 @@ export const BaseTexts = {
36
36
  'unauthorized.label.disclaimer': 'Non sei autorizzato a accedere a questo contenuto.',
37
37
  'unauthorized.label.redirect': 'Clicca qui per essere reindirizzato alla pagina di accesso',
38
38
  'notfound.label.disclaimer': 'Ops, pagina non trovata.',
39
- 'label.redirect': 'Clicca qui per essere reindirizzato alla pagina di accesso',
40
- 'label.error.details': "Clicca qui per i dettagli dell'errore",
39
+ 'label.redirect': 'Pagina di accesso',
40
+ 'label.retry': 'Riprova',
41
+ 'label.error.details': "Dettagli dell'errore",
41
42
  'label.error.found': 'Ops, si è verificato un errore.',
42
- 'label.divider': '-- o --',
43
43
  },
44
44
  };
package/dist/index.d.ts CHANGED
@@ -66,4 +66,4 @@ export { default as Login } from './Base/Login';
66
66
  export { default as Logout } from './Base/Logout';
67
67
  export { default as Unauthorized } from './Base/Unauthorized';
68
68
  export { default as NotFound } from './Base/NotFound';
69
- export { default as CookieStorage } from './functions/CookieStorage';
69
+ export { default as CookieStorage } from './configs/CookieStorage';
package/dist/index.js CHANGED
@@ -51,4 +51,4 @@ export { default as Login } from './Base/Login';
51
51
  export { default as Logout } from './Base/Logout';
52
52
  export { default as Unauthorized } from './Base/Unauthorized';
53
53
  export { default as NotFound } from './Base/NotFound';
54
- export { default as CookieStorage } from './functions/CookieStorage';
54
+ export { default as CookieStorage } from './configs/CookieStorage';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.2.2-SNAPSHOT-4",
4
+ "version": "0.2.2-SNAPSHOT-5",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -1,10 +0,0 @@
1
- declare function setRedirectUri(uri: string): void;
2
- declare function removeRedirectUri(): void;
3
- declare const CookieStorage: {
4
- setJwtToken: (jwtToken: string) => void;
5
- getJwtToken: () => string | undefined;
6
- removeJwtToken: () => void;
7
- setRedirectUri: typeof setRedirectUri;
8
- removeRedirectUri: typeof removeRedirectUri;
9
- };
10
- export default CookieStorage;
@@ -1,28 +0,0 @@
1
- import Cookies from 'js-cookie';
2
- const REDIRECT_URI = 'redirect_uri_tycho';
3
- const JWT_TOKEN = 'jwt_token_tycho';
4
- const expireDays = 7;
5
- const setJwtToken = (jwtToken) => {
6
- Cookies.set(JWT_TOKEN, jwtToken, { expires: expireDays });
7
- };
8
- const getJwtToken = () => {
9
- const cookie = Cookies.get(JWT_TOKEN);
10
- return cookie === 'undefined' ? '' : cookie;
11
- };
12
- const removeJwtToken = () => {
13
- return Cookies.remove(JWT_TOKEN);
14
- };
15
- function setRedirectUri(uri) {
16
- Cookies.set(REDIRECT_URI, uri);
17
- }
18
- function removeRedirectUri() {
19
- Cookies.remove(REDIRECT_URI);
20
- }
21
- const CookieStorage = {
22
- setJwtToken,
23
- getJwtToken,
24
- removeJwtToken,
25
- setRedirectUri,
26
- removeRedirectUri,
27
- };
28
- export default CookieStorage;