aq-fe-framework 0.1.219 → 0.1.221

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.
@@ -2,47 +2,23 @@ import {
2
2
  __spreadValues
3
3
  } from "./chunk-FWCSY2DS.mjs";
4
4
 
5
- // src/api/config/baseAxios.ts
6
- import axios from "axios";
7
- var baseAxios = axios.create({
8
- baseURL: process.env.NEXT_PUBLIC_API
9
- // server
10
- // baseURL: process.env.NEXT_PUBLIC_API_LOCAL, // local debug
11
- });
12
- baseAxios.interceptors.request.use(
13
- (config) => {
14
- var _a, _b;
15
- const tokenData = localStorage.getItem("useS_authenticate");
16
- const state = JSON.parse(tokenData);
17
- const token = (_b = (_a = state == null ? void 0 : state.state) == null ? void 0 : _a.state) == null ? void 0 : _b.token;
18
- if (token) {
19
- config.headers.Authorization = `Bearer ${token}`;
20
- }
21
- return config;
22
- },
23
- (error) => {
24
- return Promise.reject(error);
25
- }
26
- );
27
- var baseAxios_default = baseAxios;
28
-
29
5
  // src/hooks/useLoadConfig.ts
30
6
  import { useEffect } from "react";
31
- var useLoadConfig = () => {
7
+ var useLoadAxiosConfig = (axiosInstance) => {
32
8
  useEffect(() => {
33
9
  (async () => {
34
10
  try {
35
11
  const res = await fetch("/config.json");
36
12
  const config = await res.json();
37
13
  if (config.baseURL) {
38
- baseAxios_default.defaults.baseURL = config.baseURL;
14
+ axiosInstance.defaults.baseURL = config.baseURL;
39
15
  console.log("\u2705 baseURL set to", config.baseURL);
40
16
  }
41
17
  } catch (err) {
42
18
  console.error("\u274C L\u1ED7i khi load config.json:", err);
43
19
  }
44
20
  })();
45
- }, []);
21
+ }, [axiosInstance]);
46
22
  };
47
23
 
48
24
  // src/hooks/custom-hooks/createBaseApi.ts
@@ -102,6 +78,30 @@ function useMyReactQuery({
102
78
  }, options));
103
79
  }
104
80
 
81
+ // src/api/config/baseAxios.ts
82
+ import axios from "axios";
83
+ var baseAxios = axios.create({
84
+ baseURL: process.env.NEXT_PUBLIC_API
85
+ // server
86
+ // baseURL: process.env.NEXT_PUBLIC_API_LOCAL, // local debug
87
+ });
88
+ baseAxios.interceptors.request.use(
89
+ (config) => {
90
+ var _a, _b;
91
+ const tokenData = localStorage.getItem("useS_authenticate");
92
+ const state = JSON.parse(tokenData);
93
+ const token = (_b = (_a = state == null ? void 0 : state.state) == null ? void 0 : _a.state) == null ? void 0 : _b.token;
94
+ if (token) {
95
+ config.headers.Authorization = `Bearer ${token}`;
96
+ }
97
+ return config;
98
+ },
99
+ (error) => {
100
+ return Promise.reject(error);
101
+ }
102
+ );
103
+ var baseAxios_default = baseAxios;
104
+
105
105
  // src/hooks/query/AQ/useQ_AQ_GetAQModule.ts
106
106
  import { useQuery as useQuery2 } from "@tanstack/react-query";
107
107
  function useQ_AQ_GetAQModule() {
@@ -131,7 +131,7 @@ function useQ_SkillCenter_GetAll() {
131
131
  export {
132
132
  baseAxios_default,
133
133
  useQ_AQ_GetAQModule,
134
- useLoadConfig,
134
+ useLoadAxiosConfig,
135
135
  createBaseApi,
136
136
  useMyReactMutation,
137
137
  useMyReactQuery,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  baseAxios_default,
3
3
  useQ_AQ_GetAQModule
4
- } from "./chunk-UKHSZRVN.mjs";
4
+ } from "./chunk-NUVAE2KU.mjs";
5
5
  import {
6
6
  createGenericStore
7
7
  } from "./chunk-Y3YGC5IH.mjs";
@@ -65,8 +65,8 @@ import {
65
65
  useS_BasicAppShell,
66
66
  useS_ButtonImport,
67
67
  utils_layout_getItemsWithoutLinks
68
- } from "../chunk-VPSC5QBR.mjs";
69
- import "../chunk-UKHSZRVN.mjs";
68
+ } from "../chunk-TLIVIMUO.mjs";
69
+ import "../chunk-NUVAE2KU.mjs";
70
70
  import "../chunk-Y3YGC5IH.mjs";
71
71
  import "../chunk-5U2JSHSJ.mjs";
72
72
  import "../chunk-7ZCOFATU.mjs";
@@ -4,7 +4,7 @@ import * as _tanstack_react_query from '@tanstack/react-query';
4
4
  import { UseMutationOptions, QueryKey, UseQueryOptions } from '@tanstack/react-query';
5
5
  import { I as IAQModule } from '../IAQModule-XZYlbivW.mjs';
6
6
 
7
- declare const useLoadConfig: () => void;
7
+ declare const useLoadAxiosConfig: (axiosInstance: AxiosInstance) => void;
8
8
 
9
9
  interface MyApiResponse<IRes> {
10
10
  isSuccess: 1 | 0;
@@ -36,4 +36,4 @@ declare function useMyReactQuery<IRes, IBody>({ queryKey, axiosFn, options }: My
36
36
 
37
37
  declare function useQ_AQ_GetAQModule(): _tanstack_react_query.UseQueryResult<IAQModule, Error>;
38
38
 
39
- export { type MyApiResponse, createBaseApi, useLoadConfig, useMyReactMutation, useMyReactQuery, useQ_AQ_GetAQModule };
39
+ export { type MyApiResponse, createBaseApi, useLoadAxiosConfig, useMyReactMutation, useMyReactQuery, useQ_AQ_GetAQModule };
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  createBaseApi,
3
- useLoadConfig,
3
+ useLoadAxiosConfig,
4
4
  useMyReactMutation,
5
5
  useMyReactQuery,
6
6
  useQ_AQ_GetAQModule
7
- } from "../chunk-UKHSZRVN.mjs";
7
+ } from "../chunk-NUVAE2KU.mjs";
8
8
  import "../chunk-7ZCOFATU.mjs";
9
9
  import "../chunk-FWCSY2DS.mjs";
10
10
  export {
11
11
  createBaseApi,
12
- useLoadConfig,
12
+ useLoadAxiosConfig,
13
13
  useMyReactMutation,
14
14
  useMyReactQuery,
15
15
  useQ_AQ_GetAQModule
@@ -25,12 +25,12 @@ import {
25
25
  useS_BasicAppShell,
26
26
  useS_authenticate,
27
27
  utils_layout_getItemsWithoutLinks
28
- } from "../chunk-VPSC5QBR.mjs";
28
+ } from "../chunk-TLIVIMUO.mjs";
29
29
  import {
30
30
  baseAxios_default,
31
31
  useQ_AQ_GetAQModule,
32
32
  useQ_SkillCenter_GetAll
33
- } from "../chunk-UKHSZRVN.mjs";
33
+ } from "../chunk-NUVAE2KU.mjs";
34
34
  import {
35
35
  createGenericStore
36
36
  } from "../chunk-Y3YGC5IH.mjs";
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "types": "./dist/hooks/index.d.mts"
23
23
  }
24
24
  },
25
- "version": "0.1.219",
25
+ "version": "0.1.221",
26
26
  "private": false,
27
27
  "files": [
28
28
  "dist"