@fctc/widget-logic 2.4.3 → 2.4.6
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/dist/hooks.d.mts +559 -346
- package/dist/hooks.d.ts +559 -346
- package/dist/hooks.js +604 -480
- package/dist/hooks.mjs +615 -498
- package/dist/index.d.mts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.js +706 -612
- package/dist/index.mjs +799 -647
- package/dist/utils.d.mts +1 -9
- package/dist/utils.d.ts +1 -9
- package/dist/utils.js +0 -12
- package/dist/utils.mjs +0 -10
- package/dist/widget.d.mts +6 -6
- package/dist/widget.d.ts +6 -6
- package/dist/widget.js +168 -713
- package/dist/widget.mjs +258 -745
- package/package.json +2 -2
package/dist/hooks.js
CHANGED
|
@@ -23,116 +23,204 @@ var hooks_exports = {};
|
|
|
23
23
|
__export(hooks_exports, {
|
|
24
24
|
AppProvider: () => AppProvider,
|
|
25
25
|
useAppProvider: () => useAppProvider,
|
|
26
|
-
|
|
26
|
+
useButton: () => import_hooks2.useButton,
|
|
27
27
|
useCallAction: () => useCallAction,
|
|
28
|
+
useChangeStatus: () => import_hooks2.useChangeStatus,
|
|
28
29
|
useClickOutside: () => useClickOutside,
|
|
30
|
+
useCompany: () => useCompany,
|
|
29
31
|
useConfig: () => useConfig,
|
|
30
32
|
useDebounce: () => useDebounce,
|
|
33
|
+
useDelete: () => import_hooks2.useDelete,
|
|
34
|
+
useDeleteComment: () => import_hooks2.useDeleteComment,
|
|
31
35
|
useDetail: () => useDetail,
|
|
36
|
+
useDuplicateRecord: () => import_hooks2.useDuplicateRecord,
|
|
37
|
+
useExecuteImport: () => import_hooks2.useExecuteImport,
|
|
38
|
+
useExportExcel: () => import_hooks2.useExportExcel,
|
|
39
|
+
useForgotPassword: () => import_hooks2.useForgotPassword,
|
|
40
|
+
useForgotPasswordSSO: () => import_hooks2.useForgotPasswordSSO,
|
|
41
|
+
useGet2FAMethods: () => import_hooks2.useGet2FAMethods,
|
|
42
|
+
useGetAccessByCode: () => import_hooks2.useGetAccessByCode,
|
|
43
|
+
useGetAction: () => useGetAction,
|
|
44
|
+
useGetActionDetail: () => import_hooks2.useGetActionDetail,
|
|
45
|
+
useGetAll: () => import_hooks2.useGetAll,
|
|
46
|
+
useGetCalendar: () => import_hooks2.useGetCalendar,
|
|
47
|
+
useGetComment: () => import_hooks2.useGetComment,
|
|
48
|
+
useGetCompanyInfo: () => import_hooks2.useGetCompanyInfo,
|
|
49
|
+
useGetConversionRate: () => import_hooks2.useGetConversionRate,
|
|
50
|
+
useGetCurrency: () => import_hooks2.useGetCurrency,
|
|
51
|
+
useGetCurrentCompany: () => import_hooks2.useGetCurrentCompany,
|
|
52
|
+
useGetDetail: () => import_hooks2.useGetDetail,
|
|
53
|
+
useGetFieldExport: () => import_hooks2.useGetFieldExport,
|
|
54
|
+
useGetFieldOnChange: () => import_hooks2.useGetFieldOnChange,
|
|
55
|
+
useGetFileExcel: () => import_hooks2.useGetFileExcel,
|
|
56
|
+
useGetFormView: () => import_hooks2.useGetFormView,
|
|
57
|
+
useGetGroups: () => import_hooks2.useGetGroups,
|
|
58
|
+
useGetImage: () => import_hooks2.useGetImage,
|
|
59
|
+
useGetListCompany: () => import_hooks2.useGetListCompany,
|
|
60
|
+
useGetListData: () => import_hooks2.useGetListData,
|
|
61
|
+
useGetListMyBankAccount: () => import_hooks2.useGetListMyBankAccount,
|
|
62
|
+
useGetMenu: () => import_hooks2.useGetMenu,
|
|
63
|
+
useGetPrintReport: () => import_hooks2.useGetPrintReport,
|
|
64
|
+
useGetProGressBar: () => import_hooks2.useGetProGressBar,
|
|
65
|
+
useGetProfile: () => import_hooks2.useGetProfile,
|
|
66
|
+
useGetProvider: () => import_hooks2.useGetProvider,
|
|
67
|
+
useGetResequence: () => import_hooks2.useGetResequence,
|
|
32
68
|
useGetRowIds: () => useGetRowIds,
|
|
69
|
+
useGetSelection: () => import_hooks2.useGetSelection,
|
|
70
|
+
useGetSpecification: () => useGetSpecification,
|
|
71
|
+
useGetUser: () => import_hooks2.useGetUser,
|
|
72
|
+
useGetView: () => import_hooks2.useGetView,
|
|
73
|
+
useGrantAccess: () => import_hooks2.useGrantAccess,
|
|
74
|
+
useIsValidToken: () => import_hooks2.useIsValidToken,
|
|
33
75
|
useListData: () => useListData,
|
|
76
|
+
useLoadAction: () => import_hooks2.useLoadAction,
|
|
77
|
+
useLoadMessage: () => import_hooks2.useLoadMessage,
|
|
78
|
+
useLoginCredential: () => import_hooks2.useLoginCredential,
|
|
79
|
+
useLoginSocial: () => import_hooks2.useLoginSocial,
|
|
80
|
+
useLogout: () => import_hooks2.useLogout,
|
|
34
81
|
useMenu: () => useMenu,
|
|
35
|
-
|
|
82
|
+
useModel: () => import_hooks2.useModel,
|
|
83
|
+
useOdooDataTransform: () => import_hooks2.useOdooDataTransform,
|
|
84
|
+
useOnChangeForm: () => import_hooks2.useOnChangeForm,
|
|
85
|
+
useParsePreview: () => import_hooks2.useParsePreview,
|
|
86
|
+
usePrint: () => import_hooks2.usePrint,
|
|
36
87
|
useProfile: () => useProfile,
|
|
88
|
+
useRemoveRow: () => import_hooks2.useRemoveRow,
|
|
89
|
+
useRemoveTotpSetup: () => import_hooks2.useRemoveTotpSetup,
|
|
90
|
+
useRequestSetupTotp: () => import_hooks2.useRequestSetupTotp,
|
|
91
|
+
useResetPassword: () => import_hooks2.useResetPassword,
|
|
92
|
+
useResetPasswordSSO: () => import_hooks2.useResetPasswordSSO,
|
|
93
|
+
useRunAction: () => import_hooks2.useRunAction,
|
|
94
|
+
useSave: () => import_hooks2.useSave,
|
|
95
|
+
useSendComment: () => import_hooks2.useSendComment,
|
|
96
|
+
useSettingsWebRead2fa: () => import_hooks2.useSettingsWebRead2fa,
|
|
97
|
+
useSignInSSO: () => import_hooks2.useSignInSSO,
|
|
98
|
+
useSwitchLocale: () => import_hooks2.useSwitchLocale,
|
|
99
|
+
useUpdatePassword: () => import_hooks2.useUpdatePassword,
|
|
100
|
+
useUploadFile: () => import_hooks2.useUploadFile,
|
|
101
|
+
useUploadFileExcel: () => import_hooks2.useUploadFileExcel,
|
|
102
|
+
useUploadIdFile: () => import_hooks2.useUploadIdFile,
|
|
103
|
+
useUploadImage: () => import_hooks2.useUploadImage,
|
|
37
104
|
useUser: () => useUser,
|
|
105
|
+
useValidateActionToken: () => import_hooks2.useValidateActionToken,
|
|
106
|
+
useVerify2FA: () => import_hooks2.useVerify2FA,
|
|
107
|
+
useVerifyTotp: () => import_hooks2.useVerifyTotp,
|
|
38
108
|
useViewV2: () => useViewV2
|
|
39
109
|
});
|
|
40
110
|
module.exports = __toCommonJS(hooks_exports);
|
|
111
|
+
var import_hooks2 = require("@fctc/interface-logic/hooks");
|
|
112
|
+
|
|
113
|
+
// src/hooks/core/use-app-provider.tsx
|
|
114
|
+
var import_react8 = require("react");
|
|
115
|
+
|
|
116
|
+
// src/hooks/core/use-menu.ts
|
|
117
|
+
var import_react2 = require("react");
|
|
41
118
|
|
|
42
119
|
// src/hooks/core/use-call-action.ts
|
|
43
120
|
var import_react = require("react");
|
|
44
|
-
|
|
45
|
-
|
|
121
|
+
|
|
122
|
+
// src/provider.ts
|
|
123
|
+
var provider_exports = {};
|
|
124
|
+
__reExport(provider_exports, require("@fctc/interface-logic/provider"));
|
|
125
|
+
|
|
126
|
+
// src/hooks/core/use-call-action.ts
|
|
46
127
|
var useCallAction = () => {
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
128
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
129
|
+
const { useLoadAction: useLoadAction2, useRunAction: useRunAction2 } = (0, provider_exports.useService)();
|
|
130
|
+
const queryLoadAction = useLoadAction2();
|
|
131
|
+
const queryRunAction = useRunAction2();
|
|
132
|
+
const [actionData, setActionData] = (0, import_react.useState)(
|
|
133
|
+
void 0
|
|
134
|
+
);
|
|
135
|
+
const callAction = (0, import_react.useCallback)(
|
|
136
|
+
async ({
|
|
137
|
+
aid
|
|
138
|
+
}) => {
|
|
139
|
+
try {
|
|
140
|
+
const loadRes = await queryLoadAction.mutateAsync({
|
|
141
|
+
idAction: aid,
|
|
142
|
+
context: env.context
|
|
143
|
+
});
|
|
144
|
+
if (loadRes?.result?.type === "ir.actions.server") {
|
|
145
|
+
const runRes = await queryRunAction.mutateAsync({
|
|
146
|
+
idAction: aid,
|
|
147
|
+
context: env.context
|
|
148
|
+
});
|
|
149
|
+
setActionData(runRes?.result);
|
|
150
|
+
return runRes?.result;
|
|
151
|
+
} else {
|
|
152
|
+
setActionData(loadRes?.result);
|
|
153
|
+
return loadRes?.result;
|
|
154
|
+
}
|
|
155
|
+
} catch (err) {
|
|
156
|
+
console.error("callAction error:", err);
|
|
157
|
+
return void 0;
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
[env?.context?.lang]
|
|
161
|
+
);
|
|
162
|
+
return [actionData, callAction];
|
|
71
163
|
};
|
|
72
164
|
|
|
73
|
-
// src/hooks/core/use-
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
env.setupEnv({
|
|
107
|
-
baseUrl: envConfig.baseUrl,
|
|
108
|
-
port: 3e3,
|
|
109
|
-
config: {
|
|
110
|
-
grantType: envConfig.config.grantType,
|
|
111
|
-
clientId: envConfig.config.clientId,
|
|
112
|
-
clientSecret: envConfig.config.clientSecret
|
|
113
|
-
},
|
|
114
|
-
db: "preschool",
|
|
115
|
-
localStorageUtils: localStorageUtils(),
|
|
116
|
-
sessionStorageUtils: sessionStorageUtils()
|
|
165
|
+
// src/hooks/core/use-menu.ts
|
|
166
|
+
var useMenu = ({
|
|
167
|
+
context,
|
|
168
|
+
specification
|
|
169
|
+
}) => {
|
|
170
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
171
|
+
const { useGetMenu: useGetMenu2 } = (0, provider_exports.useService)();
|
|
172
|
+
const [action, callAction] = useCallAction();
|
|
173
|
+
const menuData = useGetMenu2(context, specification, !!context);
|
|
174
|
+
const [menuId, setMenuId] = (0, import_react2.useState)(void 0);
|
|
175
|
+
const configedIconData = (0, import_react2.useMemo)(() => {
|
|
176
|
+
const data = menuData.data;
|
|
177
|
+
return data?.map((item) => {
|
|
178
|
+
return {
|
|
179
|
+
...item,
|
|
180
|
+
child_id: item?.child_id?.map((child) => {
|
|
181
|
+
return {
|
|
182
|
+
...child,
|
|
183
|
+
url_icon: env?.envFile?.VITE_APP_DOMAIN + "/" + child.url_icon
|
|
184
|
+
};
|
|
185
|
+
}) ?? [],
|
|
186
|
+
url_icon: env?.envFile?.VITE_APP_DOMAIN + "/" + item.url_icon
|
|
187
|
+
};
|
|
188
|
+
});
|
|
189
|
+
}, [menuData.data, env?.envFile?.VITE_APP_DOMAIN]);
|
|
190
|
+
const handleChangeMenu = async ({ menu }) => {
|
|
191
|
+
const aidMenu = menu?.action?.id?.id;
|
|
192
|
+
if (menu) {
|
|
193
|
+
setMenuId(menu.id?.toString() ?? "");
|
|
194
|
+
}
|
|
195
|
+
if (aidMenu) {
|
|
196
|
+
const actionResponse = await callAction({
|
|
197
|
+
aid: Number(aidMenu)
|
|
117
198
|
});
|
|
118
|
-
|
|
119
|
-
} catch (error) {
|
|
120
|
-
console.error("Error loading env or config:", error);
|
|
199
|
+
return actionResponse;
|
|
121
200
|
}
|
|
122
|
-
}
|
|
123
|
-
return {
|
|
201
|
+
};
|
|
202
|
+
return {
|
|
203
|
+
...menuData,
|
|
204
|
+
data: configedIconData,
|
|
205
|
+
action: { handleChangeMenu },
|
|
206
|
+
state: { menuId, action },
|
|
207
|
+
context,
|
|
208
|
+
isLoading: menuData.isLoading,
|
|
209
|
+
isError: menuData.isError,
|
|
210
|
+
error: menuData.error,
|
|
211
|
+
refetch: menuData.refetch
|
|
212
|
+
};
|
|
124
213
|
};
|
|
125
214
|
|
|
126
215
|
// src/hooks/core/use-detail.ts
|
|
127
|
-
var import_store2 = require("@fctc/interface-logic/store");
|
|
128
216
|
var import_react_query = require("@tanstack/react-query");
|
|
129
217
|
var import_react3 = require("react");
|
|
130
|
-
var
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
const fetchGetDetail = (
|
|
218
|
+
var useDetail = (sub) => {
|
|
219
|
+
const { setUserInfo, env } = (0, provider_exports.useEnv)();
|
|
220
|
+
const { useGetDetail: useGetDetail2 } = (0, provider_exports.useService)();
|
|
221
|
+
const fetchGetDetail = useGetDetail2();
|
|
134
222
|
const userDetailQuery = (0, import_react_query.useQuery)({
|
|
135
|
-
queryKey: ["userDetailQuery", sub
|
|
223
|
+
queryKey: ["userDetailQuery", sub],
|
|
136
224
|
queryFn: () => {
|
|
137
225
|
return fetchGetDetail.mutateAsync({
|
|
138
226
|
model: "res.users",
|
|
@@ -140,21 +228,41 @@ var useDetail = (accessToken, sub) => {
|
|
|
140
228
|
specification: { image_256: {} }
|
|
141
229
|
});
|
|
142
230
|
},
|
|
143
|
-
enabled: !!sub
|
|
231
|
+
enabled: !!sub
|
|
144
232
|
});
|
|
145
233
|
(0, import_react3.useEffect)(() => {
|
|
146
234
|
if (userDetailQuery.data) {
|
|
147
235
|
const userPicture = userDetailQuery.data;
|
|
148
|
-
|
|
149
|
-
(0, import_store2.setProfile)({ ...userPicture, image: userPicture?.[0]?.image_256 })
|
|
150
|
-
);
|
|
236
|
+
setUserInfo({ ...env?.user, image: userPicture?.[0]?.image_256 });
|
|
151
237
|
}
|
|
152
|
-
}, [userDetailQuery.
|
|
153
|
-
return userDetailQuery;
|
|
238
|
+
}, [userDetailQuery.isFetched]);
|
|
239
|
+
return { ...userDetailQuery };
|
|
154
240
|
};
|
|
155
241
|
|
|
156
|
-
// src/hooks/core/use-
|
|
242
|
+
// src/hooks/core/use-profile.ts
|
|
243
|
+
var import_react_query2 = require("@tanstack/react-query");
|
|
157
244
|
var import_react5 = require("react");
|
|
245
|
+
var import_react_i18next = require("react-i18next");
|
|
246
|
+
|
|
247
|
+
// src/utils.ts
|
|
248
|
+
var utils_exports = {};
|
|
249
|
+
__export(utils_exports, {
|
|
250
|
+
STORAGES: () => STORAGES,
|
|
251
|
+
combineContexts: () => combineContexts,
|
|
252
|
+
convertFieldsToArray: () => convertFieldsToArray,
|
|
253
|
+
countSum: () => countSum,
|
|
254
|
+
getDateRange: () => getDateRange,
|
|
255
|
+
languages: () => languages,
|
|
256
|
+
mergeButtons: () => mergeButtons,
|
|
257
|
+
setStorageItemAsync: () => setStorageItemAsync,
|
|
258
|
+
useStorageState: () => useStorageState
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
// src/utils/constants.ts
|
|
262
|
+
var languages = [
|
|
263
|
+
{ id: "vi_VN", name: "VIE" },
|
|
264
|
+
{ id: "en_US", name: "ENG" }
|
|
265
|
+
];
|
|
158
266
|
|
|
159
267
|
// src/utils/function.ts
|
|
160
268
|
var import_react4 = require("react");
|
|
@@ -314,180 +422,31 @@ function useStorageState(key) {
|
|
|
314
422
|
return [state, setValue];
|
|
315
423
|
}
|
|
316
424
|
|
|
317
|
-
// src/
|
|
318
|
-
|
|
319
|
-
var import_store3 = require("@fctc/interface-logic/store");
|
|
320
|
-
var import_utils = require("@fctc/interface-logic/utils");
|
|
321
|
-
var useListData = ({
|
|
322
|
-
action,
|
|
323
|
-
context,
|
|
324
|
-
viewResponse
|
|
325
|
-
}) => {
|
|
326
|
-
const { groupByDomain } = (0, import_store3.useAppSelector)(import_store3.selectSearch);
|
|
327
|
-
const initModel = (0, import_hooks3.useModel)();
|
|
328
|
-
const [type, setType] = (0, import_react5.useState)("list");
|
|
329
|
-
const [mode, setMode] = (0, import_react5.useState)("month");
|
|
330
|
-
const [currentDate, setCurrentDate] = (0, import_react5.useState)(/* @__PURE__ */ new Date());
|
|
331
|
-
const { pageLimit, page, order } = (0, import_store3.useAppSelector)(import_store3.selectList);
|
|
332
|
-
const listDataProps = (0, import_react5.useMemo)(() => {
|
|
333
|
-
const actData = action?.result;
|
|
334
|
-
if (!viewResponse || !actData || !context) {
|
|
335
|
-
return null;
|
|
336
|
-
}
|
|
337
|
-
const specification = initModel.initModel({
|
|
338
|
-
name: String(actData.res_model),
|
|
339
|
-
view: viewResponse || {},
|
|
340
|
-
actContext: context,
|
|
341
|
-
fields: type === "kanban" ? viewResponse?.views?.kanban?.fields : type === "calendar" ? viewResponse?.views?.calendar?.fields : viewResponse?.views?.list?.fields
|
|
342
|
-
}).getSpecification();
|
|
343
|
-
const domain = type === "calendar" ? getDateRange(currentDate, mode) : actData?.domain ? Array.isArray(actData?.domain) ? [...actData?.domain] : (0, import_utils.evalJSONDomain)(actData?.domain, context) : [];
|
|
344
|
-
const limit = type === "calendar" ? 2500 : pageLimit;
|
|
345
|
-
const offset = page * pageLimit;
|
|
346
|
-
const fields = type === "calendar" ? convertFieldsToArray(viewResponse?.views?.calendar?.fields) || [] : typeof groupByDomain === "object" ? groupByDomain?.fields : void 0;
|
|
347
|
-
const groupby = typeof groupByDomain === "object" ? [groupByDomain?.contexts?.[0]?.group_by] : [];
|
|
348
|
-
const sort = order ? order : viewResponse?.views?.list?.default_order ? (0, import_utils.formatSortingString)(viewResponse?.views?.list?.default_order) : "";
|
|
349
|
-
return {
|
|
350
|
-
model: actData.res_model,
|
|
351
|
-
specification,
|
|
352
|
-
domain,
|
|
353
|
-
limit,
|
|
354
|
-
offset,
|
|
355
|
-
fields,
|
|
356
|
-
groupby,
|
|
357
|
-
context,
|
|
358
|
-
sort,
|
|
359
|
-
type
|
|
360
|
-
};
|
|
361
|
-
}, [
|
|
362
|
-
action?.result,
|
|
363
|
-
context,
|
|
364
|
-
currentDate,
|
|
365
|
-
groupByDomain,
|
|
366
|
-
initModel,
|
|
367
|
-
mode,
|
|
368
|
-
order,
|
|
369
|
-
page,
|
|
370
|
-
pageLimit,
|
|
371
|
-
type,
|
|
372
|
-
viewResponse
|
|
373
|
-
]);
|
|
374
|
-
const list = (0, import_hooks3.useGetListData)(
|
|
375
|
-
listDataProps,
|
|
376
|
-
[listDataProps],
|
|
377
|
-
!!listDataProps
|
|
378
|
-
);
|
|
379
|
-
return {
|
|
380
|
-
...list,
|
|
381
|
-
state: {
|
|
382
|
-
type,
|
|
383
|
-
setType,
|
|
384
|
-
mode,
|
|
385
|
-
setMode,
|
|
386
|
-
currentDate,
|
|
387
|
-
setCurrentDate
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
// src/hooks/core/use-menu.ts
|
|
393
|
-
var import_react6 = require("react");
|
|
394
|
-
|
|
395
|
-
// src/utils/constants.ts
|
|
396
|
-
var languages = [
|
|
397
|
-
{ id: "vi_VN", name: "VIE" },
|
|
398
|
-
{ id: "en_US", name: "ENG" }
|
|
399
|
-
];
|
|
400
|
-
var API_PRESCHOOL_URL = {
|
|
401
|
-
baseURL: "https://preschool.vitrust.app"
|
|
402
|
-
};
|
|
403
|
-
var API_APP_URL = {
|
|
404
|
-
baseUrl: "https://api.vitrust.app",
|
|
405
|
-
c2: "https://api.vitrust.app/c2",
|
|
406
|
-
apiV2: "https://api.vitrust.app/c2/api/v2"
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
// src/hooks/core/use-menu.ts
|
|
410
|
-
var import_hooks4 = require("@fctc/interface-logic/hooks");
|
|
411
|
-
var useMenu = ({ context }) => {
|
|
412
|
-
const menuData = (0, import_hooks4.useGetMenu)(context, !!context);
|
|
413
|
-
const [menuid, setMenuId] = (0, import_react6.useState)(void 0);
|
|
414
|
-
const [action, setAction] = useCallAction();
|
|
415
|
-
const configedIconData = (0, import_react6.useMemo)(() => {
|
|
416
|
-
const data = menuData.data;
|
|
417
|
-
return data?.map((item) => {
|
|
418
|
-
return {
|
|
419
|
-
...item,
|
|
420
|
-
child_id: item?.child_id?.map((child) => {
|
|
421
|
-
return {
|
|
422
|
-
...child,
|
|
423
|
-
url_icon: API_APP_URL.c2 + "/" + child.url_icon
|
|
424
|
-
};
|
|
425
|
-
}) ?? [],
|
|
426
|
-
url_icon: API_APP_URL.c2 + "/" + item.url_icon
|
|
427
|
-
};
|
|
428
|
-
});
|
|
429
|
-
}, [menuData.data]);
|
|
430
|
-
const handleChangeMenu = async ({
|
|
431
|
-
menu,
|
|
432
|
-
subMenu
|
|
433
|
-
}) => {
|
|
434
|
-
const aid = subMenu?.action?.id?.id;
|
|
435
|
-
const actionType = subMenu?.action?.type;
|
|
436
|
-
await setAction({
|
|
437
|
-
aid: Number(aid),
|
|
438
|
-
actionType
|
|
439
|
-
});
|
|
440
|
-
if (menu) {
|
|
441
|
-
setMenuId(menu.id?.toString() ?? "");
|
|
442
|
-
}
|
|
443
|
-
};
|
|
444
|
-
(0, import_react6.useEffect)(() => {
|
|
445
|
-
const firstRecord = configedIconData?.[0];
|
|
446
|
-
const firstChild = firstRecord?.child_id?.[0];
|
|
447
|
-
if (firstChild && firstRecord) {
|
|
448
|
-
handleChangeMenu({ menu: firstRecord, subMenu: firstChild });
|
|
449
|
-
}
|
|
450
|
-
}, [configedIconData]);
|
|
451
|
-
return {
|
|
452
|
-
...menuData,
|
|
453
|
-
data: configedIconData,
|
|
454
|
-
action: { handleChangeMenu },
|
|
455
|
-
state: { menuid, action },
|
|
456
|
-
context
|
|
457
|
-
};
|
|
458
|
-
};
|
|
425
|
+
// src/utils.ts
|
|
426
|
+
__reExport(utils_exports, require("@fctc/interface-logic/utils"));
|
|
459
427
|
|
|
460
428
|
// src/hooks/core/use-profile.ts
|
|
461
|
-
var
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
var import_hooks5 = require("@fctc/interface-logic/hooks");
|
|
466
|
-
var import_store4 = require("@fctc/interface-logic/store");
|
|
467
|
-
var useProfile = (accessToken) => {
|
|
468
|
-
const getProfile = (0, import_hooks5.useGetProfile)();
|
|
469
|
-
const dispatch = (0, import_store4.useAppDispatch)();
|
|
429
|
+
var useProfile = () => {
|
|
430
|
+
const { setUid, setLang, setUserInfo, env } = (0, provider_exports.useEnv)();
|
|
431
|
+
const { useGetProfile: useGetProfile2 } = (0, provider_exports.useService)();
|
|
432
|
+
const getProfile = useGetProfile2();
|
|
470
433
|
const { i18n } = (0, import_react_i18next.useTranslation)();
|
|
471
|
-
const fetchUserProfile = async () => {
|
|
472
|
-
return await getProfile.mutateAsync();
|
|
473
|
-
};
|
|
474
434
|
const userInfoQuery = (0, import_react_query2.useQuery)({
|
|
475
|
-
queryKey: ["userInfo"
|
|
476
|
-
queryFn:
|
|
477
|
-
enabled:
|
|
435
|
+
queryKey: ["userInfo"],
|
|
436
|
+
queryFn: () => getProfile.mutateAsync(),
|
|
437
|
+
enabled: (0, utils_exports.isObjectEmpty)(env?.user)
|
|
478
438
|
});
|
|
479
|
-
(0,
|
|
439
|
+
(0, import_react5.useEffect)(() => {
|
|
480
440
|
if (userInfoQuery.data) {
|
|
481
441
|
const userInfo = userInfoQuery.data;
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
dispatch((0, import_store4.setDataUser)(userInfo));
|
|
442
|
+
setUid(userInfo?.sub);
|
|
443
|
+
setUserInfo(userInfo);
|
|
485
444
|
const userLocale = languages.find((lang) => lang?.id === userInfo?.locale);
|
|
486
|
-
|
|
445
|
+
setLang(userLocale?.id);
|
|
487
446
|
i18n.changeLanguage(userLocale?.id.split("_")[0]);
|
|
488
447
|
}
|
|
489
|
-
}, [
|
|
490
|
-
const context = (0,
|
|
448
|
+
}, [userInfoQuery.isFetched]);
|
|
449
|
+
const context = (0, import_react5.useMemo)(() => {
|
|
491
450
|
if (userInfoQuery.data?.sub && userInfoQuery.data?.locale) {
|
|
492
451
|
return {
|
|
493
452
|
uid: Number(userInfoQuery.data.sub),
|
|
@@ -497,44 +456,42 @@ var useProfile = (accessToken) => {
|
|
|
497
456
|
};
|
|
498
457
|
}
|
|
499
458
|
return void 0;
|
|
500
|
-
}, [userInfoQuery.
|
|
459
|
+
}, [userInfoQuery.isFetched]);
|
|
460
|
+
if (userInfoQuery.isLoading || !userInfoQuery.data) {
|
|
461
|
+
return null;
|
|
462
|
+
}
|
|
501
463
|
return { ...userInfoQuery, context };
|
|
502
464
|
};
|
|
503
465
|
|
|
504
466
|
// src/hooks/core/use-user.ts
|
|
505
|
-
var useUser = (
|
|
506
|
-
const userProfile = useProfile(
|
|
507
|
-
const userDetail = useDetail(
|
|
508
|
-
return { userProfile, userDetail, context: userProfile
|
|
467
|
+
var useUser = () => {
|
|
468
|
+
const userProfile = useProfile();
|
|
469
|
+
const userDetail = useDetail(userProfile?.data?.sub);
|
|
470
|
+
return { userProfile, userDetail, context: userProfile?.context };
|
|
509
471
|
};
|
|
510
472
|
|
|
511
473
|
// src/hooks/core/use-view-v2.ts
|
|
512
|
-
var
|
|
513
|
-
var import_hooks6 = require("@fctc/interface-logic/hooks");
|
|
474
|
+
var import_react6 = require("react");
|
|
514
475
|
var useViewV2 = ({
|
|
515
476
|
action,
|
|
516
|
-
context
|
|
477
|
+
context,
|
|
478
|
+
aid,
|
|
479
|
+
views,
|
|
480
|
+
model
|
|
517
481
|
}) => {
|
|
518
|
-
const
|
|
519
|
-
|
|
482
|
+
const { useGetView: useGetView2 } = (0, provider_exports.useService)();
|
|
483
|
+
const viewParams = (0, import_react6.useMemo)(() => {
|
|
484
|
+
if (!action) {
|
|
520
485
|
return void 0;
|
|
521
486
|
}
|
|
522
|
-
const actionResult = action?.result;
|
|
523
487
|
return {
|
|
524
|
-
model
|
|
525
|
-
views
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
) : [],
|
|
529
|
-
[
|
|
530
|
-
Array.isArray(actionResult?.search_view_id) ? actionResult?.search_view_id[0] : actionResult?.search_view_id,
|
|
531
|
-
"search"
|
|
532
|
-
]
|
|
533
|
-
],
|
|
534
|
-
context
|
|
488
|
+
model,
|
|
489
|
+
views,
|
|
490
|
+
context,
|
|
491
|
+
id: isNaN(Number(aid)) ? action?.id : aid
|
|
535
492
|
};
|
|
536
|
-
}, [action, context]);
|
|
537
|
-
const view = (
|
|
493
|
+
}, [action, context, aid]);
|
|
494
|
+
const view = useGetView2(
|
|
538
495
|
viewParams || {},
|
|
539
496
|
!!viewParams
|
|
540
497
|
);
|
|
@@ -544,149 +501,117 @@ var useViewV2 = ({
|
|
|
544
501
|
};
|
|
545
502
|
};
|
|
546
503
|
|
|
547
|
-
// src/hooks/core/use-auth.ts
|
|
548
|
-
var import_hooks7 = require("@fctc/interface-logic/hooks");
|
|
549
|
-
var import_store5 = require("@fctc/interface-logic/store");
|
|
550
|
-
var useAuth = () => {
|
|
551
|
-
const [[isLoading, accessToken], setAccessToken] = useStorageState("TOKEN");
|
|
552
|
-
const loginMutate = (0, import_hooks7.useLoginCredential)();
|
|
553
|
-
const dispatch = (0, import_store5.useAppDispatch)();
|
|
554
|
-
const signIn = async (email, password) => {
|
|
555
|
-
try {
|
|
556
|
-
loginMutate.mutate(
|
|
557
|
-
{
|
|
558
|
-
email,
|
|
559
|
-
password,
|
|
560
|
-
path: "/authentication/oauth2/token"
|
|
561
|
-
},
|
|
562
|
-
{
|
|
563
|
-
onSuccess: (res) => {
|
|
564
|
-
},
|
|
565
|
-
onError: (err) => {
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
);
|
|
569
|
-
} catch (error) {
|
|
570
|
-
throw new Error("Login failed");
|
|
571
|
-
}
|
|
572
|
-
};
|
|
573
|
-
const signOut = async () => {
|
|
574
|
-
dispatch((0, import_store5.setMenuList)([]));
|
|
575
|
-
dispatch((0, import_store5.setDataUser)({}));
|
|
576
|
-
dispatch((0, import_store5.setProfile)({}));
|
|
577
|
-
setAccessToken(null);
|
|
578
|
-
};
|
|
579
|
-
return {
|
|
580
|
-
signIn,
|
|
581
|
-
signOut,
|
|
582
|
-
accessToken,
|
|
583
|
-
isLoading
|
|
584
|
-
};
|
|
585
|
-
};
|
|
586
|
-
|
|
587
|
-
// src/hooks/core/use-app-provider.tsx
|
|
588
|
-
var import_react10 = require("react");
|
|
589
|
-
|
|
590
504
|
// src/hooks/core/use-company.ts
|
|
591
505
|
var import_react_query3 = require("@tanstack/react-query");
|
|
592
|
-
var
|
|
593
|
-
var
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
const getCurrentCompany = (
|
|
506
|
+
var import_react7 = require("react");
|
|
507
|
+
var useCompany = () => {
|
|
508
|
+
const { setAllowCompanies, setCompanies, setDefaultCompany, env } = (0, provider_exports.useEnv)();
|
|
509
|
+
const { useGetCurrentCompany: useGetCurrentCompany2, useGetCompanyInfo: useGetCompanyInfo2 } = (0, provider_exports.useService)();
|
|
510
|
+
const getCurrentCompany = useGetCurrentCompany2();
|
|
597
511
|
const fetchCurrentCompany = async () => {
|
|
598
512
|
return await getCurrentCompany.mutateAsync();
|
|
599
513
|
};
|
|
600
514
|
const currentCompany = (0, import_react_query3.useQuery)({
|
|
601
|
-
queryKey: ["currentCompany"
|
|
515
|
+
queryKey: ["currentCompany"],
|
|
602
516
|
queryFn: fetchCurrentCompany,
|
|
603
|
-
enabled: !!
|
|
517
|
+
enabled: !!env?.defaultCompany
|
|
604
518
|
});
|
|
605
|
-
const current_company_id = (0,
|
|
519
|
+
const current_company_id = (0, import_react7.useMemo)(() => {
|
|
606
520
|
return currentCompany.data?.current_company_id;
|
|
607
521
|
}, [currentCompany.data]);
|
|
608
|
-
(0,
|
|
522
|
+
(0, import_react7.useEffect)(() => {
|
|
609
523
|
if (current_company_id) {
|
|
610
524
|
const companyIDs = [current_company_id];
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
env.setCompanies(companyIDs);
|
|
525
|
+
setAllowCompanies([...companyIDs]);
|
|
526
|
+
setCompanies(companyIDs);
|
|
614
527
|
}
|
|
615
528
|
}, [current_company_id]);
|
|
616
|
-
const getCompanyInfo = (
|
|
529
|
+
const getCompanyInfo = useGetCompanyInfo2();
|
|
617
530
|
const companyInfo = (0, import_react_query3.useQuery)({
|
|
618
|
-
queryKey: ["companyInfoQuery", current_company_id
|
|
531
|
+
queryKey: ["companyInfoQuery", current_company_id],
|
|
619
532
|
queryFn: () => getCompanyInfo.mutateAsync(Number(current_company_id)),
|
|
620
|
-
enabled: !!current_company_id
|
|
533
|
+
enabled: !!current_company_id
|
|
621
534
|
});
|
|
622
|
-
(0,
|
|
535
|
+
(0, import_react7.useEffect)(() => {
|
|
623
536
|
if (companyInfo.data) {
|
|
624
537
|
const companyInfoData = companyInfo.data;
|
|
625
538
|
if (companyInfoData?.length) {
|
|
626
|
-
|
|
627
|
-
env.setDefaultCompany(companyInfoData[0]);
|
|
539
|
+
setDefaultCompany(companyInfoData[0]);
|
|
628
540
|
}
|
|
629
541
|
}
|
|
630
542
|
}, [companyInfo.data]);
|
|
543
|
+
if (!companyInfo?.data || !currentCompany?.data) return;
|
|
631
544
|
return {
|
|
632
|
-
currentCompany,
|
|
633
|
-
companyInfo,
|
|
545
|
+
currentCompany: { ...currentCompany },
|
|
546
|
+
companyInfo: { ...companyInfo },
|
|
634
547
|
context: { allowed_company_ids: [current_company_id] }
|
|
635
548
|
};
|
|
636
549
|
};
|
|
637
|
-
var use_company_default = useCompany;
|
|
638
550
|
|
|
639
551
|
// src/hooks/core/use-app-provider.tsx
|
|
640
|
-
var import_utils2 = require("@fctc/interface-logic/utils");
|
|
641
552
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
642
553
|
var AppProviderInitialValue = {
|
|
643
|
-
config: {},
|
|
644
554
|
user: {},
|
|
645
|
-
auth: {},
|
|
646
555
|
company: {},
|
|
647
556
|
action: {},
|
|
648
557
|
menu: {},
|
|
649
|
-
view: {}
|
|
650
|
-
list: {}
|
|
558
|
+
view: {}
|
|
651
559
|
};
|
|
652
|
-
var ReactContext = (0,
|
|
653
|
-
var AppProvider = ({
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
const
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
const
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
560
|
+
var ReactContext = (0, import_react8.createContext)(AppProviderInitialValue);
|
|
561
|
+
var AppProvider = ({
|
|
562
|
+
children,
|
|
563
|
+
menuSpecification,
|
|
564
|
+
aid
|
|
565
|
+
}) => {
|
|
566
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
567
|
+
const user = useUser();
|
|
568
|
+
const company = useCompany();
|
|
569
|
+
const menuContext = (0, import_react8.useMemo)(() => {
|
|
570
|
+
return combineContexts([
|
|
571
|
+
{
|
|
572
|
+
...user?.context,
|
|
573
|
+
...!(0, utils_exports.isObjectEmpty)(env?.user) && company?.context?.allowed_company_ids ? { lang: env?.context?.lang } : {}
|
|
574
|
+
},
|
|
575
|
+
company?.context
|
|
576
|
+
]);
|
|
577
|
+
}, [user?.context, company?.context]);
|
|
578
|
+
const menu = useMenu({
|
|
579
|
+
context: {
|
|
580
|
+
...menuContext
|
|
581
|
+
},
|
|
582
|
+
specification: menuSpecification
|
|
583
|
+
});
|
|
584
|
+
const action = (0, import_react8.useMemo)(() => {
|
|
585
|
+
return menu?.state?.action;
|
|
586
|
+
}, [menu?.state?.action, env?.context?.lang]);
|
|
587
|
+
const viewContext = (0, import_react8.useMemo)(() => {
|
|
666
588
|
return combineContexts([
|
|
667
589
|
menuContext,
|
|
668
|
-
{ ...(0,
|
|
590
|
+
{ ...(0, utils_exports.evalJSONContext)(action?.context) }
|
|
669
591
|
]);
|
|
670
|
-
}, [menuContext, action?.
|
|
592
|
+
}, [menuContext, action?.context, env?.context?.lang]);
|
|
671
593
|
const view = useViewV2({
|
|
672
594
|
action,
|
|
673
|
-
context: viewContext
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
595
|
+
context: viewContext,
|
|
596
|
+
aid,
|
|
597
|
+
views: [
|
|
598
|
+
...Array.isArray(action?.views) ? action?.views.map(
|
|
599
|
+
(view2) => view2[1] === "list" ? [view2[0], "list"] : view2
|
|
600
|
+
) : [],
|
|
601
|
+
[
|
|
602
|
+
Array.isArray(action?.search_view_id) ? action?.search_view_id[0] : action?.search_view_id,
|
|
603
|
+
"search"
|
|
604
|
+
]
|
|
605
|
+
],
|
|
606
|
+
model: String(action?.res_model)
|
|
679
607
|
});
|
|
680
608
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
681
609
|
ReactContext.Provider,
|
|
682
610
|
{
|
|
683
611
|
value: {
|
|
684
|
-
config,
|
|
685
|
-
auth,
|
|
686
612
|
user,
|
|
687
613
|
company,
|
|
688
614
|
menu,
|
|
689
|
-
list,
|
|
690
615
|
action,
|
|
691
616
|
view
|
|
692
617
|
},
|
|
@@ -695,74 +620,164 @@ var AppProvider = ({ children }) => {
|
|
|
695
620
|
);
|
|
696
621
|
};
|
|
697
622
|
var useAppProvider = () => {
|
|
698
|
-
const context = (0,
|
|
623
|
+
const context = (0, import_react8.useContext)(ReactContext);
|
|
699
624
|
if (!context) {
|
|
700
625
|
return AppProviderInitialValue;
|
|
701
626
|
}
|
|
702
627
|
return context;
|
|
703
628
|
};
|
|
704
629
|
|
|
705
|
-
// src/hooks/core/use-
|
|
706
|
-
var
|
|
707
|
-
var
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
})
|
|
725
|
-
|
|
630
|
+
// src/hooks/core/use-config.ts
|
|
631
|
+
var import_react9 = require("react");
|
|
632
|
+
var useConfig = ({
|
|
633
|
+
envConfig,
|
|
634
|
+
config,
|
|
635
|
+
localStorageUtils,
|
|
636
|
+
sessionStorageUtils
|
|
637
|
+
}) => {
|
|
638
|
+
const { setupEnv, setEnvFile } = (0, provider_exports.useEnv)();
|
|
639
|
+
(0, import_react9.useEffect)(() => {
|
|
640
|
+
try {
|
|
641
|
+
setupEnv({
|
|
642
|
+
baseUrl: envConfig.baseUrl,
|
|
643
|
+
config: envConfig.config,
|
|
644
|
+
default_service: "",
|
|
645
|
+
localStorageUtils: localStorageUtils && localStorageUtils(),
|
|
646
|
+
sessionStorageUtils: localStorageUtils && sessionStorageUtils()
|
|
647
|
+
});
|
|
648
|
+
setEnvFile(config);
|
|
649
|
+
} catch (error) {
|
|
650
|
+
console.error("Error loading env or config:", error);
|
|
651
|
+
}
|
|
652
|
+
}, [envConfig, config]);
|
|
653
|
+
return { envConfig, config };
|
|
654
|
+
};
|
|
726
655
|
|
|
727
|
-
// src/hooks/core/use-
|
|
728
|
-
var
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
const
|
|
733
|
-
const
|
|
734
|
-
const
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
model,
|
|
738
|
-
context,
|
|
739
|
-
enabled: true,
|
|
740
|
-
queryKey: [`action-${aid}`]
|
|
741
|
-
}).data;
|
|
742
|
-
const [path, setPath] = (0, import_react11.useState)("");
|
|
743
|
-
const handleClick = () => {
|
|
744
|
-
if (location?.pathname === "/list/menu" && activeMenuId === menu?.id) {
|
|
745
|
-
return;
|
|
656
|
+
// src/hooks/core/use-get-action.ts
|
|
657
|
+
var useGetAction = ({
|
|
658
|
+
aid,
|
|
659
|
+
context
|
|
660
|
+
}) => {
|
|
661
|
+
const { useLoadAction: useLoadAction2, useRunAction: useRunAction2 } = (0, provider_exports.useService)();
|
|
662
|
+
const queryLoadAction = useLoadAction2();
|
|
663
|
+
const queryRunAction = useRunAction2();
|
|
664
|
+
const handleActionResult = (data) => {
|
|
665
|
+
if (data && data.result && data.result.views && Array.isArray(data.result.views) && data.result.views.length > 0) {
|
|
746
666
|
}
|
|
747
|
-
|
|
748
|
-
|
|
667
|
+
};
|
|
668
|
+
const onLoadAction = () => {
|
|
669
|
+
queryLoadAction.mutate(
|
|
670
|
+
{
|
|
671
|
+
idAction: aid,
|
|
672
|
+
context
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
onSuccess: (data) => {
|
|
676
|
+
if (data?.result?.type === "ir.actions.act_window") {
|
|
677
|
+
handleActionResult(data);
|
|
678
|
+
} else if (data?.result?.type === "ir.actions.server") {
|
|
679
|
+
queryRunAction.mutate(
|
|
680
|
+
{
|
|
681
|
+
idAction: aid,
|
|
682
|
+
context
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
onSuccess: handleActionResult
|
|
686
|
+
}
|
|
687
|
+
);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}
|
|
749
691
|
);
|
|
750
|
-
const viewType = hasListView ? "list" : "form";
|
|
751
|
-
const isAccountPayment = menu?.action?.res_model === "account.payment" && menu?.action?.id?.id === 1551;
|
|
752
|
-
const isConvertCurrencyMenu = menu?.action?.res_model === "currency.convert" && menu?.action?.id?.id === 1562;
|
|
753
|
-
const path2 = (0, utils_exports.formatUrlPath)({
|
|
754
|
-
viewType,
|
|
755
|
-
actionPath: isConvertCurrencyMenu ? "menu" : isAccountPayment ? "menu" : menu?.action?.path || "menu",
|
|
756
|
-
aid: menu?.action?.id?.id,
|
|
757
|
-
model: queryActionDetail.res_model
|
|
758
|
-
});
|
|
759
|
-
setPath(path2);
|
|
760
692
|
};
|
|
761
|
-
return {
|
|
693
|
+
return {
|
|
694
|
+
onLoadAction
|
|
695
|
+
};
|
|
696
|
+
};
|
|
697
|
+
|
|
698
|
+
// src/hooks/core/use-get-specification.ts
|
|
699
|
+
var import_react10 = require("react");
|
|
700
|
+
var useGetSpecification = ({
|
|
701
|
+
model,
|
|
702
|
+
viewData,
|
|
703
|
+
fields
|
|
704
|
+
}) => {
|
|
705
|
+
const baseModel = (0, import_react10.useMemo)(
|
|
706
|
+
() => ({
|
|
707
|
+
name: String(model),
|
|
708
|
+
view: viewData || {},
|
|
709
|
+
fields
|
|
710
|
+
}),
|
|
711
|
+
[model, viewData]
|
|
712
|
+
);
|
|
713
|
+
const initModel = (0, import_hooks2.useModel)();
|
|
714
|
+
const modelInstance = (0, import_react10.useMemo)(() => {
|
|
715
|
+
if (viewData) {
|
|
716
|
+
return initModel.initModel(baseModel);
|
|
717
|
+
}
|
|
718
|
+
return null;
|
|
719
|
+
}, [baseModel, viewData]);
|
|
720
|
+
const specification = (0, import_react10.useMemo)(() => {
|
|
721
|
+
if (modelInstance) {
|
|
722
|
+
return modelInstance.getSpecification();
|
|
723
|
+
}
|
|
724
|
+
return null;
|
|
725
|
+
}, [modelInstance]);
|
|
726
|
+
return { specification };
|
|
727
|
+
};
|
|
728
|
+
|
|
729
|
+
// src/hooks/core/use-list-data.ts
|
|
730
|
+
var import_react14 = require("react");
|
|
731
|
+
var import_utils4 = require("@fctc/interface-logic/utils");
|
|
732
|
+
|
|
733
|
+
// src/hooks/utils/use-click-outside.ts
|
|
734
|
+
var import_react11 = require("react");
|
|
735
|
+
var DEFAULT_EVENTS = ["mousedown", "touchstart"];
|
|
736
|
+
var useClickOutside = ({
|
|
737
|
+
handler,
|
|
738
|
+
events = DEFAULT_EVENTS,
|
|
739
|
+
nodes = [],
|
|
740
|
+
refs
|
|
741
|
+
}) => {
|
|
742
|
+
const ref = (0, import_react11.useRef)(null);
|
|
743
|
+
(0, import_react11.useEffect)(() => {
|
|
744
|
+
const listener = (event) => {
|
|
745
|
+
const { target } = event;
|
|
746
|
+
if (refs && refs?.length > 0 && refs?.some((r) => r.current?.contains(target))) {
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
if (!(target instanceof HTMLElement)) return;
|
|
750
|
+
const shouldIgnore = target.hasAttribute("data-ignore-outside-clicks") || !document.body.contains(target) && target.tagName !== "HTML";
|
|
751
|
+
const shouldTrigger = nodes.length > 0 ? nodes.every((node) => node && !event.composedPath().includes(node)) : ref.current && !ref.current.contains(target);
|
|
752
|
+
if (shouldTrigger && !shouldIgnore) {
|
|
753
|
+
handler(event);
|
|
754
|
+
}
|
|
755
|
+
};
|
|
756
|
+
events.forEach((event) => document.addEventListener(event, listener));
|
|
757
|
+
return () => {
|
|
758
|
+
events.forEach((event) => document.removeEventListener(event, listener));
|
|
759
|
+
};
|
|
760
|
+
}, [handler, nodes, events]);
|
|
761
|
+
return ref;
|
|
762
762
|
};
|
|
763
763
|
|
|
764
|
-
// src/hooks/
|
|
764
|
+
// src/hooks/utils/use-debounce.ts
|
|
765
765
|
var import_react12 = require("react");
|
|
766
|
+
function useDebounce(value, delay) {
|
|
767
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react12.useState)(value);
|
|
768
|
+
(0, import_react12.useEffect)(() => {
|
|
769
|
+
const handler = setTimeout(() => {
|
|
770
|
+
setDebouncedValue(value);
|
|
771
|
+
}, delay);
|
|
772
|
+
return () => {
|
|
773
|
+
clearTimeout(handler);
|
|
774
|
+
};
|
|
775
|
+
}, [value, delay]);
|
|
776
|
+
return [debouncedValue];
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// src/hooks/utils/use-get-rowids.ts
|
|
780
|
+
var import_react13 = require("react");
|
|
766
781
|
var useGetRowIds = (tableRef) => {
|
|
767
782
|
function isElementVisible(el) {
|
|
768
783
|
const style = window.getComputedStyle(el);
|
|
@@ -779,9 +794,9 @@ var useGetRowIds = (tableRef) => {
|
|
|
779
794
|
}
|
|
780
795
|
return true;
|
|
781
796
|
}
|
|
782
|
-
const [rowIds, setRowIds] = (0,
|
|
783
|
-
const lastRowIdsRef = (0,
|
|
784
|
-
const updateVisibleRowIds = (0,
|
|
797
|
+
const [rowIds, setRowIds] = (0, import_react13.useState)([]);
|
|
798
|
+
const lastRowIdsRef = (0, import_react13.useRef)([]);
|
|
799
|
+
const updateVisibleRowIds = (0, import_react13.useCallback)(() => {
|
|
785
800
|
const table = tableRef.current;
|
|
786
801
|
if (!table) return;
|
|
787
802
|
const rows = table.querySelectorAll("tr[data-row-id]");
|
|
@@ -799,7 +814,7 @@ var useGetRowIds = (tableRef) => {
|
|
|
799
814
|
setRowIds(uniqueIds);
|
|
800
815
|
}
|
|
801
816
|
}, [tableRef]);
|
|
802
|
-
(0,
|
|
817
|
+
(0, import_react13.useEffect)(() => {
|
|
803
818
|
const table = tableRef.current;
|
|
804
819
|
if (!table) return;
|
|
805
820
|
const mutationObserver = new MutationObserver(() => {
|
|
@@ -827,70 +842,179 @@ var useGetRowIds = (tableRef) => {
|
|
|
827
842
|
return { rowIds, refresh: updateVisibleRowIds };
|
|
828
843
|
};
|
|
829
844
|
|
|
830
|
-
// src/hooks/
|
|
831
|
-
var
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
nodes = [],
|
|
837
|
-
refs
|
|
845
|
+
// src/hooks/core/use-list-data.ts
|
|
846
|
+
var useListData = ({
|
|
847
|
+
action,
|
|
848
|
+
context,
|
|
849
|
+
viewData,
|
|
850
|
+
model
|
|
838
851
|
}) => {
|
|
839
|
-
const
|
|
840
|
-
(0,
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
852
|
+
const { useGetListData: useGetListData2 } = (0, provider_exports.useService)();
|
|
853
|
+
const [page, setPage] = (0, import_react14.useState)(0);
|
|
854
|
+
const [pageLimit, setPageLimit] = (0, import_react14.useState)(10);
|
|
855
|
+
const [groupByList, setGroupByList] = (0, import_react14.useState)(null);
|
|
856
|
+
const [domain, setDomain] = (0, import_react14.useState)(null);
|
|
857
|
+
const [order, setOrder] = (0, import_react14.useState)("");
|
|
858
|
+
const [mode, setMode] = (0, import_react14.useState)("month");
|
|
859
|
+
const [type, setType] = (0, import_react14.useState)("list");
|
|
860
|
+
const [currentDate, setCurrentDate] = (0, import_react14.useState)(/* @__PURE__ */ new Date());
|
|
861
|
+
const [selectedRowKeys, setSelectedRowKeys] = (0, import_react14.useState)([]);
|
|
862
|
+
const [debouncedPage] = useDebounce(page, 500);
|
|
863
|
+
const [debouncedDomain] = useDebounce(domain, 500);
|
|
864
|
+
const { specification } = useGetSpecification({
|
|
865
|
+
model,
|
|
866
|
+
viewData,
|
|
867
|
+
fields: viewData?.views?.list?.fields
|
|
868
|
+
});
|
|
869
|
+
const listDataProps = (0, import_react14.useMemo)(() => {
|
|
870
|
+
if (!viewData || !action || !context) {
|
|
871
|
+
return null;
|
|
872
|
+
}
|
|
873
|
+
const domainParse = type === "calendar" ? getDateRange(currentDate, mode) : action?.domain ? Array.isArray(action?.domain) ? [...action?.domain] : (0, import_utils4.evalJSONDomain)(action?.domain, context) : [];
|
|
874
|
+
const limit = type === "calendar" ? 2500 : pageLimit;
|
|
875
|
+
const offset = debouncedPage * pageLimit;
|
|
876
|
+
const fields = type === "calendar" ? convertFieldsToArray(viewData?.views?.calendar?.fields) || [] : typeof groupByList === "object" ? groupByList?.fields : void 0;
|
|
877
|
+
const groupby = typeof groupByList === "object" ? [groupByList?.contexts?.[0]?.group_by] : [];
|
|
878
|
+
const sort = order ? order : viewData?.views?.list?.default_order ? (0, import_utils4.formatSortingString)(viewData?.views?.list?.default_order) : "";
|
|
879
|
+
return {
|
|
880
|
+
model: action.res_model,
|
|
881
|
+
specification,
|
|
882
|
+
domain: domainParse,
|
|
883
|
+
limit,
|
|
884
|
+
offset,
|
|
885
|
+
fields,
|
|
886
|
+
groupby,
|
|
887
|
+
context,
|
|
888
|
+
sort,
|
|
889
|
+
type
|
|
856
890
|
};
|
|
857
|
-
}, [
|
|
858
|
-
|
|
891
|
+
}, [
|
|
892
|
+
action,
|
|
893
|
+
context,
|
|
894
|
+
currentDate,
|
|
895
|
+
groupByList,
|
|
896
|
+
mode,
|
|
897
|
+
order,
|
|
898
|
+
debouncedPage,
|
|
899
|
+
pageLimit,
|
|
900
|
+
type,
|
|
901
|
+
debouncedDomain
|
|
902
|
+
]);
|
|
903
|
+
const list = useGetListData2(
|
|
904
|
+
listDataProps,
|
|
905
|
+
[listDataProps],
|
|
906
|
+
!!listDataProps && !!specification && !(0, import_utils4.isObjectEmpty)(specification)
|
|
907
|
+
);
|
|
908
|
+
return {
|
|
909
|
+
...list,
|
|
910
|
+
state: {
|
|
911
|
+
specification,
|
|
912
|
+
type,
|
|
913
|
+
page,
|
|
914
|
+
mode,
|
|
915
|
+
order,
|
|
916
|
+
domain: listDataProps?.domain,
|
|
917
|
+
pageLimit,
|
|
918
|
+
groupByList,
|
|
919
|
+
currentDate,
|
|
920
|
+
selectedRowKeys,
|
|
921
|
+
setType,
|
|
922
|
+
setMode,
|
|
923
|
+
setPage,
|
|
924
|
+
setOrder,
|
|
925
|
+
setDomain,
|
|
926
|
+
setPageLimit,
|
|
927
|
+
setGroupByList,
|
|
928
|
+
setCurrentDate,
|
|
929
|
+
setSelectedRowKeys
|
|
930
|
+
}
|
|
931
|
+
};
|
|
859
932
|
};
|
|
860
|
-
|
|
861
|
-
// src/hooks/utils/use-debounce.ts
|
|
862
|
-
var import_react14 = require("react");
|
|
863
|
-
function useDebounce(value, delay) {
|
|
864
|
-
const [debouncedValue, setDebouncedValue] = (0, import_react14.useState)(value);
|
|
865
|
-
(0, import_react14.useEffect)(() => {
|
|
866
|
-
const handler = setTimeout(() => {
|
|
867
|
-
setDebouncedValue(value);
|
|
868
|
-
}, delay);
|
|
869
|
-
return () => {
|
|
870
|
-
clearTimeout(handler);
|
|
871
|
-
};
|
|
872
|
-
}, [value, delay]);
|
|
873
|
-
return [debouncedValue];
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
// src/hooks.ts
|
|
877
|
-
__reExport(hooks_exports, require("@fctc/interface-logic/hooks"), module.exports);
|
|
878
933
|
// Annotate the CommonJS export names for ESM import in node:
|
|
879
934
|
0 && (module.exports = {
|
|
880
935
|
AppProvider,
|
|
881
936
|
useAppProvider,
|
|
882
|
-
|
|
937
|
+
useButton,
|
|
883
938
|
useCallAction,
|
|
939
|
+
useChangeStatus,
|
|
884
940
|
useClickOutside,
|
|
941
|
+
useCompany,
|
|
885
942
|
useConfig,
|
|
886
943
|
useDebounce,
|
|
944
|
+
useDelete,
|
|
945
|
+
useDeleteComment,
|
|
887
946
|
useDetail,
|
|
947
|
+
useDuplicateRecord,
|
|
948
|
+
useExecuteImport,
|
|
949
|
+
useExportExcel,
|
|
950
|
+
useForgotPassword,
|
|
951
|
+
useForgotPasswordSSO,
|
|
952
|
+
useGet2FAMethods,
|
|
953
|
+
useGetAccessByCode,
|
|
954
|
+
useGetAction,
|
|
955
|
+
useGetActionDetail,
|
|
956
|
+
useGetAll,
|
|
957
|
+
useGetCalendar,
|
|
958
|
+
useGetComment,
|
|
959
|
+
useGetCompanyInfo,
|
|
960
|
+
useGetConversionRate,
|
|
961
|
+
useGetCurrency,
|
|
962
|
+
useGetCurrentCompany,
|
|
963
|
+
useGetDetail,
|
|
964
|
+
useGetFieldExport,
|
|
965
|
+
useGetFieldOnChange,
|
|
966
|
+
useGetFileExcel,
|
|
967
|
+
useGetFormView,
|
|
968
|
+
useGetGroups,
|
|
969
|
+
useGetImage,
|
|
970
|
+
useGetListCompany,
|
|
971
|
+
useGetListData,
|
|
972
|
+
useGetListMyBankAccount,
|
|
973
|
+
useGetMenu,
|
|
974
|
+
useGetPrintReport,
|
|
975
|
+
useGetProGressBar,
|
|
976
|
+
useGetProfile,
|
|
977
|
+
useGetProvider,
|
|
978
|
+
useGetResequence,
|
|
888
979
|
useGetRowIds,
|
|
980
|
+
useGetSelection,
|
|
981
|
+
useGetSpecification,
|
|
982
|
+
useGetUser,
|
|
983
|
+
useGetView,
|
|
984
|
+
useGrantAccess,
|
|
985
|
+
useIsValidToken,
|
|
889
986
|
useListData,
|
|
987
|
+
useLoadAction,
|
|
988
|
+
useLoadMessage,
|
|
989
|
+
useLoginCredential,
|
|
990
|
+
useLoginSocial,
|
|
991
|
+
useLogout,
|
|
890
992
|
useMenu,
|
|
891
|
-
|
|
993
|
+
useModel,
|
|
994
|
+
useOdooDataTransform,
|
|
995
|
+
useOnChangeForm,
|
|
996
|
+
useParsePreview,
|
|
997
|
+
usePrint,
|
|
892
998
|
useProfile,
|
|
999
|
+
useRemoveRow,
|
|
1000
|
+
useRemoveTotpSetup,
|
|
1001
|
+
useRequestSetupTotp,
|
|
1002
|
+
useResetPassword,
|
|
1003
|
+
useResetPasswordSSO,
|
|
1004
|
+
useRunAction,
|
|
1005
|
+
useSave,
|
|
1006
|
+
useSendComment,
|
|
1007
|
+
useSettingsWebRead2fa,
|
|
1008
|
+
useSignInSSO,
|
|
1009
|
+
useSwitchLocale,
|
|
1010
|
+
useUpdatePassword,
|
|
1011
|
+
useUploadFile,
|
|
1012
|
+
useUploadFileExcel,
|
|
1013
|
+
useUploadIdFile,
|
|
1014
|
+
useUploadImage,
|
|
893
1015
|
useUser,
|
|
894
|
-
|
|
895
|
-
|
|
1016
|
+
useValidateActionToken,
|
|
1017
|
+
useVerify2FA,
|
|
1018
|
+
useVerifyTotp,
|
|
1019
|
+
useViewV2
|
|
896
1020
|
});
|