tsv2-library 0.2.68 → 0.2.69

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsv2-library",
3
- "version": "0.2.68",
3
+ "version": "0.2.69",
4
4
  "author": "fixedassetv2-fe",
5
5
  "license": "ISC",
6
6
  "homepage": "https://github.com/fixedassetv2-fe/tsv2-library#readme",
@@ -0,0 +1,36 @@
1
+ import axios, { AxiosInstance, AxiosResponse } from 'axios';
2
+
3
+ const getBaseURL = (env: string): string | undefined => {
4
+ if (window.Cypress) {
5
+ return Cypress.env('CY_' + env); // When running Cypress Intercept
6
+ } else if (import.meta.env) {
7
+ return import.meta.env['VITE_' + env]; // When running in development mode with Vite
8
+ }
9
+
10
+ return process.env['VUE_' + env]; // When building for production with Vue CLI
11
+ };
12
+
13
+ const API = ({ headers = {}, params = {} } = {}): AxiosInstance => {
14
+ const user = JSON.parse(localStorage.getItem('user') as string) ?? {};
15
+ const BASE_URL = getBaseURL('APP_DAMAGE_API');
16
+
17
+ const instance = axios.create({
18
+ baseURL: `${BASE_URL}/v2`,
19
+ headers: {
20
+ 'Content-type': 'application/json',
21
+ 'Authorization': `Bearer ${user.token}`,
22
+ ...headers,
23
+ },
24
+ params,
25
+ });
26
+
27
+ return instance;
28
+ };
29
+
30
+ const AssetDamageServices = {
31
+ getDetail: (id: string): Promise<AxiosResponse> => {
32
+ return API().get(`/${id}`);
33
+ },
34
+ };
35
+
36
+ export default AssetDamageServices;
@@ -0,0 +1,36 @@
1
+ import axios, { AxiosInstance, AxiosResponse } from 'axios';
2
+
3
+ const getBaseURL = (env: string): string | undefined => {
4
+ if (window.Cypress) {
5
+ return Cypress.env('CY_' + env); // When running Cypress Intercept
6
+ } else if (import.meta.env) {
7
+ return import.meta.env['VITE_' + env]; // When running in development mode with Vite
8
+ }
9
+
10
+ return process.env['VUE_' + env]; // When building for production with Vue CLI
11
+ };
12
+
13
+ const API = ({ headers = {}, params = {} } = {}): AxiosInstance => {
14
+ const user = JSON.parse(localStorage.getItem('user') as string) ?? {};
15
+ const BASE_URL = getBaseURL('APP_MISSING_API');
16
+
17
+ const instance = axios.create({
18
+ baseURL: `${BASE_URL}/v2`,
19
+ headers: {
20
+ 'Content-type': 'application/json',
21
+ 'Authorization': `Bearer ${user.token}`,
22
+ ...headers,
23
+ },
24
+ params,
25
+ });
26
+
27
+ return instance;
28
+ };
29
+
30
+ const AssetMissingServices = {
31
+ getDetail: (id: string): Promise<AxiosResponse> => {
32
+ return API().get(`/${id}`);
33
+ },
34
+ };
35
+
36
+ export default AssetMissingServices;