@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.
Files changed (77) hide show
  1. package/.eslintrc.json +32 -0
  2. package/README.md +45 -0
  3. package/dist/bundle.js +5496 -0
  4. package/dist/types/components/BottomDrawer/index.d.ts +2 -0
  5. package/dist/types/components/Button/index.d.ts +6 -0
  6. package/dist/types/components/Footer/index.d.ts +3 -0
  7. package/dist/types/components/Form/FormInputField/index.d.ts +8 -0
  8. package/dist/types/components/Form/FormSelectField/index.d.ts +9 -0
  9. package/dist/types/components/Form/index.d.ts +2 -0
  10. package/dist/types/components/Header/index.d.ts +4 -0
  11. package/dist/types/components/Link/index.d.ts +6 -0
  12. package/dist/types/components/Navigation/index.d.ts +8 -0
  13. package/dist/types/components/Page/index.d.ts +13 -0
  14. package/dist/types/components/SharedContextProvider/index.d.ts +7 -0
  15. package/dist/types/components/index.d.ts +9 -0
  16. package/dist/types/constants/Icons.d.ts +13 -0
  17. package/dist/types/constants/QueryClient.d.ts +2 -0
  18. package/dist/types/constants/index.d.ts +2 -0
  19. package/dist/types/contexts/useStore.d.ts +8 -0
  20. package/dist/types/hooks/index.d.ts +2 -0
  21. package/dist/types/hooks/useApplicationDataQuery.hook.d.ts +2 -0
  22. package/dist/types/hooks/useStoreQuery.d.ts +7 -0
  23. package/dist/types/index.d.ts +7 -0
  24. package/dist/types/interfaces/ApplicationsByCategory.d.ts +16 -0
  25. package/dist/types/interfaces/Configuration.d.ts +6 -0
  26. package/dist/types/interfaces/Customer.d.ts +21 -0
  27. package/dist/types/interfaces/Product.d.ts +33 -0
  28. package/dist/types/interfaces/ResponseList.d.ts +5 -0
  29. package/dist/types/interfaces/Store.d.ts +7 -0
  30. package/dist/types/interfaces/index.d.ts +6 -0
  31. package/dist/types/services/ApiService/index.d.ts +5 -0
  32. package/dist/types/services/InitService/index.d.ts +3 -0
  33. package/dist/types/services/index.d.ts +2 -0
  34. package/package.json +54 -0
  35. package/src/assets/omniu-retail_branco_s-fundo.png +0 -0
  36. package/src/assets/sitoo.svg +9 -0
  37. package/src/components/BottomDrawer/index.tsx +8 -0
  38. package/src/components/BottomDrawer/styles.module.scss +37 -0
  39. package/src/components/Button/index.tsx +22 -0
  40. package/src/components/Button/styles.module.scss +67 -0
  41. package/src/components/Footer/index.tsx +44 -0
  42. package/src/components/Footer/styles.module.scss +33 -0
  43. package/src/components/Form/FormInputField/index.tsx +18 -0
  44. package/src/components/Form/FormSelectField/index.tsx +16 -0
  45. package/src/components/Form/index.ts +2 -0
  46. package/src/components/Header/index.tsx +20 -0
  47. package/src/components/Header/styles.module.scss +16 -0
  48. package/src/components/Link/index.tsx +21 -0
  49. package/src/components/Link/styles.module.scss +24 -0
  50. package/src/components/Navigation/index.tsx +30 -0
  51. package/src/components/Navigation/styles.module.scss +34 -0
  52. package/src/components/Page/index.tsx +35 -0
  53. package/src/components/Page/styles.module.scss +26 -0
  54. package/src/components/SharedContextProvider/index.tsx +30 -0
  55. package/src/components/index.ts +9 -0
  56. package/src/constants/Icons.ts +19 -0
  57. package/src/constants/QueryClient.ts +3 -0
  58. package/src/constants/index.ts +2 -0
  59. package/src/contexts/useStore.tsx +20 -0
  60. package/src/global.scss +124 -0
  61. package/src/hooks/index.ts +2 -0
  62. package/src/hooks/useApplicationDataQuery.hook.ts +10 -0
  63. package/src/hooks/useStoreQuery.ts +13 -0
  64. package/src/index.ts +9 -0
  65. package/src/interfaces/ApplicationsByCategory.ts +19 -0
  66. package/src/interfaces/Configuration.ts +7 -0
  67. package/src/interfaces/Customer.ts +23 -0
  68. package/src/interfaces/Product.ts +36 -0
  69. package/src/interfaces/ResponseList.ts +6 -0
  70. package/src/interfaces/Store.ts +8 -0
  71. package/src/interfaces/index.ts +6 -0
  72. package/src/services/ApiService/index.ts +80 -0
  73. package/src/services/InitService/index.ts +7 -0
  74. package/src/services/index.ts +3 -0
  75. package/src/types/Global.d.ts +4 -0
  76. package/tsconfig.json +26 -0
  77. 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
+ };
@@ -0,0 +1,7 @@
1
+ import { Configuration } from "../../interfaces/Configuration";
2
+
3
+ export const appConfig: Partial<Configuration> = {};
4
+
5
+ export const initService = (configuration: Configuration) => {
6
+ Object.assign(appConfig, configuration);
7
+ }
@@ -0,0 +1,3 @@
1
+
2
+ export * from './InitService';
3
+ export * from './ApiService';
@@ -0,0 +1,4 @@
1
+ declare module "*.module.css";
2
+ declare module "*.module.scss";
3
+ declare module "*.png";
4
+ declare module "*.svg";
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
+ };