@tracktor/shared-module 0.0.3 → 0.2.0

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.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
1
  # [Versions](https://github.com/Tracktor/react-google-tag-manager/releases)
2
2
 
3
- ## v0.0.3
4
- - **[docs]** : readme.md
3
+ ## v0.2.0
4
+ - **[refactor]** : export module structure
package/README.md CHANGED
@@ -1,14 +1,12 @@
1
1
  # shared-module
2
2
 
3
- > This package contains shared components and utilities for the Tracktor project.
4
- > This package don't use any external dependencies.
5
- > Note: This package is not intended to be used outside the Tracktor project.
3
+ > This package contains shared components, hooks and utilities for the Tracktor project.
4
+ > This package don't use any external dependencies.
5
+ > This package is not intended to be used outside the Tracktor project.
6
6
 
7
7
  - [Installation](#Installation)
8
8
  - [Usage](#Usage)
9
9
  - [Inject dependencies with provider](#Inject-dependencies-with-provider)
10
- - [Package](#Package)
11
-
12
10
 
13
11
  ## Installation
14
12
 
@@ -21,12 +19,6 @@ yarn add @tracktor/shared-module
21
19
  ```typescript jsx
22
20
  import { RequireAuth } from "@tracktor/shared-module";
23
21
  ```
24
- Or you can import only the package do you
25
- need with `@tracktor/shared-module/{package}` like this:
26
-
27
- ```typescript jsx
28
- import { RequireAuth } from "@tracktor/shared-module/auth";
29
- ```
30
22
 
31
23
  ## Inject dependencies with provider
32
24
 
@@ -34,8 +26,7 @@ On this exemple below, dependencies are injected with the
34
26
  provider `InjectDependenciesProvider` for the component `RequireAuth`:
35
27
 
36
28
  ```typescript jsx
37
- import { RequireAuth } from "@tracktor/shared-module/auth"
38
- import { InjectDependenciesProvider } from "@tracktor/shared-module/context";
29
+ import { InjectDependenciesProvider, RequireAuth } from "@tracktor/shared-module";
39
30
  import { Navigate, Outlet, Route, RouterProvider, useLocation } from "react-router-dom";
40
31
  import { t } from "i18next";
41
32
 
@@ -59,11 +50,3 @@ const App = () => (
59
50
 
60
51
  export default App;
61
52
  ```
62
-
63
- ## Package
64
-
65
- | Package | Description |
66
- |---------|----------------------------------------------------------------------------------------------------------|
67
- | api | This package contains the api to communicate with the backend. |
68
- | auth | This package contains the component `RequireAuth` that can be used to protect routes. |
69
- | context | This package contains the provider `InjectDependenciesProvider` that can be used to inject dependencies. |
@@ -0,0 +1,3 @@
1
+ import RequireAuth from "./RequireAuth";
2
+ export default RequireAuth;
3
+ export * from "./RequireAuth";
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from "react";
2
- import type { useResponseErrorParams } from '../api/hooks/useResponseError';
3
- import type { RequireAuthProps } from '../auth/components/RequireAuth';
2
+ import type { RequireAuthProps } from '../components/RequireAuth';
3
+ import type { useResponseErrorParams } from '../hooks/useResponseError';
4
4
  export interface InjectDependenciesContextProps {
5
5
  /**
6
6
  * Children
@@ -0,0 +1,3 @@
1
+ import useResponseError from "./useResponseError";
2
+ export default useResponseError;
3
+ export * from "./useResponseError";
@@ -1,4 +1,16 @@
1
- import type ResponseError from '../../api/types/error';
1
+ export interface ResponseError {
2
+ data?: {
3
+ code?: number;
4
+ message?: string;
5
+ payload?: any;
6
+ reason?: string;
7
+ detail?: {
8
+ loc?: [];
9
+ msg?: string;
10
+ type?: string;
11
+ }[];
12
+ };
13
+ }
2
14
  export interface useResponseErrorParams {
3
15
  /**
4
16
  * Translation function if you want to use your own translation function
@@ -13,7 +25,7 @@ export interface useResponseErrorParams {
13
25
  /**
14
26
  * This hook is used to print error messages from the API
15
27
  */
16
- export declare const useResponseError: (params?: useResponseErrorParams) => {
17
- printError: (response?: ResponseError) => string;
28
+ export declare const useResponseError: <T = ResponseError>(params?: useResponseErrorParams) => {
29
+ printError: (response?: any) => string;
18
30
  };
19
31
  export default useResponseError;
package/dist/main.d.ts CHANGED
@@ -1,3 +1,6 @@
1
- export * from './api/main';
2
- export * from './auth/main';
3
- export * from './context/main';
1
+ export { default as RequireAuth } from './components/RequireAuth';
2
+ export * from './components/RequireAuth';
3
+ export { default as InjectDependenciesProvider } from './context/InjectDependenciesProvider';
4
+ export * from './context/InjectDependenciesProvider';
5
+ export { default as useResponseError } from './hooks/useResponseError';
6
+ export * from './hooks/useResponseError';