aq-fe-framework 0.1.203 → 0.1.205

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.
@@ -1,18 +1,28 @@
1
+ import {
2
+ __spreadValues
3
+ } from "./chunk-FWCSY2DS.mjs";
4
+
1
5
  // src/api/baseAxios.ts
2
6
  import axios from "axios";
3
- var baseAxios = axios.create();
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
+ });
4
12
  baseAxios.interceptors.request.use(
5
13
  (config) => {
6
14
  var _a, _b;
7
15
  const tokenData = localStorage.getItem("useS_authenticate");
8
- const state = tokenData ? JSON.parse(tokenData) : null;
16
+ const state = JSON.parse(tokenData);
9
17
  const token = (_b = (_a = state == null ? void 0 : state.state) == null ? void 0 : _a.state) == null ? void 0 : _b.token;
10
18
  if (token) {
11
19
  config.headers.Authorization = `Bearer ${token}`;
12
20
  }
13
21
  return config;
14
22
  },
15
- (error) => Promise.reject(error)
23
+ (error) => {
24
+ return Promise.reject(error);
25
+ }
16
26
  );
17
27
  var baseAxios_default = baseAxios;
18
28
 
@@ -35,13 +45,55 @@ var useLoadConfig = () => {
35
45
  }, []);
36
46
  };
37
47
 
48
+ // src/hooks/custom-hooks/createBaseApi.ts
49
+ function createBaseApi(baseUrl, axiosInstance) {
50
+ return {
51
+ getAll: () => {
52
+ return axiosInstance.get(`${baseUrl}/GetAll`);
53
+ },
54
+ getById: (id) => {
55
+ return axiosInstance.get(`${baseUrl}/${id}`);
56
+ },
57
+ create: (data) => {
58
+ return axiosInstance.post(`${baseUrl}/create`, data);
59
+ },
60
+ update: (data) => {
61
+ return axiosInstance.put(`${baseUrl}/update`, data);
62
+ },
63
+ createOrUpdate: (data) => {
64
+ return axiosInstance.put(`${baseUrl}/createOrUpdate`, data);
65
+ },
66
+ delete: (id) => {
67
+ return axiosInstance.post(`${baseUrl}/delete`, { id });
68
+ }
69
+ };
70
+ }
71
+
38
72
  // src/hooks/custom-hooks/useC_MutationAction.tsx
39
73
  import { useQueryClient } from "@tanstack/react-query";
40
74
 
41
- // src/hooks/query/AQ/useQ_AQ_GetAQModule.ts
75
+ // src/hooks/custom-hooks/useMyReactMutation.ts
76
+ import { useMutation } from "@tanstack/react-query";
77
+ function useMyReactMutation({
78
+ axiosFn,
79
+ options
80
+ }) {
81
+ return useMutation(__spreadValues({
82
+ mutationFn: async (variables) => {
83
+ const res = await axiosFn(variables);
84
+ if (res.data.isSuccess == 0) throw new Error(res.data.message);
85
+ return res.data.data;
86
+ }
87
+ }, options));
88
+ }
89
+
90
+ // src/hooks/custom-hooks/useMyReactQuery.ts
42
91
  import { useQuery } from "@tanstack/react-query";
92
+
93
+ // src/hooks/query/AQ/useQ_AQ_GetAQModule.ts
94
+ import { useQuery as useQuery2 } from "@tanstack/react-query";
43
95
  function useQ_AQ_GetAQModule() {
44
- const query = useQuery({
96
+ const query = useQuery2({
45
97
  queryKey: ["/AQ/GetAQModule"],
46
98
  queryFn: async () => {
47
99
  const res = await baseAxios_default.get("/AQ/GetAQModule");
@@ -52,9 +104,9 @@ function useQ_AQ_GetAQModule() {
52
104
  }
53
105
 
54
106
  // src/hooks/query/SkillCenter/useQ_SkillCenter_GetAll.ts
55
- import { useQuery as useQuery2 } from "@tanstack/react-query";
107
+ import { useQuery as useQuery3 } from "@tanstack/react-query";
56
108
  function useQ_SkillCenter_GetAll() {
57
- const query = useQuery2({
109
+ const query = useQuery3({
58
110
  queryKey: [],
59
111
  queryFn: async () => {
60
112
  const res = await baseAxios_default.get("/SkillCenter/GetAll");
@@ -68,5 +120,7 @@ export {
68
120
  baseAxios_default,
69
121
  useQ_AQ_GetAQModule,
70
122
  useLoadConfig,
123
+ createBaseApi,
124
+ useMyReactMutation,
71
125
  useQ_SkillCenter_GetAll
72
126
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  baseAxios_default,
3
3
  useQ_AQ_GetAQModule
4
- } from "./chunk-XBRWDG25.mjs";
4
+ } from "./chunk-CUMGXY5T.mjs";
5
5
  import {
6
6
  createGenericStore
7
7
  } from "./chunk-Y3YGC5IH.mjs";
@@ -66,8 +66,8 @@ import {
66
66
  useS_BasicAppShell,
67
67
  useS_ButtonImport,
68
68
  utils_layout_getItemsWithoutLinks
69
- } from "../chunk-RZDOLASD.mjs";
70
- import "../chunk-XBRWDG25.mjs";
69
+ } from "../chunk-DTTVAJG7.mjs";
70
+ import "../chunk-CUMGXY5T.mjs";
71
71
  import "../chunk-Y3YGC5IH.mjs";
72
72
  import "../chunk-5U2JSHSJ.mjs";
73
73
  import "../chunk-7ZCOFATU.mjs";
@@ -1,8 +1,31 @@
1
+ import * as axios from 'axios';
2
+ import { AxiosInstance, AxiosResponse } from 'axios';
1
3
  import * as _tanstack_react_query from '@tanstack/react-query';
4
+ import { UseMutationOptions } from '@tanstack/react-query';
2
5
  import { I as IAQModule } from '../IAQModule-XZYlbivW.mjs';
3
6
 
4
7
  declare const useLoadConfig: () => void;
5
8
 
9
+ interface MyApiResponse<IRes> {
10
+ isSuccess: 1 | 0;
11
+ message: string;
12
+ data: IRes;
13
+ }
14
+ declare function createBaseApi<T>(baseUrl: string, axiosInstance: AxiosInstance): {
15
+ getAll: () => Promise<axios.AxiosResponse<MyApiResponse<T[]>, any>>;
16
+ getById: (id: number | string) => Promise<axios.AxiosResponse<MyApiResponse<T>, any>>;
17
+ create: (data: Partial<T>) => Promise<axios.AxiosResponse<MyApiResponse<T>, any>>;
18
+ update: (data: Partial<T>) => Promise<axios.AxiosResponse<MyApiResponse<T>, any>>;
19
+ createOrUpdate: (data: Partial<T>) => Promise<axios.AxiosResponse<MyApiResponse<T>, any>>;
20
+ delete: (id: number) => Promise<axios.AxiosResponse<any, any>>;
21
+ };
22
+
23
+ interface MyReactMutationProps<IReq, IRes> {
24
+ axiosFn: (variables: IReq) => Promise<AxiosResponse<MyApiResponse<IRes>>>;
25
+ options?: UseMutationOptions<IRes, Error, IReq>;
26
+ }
27
+ declare function useMyReactMutation<IReq, IRes>({ axiosFn, options, }: MyReactMutationProps<IReq, IRes>): _tanstack_react_query.UseMutationResult<IRes, Error, IReq, unknown>;
28
+
6
29
  declare function useQ_AQ_GetAQModule(): _tanstack_react_query.UseQueryResult<IAQModule, Error>;
7
30
 
8
- export { useLoadConfig, useQ_AQ_GetAQModule };
31
+ export { type MyApiResponse, createBaseApi, useLoadConfig, useMyReactMutation, useQ_AQ_GetAQModule };
@@ -1,10 +1,14 @@
1
1
  import {
2
+ createBaseApi,
2
3
  useLoadConfig,
4
+ useMyReactMutation,
3
5
  useQ_AQ_GetAQModule
4
- } from "../chunk-XBRWDG25.mjs";
6
+ } from "../chunk-CUMGXY5T.mjs";
5
7
  import "../chunk-7ZCOFATU.mjs";
6
8
  import "../chunk-FWCSY2DS.mjs";
7
9
  export {
10
+ createBaseApi,
8
11
  useLoadConfig,
12
+ useMyReactMutation,
9
13
  useQ_AQ_GetAQModule
10
14
  };
@@ -25,12 +25,12 @@ import {
25
25
  useS_BasicAppShell,
26
26
  useS_authenticate,
27
27
  utils_layout_getItemsWithoutLinks
28
- } from "../chunk-RZDOLASD.mjs";
28
+ } from "../chunk-DTTVAJG7.mjs";
29
29
  import {
30
30
  baseAxios_default,
31
31
  useQ_AQ_GetAQModule,
32
32
  useQ_SkillCenter_GetAll
33
- } from "../chunk-XBRWDG25.mjs";
33
+ } from "../chunk-CUMGXY5T.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.203",
25
+ "version": "0.1.205",
26
26
  "private": false,
27
27
  "files": [
28
28
  "dist"