@tracktor/shared-module
> This package contains shared components, hooks and utilities for the Tracktor project.
> This package use dependencies only with injection.
> This package is not intended to be used outside the Tracktor project.
- Installation
- Usage
- Inject dependencies with provider
Installation
``console
yarn add @tracktor/shared-module
`
Usage
`typescript jsx
import { InitializeAxiosConfig } from "@tracktor/shared-module";
`
Inject dependencies with provider
`typescript jsx
import { InjectDependenciesProvider, InitializeAxiosConfig } from "@tracktor/shared-module";
const App = () => (
axios,
}}>
...
);
export default App;
``
Providers
| Module | Description | Dependencies |
|-------------------------------|------------------------------------------------|--------------|
| InjectDependenciesProvider | Inject dependencies for other shared component | - |
| QueryClientProviderWithConfig | React Query provider with default config | React Query |
Components
| Module | Type | Description | Dependencies |
|------------------------|-----------------|-----------------------------------------------------|------------------------------------------------------------|
| RequireAuth | React Component | Component for protected routing | Axios & react-router-dom |
| GTMSendPageView | React Component | Send page view event to Google Tag Manager | @tracktor/react-google-tag-manager & react-router-dom |
| InitializeAxiosConfig | React Component | Initialize Axios with custom default config options | Axios |
| InitializeI18nConfig | React Component | Initialize i18n with custom config options | i18next & react-i18next & i18next-browser-languagedetector |
| InitializeSentryConfig | React Component | Initialize Sentry | @sentry/react & react-router-dom |
| InitializeMapBoxConfig | React Component | Initialize MapBox | mapbox-gl |
| InitializeDaysJSConfig | React Component | Initialize DayJS | dayjs |
| PreloadErrorHandler | React Component | his component is used to handle preload error. | dayjs |
Hooks
| Module | Description | Dependencies |
|---------------------|----------------------------------------------------------------------------|--------------|
| useAdapter | Hook with several adapter | - |
| useAuth | Hook for authentification management | Axios |
| useResponseError | This hook is used to print error messages from the API | i18next |
| useInfiniteDataGrid | This hook is used to handle the infinite scroll of the DataGrid component. | - |
| useCurrentLanguage | This get the current language of app | - |
| useFilters | Hook to handle filter | - |
Config
| Module | Description |
|-----------------------|------------------------------------|
| getOrvalOperationName | Get config for orval operationName |
Utils function
| Module | Description |
|---------------------|----------------------|
| dateAdapter | Adapt given date |
| distanceAdapter | Adapt given distance |
| worksiteNameAdapter | Adapt worksite name |