@fctc/widget-logic 5.3.7-beta.15 → 5.3.7-beta.16
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.
- package/package.json +1 -1
- package/dist/config.d.mts +0 -5
- package/dist/config.d.ts +0 -5
- package/dist/config.js +0 -24
- package/dist/config.mjs +0 -2
- package/dist/constants.d.mts +0 -1
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -24
- package/dist/constants.mjs +0 -2
- package/dist/environment.d.mts +0 -1
- package/dist/environment.d.ts +0 -1
- package/dist/environment.js +0 -24
- package/dist/environment.mjs +0 -2
- package/dist/hooks.d.mts +0 -1179
- package/dist/hooks.d.ts +0 -1179
- package/dist/hooks.js +0 -1273
- package/dist/hooks.mjs +0 -1247
- package/dist/index.d.mts +0 -15
- package/dist/index.d.ts +0 -15
- package/dist/index.js +0 -3009
- package/dist/index.mjs +0 -3089
- package/dist/provider.d.mts +0 -1
- package/dist/provider.d.ts +0 -1
- package/dist/provider.js +0 -24
- package/dist/provider.mjs +0 -2
- package/dist/services.d.mts +0 -1
- package/dist/services.d.ts +0 -1
- package/dist/services.js +0 -24
- package/dist/services.mjs +0 -2
- package/dist/types.d.mts +0 -36
- package/dist/types.d.ts +0 -36
- package/dist/types.js +0 -24
- package/dist/types.mjs +0 -2
- package/dist/utils.d.mts +0 -23
- package/dist/utils.d.ts +0 -23
- package/dist/utils.js +0 -436
- package/dist/utils.mjs +0 -389
- package/dist/widget.d.mts +0 -328
- package/dist/widget.d.ts +0 -328
- package/dist/widget.js +0 -2379
- package/dist/widget.mjs +0 -2432
package/dist/hooks.js
DELETED
|
@@ -1,1273 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
|
|
31
|
-
// src/hooks.ts
|
|
32
|
-
var hooks_exports = {};
|
|
33
|
-
__export(hooks_exports, {
|
|
34
|
-
AppProvider: () => AppProvider,
|
|
35
|
-
useAddEntity: () => import_hooks2.useAddEntity,
|
|
36
|
-
useAppProvider: () => useAppProvider,
|
|
37
|
-
useButton: () => import_hooks2.useButton,
|
|
38
|
-
useCallAction: () => useCallAction,
|
|
39
|
-
useChangeOrderPreparationState: () => import_hooks2.useChangeOrderPreparationState,
|
|
40
|
-
useChangeStatus: () => import_hooks2.useChangeStatus,
|
|
41
|
-
useCheckPayment: () => import_hooks2.useCheckPayment,
|
|
42
|
-
useCompany: () => useCompany,
|
|
43
|
-
useConfig: () => useConfig,
|
|
44
|
-
useCreateEntity: () => import_hooks2.useCreateEntity,
|
|
45
|
-
useCreatePosConfig: () => import_hooks2.useCreatePosConfig,
|
|
46
|
-
useCreateSession: () => import_hooks2.useCreateSession,
|
|
47
|
-
useDebounce: () => useDebounce,
|
|
48
|
-
useDelete: () => import_hooks2.useDelete,
|
|
49
|
-
useDeleteComment: () => import_hooks2.useDeleteComment,
|
|
50
|
-
useDeleteEntity: () => import_hooks2.useDeleteEntity,
|
|
51
|
-
useDetail: () => useDetail,
|
|
52
|
-
useDuplicateRecord: () => import_hooks2.useDuplicateRecord,
|
|
53
|
-
useExecuteImport: () => import_hooks2.useExecuteImport,
|
|
54
|
-
useExportExcel: () => import_hooks2.useExportExcel,
|
|
55
|
-
useForgotPassword: () => import_hooks2.useForgotPassword,
|
|
56
|
-
useForgotPasswordSSO: () => import_hooks2.useForgotPasswordSSO,
|
|
57
|
-
useGenSerialNumber: () => import_hooks2.useGenSerialNumber,
|
|
58
|
-
useGeneratePaymentQrInfo: () => import_hooks2.useGeneratePaymentQrInfo,
|
|
59
|
-
useGet2FAMethods: () => import_hooks2.useGet2FAMethods,
|
|
60
|
-
useGetASession: () => import_hooks2.useGetASession,
|
|
61
|
-
useGetAccessByCode: () => import_hooks2.useGetAccessByCode,
|
|
62
|
-
useGetAction: () => useGetAction,
|
|
63
|
-
useGetActionDetail: () => import_hooks2.useGetActionDetail,
|
|
64
|
-
useGetAll: () => import_hooks2.useGetAll,
|
|
65
|
-
useGetCalendar: () => import_hooks2.useGetCalendar,
|
|
66
|
-
useGetComment: () => import_hooks2.useGetComment,
|
|
67
|
-
useGetCompanyInfo: () => import_hooks2.useGetCompanyInfo,
|
|
68
|
-
useGetConversionRate: () => import_hooks2.useGetConversionRate,
|
|
69
|
-
useGetCurrency: () => import_hooks2.useGetCurrency,
|
|
70
|
-
useGetCurrentCompany: () => import_hooks2.useGetCurrentCompany,
|
|
71
|
-
useGetDetail: () => import_hooks2.useGetDetail,
|
|
72
|
-
useGetExternalTabs: () => import_hooks2.useGetExternalTabs,
|
|
73
|
-
useGetFieldExport: () => import_hooks2.useGetFieldExport,
|
|
74
|
-
useGetFieldOnChange: () => import_hooks2.useGetFieldOnChange,
|
|
75
|
-
useGetFileExcel: () => import_hooks2.useGetFileExcel,
|
|
76
|
-
useGetFormView: () => import_hooks2.useGetFormView,
|
|
77
|
-
useGetGroups: () => import_hooks2.useGetGroups,
|
|
78
|
-
useGetList: () => import_hooks2.useGetList,
|
|
79
|
-
useGetListCompany: () => import_hooks2.useGetListCompany,
|
|
80
|
-
useGetListData: () => import_hooks2.useGetListData,
|
|
81
|
-
useGetListMyBankAccount: () => import_hooks2.useGetListMyBankAccount,
|
|
82
|
-
useGetMenu: () => import_hooks2.useGetMenu,
|
|
83
|
-
useGetOrderLine: () => import_hooks2.useGetOrderLine,
|
|
84
|
-
useGetPinCode: () => import_hooks2.useGetPinCode,
|
|
85
|
-
useGetPrintReport: () => import_hooks2.useGetPrintReport,
|
|
86
|
-
useGetProGressBar: () => import_hooks2.useGetProGressBar,
|
|
87
|
-
useGetProfile: () => import_hooks2.useGetProfile,
|
|
88
|
-
useGetProvider: () => import_hooks2.useGetProvider,
|
|
89
|
-
useGetResequence: () => import_hooks2.useGetResequence,
|
|
90
|
-
useGetRowIds: () => useGetRowIds,
|
|
91
|
-
useGetSelection: () => import_hooks2.useGetSelection,
|
|
92
|
-
useGetSpecification: () => useGetSpecification,
|
|
93
|
-
useGetUser: () => import_hooks2.useGetUser,
|
|
94
|
-
useGetView: () => import_hooks2.useGetView,
|
|
95
|
-
useGrantAccess: () => import_hooks2.useGrantAccess,
|
|
96
|
-
useIsValidToken: () => import_hooks2.useIsValidToken,
|
|
97
|
-
useListData: () => useListData,
|
|
98
|
-
useLoadAction: () => import_hooks2.useLoadAction,
|
|
99
|
-
useLoadMessage: () => import_hooks2.useLoadMessage,
|
|
100
|
-
useLoginCredential: () => import_hooks2.useLoginCredential,
|
|
101
|
-
useLoginSocial: () => import_hooks2.useLoginSocial,
|
|
102
|
-
useLogout: () => import_hooks2.useLogout,
|
|
103
|
-
useMenu: () => useMenu,
|
|
104
|
-
useModel: () => import_hooks2.useModel,
|
|
105
|
-
useOdooDataTransform: () => import_hooks2.useOdooDataTransform,
|
|
106
|
-
useOnChangeForm: () => import_hooks2.useOnChangeForm,
|
|
107
|
-
useParsePreview: () => import_hooks2.useParsePreview,
|
|
108
|
-
usePrint: () => import_hooks2.usePrint,
|
|
109
|
-
useProfile: () => useProfile,
|
|
110
|
-
useReadGroup: () => import_hooks2.useReadGroup,
|
|
111
|
-
useRemoveRow: () => import_hooks2.useRemoveRow,
|
|
112
|
-
useRemoveTotpSetup: () => import_hooks2.useRemoveTotpSetup,
|
|
113
|
-
useRequestSetupTotp: () => import_hooks2.useRequestSetupTotp,
|
|
114
|
-
useResetPassword: () => import_hooks2.useResetPassword,
|
|
115
|
-
useResetPasswordSSO: () => import_hooks2.useResetPasswordSSO,
|
|
116
|
-
useRunAction: () => import_hooks2.useRunAction,
|
|
117
|
-
useSave: () => import_hooks2.useSave,
|
|
118
|
-
useSendComment: () => import_hooks2.useSendComment,
|
|
119
|
-
useSettingsWebRead2fa: () => import_hooks2.useSettingsWebRead2fa,
|
|
120
|
-
useSignInSSO: () => import_hooks2.useSignInSSO,
|
|
121
|
-
useSwitchLocale: () => import_hooks2.useSwitchLocale,
|
|
122
|
-
useUpdatePassword: () => import_hooks2.useUpdatePassword,
|
|
123
|
-
useUploadFile: () => import_hooks2.useUploadFile,
|
|
124
|
-
useUploadFileExcel: () => import_hooks2.useUploadFileExcel,
|
|
125
|
-
useUploadIdFile: () => import_hooks2.useUploadIdFile,
|
|
126
|
-
useUploadImage: () => import_hooks2.useUploadImage,
|
|
127
|
-
useUser: () => useUser,
|
|
128
|
-
useValidateActionToken: () => import_hooks2.useValidateActionToken,
|
|
129
|
-
useVerify2FA: () => import_hooks2.useVerify2FA,
|
|
130
|
-
useVerifyTotp: () => import_hooks2.useVerifyTotp,
|
|
131
|
-
useViewV2: () => useViewV2
|
|
132
|
-
});
|
|
133
|
-
module.exports = __toCommonJS(hooks_exports);
|
|
134
|
-
var import_hooks2 = require("@fctc/interface-logic/hooks");
|
|
135
|
-
|
|
136
|
-
// src/hooks/core/use-app-provider.tsx
|
|
137
|
-
var import_react8 = require("react");
|
|
138
|
-
|
|
139
|
-
// src/hooks/core/use-menu.ts
|
|
140
|
-
var import_react3 = require("react");
|
|
141
|
-
|
|
142
|
-
// src/hooks/core/use-call-action.ts
|
|
143
|
-
var import_react = require("react");
|
|
144
|
-
|
|
145
|
-
// src/provider.ts
|
|
146
|
-
var provider_exports = {};
|
|
147
|
-
__reExport(provider_exports, require("@fctc/interface-logic/provider"));
|
|
148
|
-
|
|
149
|
-
// src/hooks/core/use-call-action.ts
|
|
150
|
-
var useCallAction = () => {
|
|
151
|
-
const { env } = (0, provider_exports.useEnv)();
|
|
152
|
-
const { useLoadAction: useLoadAction2, useRunAction: useRunAction2 } = (0, provider_exports.useService)();
|
|
153
|
-
const queryLoadAction = useLoadAction2();
|
|
154
|
-
const queryRunAction = useRunAction2();
|
|
155
|
-
const [actionData, setActionData] = (0, import_react.useState)(
|
|
156
|
-
void 0
|
|
157
|
-
);
|
|
158
|
-
const callAction = (0, import_react.useCallback)(
|
|
159
|
-
async ({
|
|
160
|
-
aid,
|
|
161
|
-
service,
|
|
162
|
-
xNode,
|
|
163
|
-
context
|
|
164
|
-
}) => {
|
|
165
|
-
try {
|
|
166
|
-
const menuContext = {
|
|
167
|
-
...env?.context,
|
|
168
|
-
...context
|
|
169
|
-
};
|
|
170
|
-
const loadRes = await queryLoadAction.mutateAsync({
|
|
171
|
-
idAction: aid,
|
|
172
|
-
context: menuContext,
|
|
173
|
-
service,
|
|
174
|
-
xNode
|
|
175
|
-
});
|
|
176
|
-
if (loadRes?.result?.type === "ir.actions.server") {
|
|
177
|
-
const runRes = await queryRunAction.mutateAsync({
|
|
178
|
-
idAction: aid,
|
|
179
|
-
context: menuContext,
|
|
180
|
-
service,
|
|
181
|
-
xNode
|
|
182
|
-
});
|
|
183
|
-
setActionData(runRes?.result);
|
|
184
|
-
return runRes?.result;
|
|
185
|
-
} else {
|
|
186
|
-
setActionData(loadRes?.result);
|
|
187
|
-
return loadRes?.result;
|
|
188
|
-
}
|
|
189
|
-
} catch (err) {
|
|
190
|
-
console.error("callAction error:", err);
|
|
191
|
-
return void 0;
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
[env?.context?.lang]
|
|
195
|
-
);
|
|
196
|
-
return [actionData, callAction];
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
// src/utils.ts
|
|
200
|
-
var utils_exports = {};
|
|
201
|
-
__export(utils_exports, {
|
|
202
|
-
STORAGES: () => STORAGES,
|
|
203
|
-
countSum: () => countSum,
|
|
204
|
-
guessTypeFromUrl: () => guessTypeFromUrl,
|
|
205
|
-
isObjectEmpty: () => isObjectEmpty,
|
|
206
|
-
languages: () => languages,
|
|
207
|
-
mergeButtons: () => mergeButtons,
|
|
208
|
-
setStorageItemAsync: () => setStorageItemAsync,
|
|
209
|
-
useStorageState: () => useStorageState,
|
|
210
|
-
validateAndParseDate: () => validateAndParseDate
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
// src/utils/constants.ts
|
|
214
|
-
var languages = [
|
|
215
|
-
{ id: "vi_VN", name: "VIE" },
|
|
216
|
-
{ id: "en_US", name: "ENG" }
|
|
217
|
-
];
|
|
218
|
-
|
|
219
|
-
// src/utils/function.ts
|
|
220
|
-
var import_react2 = require("react");
|
|
221
|
-
var countSum = (data, field) => {
|
|
222
|
-
if (!data || !field) return 0;
|
|
223
|
-
return data.reduce(
|
|
224
|
-
(total, item) => total + (item?.[`${field}_count`] || 0),
|
|
225
|
-
0
|
|
226
|
-
);
|
|
227
|
-
};
|
|
228
|
-
var isObjectEmpty = (obj) => {
|
|
229
|
-
return Object.keys(obj).length === 0;
|
|
230
|
-
};
|
|
231
|
-
function mergeButtons(fields) {
|
|
232
|
-
const buttons = fields?.filter((f) => f.type_co === "button");
|
|
233
|
-
const others = fields?.filter((f) => f.type_co !== "button");
|
|
234
|
-
if (buttons?.length) {
|
|
235
|
-
others.push({
|
|
236
|
-
type_co: "buttons",
|
|
237
|
-
buttons
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
return others;
|
|
241
|
-
}
|
|
242
|
-
var STORAGES = {
|
|
243
|
-
TOKEN: "accessToken",
|
|
244
|
-
USER_INFO: "USER_INFO"
|
|
245
|
-
};
|
|
246
|
-
function useAsyncState(initialValue = [true, null]) {
|
|
247
|
-
return (0, import_react2.useReducer)(
|
|
248
|
-
(_state, action = null) => [false, action],
|
|
249
|
-
initialValue
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
async function setStorageItemAsync(key, value) {
|
|
253
|
-
try {
|
|
254
|
-
if (value === null) {
|
|
255
|
-
localStorage.removeItem(key);
|
|
256
|
-
} else {
|
|
257
|
-
localStorage.setItem(key, value);
|
|
258
|
-
}
|
|
259
|
-
} catch (e) {
|
|
260
|
-
console.error("Local storage is unavailable:", e);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
function useStorageState(key) {
|
|
264
|
-
const [state, setState] = useAsyncState();
|
|
265
|
-
(0, import_react2.useEffect)(() => {
|
|
266
|
-
try {
|
|
267
|
-
const storedValue = localStorage.getItem(key);
|
|
268
|
-
setState(storedValue);
|
|
269
|
-
} catch (e) {
|
|
270
|
-
console.error("Local storage is unavailable:", e);
|
|
271
|
-
}
|
|
272
|
-
}, [key]);
|
|
273
|
-
const setValue = (0, import_react2.useCallback)(
|
|
274
|
-
(value) => {
|
|
275
|
-
setState(value);
|
|
276
|
-
setStorageItemAsync(key, value);
|
|
277
|
-
},
|
|
278
|
-
[key]
|
|
279
|
-
);
|
|
280
|
-
return [state, setValue];
|
|
281
|
-
}
|
|
282
|
-
var guessTypeFromUrl = (url) => {
|
|
283
|
-
const ext = url.split(".").pop()?.toLowerCase();
|
|
284
|
-
if (!ext) return null;
|
|
285
|
-
const map = {
|
|
286
|
-
jpg: "image/jpeg",
|
|
287
|
-
jpeg: "image/jpeg",
|
|
288
|
-
png: "image/png",
|
|
289
|
-
webp: "image/webp",
|
|
290
|
-
gif: "image/gif",
|
|
291
|
-
svg: "image/svg+xml",
|
|
292
|
-
bmp: "image/bmp",
|
|
293
|
-
tiff: "image/tiff",
|
|
294
|
-
pdf: "application/pdf",
|
|
295
|
-
zip: "application/zip",
|
|
296
|
-
rar: "application/x-rar-compressed",
|
|
297
|
-
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
298
|
-
xls: "application/vnd.ms-excel",
|
|
299
|
-
mp4: "video/mp4",
|
|
300
|
-
mov: "video/quicktime"
|
|
301
|
-
};
|
|
302
|
-
return map[ext] || null;
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
// src/utils/format-date.ts
|
|
306
|
-
var import_moment = __toESM(require("moment"));
|
|
307
|
-
var validateAndParseDate = (input, isDateTime = false) => {
|
|
308
|
-
if (!input || typeof input !== "string") return null;
|
|
309
|
-
const cleanInput = input.replace(/[^0-9-\/:\s]/g, "");
|
|
310
|
-
const dateFormat = "YYYY-MM-DD";
|
|
311
|
-
const dateTimeFormat = "YYYY-MM-DD HH:mm:ss";
|
|
312
|
-
const currentDay = (0, import_moment.default)().format("DD");
|
|
313
|
-
const currentMonth = (0, import_moment.default)().format("MM");
|
|
314
|
-
const currentYear = (0, import_moment.default)().format("YYYY");
|
|
315
|
-
const defaultTime = "00:00:00";
|
|
316
|
-
const maxYear = parseInt(currentYear) + 10;
|
|
317
|
-
const isValidDate = (day, month, year) => {
|
|
318
|
-
const date = (0, import_moment.default)(`${day}-${month}-${year}`, "DD-MM-YYYY", true);
|
|
319
|
-
return date.isValid();
|
|
320
|
-
};
|
|
321
|
-
const isValidTime = (hour, minute = "00", second = "00") => {
|
|
322
|
-
const h = parseInt(hour, 10);
|
|
323
|
-
const m = parseInt(minute, 10);
|
|
324
|
-
const s = parseInt(second, 10);
|
|
325
|
-
return h >= 0 && h <= 23 && m >= 0 && m <= 59 && s >= 0 && s <= 59;
|
|
326
|
-
};
|
|
327
|
-
const formatOutput = (day, month, year, time = defaultTime) => {
|
|
328
|
-
let result = (0, import_moment.default)(
|
|
329
|
-
`${day}-${month}-${year} ${time}`,
|
|
330
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
331
|
-
);
|
|
332
|
-
if (!result.isValid()) return null;
|
|
333
|
-
if (isDateTime) {
|
|
334
|
-
result = result.subtract(7, "hours");
|
|
335
|
-
return result.format(dateTimeFormat);
|
|
336
|
-
}
|
|
337
|
-
return result.format(dateFormat);
|
|
338
|
-
};
|
|
339
|
-
if (isDateTime && input.match(
|
|
340
|
-
/^\d{1,2}[\/-]\d{1,2}[\/-]\d{2,4}\s+\d{1,2}(:\d{1,2}(:\d{1,2})?)?$/
|
|
341
|
-
)) {
|
|
342
|
-
const [datePart, timePart] = input.split(/\s+/);
|
|
343
|
-
const dateParts = datePart.split(/[\/-]/);
|
|
344
|
-
const timeParts = timePart.split(":");
|
|
345
|
-
const day = dateParts[0].padStart(2, "0");
|
|
346
|
-
const month = dateParts[1].padStart(2, "0");
|
|
347
|
-
const year = dateParts[2].length <= 2 ? `20${dateParts[2].padStart(2, "0")}` : dateParts[2].padStart(4, "0");
|
|
348
|
-
const hour = timeParts[0].padStart(2, "0");
|
|
349
|
-
const minute = timeParts[1] ? timeParts[1].padStart(2, "0") : "00";
|
|
350
|
-
const second = timeParts[2] ? timeParts[2].padStart(2, "0") : "00";
|
|
351
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
352
|
-
let result = (0, import_moment.default)(
|
|
353
|
-
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
354
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
355
|
-
);
|
|
356
|
-
if (!result.isValid()) return null;
|
|
357
|
-
result = result.subtract(7, "hours");
|
|
358
|
-
return result.format(dateTimeFormat);
|
|
359
|
-
}
|
|
360
|
-
return null;
|
|
361
|
-
}
|
|
362
|
-
if (cleanInput.match(/^\d{4}-\d{2}-\d{2}$/)) {
|
|
363
|
-
const [year, month, day] = cleanInput.split("-");
|
|
364
|
-
if (isValidDate(day, month, year)) {
|
|
365
|
-
return formatOutput(day, month, year);
|
|
366
|
-
}
|
|
367
|
-
return null;
|
|
368
|
-
}
|
|
369
|
-
if (cleanInput.match(/^\d{1,2}\/\d{1,2}\/\d{2,4}$/)) {
|
|
370
|
-
const [day, month, year] = cleanInput.split("/");
|
|
371
|
-
const paddedDay = day.padStart(2, "0");
|
|
372
|
-
const paddedMonth = month.padStart(2, "0");
|
|
373
|
-
const fullYear = year.length <= 2 ? `20${year.padStart(2, "0")}` : year.padStart(4, "0");
|
|
374
|
-
if (isValidDate(paddedDay, paddedMonth, fullYear)) {
|
|
375
|
-
return formatOutput(paddedDay, paddedMonth, fullYear);
|
|
376
|
-
}
|
|
377
|
-
return null;
|
|
378
|
-
}
|
|
379
|
-
if (cleanInput.match(/^\d{1,2}-\d{1,2}-\d{2,4}$/)) {
|
|
380
|
-
const [day, month, year] = cleanInput.split("-");
|
|
381
|
-
const paddedDay = day.padStart(2, "0");
|
|
382
|
-
const paddedMonth = month.padStart(2, "0");
|
|
383
|
-
const fullYear = year.length <= 2 ? `20${year.padStart(2, "0")}` : year.padStart(4, "0");
|
|
384
|
-
if (isValidDate(paddedDay, paddedMonth, fullYear)) {
|
|
385
|
-
return formatOutput(paddedDay, paddedMonth, fullYear);
|
|
386
|
-
}
|
|
387
|
-
return null;
|
|
388
|
-
}
|
|
389
|
-
if (cleanInput.match(/^\d{1,2}[\/-]\d{1,2}$/)) {
|
|
390
|
-
const [day, month] = cleanInput.split(/[\/-]/);
|
|
391
|
-
const paddedDay = day.padStart(2, "0");
|
|
392
|
-
const paddedMonth = month.padStart(2, "0");
|
|
393
|
-
if (isValidDate(paddedDay, paddedMonth, currentYear)) {
|
|
394
|
-
return formatOutput(paddedDay, paddedMonth, currentYear);
|
|
395
|
-
}
|
|
396
|
-
return null;
|
|
397
|
-
}
|
|
398
|
-
if (cleanInput.match(/^\d{4}$/)) {
|
|
399
|
-
const num = parseInt(cleanInput, 10);
|
|
400
|
-
if (num >= 2e3 && num <= maxYear) {
|
|
401
|
-
if (isValidDate(currentDay, currentMonth, num.toString())) {
|
|
402
|
-
return formatOutput(currentDay, currentMonth, num.toString());
|
|
403
|
-
}
|
|
404
|
-
return null;
|
|
405
|
-
}
|
|
406
|
-
const day = cleanInput.slice(0, 2);
|
|
407
|
-
const month = cleanInput.slice(2, 4);
|
|
408
|
-
if (isValidDate(day, month, currentYear)) {
|
|
409
|
-
return formatOutput(day, month, currentYear);
|
|
410
|
-
}
|
|
411
|
-
return null;
|
|
412
|
-
}
|
|
413
|
-
if (cleanInput.startsWith("-") && /^\-\d+$/.test(cleanInput)) {
|
|
414
|
-
const daysToSubtract = Math.abs(parseInt(cleanInput, 10));
|
|
415
|
-
let result = (0, import_moment.default)().subtract(daysToSubtract, "days");
|
|
416
|
-
if (isDateTime) {
|
|
417
|
-
result = result.subtract(7, "hours");
|
|
418
|
-
}
|
|
419
|
-
if (result.isValid()) {
|
|
420
|
-
return isDateTime ? result.format(dateTimeFormat) : result.format(dateFormat);
|
|
421
|
-
}
|
|
422
|
-
return null;
|
|
423
|
-
}
|
|
424
|
-
if (input.match(/^\d{1,2}[^0-9-\/]+\d{1,2}[^0-9-\/]+\d{2,4}.*$/)) {
|
|
425
|
-
const parts = input.split(/[^0-9-\/]+/).filter(Boolean);
|
|
426
|
-
const day = parts[0].padStart(2, "0");
|
|
427
|
-
const month = parts[1].padStart(2, "0");
|
|
428
|
-
let year = parts[2];
|
|
429
|
-
year = year.length === 2 ? `20${year}` : year.padStart(4, "0");
|
|
430
|
-
if (isValidDate(day, month, year)) {
|
|
431
|
-
return formatOutput(day, month, year);
|
|
432
|
-
}
|
|
433
|
-
return null;
|
|
434
|
-
}
|
|
435
|
-
if (isDateTime) {
|
|
436
|
-
if (cleanInput.length === 9) {
|
|
437
|
-
const day = cleanInput.slice(0, 2);
|
|
438
|
-
const month = cleanInput.slice(2, 4);
|
|
439
|
-
const year = cleanInput.slice(4, 8);
|
|
440
|
-
const hour = cleanInput.slice(8, 9).padStart(2, "0");
|
|
441
|
-
if (isValidDate(day, month, year) && isValidTime(hour)) {
|
|
442
|
-
let result = (0, import_moment.default)(
|
|
443
|
-
`${day}-${month}-${year} ${hour}:00:00`,
|
|
444
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
445
|
-
);
|
|
446
|
-
if (!result.isValid()) return null;
|
|
447
|
-
result = result.subtract(7, "hours");
|
|
448
|
-
return result.format(dateTimeFormat);
|
|
449
|
-
}
|
|
450
|
-
return null;
|
|
451
|
-
}
|
|
452
|
-
if (cleanInput.length === 10) {
|
|
453
|
-
const day = cleanInput.slice(0, 2);
|
|
454
|
-
const month = cleanInput.slice(2, 4);
|
|
455
|
-
const year = cleanInput.slice(4, 8);
|
|
456
|
-
const hour = cleanInput.slice(8, 10);
|
|
457
|
-
if (isValidDate(day, month, year) && isValidTime(hour)) {
|
|
458
|
-
let result = (0, import_moment.default)(
|
|
459
|
-
`${day}-${month}-${year} ${hour}:00:00`,
|
|
460
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
461
|
-
);
|
|
462
|
-
if (!result.isValid()) return null;
|
|
463
|
-
result = result.subtract(7, "hours");
|
|
464
|
-
return result.format(dateTimeFormat);
|
|
465
|
-
}
|
|
466
|
-
return null;
|
|
467
|
-
}
|
|
468
|
-
if (cleanInput.length === 11) {
|
|
469
|
-
const day = cleanInput.slice(0, 2);
|
|
470
|
-
const month = cleanInput.slice(2, 4);
|
|
471
|
-
const year = cleanInput.slice(4, 8);
|
|
472
|
-
const hour = cleanInput.slice(8, 10);
|
|
473
|
-
const minute = cleanInput.slice(10, 11).padStart(2, "0");
|
|
474
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
|
|
475
|
-
let result = (0, import_moment.default)(
|
|
476
|
-
`${day}-${month}-${year} ${hour}:${minute}:00`,
|
|
477
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
478
|
-
);
|
|
479
|
-
if (!result.isValid()) return null;
|
|
480
|
-
result = result.subtract(7, "hours");
|
|
481
|
-
return result.format(dateTimeFormat);
|
|
482
|
-
}
|
|
483
|
-
return null;
|
|
484
|
-
}
|
|
485
|
-
if (cleanInput.length === 12) {
|
|
486
|
-
const day = cleanInput.slice(0, 2);
|
|
487
|
-
const month = cleanInput.slice(2, 4);
|
|
488
|
-
const year = cleanInput.slice(4, 8);
|
|
489
|
-
const hour = cleanInput.slice(8, 10);
|
|
490
|
-
const minute = cleanInput.slice(10, 12);
|
|
491
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
|
|
492
|
-
let result = (0, import_moment.default)(
|
|
493
|
-
`${day}-${month}-${year} ${hour}:${minute}:00`,
|
|
494
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
495
|
-
);
|
|
496
|
-
if (!result.isValid()) return null;
|
|
497
|
-
result = result.subtract(7, "hours");
|
|
498
|
-
return result.format(dateTimeFormat);
|
|
499
|
-
}
|
|
500
|
-
return null;
|
|
501
|
-
}
|
|
502
|
-
if (cleanInput.length === 13) {
|
|
503
|
-
const day = cleanInput.slice(0, 2);
|
|
504
|
-
const month = cleanInput.slice(2, 4);
|
|
505
|
-
const year = cleanInput.slice(4, 8);
|
|
506
|
-
const hour = cleanInput.slice(8, 10);
|
|
507
|
-
const minute = cleanInput.slice(10, 12);
|
|
508
|
-
const second = cleanInput.slice(12, 13).padStart(2, "0");
|
|
509
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
510
|
-
let result = (0, import_moment.default)(
|
|
511
|
-
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
512
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
513
|
-
);
|
|
514
|
-
if (!result.isValid()) return null;
|
|
515
|
-
result = result.subtract(7, "hours");
|
|
516
|
-
return result.format(dateTimeFormat);
|
|
517
|
-
}
|
|
518
|
-
return null;
|
|
519
|
-
}
|
|
520
|
-
if (cleanInput.length === 14) {
|
|
521
|
-
const day = cleanInput.slice(0, 2);
|
|
522
|
-
const month = cleanInput.slice(2, 4);
|
|
523
|
-
const year = cleanInput.slice(4, 8);
|
|
524
|
-
const hour = cleanInput.slice(8, 10);
|
|
525
|
-
const minute = cleanInput.slice(10, 12);
|
|
526
|
-
const second = cleanInput.slice(12, 14);
|
|
527
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
528
|
-
let result = (0, import_moment.default)(
|
|
529
|
-
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
530
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
531
|
-
);
|
|
532
|
-
if (!result.isValid()) return null;
|
|
533
|
-
result = result.subtract(7, "hours");
|
|
534
|
-
return result.format(dateTimeFormat);
|
|
535
|
-
}
|
|
536
|
-
return null;
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
const len = cleanInput.length;
|
|
540
|
-
if (len === 1 || len === 2) {
|
|
541
|
-
const paddedDay = cleanInput.padStart(2, "0");
|
|
542
|
-
if (isValidDate(paddedDay, currentMonth, currentYear)) {
|
|
543
|
-
return formatOutput(paddedDay, currentMonth, currentYear);
|
|
544
|
-
}
|
|
545
|
-
return null;
|
|
546
|
-
}
|
|
547
|
-
if (len === 3) {
|
|
548
|
-
const day = cleanInput.slice(0, 2);
|
|
549
|
-
const month = cleanInput.slice(2, 3).padStart(2, "0");
|
|
550
|
-
if (isValidDate(day, month, currentYear)) {
|
|
551
|
-
return formatOutput(day, month, currentYear);
|
|
552
|
-
}
|
|
553
|
-
return null;
|
|
554
|
-
}
|
|
555
|
-
if (len === 6) {
|
|
556
|
-
const day = cleanInput.slice(0, 2);
|
|
557
|
-
const month = cleanInput.slice(2, 4);
|
|
558
|
-
let year = cleanInput.slice(4, 6);
|
|
559
|
-
year = `20${year}`;
|
|
560
|
-
if (parseInt(month) > 12) {
|
|
561
|
-
if (isValidDate(day, currentMonth, currentYear)) {
|
|
562
|
-
return formatOutput(day, currentMonth, currentYear);
|
|
563
|
-
}
|
|
564
|
-
return null;
|
|
565
|
-
}
|
|
566
|
-
if (isValidDate(day, month, year)) {
|
|
567
|
-
return formatOutput(day, month, year);
|
|
568
|
-
}
|
|
569
|
-
return null;
|
|
570
|
-
}
|
|
571
|
-
if (len === 7) {
|
|
572
|
-
return null;
|
|
573
|
-
}
|
|
574
|
-
if (len === 8) {
|
|
575
|
-
const day = cleanInput.slice(0, 2);
|
|
576
|
-
const month = cleanInput.slice(2, 4);
|
|
577
|
-
const year = cleanInput.slice(4, 8);
|
|
578
|
-
if (isValidDate(day, month, year)) {
|
|
579
|
-
return formatOutput(day, month, year);
|
|
580
|
-
}
|
|
581
|
-
return null;
|
|
582
|
-
}
|
|
583
|
-
if (len > 8 && !isDateTime) {
|
|
584
|
-
return null;
|
|
585
|
-
}
|
|
586
|
-
return null;
|
|
587
|
-
};
|
|
588
|
-
|
|
589
|
-
// src/utils.ts
|
|
590
|
-
__reExport(utils_exports, require("@fctc/interface-logic/utils"));
|
|
591
|
-
|
|
592
|
-
// src/hooks/core/use-menu.ts
|
|
593
|
-
var useMenu = ({
|
|
594
|
-
context,
|
|
595
|
-
specification,
|
|
596
|
-
domain,
|
|
597
|
-
defaultService
|
|
598
|
-
}) => {
|
|
599
|
-
const { useGetMenu: useGetMenu2 } = (0, provider_exports.useService)();
|
|
600
|
-
const [action, callAction] = useCallAction();
|
|
601
|
-
const [service, setService] = (0, import_react3.useState)("");
|
|
602
|
-
const [xNode, setXNode] = (0, import_react3.useState)("");
|
|
603
|
-
const menuData = useGetMenu2(
|
|
604
|
-
context,
|
|
605
|
-
specification,
|
|
606
|
-
!!context && !isObjectEmpty(context) && !!context?.uid && !!context?.lang,
|
|
607
|
-
domain,
|
|
608
|
-
defaultService
|
|
609
|
-
);
|
|
610
|
-
const [menuId, setMenuId] = (0, import_react3.useState)(void 0);
|
|
611
|
-
const handleChangeMenu = async ({
|
|
612
|
-
menu,
|
|
613
|
-
service: service2,
|
|
614
|
-
xNode: xNode2,
|
|
615
|
-
context: context2
|
|
616
|
-
}) => {
|
|
617
|
-
const aidMenu = menu?.action?.external_xml_id || menu?.action?.id?.id;
|
|
618
|
-
if (menu) {
|
|
619
|
-
setMenuId(menu.id?.toString() ?? "");
|
|
620
|
-
}
|
|
621
|
-
if (aidMenu) {
|
|
622
|
-
const actionResponse = await callAction({
|
|
623
|
-
aid: aidMenu,
|
|
624
|
-
service: service2 ?? "",
|
|
625
|
-
xNode: xNode2,
|
|
626
|
-
context: context2
|
|
627
|
-
});
|
|
628
|
-
setService(service2 ?? "");
|
|
629
|
-
setXNode(xNode2 ?? "");
|
|
630
|
-
return actionResponse;
|
|
631
|
-
}
|
|
632
|
-
};
|
|
633
|
-
return {
|
|
634
|
-
...menuData,
|
|
635
|
-
service,
|
|
636
|
-
xNode,
|
|
637
|
-
data: menuData?.data,
|
|
638
|
-
action: { handleChangeMenu },
|
|
639
|
-
state: { menuId, action },
|
|
640
|
-
context,
|
|
641
|
-
isLoading: menuData.isLoading,
|
|
642
|
-
isError: menuData.isError,
|
|
643
|
-
error: menuData.error,
|
|
644
|
-
refetch: menuData.refetch
|
|
645
|
-
};
|
|
646
|
-
};
|
|
647
|
-
|
|
648
|
-
// src/hooks/core/use-detail.ts
|
|
649
|
-
var import_react_query = require("@tanstack/react-query");
|
|
650
|
-
var import_react4 = require("react");
|
|
651
|
-
var useDetail = (sub) => {
|
|
652
|
-
const { setUserInfo, env } = (0, provider_exports.useEnv)();
|
|
653
|
-
const { useGetDetail: useGetDetail2 } = (0, provider_exports.useService)();
|
|
654
|
-
const fetchGetDetail = useGetDetail2();
|
|
655
|
-
const userDetailQuery = (0, import_react_query.useQuery)({
|
|
656
|
-
queryKey: ["userDetailQuery", sub],
|
|
657
|
-
queryFn: () => {
|
|
658
|
-
return fetchGetDetail.mutateAsync({
|
|
659
|
-
model: "res.users",
|
|
660
|
-
ids: [sub],
|
|
661
|
-
specification: { image_256: {} },
|
|
662
|
-
service: env?.default_service
|
|
663
|
-
});
|
|
664
|
-
},
|
|
665
|
-
enabled: !!sub
|
|
666
|
-
});
|
|
667
|
-
(0, import_react4.useEffect)(() => {
|
|
668
|
-
if (userDetailQuery.data) {
|
|
669
|
-
const userPicture = userDetailQuery.data;
|
|
670
|
-
setUserInfo({ ...env?.user, image: userPicture?.[0]?.image_256 });
|
|
671
|
-
}
|
|
672
|
-
}, [userDetailQuery.isFetched]);
|
|
673
|
-
return { ...userDetailQuery };
|
|
674
|
-
};
|
|
675
|
-
|
|
676
|
-
// src/hooks/core/use-profile.ts
|
|
677
|
-
var import_react_query2 = require("@tanstack/react-query");
|
|
678
|
-
var import_react5 = require("react");
|
|
679
|
-
var useProfile = ({
|
|
680
|
-
service,
|
|
681
|
-
i18n
|
|
682
|
-
}) => {
|
|
683
|
-
const { setUid, setLang, setUserInfo, env } = (0, provider_exports.useEnv)();
|
|
684
|
-
const { useGetProfile: useGetProfile2 } = (0, provider_exports.useService)();
|
|
685
|
-
const getProfile = useGetProfile2(service);
|
|
686
|
-
const userInfoQuery = (0, import_react_query2.useQuery)({
|
|
687
|
-
queryKey: ["userInfo"],
|
|
688
|
-
queryFn: () => getProfile.mutateAsync(),
|
|
689
|
-
enabled: isObjectEmpty(env?.user)
|
|
690
|
-
});
|
|
691
|
-
(0, import_react5.useEffect)(() => {
|
|
692
|
-
if (userInfoQuery.data) {
|
|
693
|
-
const userInfo = userInfoQuery.data;
|
|
694
|
-
utils_exports.sessionStorageUtils.setXNode(userInfo?.x_node);
|
|
695
|
-
setUid(userInfo?.sub);
|
|
696
|
-
setUserInfo(userInfo);
|
|
697
|
-
const userLocale = languages.find((lang) => lang?.id === userInfo?.locale);
|
|
698
|
-
setLang(userLocale?.id);
|
|
699
|
-
i18n.changeLanguage(userLocale?.id.split("_")[0]);
|
|
700
|
-
}
|
|
701
|
-
}, [userInfoQuery.isFetched]);
|
|
702
|
-
const context = (0, import_react5.useMemo)(() => {
|
|
703
|
-
if (userInfoQuery.data?.sub && userInfoQuery.data?.locale) {
|
|
704
|
-
return {
|
|
705
|
-
uid: Number(userInfoQuery.data.sub),
|
|
706
|
-
lang: String(userInfoQuery.data.locale),
|
|
707
|
-
tz: "Asia/Saigon"
|
|
708
|
-
};
|
|
709
|
-
}
|
|
710
|
-
return void 0;
|
|
711
|
-
}, [userInfoQuery.isFetched]);
|
|
712
|
-
if (userInfoQuery.isLoading || !userInfoQuery.data) {
|
|
713
|
-
return null;
|
|
714
|
-
}
|
|
715
|
-
return {
|
|
716
|
-
...userInfoQuery,
|
|
717
|
-
context
|
|
718
|
-
};
|
|
719
|
-
};
|
|
720
|
-
|
|
721
|
-
// src/hooks/core/use-user.ts
|
|
722
|
-
var useUser = ({ service, i18n }) => {
|
|
723
|
-
const userProfile = useProfile({ service, i18n });
|
|
724
|
-
const userDetail = useDetail(userProfile?.data?.sub);
|
|
725
|
-
return { userProfile, userDetail, context: userProfile?.context };
|
|
726
|
-
};
|
|
727
|
-
|
|
728
|
-
// src/hooks/core/use-view-v2.ts
|
|
729
|
-
var import_react6 = require("react");
|
|
730
|
-
var useViewV2 = ({
|
|
731
|
-
action,
|
|
732
|
-
context,
|
|
733
|
-
aid,
|
|
734
|
-
service,
|
|
735
|
-
xNode
|
|
736
|
-
}) => {
|
|
737
|
-
const { useGetView: useGetView2 } = (0, provider_exports.useService)();
|
|
738
|
-
const viewParams = (0, import_react6.useMemo)(() => {
|
|
739
|
-
if (!action || !action?.res_model) {
|
|
740
|
-
return void 0;
|
|
741
|
-
}
|
|
742
|
-
const actionResult = action;
|
|
743
|
-
return {
|
|
744
|
-
aid,
|
|
745
|
-
model: String(actionResult?.res_model),
|
|
746
|
-
views: [
|
|
747
|
-
...Array.isArray(actionResult?.views) ? actionResult?.views.map(
|
|
748
|
-
(view2) => view2[1] === "list" ? [view2[0], "list"] : view2
|
|
749
|
-
) : [],
|
|
750
|
-
[
|
|
751
|
-
Array.isArray(actionResult?.search_view_id) ? actionResult?.search_view_id[0] : actionResult?.search_view_id,
|
|
752
|
-
"search"
|
|
753
|
-
]
|
|
754
|
-
],
|
|
755
|
-
context,
|
|
756
|
-
id: isNaN(Number(aid)) ? action?.id : aid,
|
|
757
|
-
service,
|
|
758
|
-
xNode
|
|
759
|
-
};
|
|
760
|
-
}, [action, context, aid]);
|
|
761
|
-
const view = useGetView2({
|
|
762
|
-
viewParams: viewParams ?? {},
|
|
763
|
-
enabled: !!viewParams
|
|
764
|
-
});
|
|
765
|
-
return {
|
|
766
|
-
...view,
|
|
767
|
-
context
|
|
768
|
-
};
|
|
769
|
-
};
|
|
770
|
-
|
|
771
|
-
// src/hooks/core/use-company.ts
|
|
772
|
-
var import_react_query3 = require("@tanstack/react-query");
|
|
773
|
-
var import_react7 = require("react");
|
|
774
|
-
var useCompany = ({ service }) => {
|
|
775
|
-
const { setCompanies, setDefaultCompany, env } = (0, provider_exports.useEnv)();
|
|
776
|
-
const { useGetCurrentCompany: useGetCurrentCompany2, useGetCompanyInfo: useGetCompanyInfo2 } = (0, provider_exports.useService)();
|
|
777
|
-
const getCurrentCompany = useGetCurrentCompany2();
|
|
778
|
-
const fetchCurrentCompany = async () => {
|
|
779
|
-
return await getCurrentCompany.mutateAsync({
|
|
780
|
-
service
|
|
781
|
-
});
|
|
782
|
-
};
|
|
783
|
-
const currentCompany = (0, import_react_query3.useQuery)({
|
|
784
|
-
queryKey: ["currentCompany"],
|
|
785
|
-
queryFn: fetchCurrentCompany,
|
|
786
|
-
enabled: !!env?.defaultCompany
|
|
787
|
-
});
|
|
788
|
-
const current_company_id = (0, import_react7.useMemo)(() => {
|
|
789
|
-
return currentCompany.data?.current_company_id;
|
|
790
|
-
}, [currentCompany.data]);
|
|
791
|
-
(0, import_react7.useEffect)(() => {
|
|
792
|
-
if (current_company_id) {
|
|
793
|
-
const companyIDs = [current_company_id];
|
|
794
|
-
setCompanies(companyIDs);
|
|
795
|
-
}
|
|
796
|
-
}, [current_company_id]);
|
|
797
|
-
const getCompanyInfo = useGetCompanyInfo2();
|
|
798
|
-
const companyInfo = (0, import_react_query3.useQuery)({
|
|
799
|
-
queryKey: ["companyInfoQuery", current_company_id],
|
|
800
|
-
queryFn: () => getCompanyInfo.mutateAsync({
|
|
801
|
-
service,
|
|
802
|
-
id: Number(current_company_id)
|
|
803
|
-
}),
|
|
804
|
-
enabled: !!current_company_id
|
|
805
|
-
});
|
|
806
|
-
(0, import_react7.useEffect)(() => {
|
|
807
|
-
if (companyInfo.data) {
|
|
808
|
-
const companyInfoData = companyInfo.data;
|
|
809
|
-
if (companyInfoData?.length) {
|
|
810
|
-
setDefaultCompany(companyInfoData[0]);
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
}, [companyInfo.data]);
|
|
814
|
-
if (!companyInfo?.data || !currentCompany?.data) return;
|
|
815
|
-
return {
|
|
816
|
-
currentCompany: { ...currentCompany },
|
|
817
|
-
companyInfo: { ...companyInfo }
|
|
818
|
-
};
|
|
819
|
-
};
|
|
820
|
-
|
|
821
|
-
// src/hooks/core/use-app-provider.tsx
|
|
822
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
823
|
-
var AppProviderInitialValue = {
|
|
824
|
-
user: {},
|
|
825
|
-
company: {},
|
|
826
|
-
action: {},
|
|
827
|
-
menu: {},
|
|
828
|
-
view: {}
|
|
829
|
-
};
|
|
830
|
-
var ReactContext = (0, import_react8.createContext)(AppProviderInitialValue);
|
|
831
|
-
var AppProvider = ({
|
|
832
|
-
children,
|
|
833
|
-
menuParams,
|
|
834
|
-
aid,
|
|
835
|
-
i18n
|
|
836
|
-
}) => {
|
|
837
|
-
const { env } = (0, provider_exports.useEnv)();
|
|
838
|
-
const user = useUser({ service: env.default_service, i18n });
|
|
839
|
-
const company = useCompany({ service: env.default_service });
|
|
840
|
-
const menuContext = (0, import_react8.useMemo)(() => {
|
|
841
|
-
return (0, utils_exports.combineContexts)([
|
|
842
|
-
{
|
|
843
|
-
...user?.context,
|
|
844
|
-
...!isObjectEmpty(env?.user) ? { lang: env?.context?.lang } : {},
|
|
845
|
-
...menuParams?.context ?? {}
|
|
846
|
-
}
|
|
847
|
-
]);
|
|
848
|
-
}, [user?.context, company?.companyInfo?.isFetched, env?.context?.lang]);
|
|
849
|
-
const menu = useMenu({
|
|
850
|
-
context: {
|
|
851
|
-
...menuContext
|
|
852
|
-
},
|
|
853
|
-
specification: menuParams?.specification,
|
|
854
|
-
domain: menuParams?.domain,
|
|
855
|
-
defaultService: env.default_service
|
|
856
|
-
});
|
|
857
|
-
const action = (0, import_react8.useMemo)(() => {
|
|
858
|
-
return menu?.state?.action;
|
|
859
|
-
}, [menu?.state?.action, env?.context?.lang]);
|
|
860
|
-
const viewContext = (0, import_react8.useMemo)(() => {
|
|
861
|
-
return (0, utils_exports.combineContexts)([
|
|
862
|
-
menuContext,
|
|
863
|
-
{ ...(0, utils_exports.evalJSONContext)(action?.context) }
|
|
864
|
-
]);
|
|
865
|
-
}, [menuContext, action?.context, env?.context?.lang]);
|
|
866
|
-
const view = useViewV2({
|
|
867
|
-
action,
|
|
868
|
-
context: viewContext,
|
|
869
|
-
aid,
|
|
870
|
-
service: menu?.service,
|
|
871
|
-
xNode: menu?.xNode
|
|
872
|
-
});
|
|
873
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
874
|
-
ReactContext.Provider,
|
|
875
|
-
{
|
|
876
|
-
value: {
|
|
877
|
-
user,
|
|
878
|
-
company,
|
|
879
|
-
menu,
|
|
880
|
-
action,
|
|
881
|
-
view
|
|
882
|
-
},
|
|
883
|
-
children
|
|
884
|
-
}
|
|
885
|
-
);
|
|
886
|
-
};
|
|
887
|
-
var useAppProvider = () => {
|
|
888
|
-
const context = (0, import_react8.useContext)(ReactContext);
|
|
889
|
-
if (!context) {
|
|
890
|
-
return AppProviderInitialValue;
|
|
891
|
-
}
|
|
892
|
-
return context;
|
|
893
|
-
};
|
|
894
|
-
|
|
895
|
-
// src/hooks/core/use-config.ts
|
|
896
|
-
var import_react9 = require("react");
|
|
897
|
-
var useConfig = ({
|
|
898
|
-
envConfig,
|
|
899
|
-
config,
|
|
900
|
-
localStorageUtils,
|
|
901
|
-
sessionStorageUtils: sessionStorageUtils2
|
|
902
|
-
}) => {
|
|
903
|
-
const { setupEnv, setEnvFile } = (0, provider_exports.useEnv)();
|
|
904
|
-
(0, import_react9.useEffect)(() => {
|
|
905
|
-
try {
|
|
906
|
-
setupEnv({
|
|
907
|
-
baseUrl: envConfig.baseUrl,
|
|
908
|
-
config: envConfig.config,
|
|
909
|
-
default_service: "",
|
|
910
|
-
localStorageUtils: localStorageUtils && localStorageUtils(),
|
|
911
|
-
sessionStorageUtils: localStorageUtils && sessionStorageUtils2()
|
|
912
|
-
});
|
|
913
|
-
setEnvFile(config);
|
|
914
|
-
} catch (error) {
|
|
915
|
-
console.error("Error loading env or config:", error);
|
|
916
|
-
}
|
|
917
|
-
}, [envConfig, config]);
|
|
918
|
-
return { envConfig, config };
|
|
919
|
-
};
|
|
920
|
-
|
|
921
|
-
// src/hooks/core/use-get-action.ts
|
|
922
|
-
var useGetAction = ({
|
|
923
|
-
aid,
|
|
924
|
-
context
|
|
925
|
-
}) => {
|
|
926
|
-
const { useLoadAction: useLoadAction2, useRunAction: useRunAction2 } = (0, provider_exports.useService)();
|
|
927
|
-
const queryLoadAction = useLoadAction2();
|
|
928
|
-
const queryRunAction = useRunAction2();
|
|
929
|
-
const handleActionResult = (data) => {
|
|
930
|
-
if (data && data.result && data.result.views && Array.isArray(data.result.views) && data.result.views.length > 0) {
|
|
931
|
-
}
|
|
932
|
-
};
|
|
933
|
-
const onLoadAction = () => {
|
|
934
|
-
queryLoadAction.mutate(
|
|
935
|
-
{
|
|
936
|
-
idAction: aid,
|
|
937
|
-
context
|
|
938
|
-
},
|
|
939
|
-
{
|
|
940
|
-
onSuccess: (data) => {
|
|
941
|
-
if (data?.result?.type === "ir.actions.act_window") {
|
|
942
|
-
handleActionResult(data);
|
|
943
|
-
} else if (data?.result?.type === "ir.actions.server") {
|
|
944
|
-
queryRunAction.mutate(
|
|
945
|
-
{
|
|
946
|
-
idAction: aid,
|
|
947
|
-
context
|
|
948
|
-
},
|
|
949
|
-
{
|
|
950
|
-
onSuccess: handleActionResult
|
|
951
|
-
}
|
|
952
|
-
);
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
);
|
|
957
|
-
};
|
|
958
|
-
return {
|
|
959
|
-
onLoadAction
|
|
960
|
-
};
|
|
961
|
-
};
|
|
962
|
-
|
|
963
|
-
// src/hooks/core/use-get-specification.ts
|
|
964
|
-
var import_react10 = require("react");
|
|
965
|
-
var useGetSpecification = ({
|
|
966
|
-
model,
|
|
967
|
-
viewData,
|
|
968
|
-
fields
|
|
969
|
-
}) => {
|
|
970
|
-
const baseModel = (0, import_react10.useMemo)(
|
|
971
|
-
() => ({
|
|
972
|
-
name: String(model),
|
|
973
|
-
view: viewData,
|
|
974
|
-
fields
|
|
975
|
-
}),
|
|
976
|
-
[model, viewData, fields]
|
|
977
|
-
);
|
|
978
|
-
const initModel = (0, import_hooks2.useModel)();
|
|
979
|
-
const modelInstance = (0, import_react10.useMemo)(() => {
|
|
980
|
-
if (viewData) {
|
|
981
|
-
return initModel.initModel(baseModel);
|
|
982
|
-
}
|
|
983
|
-
return null;
|
|
984
|
-
}, [baseModel, viewData, model]);
|
|
985
|
-
const specification = (0, import_react10.useMemo)(() => {
|
|
986
|
-
if (modelInstance) {
|
|
987
|
-
return modelInstance.getSpecification();
|
|
988
|
-
}
|
|
989
|
-
return null;
|
|
990
|
-
}, [modelInstance, model]);
|
|
991
|
-
return { specification };
|
|
992
|
-
};
|
|
993
|
-
|
|
994
|
-
// src/hooks/core/use-list-data.ts
|
|
995
|
-
var import_react13 = require("react");
|
|
996
|
-
var import_utils5 = require("@fctc/interface-logic/utils");
|
|
997
|
-
|
|
998
|
-
// src/hooks/utils/use-debounce.ts
|
|
999
|
-
var import_react11 = require("react");
|
|
1000
|
-
function useDebounce(value, delay) {
|
|
1001
|
-
const [debouncedValue, setDebouncedValue] = (0, import_react11.useState)(value);
|
|
1002
|
-
(0, import_react11.useEffect)(() => {
|
|
1003
|
-
const handler = setTimeout(() => {
|
|
1004
|
-
setDebouncedValue(value);
|
|
1005
|
-
}, delay);
|
|
1006
|
-
return () => {
|
|
1007
|
-
clearTimeout(handler);
|
|
1008
|
-
};
|
|
1009
|
-
}, [value, delay]);
|
|
1010
|
-
return [debouncedValue];
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
// src/hooks/utils/use-get-rowids.ts
|
|
1014
|
-
var import_react12 = require("react");
|
|
1015
|
-
var useGetRowIds = (tableRef) => {
|
|
1016
|
-
function isElementVisible(el) {
|
|
1017
|
-
const style = window.getComputedStyle(el);
|
|
1018
|
-
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
|
1019
|
-
}
|
|
1020
|
-
function arraysAreEqual(a, b) {
|
|
1021
|
-
if (a.length !== b.length) return false;
|
|
1022
|
-
if (a.length === 0 && b.length === 0) return true;
|
|
1023
|
-
const setA = new Set(a);
|
|
1024
|
-
const setB = new Set(b);
|
|
1025
|
-
if (setA.size !== setB.size) return false;
|
|
1026
|
-
for (const val of setA) {
|
|
1027
|
-
if (!setB.has(val)) return false;
|
|
1028
|
-
}
|
|
1029
|
-
return true;
|
|
1030
|
-
}
|
|
1031
|
-
const [rowIds, setRowIds] = (0, import_react12.useState)([]);
|
|
1032
|
-
const lastRowIdsRef = (0, import_react12.useRef)([]);
|
|
1033
|
-
const updateVisibleRowIds = (0, import_react12.useCallback)(() => {
|
|
1034
|
-
const table = tableRef.current;
|
|
1035
|
-
if (!table) return;
|
|
1036
|
-
const rows = table.querySelectorAll("tr[data-row-id]");
|
|
1037
|
-
const ids = [];
|
|
1038
|
-
rows.forEach((row) => {
|
|
1039
|
-
const el = row;
|
|
1040
|
-
if (isElementVisible(el)) {
|
|
1041
|
-
const id = el.getAttribute("data-row-id");
|
|
1042
|
-
if (id) ids.push(id);
|
|
1043
|
-
}
|
|
1044
|
-
});
|
|
1045
|
-
const uniqueIds = Array.from(new Set(ids));
|
|
1046
|
-
if (!arraysAreEqual(lastRowIdsRef.current, uniqueIds)) {
|
|
1047
|
-
lastRowIdsRef.current = uniqueIds;
|
|
1048
|
-
setRowIds(uniqueIds);
|
|
1049
|
-
}
|
|
1050
|
-
}, [tableRef]);
|
|
1051
|
-
(0, import_react12.useEffect)(() => {
|
|
1052
|
-
const table = tableRef.current;
|
|
1053
|
-
if (!table) return;
|
|
1054
|
-
const mutationObserver = new MutationObserver(() => {
|
|
1055
|
-
updateVisibleRowIds();
|
|
1056
|
-
});
|
|
1057
|
-
mutationObserver.observe(table, {
|
|
1058
|
-
childList: true,
|
|
1059
|
-
subtree: true,
|
|
1060
|
-
attributes: true,
|
|
1061
|
-
attributeFilter: ["style", "class"]
|
|
1062
|
-
});
|
|
1063
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
1064
|
-
updateVisibleRowIds();
|
|
1065
|
-
});
|
|
1066
|
-
resizeObserver.observe(table);
|
|
1067
|
-
const handleScroll = () => updateVisibleRowIds();
|
|
1068
|
-
table.addEventListener("scroll", handleScroll, true);
|
|
1069
|
-
updateVisibleRowIds();
|
|
1070
|
-
return () => {
|
|
1071
|
-
mutationObserver.disconnect();
|
|
1072
|
-
resizeObserver.disconnect();
|
|
1073
|
-
table.removeEventListener("scroll", handleScroll, true);
|
|
1074
|
-
};
|
|
1075
|
-
}, [updateVisibleRowIds, tableRef?.current]);
|
|
1076
|
-
return { rowIds, refresh: updateVisibleRowIds };
|
|
1077
|
-
};
|
|
1078
|
-
|
|
1079
|
-
// src/hooks/core/use-list-data.ts
|
|
1080
|
-
var useListData = ({
|
|
1081
|
-
action,
|
|
1082
|
-
context,
|
|
1083
|
-
viewData,
|
|
1084
|
-
model,
|
|
1085
|
-
service,
|
|
1086
|
-
xNode,
|
|
1087
|
-
mode,
|
|
1088
|
-
limit = 10
|
|
1089
|
-
}) => {
|
|
1090
|
-
const { useGetListData: useGetListData2 } = (0, provider_exports.useService)();
|
|
1091
|
-
const [page, setPage] = (0, import_react13.useState)(0);
|
|
1092
|
-
const [pageLimit, setPageLimit] = (0, import_react13.useState)(limit);
|
|
1093
|
-
const [groupByList, setGroupByList] = (0, import_react13.useState)(null);
|
|
1094
|
-
const [domain, setDomain] = (0, import_react13.useState)(null);
|
|
1095
|
-
const [order, setOrder] = (0, import_react13.useState)("");
|
|
1096
|
-
const [selectedRowKeys, setSelectedRowKeys] = (0, import_react13.useState)([]);
|
|
1097
|
-
const [debouncedPage] = useDebounce(page, 500);
|
|
1098
|
-
const [debouncedDomain] = useDebounce(domain, 500);
|
|
1099
|
-
const { specification } = useGetSpecification({
|
|
1100
|
-
model,
|
|
1101
|
-
viewData,
|
|
1102
|
-
fields: mode === "kanban" ? viewData?.views?.kanban?.fields : viewData?.views?.list?.fields
|
|
1103
|
-
});
|
|
1104
|
-
const listDataProps = (0, import_react13.useMemo)(() => {
|
|
1105
|
-
if (!viewData || !action || !context) {
|
|
1106
|
-
return null;
|
|
1107
|
-
}
|
|
1108
|
-
const domainParse = domain ? [...domain] : action?.domain ? Array.isArray(action?.domain) ? [...action?.domain] : (0, import_utils5.evalJSONDomain)(action?.domain, context) : [];
|
|
1109
|
-
const limit2 = pageLimit;
|
|
1110
|
-
const offset = debouncedPage * pageLimit;
|
|
1111
|
-
const fields = typeof groupByList === "object" ? groupByList?.fields : void 0;
|
|
1112
|
-
const groupby = typeof groupByList === "object" ? [groupByList?.contexts?.[0]?.group_by] : [];
|
|
1113
|
-
const sort = order ?? (0, import_utils5.formatSortingString)(
|
|
1114
|
-
(mode === "kanban" ? viewData?.views?.kanban : viewData?.views?.list)?.default_order
|
|
1115
|
-
) ?? "";
|
|
1116
|
-
return {
|
|
1117
|
-
model: action?.res_model,
|
|
1118
|
-
specification,
|
|
1119
|
-
domain: domainParse,
|
|
1120
|
-
limit: limit2,
|
|
1121
|
-
offset,
|
|
1122
|
-
fields,
|
|
1123
|
-
groupby,
|
|
1124
|
-
context,
|
|
1125
|
-
sort,
|
|
1126
|
-
mode
|
|
1127
|
-
};
|
|
1128
|
-
}, [
|
|
1129
|
-
action,
|
|
1130
|
-
groupByList,
|
|
1131
|
-
order,
|
|
1132
|
-
debouncedPage,
|
|
1133
|
-
pageLimit,
|
|
1134
|
-
debouncedDomain,
|
|
1135
|
-
context,
|
|
1136
|
-
model
|
|
1137
|
-
]);
|
|
1138
|
-
const list = useGetListData2(
|
|
1139
|
-
{ ...listDataProps },
|
|
1140
|
-
[
|
|
1141
|
-
listDataProps?.domain,
|
|
1142
|
-
listDataProps?.groupby,
|
|
1143
|
-
listDataProps?.limit,
|
|
1144
|
-
listDataProps?.offset,
|
|
1145
|
-
listDataProps?.sort,
|
|
1146
|
-
listDataProps?.context,
|
|
1147
|
-
listDataProps?.specification,
|
|
1148
|
-
listDataProps?.mode
|
|
1149
|
-
],
|
|
1150
|
-
!!listDataProps && !!specification && !isObjectEmpty(specification) && !!domain,
|
|
1151
|
-
service,
|
|
1152
|
-
xNode
|
|
1153
|
-
);
|
|
1154
|
-
return {
|
|
1155
|
-
...list,
|
|
1156
|
-
state: {
|
|
1157
|
-
specification,
|
|
1158
|
-
page,
|
|
1159
|
-
order,
|
|
1160
|
-
domain: listDataProps?.domain,
|
|
1161
|
-
pageLimit,
|
|
1162
|
-
groupByList,
|
|
1163
|
-
selectedRowKeys,
|
|
1164
|
-
setPage,
|
|
1165
|
-
setOrder,
|
|
1166
|
-
setDomain,
|
|
1167
|
-
setPageLimit,
|
|
1168
|
-
setGroupByList,
|
|
1169
|
-
setSelectedRowKeys
|
|
1170
|
-
}
|
|
1171
|
-
};
|
|
1172
|
-
};
|
|
1173
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
1174
|
-
0 && (module.exports = {
|
|
1175
|
-
AppProvider,
|
|
1176
|
-
useAddEntity,
|
|
1177
|
-
useAppProvider,
|
|
1178
|
-
useButton,
|
|
1179
|
-
useCallAction,
|
|
1180
|
-
useChangeOrderPreparationState,
|
|
1181
|
-
useChangeStatus,
|
|
1182
|
-
useCheckPayment,
|
|
1183
|
-
useCompany,
|
|
1184
|
-
useConfig,
|
|
1185
|
-
useCreateEntity,
|
|
1186
|
-
useCreatePosConfig,
|
|
1187
|
-
useCreateSession,
|
|
1188
|
-
useDebounce,
|
|
1189
|
-
useDelete,
|
|
1190
|
-
useDeleteComment,
|
|
1191
|
-
useDeleteEntity,
|
|
1192
|
-
useDetail,
|
|
1193
|
-
useDuplicateRecord,
|
|
1194
|
-
useExecuteImport,
|
|
1195
|
-
useExportExcel,
|
|
1196
|
-
useForgotPassword,
|
|
1197
|
-
useForgotPasswordSSO,
|
|
1198
|
-
useGenSerialNumber,
|
|
1199
|
-
useGeneratePaymentQrInfo,
|
|
1200
|
-
useGet2FAMethods,
|
|
1201
|
-
useGetASession,
|
|
1202
|
-
useGetAccessByCode,
|
|
1203
|
-
useGetAction,
|
|
1204
|
-
useGetActionDetail,
|
|
1205
|
-
useGetAll,
|
|
1206
|
-
useGetCalendar,
|
|
1207
|
-
useGetComment,
|
|
1208
|
-
useGetCompanyInfo,
|
|
1209
|
-
useGetConversionRate,
|
|
1210
|
-
useGetCurrency,
|
|
1211
|
-
useGetCurrentCompany,
|
|
1212
|
-
useGetDetail,
|
|
1213
|
-
useGetExternalTabs,
|
|
1214
|
-
useGetFieldExport,
|
|
1215
|
-
useGetFieldOnChange,
|
|
1216
|
-
useGetFileExcel,
|
|
1217
|
-
useGetFormView,
|
|
1218
|
-
useGetGroups,
|
|
1219
|
-
useGetList,
|
|
1220
|
-
useGetListCompany,
|
|
1221
|
-
useGetListData,
|
|
1222
|
-
useGetListMyBankAccount,
|
|
1223
|
-
useGetMenu,
|
|
1224
|
-
useGetOrderLine,
|
|
1225
|
-
useGetPinCode,
|
|
1226
|
-
useGetPrintReport,
|
|
1227
|
-
useGetProGressBar,
|
|
1228
|
-
useGetProfile,
|
|
1229
|
-
useGetProvider,
|
|
1230
|
-
useGetResequence,
|
|
1231
|
-
useGetRowIds,
|
|
1232
|
-
useGetSelection,
|
|
1233
|
-
useGetSpecification,
|
|
1234
|
-
useGetUser,
|
|
1235
|
-
useGetView,
|
|
1236
|
-
useGrantAccess,
|
|
1237
|
-
useIsValidToken,
|
|
1238
|
-
useListData,
|
|
1239
|
-
useLoadAction,
|
|
1240
|
-
useLoadMessage,
|
|
1241
|
-
useLoginCredential,
|
|
1242
|
-
useLoginSocial,
|
|
1243
|
-
useLogout,
|
|
1244
|
-
useMenu,
|
|
1245
|
-
useModel,
|
|
1246
|
-
useOdooDataTransform,
|
|
1247
|
-
useOnChangeForm,
|
|
1248
|
-
useParsePreview,
|
|
1249
|
-
usePrint,
|
|
1250
|
-
useProfile,
|
|
1251
|
-
useReadGroup,
|
|
1252
|
-
useRemoveRow,
|
|
1253
|
-
useRemoveTotpSetup,
|
|
1254
|
-
useRequestSetupTotp,
|
|
1255
|
-
useResetPassword,
|
|
1256
|
-
useResetPasswordSSO,
|
|
1257
|
-
useRunAction,
|
|
1258
|
-
useSave,
|
|
1259
|
-
useSendComment,
|
|
1260
|
-
useSettingsWebRead2fa,
|
|
1261
|
-
useSignInSSO,
|
|
1262
|
-
useSwitchLocale,
|
|
1263
|
-
useUpdatePassword,
|
|
1264
|
-
useUploadFile,
|
|
1265
|
-
useUploadFileExcel,
|
|
1266
|
-
useUploadIdFile,
|
|
1267
|
-
useUploadImage,
|
|
1268
|
-
useUser,
|
|
1269
|
-
useValidateActionToken,
|
|
1270
|
-
useVerify2FA,
|
|
1271
|
-
useVerifyTotp,
|
|
1272
|
-
useViewV2
|
|
1273
|
-
});
|