aq-fe-framework 0.1.224 → 0.1.226

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.
@@ -3,6 +3,18 @@ import {
3
3
  __spreadValues
4
4
  } from "./chunk-FWCSY2DS.mjs";
5
5
 
6
+ // src/utils/utils_config_getBaseUrl.ts
7
+ async function utils_config_getBaseUrl({
8
+ configUrl = "/config.json"
9
+ } = {}) {
10
+ const res = await fetch(configUrl);
11
+ if (!res.ok) {
12
+ throw new Error("Kh\xF4ng th\u1EC3 t\u1EA3i c\u1EA5u h\xECnh runtime");
13
+ }
14
+ const config = await res.json();
15
+ return config.baseURL;
16
+ }
17
+
6
18
  // src/utils/utils_converter.ts
7
19
  var utils_converter_getLabelByValue = (data, value) => {
8
20
  const numericValue = Number(value);
@@ -248,6 +260,7 @@ export {
248
260
  utils_date_getHHmm,
249
261
  utils_file_fileToAQDocumentType,
250
262
  utils_file_docxtemplaterDownload,
263
+ utils_config_getBaseUrl,
251
264
  utils_converter_getLabelByValue,
252
265
  utils_converter_getKeyByValue,
253
266
  utils_converter_enumToSelectOptions,
@@ -2,25 +2,6 @@ import {
2
2
  __spreadValues
3
3
  } from "./chunk-FWCSY2DS.mjs";
4
4
 
5
- // src/hooks/useLoadAxiosConfig.ts
6
- import { useEffect } from "react";
7
- var useLoadAxiosConfig = (axiosInstance) => {
8
- useEffect(() => {
9
- (async () => {
10
- try {
11
- const res = await fetch("/config.json");
12
- const config = await res.json();
13
- if (config.baseURL) {
14
- axiosInstance.defaults.baseURL = config.baseURL;
15
- console.log("\u2705 baseURL set to", config.baseURL);
16
- }
17
- } catch (err) {
18
- console.error("\u274C L\u1ED7i khi load config.json:", err);
19
- }
20
- })();
21
- }, [axiosInstance]);
22
- };
23
-
24
5
  // src/hooks/custom-hooks/createBaseApi.ts
25
6
  function createBaseApi(baseUrl, axiosInstance) {
26
7
  return {
@@ -45,6 +26,25 @@ function createBaseApi(baseUrl, axiosInstance) {
45
26
  // src/hooks/custom-hooks/useC_MutationAction.tsx
46
27
  import { useQueryClient } from "@tanstack/react-query";
47
28
 
29
+ // src/hooks/custom-hooks/useLoadAxiosConfig.ts
30
+ import { useEffect } from "react";
31
+ var useLoadAxiosConfig = (axiosInstance) => {
32
+ useEffect(() => {
33
+ (async () => {
34
+ try {
35
+ const res = await fetch("/config.json");
36
+ const config = await res.json();
37
+ if (config.baseURL) {
38
+ axiosInstance.defaults.baseURL = config.baseURL;
39
+ console.log("\u2705 baseURL set to", config.baseURL);
40
+ }
41
+ } catch (err) {
42
+ console.error("\u274C L\u1ED7i khi load config.json:", err);
43
+ }
44
+ })();
45
+ }, [axiosInstance]);
46
+ };
47
+
48
48
  // src/hooks/custom-hooks/useMyReactMutation.ts
49
49
  import { useMutation } from "@tanstack/react-query";
50
50
  function useMyReactMutation({
@@ -81,7 +81,7 @@ function useMyReactQuery({
81
81
  // src/api/config/baseAxios.ts
82
82
  import axios from "axios";
83
83
  var baseAxios = axios.create({
84
- baseURL: process.env.NEXT_PUBLIC_API
84
+ baseURL: ""
85
85
  // server
86
86
  // baseURL: process.env.NEXT_PUBLIC_API_LOCAL, // local debug
87
87
  });
@@ -131,8 +131,8 @@ function useQ_SkillCenter_GetAll() {
131
131
  export {
132
132
  baseAxios_default,
133
133
  useQ_AQ_GetAQModule,
134
- useLoadAxiosConfig,
135
134
  createBaseApi,
135
+ useLoadAxiosConfig,
136
136
  useMyReactMutation,
137
137
  useMyReactQuery,
138
138
  useQ_SkillCenter_GetAll
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  baseAxios_default,
3
3
  useQ_AQ_GetAQModule
4
- } from "./chunk-YP4HI3R3.mjs";
4
+ } from "./chunk-D34W6WLY.mjs";
5
5
  import {
6
6
  createGenericStore
7
7
  } from "./chunk-Y3YGC5IH.mjs";
@@ -6898,13 +6898,11 @@ import { useRouter as useRouter3 } from "next/navigation";
6898
6898
 
6899
6899
  // src/modules-features/authenticate/useS_authenticate.ts
6900
6900
  var useStore3 = createGenericStore({
6901
- initialState: { token: "" },
6901
+ initialState: { token: "", saveLogin: false },
6902
6902
  storageKey: "useS_authenticate"
6903
6903
  });
6904
6904
  function useS_authenticate() {
6905
6905
  const store = useStore3();
6906
- function logOut() {
6907
- }
6908
6906
  return __spreadValues({}, store);
6909
6907
  }
6910
6908
 
@@ -65,8 +65,8 @@ import {
65
65
  useS_BasicAppShell,
66
66
  useS_ButtonImport,
67
67
  utils_layout_getItemsWithoutLinks
68
- } from "../chunk-WXBH6C7J.mjs";
69
- import "../chunk-YP4HI3R3.mjs";
68
+ } from "../chunk-EKVQH4CN.mjs";
69
+ import "../chunk-D34W6WLY.mjs";
70
70
  import "../chunk-Y3YGC5IH.mjs";
71
71
  import "../chunk-5U2JSHSJ.mjs";
72
72
  import "../chunk-7ZCOFATU.mjs";
@@ -4,8 +4,6 @@ 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 useLoadAxiosConfig: (axiosInstance: AxiosInstance) => void;
8
-
9
7
  interface MyApiResponse<IRes> {
10
8
  isSuccess: 1 | 0;
11
9
  message: string;
@@ -21,6 +19,8 @@ declare function createBaseApi<T>(baseUrl: string, axiosInstance: AxiosInstance)
21
19
  delete: (id: number) => Promise<axios.AxiosResponse<any, any>>;
22
20
  };
23
21
 
22
+ declare const useLoadAxiosConfig: (axiosInstance: AxiosInstance) => void;
23
+
24
24
  interface MyReactMutationProps<IReq, IRes> {
25
25
  axiosFn: (variables: IReq) => Promise<AxiosResponse<MyApiResponse<IRes>>>;
26
26
  options?: UseMutationOptions<IRes, Error, IReq>;
@@ -4,7 +4,7 @@ import {
4
4
  useMyReactMutation,
5
5
  useMyReactQuery,
6
6
  useQ_AQ_GetAQModule
7
- } from "../chunk-YP4HI3R3.mjs";
7
+ } from "../chunk-D34W6WLY.mjs";
8
8
  import "../chunk-7ZCOFATU.mjs";
9
9
  import "../chunk-FWCSY2DS.mjs";
10
10
  export {
@@ -528,6 +528,9 @@ interface I$1 {
528
528
  userId?: number;
529
529
  fullName?: string;
530
530
  code?: string;
531
+ username?: string;
532
+ password?: string;
533
+ saveLogin?: boolean;
531
534
  }
532
535
  declare function useS_authenticate(): {
533
536
  state: I$1;
@@ -536,17 +539,12 @@ declare function useS_authenticate(): {
536
539
  resetState: () => void;
537
540
  };
538
541
 
539
- interface ILoginInfo {
540
- username?: string;
541
- password?: string;
542
- }
543
542
  interface I {
544
- loginInfo?: ILoginInfo;
545
543
  redirectUrlAfterLogin?: string;
546
544
  additionalActions?: ReactNode;
547
545
  backgroundImage?: string;
548
546
  onSuccess?: (data?: any) => void;
549
547
  }
550
- declare function F_authenticate_Login({ loginInfo, redirectUrlAfterLogin, additionalActions, backgroundImage, onSuccess }: I): react_jsx_runtime.JSX.Element;
548
+ declare function F_authenticate_Login({ redirectUrlAfterLogin, additionalActions, backgroundImage, onSuccess }: I): react_jsx_runtime.JSX.Element;
551
549
 
552
550
  export { F_authenticate_Login, F_authenticate_Logout, F_authenticate_SplashPage, F_core12196, F_core12196_Create, F_core12196_Delete, F_core12196_Read, F_core12196_Update, F_core16209, F_core16209_Create, F_core16209_Delete, F_core16209_Update, F_core18256, F_core18256_Create, F_core18256_Delete, F_core18256_Read, F_core18256_Select, F_core18256_Update, F_core26965, F_core26965_Create, F_core26965_Delete, F_core26965_Update, F_core27311, F_core27311_Create, F_core27311_Delete, F_core27311_Read, F_core27311_Update, F_core35923, F_core38677, F_core38677_ReadUser, F_core38677_Save, F_core38677_ViewMenuPermissions, F_core40207, F_core40207_Create, F_core40207_Delete, F_core40207_Read, F_core40207_Update, F_core47643, F_core47643_Delete, F_core47643_Form, F_core47643_Read, F_core60524, F_core64229, F_core64229_Delete, F_core64229_Form, F_core64229_Read, F_core71678, F_core71678_ChangePermission, F_core71678_Create, F_core71678_Delete, F_core71678_Read, F_core71678_Update, F_core76318, F_core76318_Create, F_core76318_Delete, F_core76318_Update, F_core83092, F_core83092_ReadUser, F_core83092_Save, F_core83092_ViewMenuPermissions, type I_core38677_User, type I_core60524_AQModule, type I_core71678_Read, type I_core83092_RolePermission, useS_authenticate, useS_core60524, useS_core83092, utils_core83092_mergePage };
@@ -25,12 +25,12 @@ import {
25
25
  useS_BasicAppShell,
26
26
  useS_authenticate,
27
27
  utils_layout_getItemsWithoutLinks
28
- } from "../chunk-WXBH6C7J.mjs";
28
+ } from "../chunk-EKVQH4CN.mjs";
29
29
  import {
30
30
  baseAxios_default,
31
31
  useQ_AQ_GetAQModule,
32
32
  useQ_SkillCenter_GetAll
33
- } from "../chunk-YP4HI3R3.mjs";
33
+ } from "../chunk-D34W6WLY.mjs";
34
34
  import {
35
35
  createGenericStore
36
36
  } from "../chunk-Y3YGC5IH.mjs";
@@ -38,9 +38,10 @@ import {
38
38
  U0DateToDDMMYYYString,
39
39
  U0MyValidateEmail,
40
40
  updateEnableList,
41
+ utils_config_getBaseUrl,
41
42
  utils_converter_enumToSelectOptions,
42
43
  utils_file_fileToAQDocumentType
43
- } from "../chunk-3MGSFSSG.mjs";
44
+ } from "../chunk-AQ2ORDKJ.mjs";
44
45
  import "../chunk-5U2JSHSJ.mjs";
45
46
  import {
46
47
  utils_notification_show
@@ -3490,7 +3491,7 @@ import { useMutation as useMutation5 } from "@tanstack/react-query";
3490
3491
  import axios from "axios";
3491
3492
  import Link from "next/link";
3492
3493
  import { useRouter as useRouter3 } from "next/navigation";
3493
- import { useState as useState9 } from "react";
3494
+ import { useEffect as useEffect12, useState as useState9 } from "react";
3494
3495
 
3495
3496
  // src/modules-features/authenticate/F_Authenticate_Login/css.module.css
3496
3497
  var css_default = {};
@@ -3498,7 +3499,6 @@ var css_default = {};
3498
3499
  // src/modules-features/authenticate/F_Authenticate_Login/F_authenticate_Login.tsx
3499
3500
  import { jsx as jsx63, jsxs as jsxs40 } from "react/jsx-runtime";
3500
3501
  function F_authenticate_Login({
3501
- loginInfo,
3502
3502
  redirectUrlAfterLogin = "/admin/dashboard",
3503
3503
  additionalActions,
3504
3504
  backgroundImage = "/imgs/0/IMG0AuthBackground.png",
@@ -3509,16 +3509,22 @@ function F_authenticate_Login({
3509
3509
  const loadingState = useState9(false);
3510
3510
  const mutation = useM_Account_Sigin();
3511
3511
  const form = useForm20({
3512
- mode: "uncontrolled",
3513
3512
  initialValues: {
3514
- username: (loginInfo == null ? void 0 : loginInfo.username) || "admincoe",
3515
- password: (loginInfo == null ? void 0 : loginInfo.password) || "123456"
3513
+ username: "",
3514
+ password: ""
3516
3515
  },
3517
3516
  validate: {
3518
3517
  username: (value) => value ? null : "Kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng",
3519
3518
  password: (value) => value ? null : "Kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng"
3520
3519
  }
3521
3520
  });
3521
+ useEffect12(() => {
3522
+ var _a;
3523
+ form.setValues({
3524
+ username: ((_a = authenticate_store.state) == null ? void 0 : _a.username) || "",
3525
+ password: ""
3526
+ });
3527
+ }, [authenticate_store.state.username]);
3522
3528
  function handleSubmit(userName, passWord) {
3523
3529
  loadingState[1](true);
3524
3530
  mutation.mutate({
@@ -3540,6 +3546,11 @@ function F_authenticate_Login({
3540
3546
  authenticate_store.setProperty("fullName", data.data.userFullName);
3541
3547
  authenticate_store.setProperty("userId", data.data.userId);
3542
3548
  authenticate_store.setProperty("token", data.data.token);
3549
+ if (authenticate_store.state.saveLogin == true) {
3550
+ authenticate_store.setProperty("username", userName);
3551
+ } else {
3552
+ authenticate_store.setProperty("username", "");
3553
+ }
3543
3554
  if (onSuccess) {
3544
3555
  onSuccess(data);
3545
3556
  loadingState[1](false);
@@ -3580,7 +3591,14 @@ function F_authenticate_Login({
3580
3591
  })
3581
3592
  ),
3582
3593
  /* @__PURE__ */ jsxs40(Group4, { justify: "space-between", children: [
3583
- /* @__PURE__ */ jsx63(Checkbox3, { label: "L\u01B0u \u0111\u0103ng nh\u1EADp" }),
3594
+ /* @__PURE__ */ jsx63(
3595
+ Checkbox3,
3596
+ {
3597
+ checked: authenticate_store.state.saveLogin,
3598
+ onChange: (e) => authenticate_store.setProperty("saveLogin", e.currentTarget.checked),
3599
+ label: "L\u01B0u \u0111\u0103ng nh\u1EADp"
3600
+ }
3601
+ ),
3584
3602
  /* @__PURE__ */ jsx63(Anchor, { component: Link, href: "quen-mat-khau", size: "sm", children: "Qu\xEAn m\u1EADt kh\u1EA9u?" })
3585
3603
  ] }),
3586
3604
  /* @__PURE__ */ jsx63(
@@ -3599,10 +3617,10 @@ function F_authenticate_Login({
3599
3617
  );
3600
3618
  }
3601
3619
  function useM_Account_Sigin() {
3602
- const ENDPOINT5 = process.env.NEXT_PUBLIC_API + "/Account/SignIn";
3603
3620
  const mutation = useMutation5({
3604
3621
  mutationFn: async (values) => {
3605
- const result = await axios.post(ENDPOINT5, values);
3622
+ const endpoint = await utils_config_getBaseUrl() + "/Account/SignIn";
3623
+ const result = await axios.post(endpoint, values);
3606
3624
  return result.data;
3607
3625
  }
3608
3626
  });
@@ -16,7 +16,7 @@ import {
16
16
  utils_file_fileToAQDocumentType,
17
17
  utils_time_convertTimeStringToSeconds,
18
18
  utils_time_getCurrentTimeString
19
- } from "../chunk-3MGSFSSG.mjs";
19
+ } from "../chunk-AQ2ORDKJ.mjs";
20
20
  import {
21
21
  utils_pdf_download
22
22
  } from "../chunk-5U2JSHSJ.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.224",
25
+ "version": "0.1.226",
26
26
  "private": false,
27
27
  "files": [
28
28
  "dist"