aq-fe-framework 0.1.199 → 0.1.201

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,3 +1,8 @@
1
+ import {
2
+ __spreadProps,
3
+ __spreadValues
4
+ } from "./chunk-FWCSY2DS.mjs";
5
+
1
6
  // src/utils/utils_converter.ts
2
7
  var utils_converter_getLabelByValue = (data, value) => {
3
8
  const numericValue = Number(value);
@@ -191,6 +196,26 @@ async function utils_file_docxtemplaterDownload({
191
196
  saveAs2(buffer, fileName || "output.docx");
192
197
  }
193
198
 
199
+ // src/utils/utils_input_updateEnableList.ts
200
+ function updateEnableList(oldList, selectedIds, getId, createNew) {
201
+ const result = [];
202
+ selectedIds.forEach((id) => {
203
+ const existing = oldList.find((item) => getId(item) === id);
204
+ if (existing) {
205
+ result.push(__spreadProps(__spreadValues({}, existing), { isEnabled: true }));
206
+ } else {
207
+ result.push(createNew(id));
208
+ }
209
+ });
210
+ oldList.forEach((item) => {
211
+ const id = getId(item);
212
+ if (id !== void 0 && !selectedIds.includes(id) && item.isEnabled !== 0) {
213
+ result.push(__spreadProps(__spreadValues({}, item), { isEnabled: 0 }));
214
+ }
215
+ });
216
+ return result;
217
+ }
218
+
194
219
  // src/utils/utils_time.ts
195
220
  var utils_time_convertTimeStringToSeconds = (time) => {
196
221
  const [hours, minutes, seconds] = time.split(":").map(Number);
@@ -229,6 +254,7 @@ export {
229
254
  utils_currency_formatWithSuffix,
230
255
  utils_excel_exportExcel,
231
256
  utils_excel_download,
257
+ updateEnableList,
232
258
  utils_time_convertTimeStringToSeconds,
233
259
  utils_time_getCurrentTimeString,
234
260
  U0MyValidateEmpty,
@@ -7068,6 +7068,11 @@ function BasicAppShell({ children, menu, extraTopRight, title }) {
7068
7068
  };
7069
7069
  }
7070
7070
  }, [GetAQModule_query.data]);
7071
+ useEffect9(() => {
7072
+ const data = GetAQModule_query.data;
7073
+ if (!data) return;
7074
+ document.title = data.name || "";
7075
+ }, [GetAQModule_query.data]);
7071
7076
  return /* @__PURE__ */ jsxs27(
7072
7077
  AppShell,
7073
7078
  {
@@ -66,7 +66,7 @@ import {
66
66
  useS_BasicAppShell,
67
67
  useS_ButtonImport,
68
68
  utils_layout_getItemsWithoutLinks
69
- } from "../chunk-5U42CUIR.mjs";
69
+ } from "../chunk-BQSJZ3WA.mjs";
70
70
  import "../chunk-J76K4YUA.mjs";
71
71
  import "../chunk-Y3YGC5IH.mjs";
72
72
  import "../chunk-5U2JSHSJ.mjs";
@@ -417,7 +417,6 @@ interface I$5 {
417
417
  email?: string;
418
418
  phoneNumber?: string;
419
419
  userSkillCenters?: IUserSkillCenters[];
420
- userSkillCentersIds?: number[];
421
420
  }
422
421
  declare function F_core71678_Update({ user }: {
423
422
  user: I$5;
@@ -25,7 +25,7 @@ import {
25
25
  useS_BasicAppShell,
26
26
  useS_authenticate,
27
27
  utils_layout_getItemsWithoutLinks
28
- } from "../chunk-5U42CUIR.mjs";
28
+ } from "../chunk-BQSJZ3WA.mjs";
29
29
  import {
30
30
  baseAxios_default,
31
31
  useQ_AQ_GetAQModule,
@@ -37,9 +37,10 @@ import {
37
37
  import {
38
38
  U0DateToDDMMYYYString,
39
39
  U0MyValidateEmail,
40
+ updateEnableList,
40
41
  utils_converter_enumToSelectOptions,
41
42
  utils_file_fileToAQDocumentType
42
- } from "../chunk-R64376EI.mjs";
43
+ } from "../chunk-3MGSFSSG.mjs";
43
44
  import "../chunk-5U2JSHSJ.mjs";
44
45
  import {
45
46
  utils_notification_show
@@ -2627,14 +2628,6 @@ function F_core71678_Create() {
2627
2628
  };
2628
2629
  }),
2629
2630
  onChange: (e) => {
2630
- const z = e.map((item) => ({
2631
- id: 0,
2632
- code: "string",
2633
- name: "string",
2634
- concurrencyStamp: "string",
2635
- isEnabled: true,
2636
- skillCenterId: parseInt(item.toString())
2637
- }));
2638
2631
  form.setFieldValue("userSkillCenters", e.map((item, idx) => ({
2639
2632
  idField: idx.toString(),
2640
2633
  id: 0,
@@ -2670,15 +2663,20 @@ function F_core71678_Delete({ id, code }) {
2670
2663
  // src/modules-features/admin/core/core71678/F_core71678_Update.tsx
2671
2664
  import { MultiSelect as MultiSelect2 } from "@mantine/core";
2672
2665
  import { useForm as useForm17 } from "@mantine/form";
2666
+ import { useState as useState5 } from "react";
2673
2667
  import { jsx as jsx50, jsxs as jsxs33 } from "react/jsx-runtime";
2674
2668
  function F_core71678_Update({ user }) {
2675
- var _a;
2669
+ var _a, _b, _c, _d;
2676
2670
  const skillCenter_getAll_query = useQ_SkillCenter_GetAll();
2677
2671
  const form = useForm17({
2678
- initialValues: user
2672
+ initialValues: __spreadProps(__spreadValues({}, user), {
2673
+ userSkillCenters: (_a = user.userSkillCenters) != null ? _a : []
2674
+ })
2679
2675
  });
2676
+ const [editedUserSkillCentersState, setEditedUserSkillCentersState] = useState5(
2677
+ (_b = user.userSkillCenters) != null ? _b : []
2678
+ );
2680
2679
  return /* @__PURE__ */ jsx50(MyActionIconUpdate, { form, onSubmit: async (values) => {
2681
- var _a2;
2682
2680
  const formValues = form.getValues();
2683
2681
  return await baseAxios_default.post(
2684
2682
  "/Account/update",
@@ -2689,14 +2687,7 @@ function F_core71678_Update({ user }) {
2689
2687
  isBlocked: false,
2690
2688
  isEnabled: true,
2691
2689
  workingUnitId: null,
2692
- userSkillCenters: (_a2 = formValues.userSkillCentersIds) == null ? void 0 : _a2.map((item, idx) => ({
2693
- id: formValues.userSkillCenters[idx].id,
2694
- code: "string",
2695
- name: "string",
2696
- concurrencyStamp: "string",
2697
- isEnabled: true,
2698
- skillCenterId: parseInt(item.toString())
2699
- }))
2690
+ userSkillCenters: editedUserSkillCentersState
2700
2691
  })
2701
2692
  );
2702
2693
  }, children: /* @__PURE__ */ jsxs33(MyFlexColumn, { children: [
@@ -2707,17 +2698,41 @@ function F_core71678_Update({ user }) {
2707
2698
  /* @__PURE__ */ jsx50(MyTextInput, __spreadValues({ label: "S\u1ED1 \u0111i\u1EC7n tho\u1EA1i" }, form.getInputProps("phoneNumber"))),
2708
2699
  skillCenter_getAll_query.data && /* @__PURE__ */ jsx50(
2709
2700
  MultiSelect2,
2710
- __spreadValues({
2701
+ {
2711
2702
  label: "Trung t\xE2m k\u1EF9 n\u0103ng",
2712
2703
  placeholder: "Ch\u1ECDn trung t\xE2m k\u1EF9 n\u0103ng",
2713
- data: (_a = skillCenter_getAll_query.data) == null ? void 0 : _a.map((item) => {
2704
+ data: (_c = skillCenter_getAll_query.data) == null ? void 0 : _c.map((item) => {
2714
2705
  var _a2;
2715
2706
  return {
2716
2707
  label: item.name,
2717
2708
  value: (_a2 = item.id) == null ? void 0 : _a2.toString()
2718
2709
  };
2719
- })
2720
- }, form.getInputProps("userSkillCentersIds"))
2710
+ }),
2711
+ value: (_d = form.getValues().userSkillCenters) == null ? void 0 : _d.map((item) => {
2712
+ var _a2;
2713
+ return (_a2 = item.skillCenterId) == null ? void 0 : _a2.toString();
2714
+ }),
2715
+ onChange: (selectedValues) => {
2716
+ const selectedIds = selectedValues.map(Number);
2717
+ form.setFieldValue("userSkillCenters", selectedValues.map((item, idx) => ({
2718
+ idField: idx.toString(),
2719
+ id: 0,
2720
+ code: "string",
2721
+ name: "string",
2722
+ concurrencyStamp: "string",
2723
+ isEnabled: true,
2724
+ skillCenterId: parseInt(item.toString())
2725
+ })));
2726
+ setEditedUserSkillCentersState(
2727
+ (prev) => updateEnableList(
2728
+ prev,
2729
+ selectedIds,
2730
+ (item) => item.skillCenterId,
2731
+ (id) => ({ id: 0, skillCenterId: id, isEnabled: true })
2732
+ )
2733
+ );
2734
+ }
2735
+ }
2721
2736
  )
2722
2737
  ] }) });
2723
2738
  }
@@ -3015,12 +3030,12 @@ import { Grid as Grid4, Paper as Paper7, ScrollArea as ScrollArea4 } from "@mant
3015
3030
  // src/modules-features/admin/core/core83092/F_core83092_ReadUser.tsx
3016
3031
  import { Container as Container2 } from "@mantine/core";
3017
3032
  import { useQuery as useQuery15 } from "@tanstack/react-query";
3018
- import { useEffect as useEffect7, useMemo as useMemo13, useState as useState5 } from "react";
3033
+ import { useEffect as useEffect7, useMemo as useMemo13, useState as useState6 } from "react";
3019
3034
  import { jsx as jsx58 } from "react/jsx-runtime";
3020
3035
  function F_core83092_ReadUser() {
3021
3036
  const store = useS_core83092();
3022
3037
  const query = useQ_core83092_Account_GetAdminAccount();
3023
- const [rowSelection, setRowSelection] = useState5({});
3038
+ const [rowSelection, setRowSelection] = useState6({});
3024
3039
  const columns = useMemo13(
3025
3040
  () => [
3026
3041
  {
@@ -3084,11 +3099,11 @@ function useQ_core83092_Account_GetAdminAccount() {
3084
3099
 
3085
3100
  // src/modules-features/admin/core/core83092/F_core83092_Save.tsx
3086
3101
  import { useMutation as useMutation4 } from "@tanstack/react-query";
3087
- import { useEffect as useEffect8, useState as useState6 } from "react";
3102
+ import { useEffect as useEffect8, useState as useState7 } from "react";
3088
3103
  import { jsx as jsx59 } from "react/jsx-runtime";
3089
3104
  function F_core83092_Save() {
3090
3105
  const store = useS_core83092();
3091
- const disable = useState6(false);
3106
+ const disable = useState7(false);
3092
3107
  const mutation = useMutation4({
3093
3108
  mutationFn: async (body) => {
3094
3109
  const res = await baseAxios_default.put("/Role/UpdateUserPermission", body);
@@ -3121,14 +3136,14 @@ function F_core83092_Save() {
3121
3136
  import { Checkbox as Checkbox2, Flex as Flex2, ScrollArea as ScrollArea3, Table as Table3, Text as Text2 } from "@mantine/core";
3122
3137
  import { IconEdit as IconEdit2, IconEyeUp as IconEyeUp2, IconFileExport as IconFileExport2, IconPlus as IconPlus2, IconPrinter as IconPrinter2, IconTrash as IconTrash2 } from "@tabler/icons-react";
3123
3138
  import { useQuery as useQuery16 } from "@tanstack/react-query";
3124
- import React3, { useEffect as useEffect9, useState as useState7 } from "react";
3139
+ import React3, { useEffect as useEffect9, useState as useState8 } from "react";
3125
3140
  import { jsx as jsx60, jsxs as jsxs38 } from "react/jsx-runtime";
3126
3141
  var title2 = "Danh s\xE1ch ch\u1EE9c n\u0103ng";
3127
3142
  function F_core83092_ViewMenuPermissions({ menuData: menuData2 }) {
3128
3143
  var _a, _b;
3129
3144
  const store = useS_core83092();
3130
3145
  const query = useGetUserPermission2({ menuData: menuData2 });
3131
- const list = useState7([]);
3146
+ const list = useState8([]);
3132
3147
  useEffect9(() => {
3133
3148
  list[1](groupToTwoLevels(menuData2));
3134
3149
  }, []);
@@ -3391,7 +3406,7 @@ import { useMutation as useMutation5 } from "@tanstack/react-query";
3391
3406
  import axios from "axios";
3392
3407
  import Link from "next/link";
3393
3408
  import { useRouter as useRouter3 } from "next/navigation";
3394
- import { useState as useState8 } from "react";
3409
+ import { useState as useState9 } from "react";
3395
3410
 
3396
3411
  // src/modules-features/authenticate/F_Authenticate_Login/css.module.css
3397
3412
  var css_default = {};
@@ -3407,7 +3422,7 @@ function F_authenticate_Login({
3407
3422
  }) {
3408
3423
  const router = useRouter3();
3409
3424
  const authenticate_store = useS_authenticate();
3410
- const loadingState = useState8(false);
3425
+ const loadingState = useState9(false);
3411
3426
  const mutation = useM_Account_Sigin();
3412
3427
  const form = useForm20({
3413
3428
  mode: "uncontrolled",
@@ -21,6 +21,15 @@ declare function utils_date_dateToDDMMYYYString(date: Date): string;
21
21
  declare function utils_date_formatToDateTimeStartEnd(startDate: Date, endDate: Date): string;
22
22
  declare function utils_date_getHHmm(date: Date): string;
23
23
 
24
+ /**
25
+ * Cập nhật danh sách dạng many-to-many có cờ enable.
26
+ * @param oldList - danh sách gốc đang lưu trong state
27
+ * @param selectedIds - danh sách id đang được chọn (sau khi onchange)
28
+ * @param getId - hàm lấy id từ mỗi item
29
+ * @param createNew - hàm tạo mới item nếu thêm mới
30
+ */
31
+ declare function updateEnableList<T>(oldList: T[], selectedIds: number[], getId: (item: T) => number | undefined, createNew: (id: number) => T): T[];
32
+
24
33
  interface I {
25
34
  crudType?: "delete" | "update" | "create" | "error" | "importSucess";
26
35
  message?: string;
@@ -36,4 +45,4 @@ declare const utils_time_getCurrentTimeString: () => string;
36
45
  declare function U0MyValidateEmpty(message?: string): (value: unknown) => React.ReactNode;
37
46
  declare function U0MyValidateEmail(value?: string): "Email không đúng định dạng" | null;
38
47
 
39
- export { U0DateToDDMMYYYString, U0MyValidateEmail, U0MyValidateEmpty, utils_converter_enumToSelectOptions, utils_converter_getKeyByValue, utils_converter_getLabelByValue, utils_currency_formatWithSuffix, utils_date_dateToDDMMYYYString, utils_date_formatToDateTimeStartEnd, utils_date_getHHmm, utils_notification_show, utils_pdf_download, utils_time_convertTimeStringToSeconds, utils_time_getCurrentTimeString };
48
+ export { U0DateToDDMMYYYString, U0MyValidateEmail, U0MyValidateEmpty, updateEnableList, utils_converter_enumToSelectOptions, utils_converter_getKeyByValue, utils_converter_getLabelByValue, utils_currency_formatWithSuffix, utils_date_dateToDDMMYYYString, utils_date_formatToDateTimeStartEnd, utils_date_getHHmm, utils_notification_show, utils_pdf_download, utils_time_convertTimeStringToSeconds, utils_time_getCurrentTimeString };
@@ -2,6 +2,7 @@ import {
2
2
  U0DateToDDMMYYYString,
3
3
  U0MyValidateEmail,
4
4
  U0MyValidateEmpty,
5
+ updateEnableList,
5
6
  utils_converter_enumToSelectOptions,
6
7
  utils_converter_getKeyByValue,
7
8
  utils_converter_getLabelByValue,
@@ -15,7 +16,7 @@ import {
15
16
  utils_file_fileToAQDocumentType,
16
17
  utils_time_convertTimeStringToSeconds,
17
18
  utils_time_getCurrentTimeString
18
- } from "../chunk-R64376EI.mjs";
19
+ } from "../chunk-3MGSFSSG.mjs";
19
20
  import {
20
21
  utils_pdf_download
21
22
  } from "../chunk-5U2JSHSJ.mjs";
@@ -27,6 +28,7 @@ export {
27
28
  U0DateToDDMMYYYString,
28
29
  U0MyValidateEmail,
29
30
  U0MyValidateEmpty,
31
+ updateEnableList,
30
32
  utils_converter_enumToSelectOptions,
31
33
  utils_converter_getKeyByValue,
32
34
  utils_converter_getLabelByValue,
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "types": "./dist/hooks/index.d.mts"
23
23
  }
24
24
  },
25
- "version": "0.1.199",
25
+ "version": "0.1.201",
26
26
  "private": false,
27
27
  "files": [
28
28
  "dist"