aq-fe-framework 0.1.401 → 0.1.403

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.
@@ -212,6 +212,8 @@ function MyButtonCreateUpdate({
212
212
  onSubmit,
213
213
  onSuccess,
214
214
  onError,
215
+ ignoreDefaultOnError,
216
+ ignoreDefaultOnSuccess,
215
217
  closeModalWhenSubmit = true,
216
218
  resetFormWhenSubmit = true,
217
219
  children,
@@ -224,10 +226,9 @@ function MyButtonCreateUpdate({
224
226
  const disclosure = externalDisclosure != null ? externalDisclosure : defaultDisclosure;
225
227
  const queryClient = useQueryClient();
226
228
  const mutation = useMyReactMutation({
227
- axiosFn: (values) => {
228
- const result = onSubmit(values);
229
- if (result === void 0) {
230
- return Promise.resolve({
229
+ axiosFn: async (values) => {
230
+ if (onSubmit === true) {
231
+ return {
231
232
  data: {
232
233
  message: "T\u1EA1o th\xE0nh c\xF4ng (gi\u1EA3 l\u1EADp)",
233
234
  data: {},
@@ -237,27 +238,40 @@ function MyButtonCreateUpdate({
237
238
  statusText: "OK",
238
239
  headers: {},
239
240
  config: {}
240
- });
241
+ };
241
242
  }
242
- return result;
243
- },
244
- options: __spreadValues(__spreadValues({
245
- onSuccess: () => {
246
- queryClient.invalidateQueries();
247
- utils_notification_show({ crudType: isUpdate ? "update" : "create" });
248
- disclosure[1].close();
249
- if (closeModalWhenSubmit) disclosure[1].close();
250
- if (resetFormWhenSubmit) form.reset();
251
- }
252
- }, onSuccess && {
253
- onSuccess: () => {
254
- onSuccess();
243
+ if (onSubmit === false) {
244
+ return {
245
+ data: {
246
+ message: "T\u1EA1o th\u1EA5t b\u1EA1i (gi\u1EA3 l\u1EADp)",
247
+ data: {},
248
+ isSuccess: 1
249
+ },
250
+ status: 500,
251
+ statusText: "OK",
252
+ headers: {},
253
+ config: {}
254
+ };
255
255
  }
256
- }), onError && {
257
- onError: () => {
258
- onError();
256
+ return await onSubmit(values);
257
+ },
258
+ options: {
259
+ onSuccess: (...args) => {
260
+ if (!ignoreDefaultOnSuccess) {
261
+ queryClient.invalidateQueries();
262
+ utils_notification_show({ crudType: isUpdate ? "update" : "create" });
263
+ if (closeModalWhenSubmit) disclosure[1].close();
264
+ if (resetFormWhenSubmit) form.reset();
265
+ }
266
+ onSuccess == null ? void 0 : onSuccess(...args);
267
+ },
268
+ onError: (...args) => {
269
+ if (!ignoreDefaultOnError) {
270
+ utils_notification_show({ message: "L\u1ED7i khi l\u01B0u d\u1EEF li\u1EC7u", color: "error" });
271
+ }
272
+ onError == null ? void 0 : onError(...args);
259
273
  }
260
- })
274
+ }
261
275
  });
262
276
  return /* @__PURE__ */ jsxs(Fragment, { children: [
263
277
  isUpdate == true ? /* @__PURE__ */ jsx4(
@@ -28,16 +28,18 @@ interface CoreButtonCreateUpdateProps<IReq, IRes> {
28
28
  buttonProps?: ButtonProps;
29
29
  scrollAreaAutosizeProps?: ScrollAreaAutosizeProps;
30
30
  isUpdate?: boolean;
31
- onSubmit: (values: IReq) => Promise<AxiosResponse<MyApiResponse<IRes>>> | void;
32
- onSuccess?: () => void;
33
- onError?: () => void;
31
+ onSubmit: ((values: IReq) => Promise<AxiosResponse<MyApiResponse<IRes>>>) | boolean;
32
+ onSuccess?: (...args: any[]) => void;
33
+ onError?: (...args: any[]) => void;
34
+ ignoreDefaultOnSuccess?: boolean;
35
+ ignoreDefaultOnError?: boolean;
34
36
  form: UseFormReturnType<IReq>;
35
37
  closeModalWhenSubmit?: boolean;
36
38
  resetFormWhenSubmit?: boolean;
37
39
  disclosure?: ReturnType<typeof useDisclosure>;
38
40
  children?: ReactNode;
39
41
  }
40
- declare function MyButtonCreateUpdate<IReq, IRes>({ modalProps, actionIconProps, buttonProps, form, onSubmit, onSuccess, onError, closeModalWhenSubmit, resetFormWhenSubmit, children, disclosure: externalDisclosure, isUpdate, scrollAreaAutosizeProps }: CoreButtonCreateUpdateProps<IReq, IRes>): react_jsx_runtime.JSX.Element;
42
+ declare function MyButtonCreateUpdate<IReq, IRes>({ modalProps, actionIconProps, buttonProps, form, onSubmit, onSuccess, onError, ignoreDefaultOnError, ignoreDefaultOnSuccess, closeModalWhenSubmit, resetFormWhenSubmit, children, disclosure: externalDisclosure, isUpdate, scrollAreaAutosizeProps }: CoreButtonCreateUpdateProps<IReq, IRes>): react_jsx_runtime.JSX.Element;
41
43
 
42
44
  interface CoreButtonModalProps {
43
45
  children?: ReactNode;
@@ -13,7 +13,7 @@ import {
13
13
  MyStatsCard,
14
14
  MyTextInput,
15
15
  MyWeeklySessionSchedulerPicker
16
- } from "../chunk-NCNHWCYV.mjs";
16
+ } from "../chunk-H46FC3HW.mjs";
17
17
  import "../chunk-GEYCGM75.mjs";
18
18
  import "../chunk-7ORPZMGL.mjs";
19
19
  import "../chunk-K6S7R6LU.mjs";
@@ -5,12 +5,6 @@ import {
5
5
  utils_converter_enumToSelectOptions,
6
6
  utils_file_fileToAQDocumentType
7
7
  } from "../chunk-P3IR7UL7.mjs";
8
- import {
9
- baseColumns
10
- } from "../chunk-2SBUKAGS.mjs";
11
- import {
12
- U0DateToDDMMYYYString
13
- } from "../chunk-I2XIN2R3.mjs";
14
8
  import {
15
9
  F_authenticate_Logout,
16
10
  MyActionIconDelete,
@@ -38,19 +32,25 @@ import {
38
32
  createGenericStore
39
33
  } from "../chunk-Y3YGC5IH.mjs";
40
34
  import "../chunk-5U2JSHSJ.mjs";
35
+ import {
36
+ baseColumns
37
+ } from "../chunk-2SBUKAGS.mjs";
38
+ import {
39
+ U0DateToDDMMYYYString
40
+ } from "../chunk-I2XIN2R3.mjs";
41
+ import {
42
+ const_object_documentTypes
43
+ } from "../chunk-BZMQOGL6.mjs";
41
44
  import {
42
45
  MyButton as MyButton2,
43
46
  MyDataTableSelectOne,
44
47
  MyTextInput as MyTextInput2
45
- } from "../chunk-NCNHWCYV.mjs";
48
+ } from "../chunk-H46FC3HW.mjs";
46
49
  import {
47
50
  MyDataTable,
48
51
  MyFlexColumn,
49
52
  MyFlexRow
50
53
  } from "../chunk-GEYCGM75.mjs";
51
- import {
52
- const_object_documentTypes
53
- } from "../chunk-BZMQOGL6.mjs";
54
54
  import {
55
55
  const_object_colors
56
56
  } from "../chunk-7ORPZMGL.mjs";
@@ -19,15 +19,15 @@ import {
19
19
  utils_time_getCurrentTimeString,
20
20
  utils_validator_validateCode
21
21
  } from "../chunk-P3IR7UL7.mjs";
22
+ import {
23
+ utils_pdf_download
24
+ } from "../chunk-5U2JSHSJ.mjs";
22
25
  import {
23
26
  U0DateToDDMMYYYString,
24
27
  utils_date_dateToDDMMYYYString,
25
28
  utils_date_formatToDateTimeStartEnd,
26
29
  utils_date_getHHmm
27
30
  } from "../chunk-I2XIN2R3.mjs";
28
- import {
29
- utils_pdf_download
30
- } from "../chunk-5U2JSHSJ.mjs";
31
31
  import {
32
32
  utils_notification_show
33
33
  } from "../chunk-7ZCOFATU.mjs";
package/package.json CHANGED
@@ -42,7 +42,7 @@
42
42
  "types": "./dist/columns/index.d.mts"
43
43
  }
44
44
  },
45
- "version": "0.1.401",
45
+ "version": "0.1.403",
46
46
  "private": false,
47
47
  "files": [
48
48
  "dist"