@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 +2 -2
- package/README.md +4 -21
- package/dist/components/RequireAuth/index.d.ts +3 -0
- package/dist/context/InjectDependenciesProvider.d.ts +2 -2
- package/dist/hooks/useResponseError/index.d.ts +3 -0
- package/dist/{api/hooks → hooks/useResponseError}/useResponseError.d.ts +15 -3
- package/dist/main.d.ts +6 -3
- package/dist/main.js +688 -8
- package/dist/main.umd.cjs +27 -0
- package/package.json +8 -19
- package/api/index.d.ts +0 -1
- package/auth/index.d.ts +0 -1
- package/context/index.d.ts +0 -1
- package/dist/InjectDependenciesProvider-3bbc437d.js +0 -661
- package/dist/InjectDependenciesProvider-40e2c821.cjs +0 -27
- package/dist/RequireAuth-c1956d94.js +0 -24
- package/dist/RequireAuth-da69fc85.cjs +0 -1
- package/dist/api/main.d.ts +0 -2
- package/dist/api/types/error.d.ts +0 -14
- package/dist/api.cjs +0 -1
- package/dist/api.js +0 -6
- package/dist/auth/main.d.ts +0 -2
- package/dist/auth.cjs +0 -1
- package/dist/auth.js +0 -6
- package/dist/context/main.d.ts +0 -2
- package/dist/context.cjs +0 -1
- package/dist/context.js +0 -6
- package/dist/main.cjs +0 -1
- package/dist/useResponseError-51d8f1ab.cjs +0 -1
- package/dist/useResponseError-adb9412c.js +0 -15
- /package/dist/{auth/components → components/RequireAuth}/RequireAuth.d.ts +0 -0
package/CHANGELOG.md
CHANGED
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
|
-
>
|
|
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
|
|
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. |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { RequireAuthProps } from '../components/RequireAuth';
|
|
3
|
+
import type { useResponseErrorParams } from '../hooks/useResponseError';
|
|
4
4
|
export interface InjectDependenciesContextProps {
|
|
5
5
|
/**
|
|
6
6
|
* Children
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
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?:
|
|
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
|
|
2
|
-
export * from './
|
|
3
|
-
export
|
|
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';
|