@omniumretail/shared-resources 0.0.1
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/.eslintrc.json +32 -0
- package/README.md +45 -0
- package/dist/bundle.js +5496 -0
- package/dist/types/components/BottomDrawer/index.d.ts +2 -0
- package/dist/types/components/Button/index.d.ts +6 -0
- package/dist/types/components/Footer/index.d.ts +3 -0
- package/dist/types/components/Form/FormInputField/index.d.ts +8 -0
- package/dist/types/components/Form/FormSelectField/index.d.ts +9 -0
- package/dist/types/components/Form/index.d.ts +2 -0
- package/dist/types/components/Header/index.d.ts +4 -0
- package/dist/types/components/Link/index.d.ts +6 -0
- package/dist/types/components/Navigation/index.d.ts +8 -0
- package/dist/types/components/Page/index.d.ts +13 -0
- package/dist/types/components/SharedContextProvider/index.d.ts +7 -0
- package/dist/types/components/index.d.ts +9 -0
- package/dist/types/constants/Icons.d.ts +13 -0
- package/dist/types/constants/QueryClient.d.ts +2 -0
- package/dist/types/constants/index.d.ts +2 -0
- package/dist/types/contexts/useStore.d.ts +8 -0
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/hooks/useApplicationDataQuery.hook.d.ts +2 -0
- package/dist/types/hooks/useStoreQuery.d.ts +7 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/interfaces/ApplicationsByCategory.d.ts +16 -0
- package/dist/types/interfaces/Configuration.d.ts +6 -0
- package/dist/types/interfaces/Customer.d.ts +21 -0
- package/dist/types/interfaces/Product.d.ts +33 -0
- package/dist/types/interfaces/ResponseList.d.ts +5 -0
- package/dist/types/interfaces/Store.d.ts +7 -0
- package/dist/types/interfaces/index.d.ts +6 -0
- package/dist/types/services/ApiService/index.d.ts +5 -0
- package/dist/types/services/InitService/index.d.ts +3 -0
- package/dist/types/services/index.d.ts +2 -0
- package/package.json +54 -0
- package/src/assets/omniu-retail_branco_s-fundo.png +0 -0
- package/src/assets/sitoo.svg +9 -0
- package/src/components/BottomDrawer/index.tsx +8 -0
- package/src/components/BottomDrawer/styles.module.scss +37 -0
- package/src/components/Button/index.tsx +22 -0
- package/src/components/Button/styles.module.scss +67 -0
- package/src/components/Footer/index.tsx +44 -0
- package/src/components/Footer/styles.module.scss +33 -0
- package/src/components/Form/FormInputField/index.tsx +18 -0
- package/src/components/Form/FormSelectField/index.tsx +16 -0
- package/src/components/Form/index.ts +2 -0
- package/src/components/Header/index.tsx +20 -0
- package/src/components/Header/styles.module.scss +16 -0
- package/src/components/Link/index.tsx +21 -0
- package/src/components/Link/styles.module.scss +24 -0
- package/src/components/Navigation/index.tsx +30 -0
- package/src/components/Navigation/styles.module.scss +34 -0
- package/src/components/Page/index.tsx +35 -0
- package/src/components/Page/styles.module.scss +26 -0
- package/src/components/SharedContextProvider/index.tsx +30 -0
- package/src/components/index.ts +9 -0
- package/src/constants/Icons.ts +19 -0
- package/src/constants/QueryClient.ts +3 -0
- package/src/constants/index.ts +2 -0
- package/src/contexts/useStore.tsx +20 -0
- package/src/global.scss +124 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useApplicationDataQuery.hook.ts +10 -0
- package/src/hooks/useStoreQuery.ts +13 -0
- package/src/index.ts +9 -0
- package/src/interfaces/ApplicationsByCategory.ts +19 -0
- package/src/interfaces/Configuration.ts +7 -0
- package/src/interfaces/Customer.ts +23 -0
- package/src/interfaces/Product.ts +36 -0
- package/src/interfaces/ResponseList.ts +6 -0
- package/src/interfaces/Store.ts +8 -0
- package/src/interfaces/index.ts +6 -0
- package/src/services/ApiService/index.ts +80 -0
- package/src/services/InitService/index.ts +7 -0
- package/src/services/index.ts +3 -0
- package/src/types/Global.d.ts +4 -0
- package/tsconfig.json +26 -0
- package/webpack.config.js +48 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import 'whatwg-fetch';
|
|
2
|
+
import { appConfig } from "../InitService";
|
|
3
|
+
|
|
4
|
+
export const get = <T>(path: string, params?: Record<string, unknown>): Promise<T> => {
|
|
5
|
+
return buildApiRequest<T>(`${path}?${buildParams(params || {})}`, 'GET');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const getAuth0 = <T>(path: string, params?: Record<string, unknown>): Promise<T> => {
|
|
9
|
+
return buildApiRequestForAuth0<T>(`${path}?${buildParams(params || {})}`, 'GET');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const post = <T>(path: string, body?: unknown): Promise<T> => {
|
|
13
|
+
return buildApiRequest<T>(path, 'POST', body);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const put = <T>(path: string, body?: unknown): Promise<T> => {
|
|
17
|
+
return buildApiRequest<T>(path, 'PUT', body);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const buildParams = (params: Record<string, unknown>): string => {
|
|
21
|
+
return Object.entries(params).reduce((c, [key, value]) => [...c, `${key}=${value}`], [] as string[]).join('&');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Build the api request
|
|
26
|
+
* @param path
|
|
27
|
+
* @param method
|
|
28
|
+
* @param data
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
const buildApiRequest = <T>(path: string, method = 'GET', data?: unknown): Promise<T> => {
|
|
32
|
+
const requestUri = buildPath(path);
|
|
33
|
+
|
|
34
|
+
return fetch(requestUri, {
|
|
35
|
+
method,
|
|
36
|
+
headers: {
|
|
37
|
+
'Content-Type': 'application/json',
|
|
38
|
+
Authorization: appConfig.token,
|
|
39
|
+
} as HeadersInit,
|
|
40
|
+
body: ['POST', 'PUT'].includes(method) ? JSON.stringify(data) : undefined,
|
|
41
|
+
}).then((response) => {
|
|
42
|
+
if (response.status >= 200 && response.status <= 300) {
|
|
43
|
+
return response.json();
|
|
44
|
+
}
|
|
45
|
+
return response.json().then((data) => Promise.reject(data));
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Build the api request with auth
|
|
51
|
+
* @param path
|
|
52
|
+
* @param method
|
|
53
|
+
* @param data
|
|
54
|
+
* @returns
|
|
55
|
+
*/
|
|
56
|
+
const buildApiRequestForAuth0 = <T>(path: string, method = 'GET', data?: unknown): Promise<T> => {
|
|
57
|
+
const requestUri = buildPath(path);
|
|
58
|
+
|
|
59
|
+
return fetch(requestUri, {
|
|
60
|
+
method,
|
|
61
|
+
headers: {
|
|
62
|
+
Authorization: `Bearer ${appConfig.tokenAuth0}`,
|
|
63
|
+
},
|
|
64
|
+
body: ['POST', 'PUT'].includes(method) ? JSON.stringify(data) : undefined,
|
|
65
|
+
}).then((response) => {
|
|
66
|
+
if (response.status >= 200 && response.status <= 300) {
|
|
67
|
+
return response.json();
|
|
68
|
+
}
|
|
69
|
+
return response;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Builds the path to access the api
|
|
75
|
+
* @param path
|
|
76
|
+
* @returns
|
|
77
|
+
*/
|
|
78
|
+
const buildPath = (path: string): string => {
|
|
79
|
+
return `${appConfig.ApiHost}${appConfig.ApiPath}${path}`;
|
|
80
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es5",
|
|
4
|
+
"outDir": "./dist",
|
|
5
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
6
|
+
"allowJs": true,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"allowSyntheticDefaultImports": true,
|
|
10
|
+
"strict": false,
|
|
11
|
+
"strictNullChecks": false,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"noFallthroughCasesInSwitch": true,
|
|
14
|
+
"module": "esnext",
|
|
15
|
+
"moduleResolution": "node",
|
|
16
|
+
"declaration": true,
|
|
17
|
+
"declarationDir": "./dist/types",
|
|
18
|
+
"resolveJsonModule": true,
|
|
19
|
+
"isolatedModules": true,
|
|
20
|
+
"noEmit": false,
|
|
21
|
+
"sourceMap": true,
|
|
22
|
+
"jsx": "react-jsx",
|
|
23
|
+
"experimentalDecorators": true
|
|
24
|
+
},
|
|
25
|
+
"include": ["src"]
|
|
26
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
mode: 'development',
|
|
5
|
+
entry: './src/index.ts',
|
|
6
|
+
devtool: "eval-cheap-source-map",
|
|
7
|
+
output: {
|
|
8
|
+
path: path.resolve(__dirname, 'dist'),
|
|
9
|
+
filename: 'bundle.js',
|
|
10
|
+
libraryTarget: 'umd',
|
|
11
|
+
library: 'lib',
|
|
12
|
+
},
|
|
13
|
+
resolve: {
|
|
14
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
15
|
+
},
|
|
16
|
+
module: {
|
|
17
|
+
rules: [
|
|
18
|
+
{
|
|
19
|
+
test: /\.s?css$/,
|
|
20
|
+
use: [
|
|
21
|
+
{ loader: 'style-loader' },
|
|
22
|
+
{
|
|
23
|
+
loader: 'css-loader',
|
|
24
|
+
options: {
|
|
25
|
+
modules: true
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{ loader: 'sass-loader' }
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
test: /\.(png|svg|jpg|gif)$/,
|
|
33
|
+
loader: 'url-loader',
|
|
34
|
+
options: {
|
|
35
|
+
limit: Infinity // everything
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{ test: /\.tsx?$/, use: 'ts-loader' },
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
externals: {
|
|
42
|
+
react: "react",
|
|
43
|
+
"react-dom": "react-dom",
|
|
44
|
+
"react-router-dom": "react-router-dom",
|
|
45
|
+
// "@tanstack/react-query": "@tanstack/react-query",
|
|
46
|
+
"@tanstack/query-core": "@tanstack/query-core",
|
|
47
|
+
},
|
|
48
|
+
};
|