@fctc/interface-logic 1.10.7 → 1.10.9

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/provider.mjs CHANGED
@@ -648,10 +648,10 @@ var MainProvider = ({ children }) => {
648
648
  };
649
649
 
650
650
  // src/provider/version-gate-provider.tsx
651
- import { useEffect as useEffect2, useState as useState3 } from "react";
651
+ import { useEffect as useEffect2, useState as useState2 } from "react";
652
652
  import { useQueryClient } from "@tanstack/react-query";
653
653
 
654
- // src/services/view-service/backup.ts
654
+ // src/services/action-service/index.ts
655
655
  import { useCallback } from "react";
656
656
 
657
657
  // src/constants/api/uri-constant.ts
@@ -684,6 +684,9 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
684
684
  return UriConstants2;
685
685
  })(UriConstants || {});
686
686
 
687
+ // src/utils/format.ts
688
+ import moment from "moment";
689
+
687
690
  // src/constants/widget/widget-avatar-constant.ts
688
691
  var WIDGETAVATAR = /* @__PURE__ */ ((WIDGETAVATAR2) => {
689
692
  WIDGETAVATAR2["many2one_avatar_user"] = "many2one_avatar_user";
@@ -691,265 +694,6 @@ var WIDGETAVATAR = /* @__PURE__ */ ((WIDGETAVATAR2) => {
691
694
  return WIDGETAVATAR2;
692
695
  })(WIDGETAVATAR || {});
693
696
 
694
- // src/services/view-service/backup.ts
695
- function useViewService() {
696
- const { env: env2 } = useEnv();
697
- const getView = useCallback(
698
- async ({ model, views, context = {}, options = {}, aid }) => {
699
- const defaultOptions = {
700
- load_filters: true,
701
- toolbar: true,
702
- action_id: aid
703
- };
704
- const jsonDataView = {
705
- model,
706
- method: "get_fields_view_v2" /* GET_FIELD_VIEW */,
707
- kwargs: {
708
- views,
709
- options: { ...options, ...defaultOptions }
710
- },
711
- with_context: context
712
- };
713
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
714
- headers: {
715
- "Content-Type": "application/json"
716
- }
717
- });
718
- },
719
- [env2]
720
- );
721
- const getMenu = useCallback(
722
- async (context) => {
723
- const jsonData = {
724
- model: "ir.ui.menu" /* MENU */,
725
- method: "web_search_read" /* WEB_SEARCH_READ */,
726
- ids: [],
727
- with_context: context,
728
- kwargs: {
729
- specification: {
730
- active: {},
731
- name: {},
732
- is_display: {},
733
- sequence: {},
734
- complete_name: {},
735
- action: {
736
- fields: {
737
- display_name: {},
738
- type: {},
739
- binding_view_types: {}
740
- }
741
- },
742
- url_icon: {},
743
- web_icon: {},
744
- web_icon_data: {},
745
- groups_id: {
746
- fields: {
747
- full_name: {}
748
- },
749
- limit: 40,
750
- order: ""
751
- },
752
- display_name: {},
753
- child_id: {
754
- fields: {
755
- active: {},
756
- name: {},
757
- is_display: {},
758
- sequence: {},
759
- complete_name: {},
760
- action: {
761
- fields: {
762
- display_name: {},
763
- type: {},
764
- binding_view_types: {}
765
- }
766
- },
767
- url_icon: {},
768
- web_icon: {},
769
- web_icon_data: {},
770
- groups_id: {
771
- fields: {
772
- full_name: {}
773
- },
774
- limit: 40,
775
- order: ""
776
- },
777
- display_name: {},
778
- child_id: {
779
- fields: {
780
- active: {},
781
- name: {},
782
- is_display: {},
783
- sequence: {},
784
- complete_name: {},
785
- action: {
786
- fields: {
787
- display_name: {},
788
- type: {},
789
- binding_view_types: {}
790
- }
791
- },
792
- url_icon: {},
793
- web_icon: {},
794
- web_icon_data: {},
795
- groups_id: {
796
- fields: {
797
- full_name: {}
798
- },
799
- limit: 40,
800
- order: ""
801
- },
802
- display_name: {},
803
- child_id: {
804
- fields: {},
805
- limit: 40,
806
- order: ""
807
- }
808
- },
809
- limit: 40,
810
- order: ""
811
- }
812
- },
813
- limit: 40,
814
- order: ""
815
- }
816
- },
817
- domain: [
818
- "&",
819
- ["is_display", "=", true],
820
- "&",
821
- ["active", "=", true],
822
- ["parent_id", "=", false]
823
- ]
824
- }
825
- };
826
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
827
- headers: {
828
- "Content-Type": "application/json"
829
- }
830
- });
831
- },
832
- [env2]
833
- );
834
- const getActionDetail = useCallback(
835
- async (aid, context) => {
836
- const jsonData = {
837
- model: "ir.actions.act_window" /* WINDOW_ACTION */,
838
- method: "web_read" /* WEB_READ */,
839
- ids: [aid],
840
- with_context: context,
841
- kwargs: {
842
- specification: {
843
- id: {},
844
- name: {},
845
- res_model: {},
846
- views: {},
847
- view_mode: {},
848
- mobile_view_mode: {},
849
- domain: {},
850
- context: {},
851
- groups_id: {},
852
- search_view_id: {}
853
- }
854
- }
855
- };
856
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
857
- headers: {
858
- "Content-Type": "application/json"
859
- }
860
- });
861
- },
862
- [env2]
863
- );
864
- const getResequence = useCallback(
865
- async ({ model, ids, context, offset }) => {
866
- const jsonData = {
867
- model,
868
- with_context: context,
869
- ids,
870
- field: "sequence",
871
- ...offset > 0 ? { offset } : {}
872
- };
873
- return env2?.requests.post("/web/dataset/resequence", jsonData, {
874
- headers: {
875
- "Content-Type": "application/json"
876
- }
877
- });
878
- },
879
- [env2]
880
- );
881
- const getSelectionItem = useCallback(
882
- async ({ data }) => {
883
- const jsonData = {
884
- model: data.model,
885
- ids: [],
886
- method: "get_data_select",
887
- with_context: data.context,
888
- kwargs: {
889
- count_limit: 10001,
890
- domain: data.domain ? data.domain : [],
891
- offset: 0,
892
- order: "",
893
- specification: data?.specification ?? {
894
- id: {},
895
- name: {},
896
- display_name: {}
897
- }
898
- }
899
- };
900
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
901
- headers: {
902
- "Content-Type": "application/json"
903
- }
904
- });
905
- },
906
- [env2]
907
- );
908
- const loadMessages = useCallback(
909
- async () => {
910
- return env2.requests.post(
911
- "/load_message_failures" /* LOAD_MESSAGE */,
912
- {},
913
- {
914
- headers: {
915
- "Content-Type": "application/json"
916
- }
917
- }
918
- );
919
- },
920
- [env2]
921
- );
922
- const getVersion = useCallback(
923
- async () => {
924
- console.log("env?.requests", env2, env2?.requests);
925
- return env2?.requests?.get("", {
926
- headers: {
927
- "Content-Type": "application/json"
928
- }
929
- });
930
- },
931
- [env2]
932
- );
933
- return {
934
- getView,
935
- getMenu,
936
- getActionDetail,
937
- getResequence,
938
- getSelectionItem,
939
- loadMessages,
940
- getVersion
941
- };
942
- }
943
-
944
- // src/hooks/auth/use-forgot-password.ts
945
- import { useMutation } from "@tanstack/react-query";
946
-
947
- // src/configs/axios-client.ts
948
- import axios from "axios";
949
-
950
- // src/utils/format.ts
951
- import moment from "moment";
952
-
953
697
  // src/utils/domain/py_tokenizer.ts
954
698
  var TokenizerError = class extends Error {
955
699
  };
@@ -3058,6 +2802,11 @@ function matchDomain(record, domain) {
3058
2802
 
3059
2803
  // src/utils/function.ts
3060
2804
  import { useEffect, useState } from "react";
2805
+ var toQueryString = (params) => {
2806
+ return Object.keys(params).map(
2807
+ (key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
2808
+ ).join("&");
2809
+ };
3061
2810
  var isBase64File = (str) => {
3062
2811
  try {
3063
2812
  const dataUriPattern = /^data:([a-zA-Z]+\/[a-zA-Z0-9-.+]+)?;base64,/;
@@ -3093,1506 +2842,1875 @@ var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
3093
2842
  return originalRequest.data;
3094
2843
  };
3095
2844
 
3096
- // src/utils/storage/local-storage.ts
3097
- var localStorageUtils = () => {
3098
- const setToken = async (access_token) => {
3099
- localStorage.setItem("accessToken", access_token);
3100
- };
3101
- const setRefreshToken = async (refresh_token) => {
3102
- localStorage.setItem("refreshToken", refresh_token);
3103
- };
3104
- const getAccessToken = async () => {
3105
- return localStorage.getItem("accessToken");
3106
- };
3107
- const getRefreshToken = async () => {
3108
- return localStorage.getItem("refreshToken");
3109
- };
3110
- const clearToken = async () => {
3111
- localStorage.removeItem("accessToken");
3112
- localStorage.removeItem("refreshToken");
3113
- };
3114
- return {
3115
- setToken,
3116
- setRefreshToken,
3117
- getAccessToken,
3118
- getRefreshToken,
3119
- clearToken
3120
- };
3121
- };
3122
-
3123
- // src/utils/storage/session-storage.ts
3124
- var sessionStorageUtils = () => {
3125
- const getBrowserSession = async () => {
3126
- return sessionStorage.getItem("browserSession");
3127
- };
2845
+ // src/services/action-service/index.ts
2846
+ function useActionService() {
2847
+ const { env } = useEnv();
2848
+ const loadAction = useCallback(
2849
+ async ({
2850
+ idAction,
2851
+ context
2852
+ }) => {
2853
+ const jsonData = {
2854
+ action_id: idAction,
2855
+ with_context: { ...context }
2856
+ };
2857
+ return env.requests.post("/load_action" /* LOAD_ACTION */, jsonData, {
2858
+ headers: { "Content-Type": "application/json" }
2859
+ });
2860
+ },
2861
+ [env]
2862
+ );
2863
+ const callButton = useCallback(
2864
+ async ({
2865
+ model,
2866
+ ids = [],
2867
+ context,
2868
+ method
2869
+ }) => {
2870
+ try {
2871
+ const jsonData = {
2872
+ model,
2873
+ method,
2874
+ ids,
2875
+ with_context: context
2876
+ };
2877
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
2878
+ headers: { "Content-Type": "application/json" }
2879
+ });
2880
+ } catch (error) {
2881
+ console.error("Error when calling button action:", error);
2882
+ throw error;
2883
+ }
2884
+ },
2885
+ [env]
2886
+ );
2887
+ const removeRows = useCallback(
2888
+ async ({
2889
+ model,
2890
+ ids,
2891
+ context
2892
+ }) => {
2893
+ const jsonData = {
2894
+ model,
2895
+ method: "unlink",
2896
+ ids,
2897
+ with_context: context
2898
+ };
2899
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
2900
+ headers: { "Content-Type": "application/json" }
2901
+ });
2902
+ },
2903
+ [env]
2904
+ );
2905
+ const duplicateRecord = useCallback(
2906
+ async ({
2907
+ model,
2908
+ id,
2909
+ context
2910
+ }) => {
2911
+ const jsonData = {
2912
+ model,
2913
+ method: "copy",
2914
+ ids: id,
2915
+ with_context: context
2916
+ };
2917
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
2918
+ headers: { "Content-Type": "application/json" }
2919
+ });
2920
+ },
2921
+ [env]
2922
+ );
2923
+ const getPrintReportName = useCallback(
2924
+ async ({ id }) => {
2925
+ const jsonData = {
2926
+ model: "ir.actions.report",
2927
+ method: "web_read",
2928
+ id,
2929
+ kwargs: {
2930
+ specification: {
2931
+ report_name: {}
2932
+ }
2933
+ }
2934
+ };
2935
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
2936
+ headers: { "Content-Type": "application/json" }
2937
+ });
2938
+ },
2939
+ [env]
2940
+ );
2941
+ const print = useCallback(
2942
+ async ({ id, report, db }) => {
2943
+ const jsonData = {
2944
+ report,
2945
+ id,
2946
+ type: "pdf",
2947
+ file_response: true,
2948
+ db
2949
+ };
2950
+ const queryString = toQueryString(jsonData);
2951
+ const urlWithParams = `${"/report" /* REPORT_PATH */}?${queryString}`;
2952
+ return env.requests.get(urlWithParams, {
2953
+ headers: { "Content-Type": "application/json" },
2954
+ responseType: "arraybuffer"
2955
+ });
2956
+ },
2957
+ [env]
2958
+ );
2959
+ const runAction = useCallback(
2960
+ async ({
2961
+ idAction,
2962
+ context
2963
+ }) => {
2964
+ const jsonData = {
2965
+ action_id: idAction,
2966
+ with_context: { ...context }
2967
+ };
2968
+ return env.requests.post("/run_action" /* RUN_ACTION_PATH */, jsonData, {
2969
+ headers: { "Content-Type": "application/json" }
2970
+ });
2971
+ },
2972
+ [env]
2973
+ );
3128
2974
  return {
3129
- getBrowserSession
2975
+ loadAction,
2976
+ callButton,
2977
+ removeRows,
2978
+ duplicateRecord,
2979
+ getPrintReportName,
2980
+ print,
2981
+ runAction
3130
2982
  };
3131
- };
2983
+ }
3132
2984
 
3133
- // src/configs/axios-client.ts
3134
- var axiosClient = {
3135
- init(config) {
3136
- const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
3137
- const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
3138
- const db = config?.db;
3139
- let isRefreshing = false;
3140
- let failedQueue = [];
3141
- const processQueue = (error, token = null) => {
3142
- failedQueue?.forEach((prom) => {
3143
- if (error) {
3144
- prom.reject(error);
3145
- } else {
3146
- prom.resolve(token);
2985
+ // src/services/auth-service/index.ts
2986
+ import { useCallback as useCallback2 } from "react";
2987
+ function useAuthService() {
2988
+ const { env } = useEnv();
2989
+ const login = useCallback2(
2990
+ async (body) => {
2991
+ const payload = Object.fromEntries(
2992
+ Object.entries({
2993
+ username: body.email,
2994
+ password: body.password,
2995
+ grant_type: env?.config?.grantType || "",
2996
+ client_id: env?.config?.clientId || "",
2997
+ client_secret: env?.config?.clientSecret || ""
2998
+ }).filter(([_, value]) => !!value)
2999
+ );
3000
+ const encodedData = new URLSearchParams(payload).toString();
3001
+ return env?.requests?.post(body.path, encodedData, {
3002
+ headers: {
3003
+ "Content-Type": "application/x-www-form-urlencoded"
3147
3004
  }
3148
3005
  });
3149
- failedQueue = [];
3150
- };
3151
- const instance = axios.create({
3152
- adapter: axios.defaults.adapter,
3153
- baseURL: config.baseUrl,
3154
- timeout: 5e4,
3155
- paramsSerializer: (params) => new URLSearchParams(params).toString()
3156
- });
3157
- instance.interceptors.request.use(async (config2) => {
3158
- const { useRefreshToken, useActionToken, actionToken } = config2;
3159
- if (useActionToken && actionToken) {
3160
- config2.headers["Action-Token"] = actionToken;
3161
- }
3162
- const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
3163
- const token = await getToken?.();
3164
- if (token) config2.headers["Authorization"] = `Bearer ${token}`;
3165
- return config2;
3166
- }, Promise.reject);
3167
- instance.interceptors.response.use(
3168
- (response) => {
3169
- return handleResponse(response);
3170
- },
3171
- async (error) => {
3172
- const handleError3 = async (error2) => {
3173
- if (!error2.response) {
3174
- return error2;
3175
- }
3176
- const { data } = error2.response;
3177
- if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
3178
- await clearAuthToken();
3179
- }
3180
- return data;
3181
- };
3182
- const originalRequest = error.config;
3183
- if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
3184
- error.response.data.code
3185
- )) {
3186
- if (isRefreshing) {
3187
- return new Promise(function(resolve, reject) {
3188
- failedQueue.push({ resolve, reject });
3189
- }).then((token) => {
3190
- originalRequest.headers["Authorization"] = "Bearer " + token;
3191
- originalRequest.data = updateTokenParamInOriginalRequest(
3192
- originalRequest,
3193
- token
3194
- );
3195
- return instance.request(originalRequest);
3196
- }).catch(async (err) => {
3197
- if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
3198
- await clearAuthToken();
3199
- }
3200
- });
3201
- }
3202
- const browserSession = await sessionStorage2.getBrowserSession();
3203
- const refreshToken = await localStorage2.getRefreshToken();
3204
- const accessTokenExp = await localStorage2.getAccessToken();
3205
- isRefreshing = true;
3206
- if (!refreshToken && (!browserSession || browserSession == "unActive")) {
3207
- await clearAuthToken();
3208
- } else {
3209
- const payload = Object.fromEntries(
3210
- Object.entries({
3211
- refresh_token: refreshToken,
3212
- grant_type: "refresh_token",
3213
- client_id: config.config.clientId,
3214
- client_secret: config.config.clientSecret
3215
- }).filter(([_, value]) => !!value)
3216
- );
3217
- return new Promise(function(resolve) {
3218
- axios.post(
3219
- `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
3220
- payload,
3221
- {
3222
- headers: {
3223
- "Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
3224
- Authorization: `Bearer ${accessTokenExp}`
3225
- }
3226
- }
3227
- ).then(async (res) => {
3228
- const data = res.data;
3229
- await localStorage2.setToken(data.access_token);
3230
- await localStorage2.setRefreshToken(data.refresh_token);
3231
- axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
3232
- originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
3233
- originalRequest.data = updateTokenParamInOriginalRequest(
3234
- originalRequest,
3235
- data.access_token
3236
- );
3237
- processQueue(null, data.access_token);
3238
- resolve(instance.request(originalRequest));
3239
- }).catch(async (err) => {
3240
- if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST") || err?.error_code === "ERR_2FA_006") {
3241
- await clearAuthToken();
3242
- }
3243
- if (err && err.response) {
3244
- const { error_code } = err.response?.data || {};
3245
- if (error_code === "AUTHEN_FAIL") {
3246
- await clearAuthToken();
3247
- }
3248
- }
3249
- processQueue(err, null);
3250
- }).finally(() => {
3251
- isRefreshing = false;
3252
- });
3253
- });
3006
+ },
3007
+ [env]
3008
+ );
3009
+ const forgotPassword = useCallback2(
3010
+ async (email) => {
3011
+ const bodyData = {
3012
+ login: email,
3013
+ url: `${window.location.origin}/reset-password`
3014
+ };
3015
+ return env?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
3016
+ headers: {
3017
+ "Content-Type": "application/json"
3018
+ }
3019
+ });
3020
+ },
3021
+ [env]
3022
+ );
3023
+ const forgotPasswordSSO = useCallback2(
3024
+ async ({
3025
+ email,
3026
+ with_context,
3027
+ method
3028
+ }) => {
3029
+ const body = {
3030
+ method,
3031
+ kwargs: {
3032
+ vals: {
3033
+ email
3254
3034
  }
3035
+ },
3036
+ with_context
3037
+ };
3038
+ return env?.requests?.post("/call" /* CALL_PATH */, body, {
3039
+ headers: {
3040
+ "Content-Type": "application/json"
3255
3041
  }
3256
- return Promise.reject(await handleError3(error));
3257
- }
3258
- );
3259
- const handleResponse = (res) => {
3260
- if (res && res.data) {
3261
- return res.data;
3262
- }
3263
- return res;
3264
- };
3265
- const handleError2 = (error) => {
3266
- if (error.isAxiosError && error.code === "ECONNABORTED") {
3267
- console.error("Request Timeout Error:", error);
3268
- return "Request Timeout Error";
3269
- } else if (error.isAxiosError && !error.response) {
3270
- console.error("Network Error:", error);
3271
- return "Network Error";
3272
- } else {
3273
- console.error("Other Error:", error?.response);
3274
- const errorMessage = error?.response?.data?.message || "An error occurred";
3275
- return { message: errorMessage, status: error?.response?.status };
3276
- }
3277
- };
3278
- const clearAuthToken = async () => {
3279
- await localStorage2.clearToken();
3280
- if (typeof window !== "undefined") {
3281
- window.location.href = `/login`;
3282
- }
3283
- };
3284
- function formatUrl(url, db2) {
3285
- return url + (db2 ? "?db=" + db2 : "");
3286
- }
3287
- const responseBody = (response) => response;
3288
- const requests = {
3289
- get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
3290
- post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
3291
- post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
3292
- responseType: "arraybuffer",
3042
+ });
3043
+ },
3044
+ [env]
3045
+ );
3046
+ const resetPassword = useCallback2(
3047
+ async (data, token) => {
3048
+ const bodyData = {
3049
+ token,
3050
+ password: data.password,
3051
+ new_password: data.confirmPassword
3052
+ };
3053
+ return env?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
3293
3054
  headers: {
3294
- "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
3295
- Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
3055
+ "Content-Type": "application/json"
3296
3056
  }
3297
- }).then(responseBody),
3298
- put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
3299
- patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
3300
- delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
3301
- };
3302
- return requests;
3303
- }
3304
- };
3305
-
3306
- // src/environment/EnvStore.ts
3307
- var EventEmitter = class {
3308
- listeners = {};
3309
- on(event, callback) {
3310
- if (!this.listeners[event]) {
3311
- this.listeners[event] = [];
3312
- }
3313
- this.listeners[event].push(callback);
3314
- }
3315
- emit(event, data) {
3316
- if (this.listeners[event]) {
3317
- this.listeners[event].forEach((callback) => callback(data));
3318
- }
3319
- }
3320
- };
3321
- var EnvStore = class {
3322
- state;
3323
- emitter;
3324
- localStorageUtil;
3325
- sessionStorageUtil;
3326
- constructor(localStorageUtil = localStorageUtils(), sessionStorageUtil = sessionStorageUtils()) {
3327
- this.state = {
3328
- baseUrl: "",
3329
- requests: null,
3330
- companies: [],
3331
- user: {},
3332
- config: null,
3333
- envFile: null,
3334
- defaultCompany: {
3335
- id: null,
3336
- logo: "",
3337
- secondary_color: "",
3338
- primary_color: ""
3339
- },
3340
- context: {
3341
- uid: null,
3342
- allowed_company_ids: [],
3343
- lang: "vi_VN",
3344
- tz: "Asia/Saigon"
3345
- },
3346
- localStorageUtils: localStorageUtil,
3347
- sessionStorageUtils: sessionStorageUtil
3348
- };
3349
- this.emitter = new EventEmitter();
3350
- this.localStorageUtil = localStorageUtil;
3351
- this.sessionStorageUtil = sessionStorageUtil;
3352
- }
3353
- getEnv() {
3354
- return { ...this.state };
3355
- }
3356
- onUpdate(callback) {
3357
- this.emitter.on("update", callback);
3358
- }
3359
- setupEnv(envConfig) {
3360
- this.state = {
3361
- ...this.state,
3362
- ...envConfig,
3363
- localStorageUtils: this.localStorageUtil,
3364
- sessionStorageUtils: this.sessionStorageUtil
3365
- };
3366
- this.state.requests = axiosClient.init(this.state);
3367
- this.emitter.emit("update", this.getEnv());
3368
- return this.getEnv();
3369
- }
3370
- setUid(uid) {
3371
- this.state = {
3372
- ...this.state,
3373
- context: { ...this.state.context, uid }
3374
- };
3375
- this.emitter.emit("update", this.getEnv());
3376
- }
3377
- setLang(lang) {
3378
- this.state = {
3379
- ...this.state,
3380
- context: { ...this.state.context, lang }
3381
- };
3382
- this.emitter.emit("update", this.getEnv());
3383
- }
3384
- setAllowCompanies(allowed_company_ids) {
3385
- this.state = {
3386
- ...this.state,
3387
- context: { ...this.state.context, allowed_company_ids }
3388
- };
3389
- this.emitter.emit("update", this.getEnv());
3390
- }
3391
- setCompanies(companies) {
3392
- this.state = { ...this.state, companies };
3393
- this.emitter.emit("update", this.getEnv());
3394
- }
3395
- setDefaultCompany(defaultCompany) {
3396
- this.state = { ...this.state, defaultCompany };
3397
- this.emitter.emit("update", this.getEnv());
3398
- }
3399
- setUserInfo(user) {
3400
- this.state = { ...this.state, user };
3401
- this.emitter.emit("update", this.getEnv());
3402
- }
3403
- setConfig(config) {
3404
- this.state = { ...this.state, config };
3405
- this.emitter.emit("update", this.getEnv());
3406
- }
3407
- setEnvFile(envFile) {
3408
- this.state = { ...this.state, envFile };
3409
- this.emitter.emit("update", this.getEnv());
3410
- }
3411
- };
3412
- var env = null;
3413
- function initEnv({
3414
- localStorageUtils: localStorageUtil = localStorageUtils(),
3415
- sessionStorageUtils: sessionStorageUtil = sessionStorageUtils()
3416
- }) {
3417
- if (!env) {
3418
- env = new EnvStore(localStorageUtil, sessionStorageUtil);
3419
- }
3420
- return env;
3421
- }
3422
- function getEnv() {
3423
- if (!env) {
3424
- env = initEnv({});
3425
- }
3426
- return env?.getEnv();
3057
+ });
3058
+ },
3059
+ [env]
3060
+ );
3061
+ const resetPasswordSSO = useCallback2(
3062
+ async ({
3063
+ method,
3064
+ password,
3065
+ with_context
3066
+ }) => {
3067
+ const bodyData = {
3068
+ method,
3069
+ kwargs: {
3070
+ vals: {
3071
+ password
3072
+ }
3073
+ },
3074
+ with_context
3075
+ };
3076
+ return env?.requests?.post("/call" /* CALL_PATH */, bodyData, {
3077
+ headers: {
3078
+ "Content-Type": "application/json"
3079
+ }
3080
+ });
3081
+ },
3082
+ [env]
3083
+ );
3084
+ const updatePassword = useCallback2(
3085
+ async (data, token) => {
3086
+ const bodyData = {
3087
+ token,
3088
+ old_password: data.oldPassword,
3089
+ new_password: data.newPassword
3090
+ };
3091
+ return env?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
3092
+ headers: {
3093
+ "Content-Type": "application/json"
3094
+ }
3095
+ });
3096
+ },
3097
+ [env]
3098
+ );
3099
+ const isValidToken = useCallback2(
3100
+ async (token) => {
3101
+ const bodyData = {
3102
+ token
3103
+ };
3104
+ return env?.requests?.post("/check_token" /* TOKEN */, bodyData, {
3105
+ headers: {
3106
+ "Content-Type": "application/json"
3107
+ }
3108
+ });
3109
+ },
3110
+ [env]
3111
+ );
3112
+ const isValidActionToken = useCallback2(
3113
+ async (actionToken, path) => {
3114
+ return env?.requests?.post(
3115
+ path,
3116
+ {},
3117
+ {
3118
+ headers: {
3119
+ "Content-Type": "application/json"
3120
+ },
3121
+ useActionToken: true,
3122
+ actionToken
3123
+ }
3124
+ );
3125
+ },
3126
+ [env]
3127
+ );
3128
+ const loginSocial = useCallback2(
3129
+ async ({
3130
+ db,
3131
+ state,
3132
+ access_token
3133
+ }) => {
3134
+ return env?.requests?.post(
3135
+ "/token/generate" /* GENTOKEN_SOCIAL */,
3136
+ { state, access_token },
3137
+ {
3138
+ headers: {
3139
+ "Content-Type": "application/json"
3140
+ }
3141
+ }
3142
+ );
3143
+ },
3144
+ [env]
3145
+ );
3146
+ const getProviders = useCallback2(
3147
+ async (db) => {
3148
+ return env?.requests?.get("/oauth/providers", { params: { db } });
3149
+ },
3150
+ [env]
3151
+ );
3152
+ const getAccessByCode = useCallback2(
3153
+ async (code) => {
3154
+ const data = new URLSearchParams();
3155
+ data.append("code", code);
3156
+ data.append("grant_type", "authorization_code");
3157
+ data.append("client_id", env?.config?.clientId || "");
3158
+ data.append("redirect_uri", env?.config?.redirectUri || "");
3159
+ return env?.requests?.post(
3160
+ `${env?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
3161
+ data,
3162
+ {
3163
+ headers: {
3164
+ "Content-Type": "application/x-www-form-urlencoded"
3165
+ }
3166
+ }
3167
+ );
3168
+ },
3169
+ [env]
3170
+ );
3171
+ const logout = useCallback2(
3172
+ async (data) => {
3173
+ console.log(data);
3174
+ return env?.requests?.post(
3175
+ "/logout" /* LOGOUT */,
3176
+ {},
3177
+ {
3178
+ headers: {
3179
+ "Content-Type": "application/json"
3180
+ },
3181
+ withCredentials: true,
3182
+ useRefreshToken: true
3183
+ }
3184
+ );
3185
+ },
3186
+ [env]
3187
+ );
3188
+ return {
3189
+ login,
3190
+ forgotPassword,
3191
+ forgotPasswordSSO,
3192
+ resetPassword,
3193
+ resetPasswordSSO,
3194
+ updatePassword,
3195
+ isValidToken,
3196
+ isValidActionToken,
3197
+ loginSocial,
3198
+ getProviders,
3199
+ getAccessByCode,
3200
+ logout
3201
+ };
3427
3202
  }
3428
3203
 
3429
- // src/services/auth-service/index.ts
3430
- var AuthService = {
3431
- async login(body) {
3432
- const env2 = getEnv();
3433
- const payload = Object.fromEntries(
3434
- Object.entries({
3435
- username: body.email,
3436
- password: body.password,
3437
- grant_type: env2?.config?.grantType || "",
3438
- client_id: env2?.config?.clientId || "",
3439
- client_secret: env2?.config?.clientSecret || ""
3440
- }).filter(([_, value]) => !!value)
3441
- );
3442
- const encodedData = new URLSearchParams(payload).toString();
3443
- return env2?.requests?.post(body.path, encodedData, {
3444
- headers: {
3445
- "Content-Type": "application/x-www-form-urlencoded"
3446
- }
3447
- });
3448
- },
3449
- async forgotPassword(email) {
3450
- const env2 = getEnv();
3451
- const bodyData = {
3452
- login: email,
3453
- url: `${window.location.origin}/reset-password`
3454
- };
3455
- return env2?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
3204
+ // src/services/company-service/index.ts
3205
+ import { useCallback as useCallback3 } from "react";
3206
+ function useCompanyService() {
3207
+ const { env } = useEnv();
3208
+ const getCurrentCompany = useCallback3(async () => {
3209
+ return await env.requests.get("/company" /* COMPANY_PATH */, {
3456
3210
  headers: {
3457
3211
  "Content-Type": "application/json"
3458
3212
  }
3459
3213
  });
3460
- },
3461
- async forgotPasswordSSO({
3462
- email,
3463
- with_context,
3464
- method
3465
- }) {
3466
- const env2 = getEnv();
3467
- const body = {
3468
- method,
3469
- kwargs: {
3470
- vals: {
3471
- email
3214
+ }, [env]);
3215
+ const getInfoCompany = useCallback3(
3216
+ async (id) => {
3217
+ const jsonData = {
3218
+ ids: [id],
3219
+ model: "res.company" /* COMPANY */,
3220
+ method: "web_read" /* WEB_READ */,
3221
+ kwargs: {
3222
+ specification: {
3223
+ primary_color: {},
3224
+ secondary_color: {},
3225
+ logo: {},
3226
+ display_name: {},
3227
+ secondary_logo: {}
3228
+ }
3472
3229
  }
3473
- },
3474
- with_context
3475
- };
3476
- return env2?.requests?.post("/call" /* CALL_PATH */, body, {
3477
- headers: {
3478
- "Content-Type": "application/json"
3479
- }
3480
- });
3481
- },
3482
- async resetPassword(data, token) {
3483
- const env2 = getEnv();
3484
- const bodyData = {
3485
- token,
3486
- password: data.password,
3487
- new_password: data.confirmPassword
3488
- };
3489
- return env2?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
3490
- headers: {
3491
- "Content-Type": "application/json"
3492
- }
3493
- });
3494
- },
3495
- async resetPasswordSSO({
3496
- method,
3497
- password,
3498
- with_context
3499
- }) {
3500
- const env2 = getEnv();
3501
- const bodyData = {
3502
- method,
3503
- kwargs: {
3504
- vals: {
3505
- password
3230
+ };
3231
+ return await env.requests.post("/call" /* CALL_PATH */, jsonData, {
3232
+ headers: {
3233
+ "Content-Type": "application/json"
3506
3234
  }
3507
- },
3508
- with_context
3509
- };
3510
- return env2?.requests?.post("/call" /* CALL_PATH */, bodyData, {
3511
- headers: {
3512
- "Content-Type": "application/json"
3513
- }
3514
- });
3515
- },
3516
- async updatePassword(data, token) {
3517
- const env2 = getEnv();
3518
- const bodyData = {
3519
- token,
3520
- old_password: data.oldPassword,
3521
- new_password: data.newPassword
3522
- };
3523
- return env2?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
3524
- headers: {
3525
- "Content-Type": "application/json"
3526
- }
3527
- });
3528
- },
3529
- async isValidToken(token) {
3530
- const env2 = getEnv();
3531
- const bodyData = {
3532
- token
3533
- };
3534
- return env2?.requests?.post("/check_token" /* TOKEN */, bodyData, {
3535
- headers: {
3536
- "Content-Type": "application/json"
3235
+ });
3236
+ },
3237
+ [env]
3238
+ );
3239
+ return {
3240
+ getCurrentCompany,
3241
+ getInfoCompany
3242
+ };
3243
+ }
3244
+
3245
+ // src/services/excel-service/index.ts
3246
+ import { useCallback as useCallback4 } from "react";
3247
+ function useExcelService() {
3248
+ const { env } = useEnv();
3249
+ const uploadFile = useCallback4(
3250
+ async ({ formData }) => {
3251
+ return env.requests.post("/upload/file" /* UPLOAD_FILE_PATH */, formData, {
3252
+ headers: {
3253
+ "Content-Type": "multipart/form-data"
3254
+ }
3255
+ });
3256
+ },
3257
+ [env]
3258
+ );
3259
+ const uploadIdFile = useCallback4(
3260
+ async ({ formData }) => {
3261
+ return env.requests.post("/upload/file" /* UPLOAD_FILE_PATH */, formData, {
3262
+ headers: {
3263
+ "Content-Type": "multipart/form-data"
3264
+ }
3265
+ });
3266
+ },
3267
+ [env]
3268
+ );
3269
+ const parsePreview = useCallback4(
3270
+ async ({
3271
+ id,
3272
+ selectedSheet,
3273
+ isHeader,
3274
+ context
3275
+ }) => {
3276
+ const jsonData = {
3277
+ model: "base_import.import" /* BASE_IMPORT */,
3278
+ method: "parse_preview",
3279
+ ids: [id],
3280
+ kwargs: {
3281
+ options: {
3282
+ import_skip_records: [],
3283
+ import_set_empty_fields: [],
3284
+ fallback_values: {},
3285
+ name_create_enabled_fields: {},
3286
+ encoding: "",
3287
+ separator: "",
3288
+ quoting: '"',
3289
+ date_format: "",
3290
+ datetime_format: "",
3291
+ float_thousand_separator: ",",
3292
+ float_decimal_separator: ".",
3293
+ advanced: true,
3294
+ has_headers: isHeader,
3295
+ keep_matches: false,
3296
+ limit: 2e3,
3297
+ sheets: [],
3298
+ sheet: selectedSheet,
3299
+ skip: 0,
3300
+ tracking_disable: true
3301
+ }
3302
+ },
3303
+ with_context: context
3304
+ };
3305
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3306
+ headers: {
3307
+ "Content-Type": "multipart/form-data"
3308
+ }
3309
+ });
3310
+ },
3311
+ [env]
3312
+ );
3313
+ const executeImport = useCallback4(
3314
+ async ({
3315
+ columns,
3316
+ fields,
3317
+ idFile,
3318
+ options,
3319
+ dryrun,
3320
+ context
3321
+ }) => {
3322
+ const jsonData = {
3323
+ model: "base_import.import" /* BASE_IMPORT */,
3324
+ method: "execute_import",
3325
+ ids: [idFile],
3326
+ kwargs: {
3327
+ fields,
3328
+ columns,
3329
+ options,
3330
+ dryrun
3331
+ },
3332
+ with_context: context
3333
+ };
3334
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3335
+ headers: {
3336
+ "Content-Type": "multipart/form-data"
3337
+ }
3338
+ });
3339
+ },
3340
+ [env]
3341
+ );
3342
+ const getFileExcel = useCallback4(
3343
+ async ({ model }) => {
3344
+ const jsonData = {
3345
+ model,
3346
+ method: "get_import_templates" /* GET_IMPORT */,
3347
+ args: []
3348
+ };
3349
+ return env.requests.post("/call" /* CALL_PATH */, jsonData);
3350
+ },
3351
+ [env]
3352
+ );
3353
+ const getFieldExport = useCallback4(
3354
+ async ({
3355
+ ids,
3356
+ model,
3357
+ isShow,
3358
+ parentField,
3359
+ fieldType,
3360
+ parentName,
3361
+ prefix,
3362
+ name,
3363
+ context,
3364
+ importCompat
3365
+ }) => {
3366
+ const jsonData = {
3367
+ model,
3368
+ import_compat: importCompat,
3369
+ domain: [["id", "in", ids]],
3370
+ with_context: context
3371
+ };
3372
+ if (isShow) {
3373
+ jsonData.parent_field = parentField;
3374
+ jsonData.parent_field_type = fieldType;
3375
+ jsonData.parent_name = parentName;
3376
+ jsonData.name = name;
3377
+ jsonData.prefix = prefix;
3378
+ jsonData.exclude = [null];
3537
3379
  }
3538
- });
3539
- },
3540
- async isValidActionToken(actionToken, path) {
3541
- const env2 = getEnv();
3542
- return env2?.requests?.post(
3543
- path,
3544
- {},
3545
- {
3380
+ return env.requests.post("/export/get_fields", jsonData);
3381
+ },
3382
+ [env]
3383
+ );
3384
+ const exportExcel = useCallback4(
3385
+ async ({
3386
+ model,
3387
+ domain,
3388
+ ids,
3389
+ fields,
3390
+ type,
3391
+ importCompat,
3392
+ context,
3393
+ groupby
3394
+ }) => {
3395
+ const jsonData = {
3396
+ model,
3397
+ domain,
3398
+ ids,
3399
+ import_compat: importCompat,
3400
+ fields,
3401
+ with_context: context,
3402
+ groupby: groupby ?? []
3403
+ };
3404
+ return env.requests.post_excel(`/export/${type}`, jsonData);
3405
+ },
3406
+ [env]
3407
+ );
3408
+ return {
3409
+ uploadFile,
3410
+ uploadIdFile,
3411
+ parsePreview,
3412
+ executeImport,
3413
+ getFileExcel,
3414
+ getFieldExport,
3415
+ exportExcel
3416
+ };
3417
+ }
3418
+
3419
+ // src/services/form-service/index.ts
3420
+ import { useCallback as useCallback5 } from "react";
3421
+ function useFormService() {
3422
+ const { env } = useEnv();
3423
+ const getComment = useCallback5(
3424
+ async ({ data }) => {
3425
+ const jsonData = {
3426
+ thread_id: data.thread_id,
3427
+ thread_model: data.thread_model,
3428
+ limit: 100,
3429
+ with_context: {
3430
+ lang: data.lang
3431
+ }
3432
+ };
3433
+ return env.requests.post("/chatter/thread/messages" /* GET_MESSAGE */, jsonData, {
3434
+ headers: {
3435
+ "Content-Type": "application/json"
3436
+ }
3437
+ });
3438
+ },
3439
+ [env]
3440
+ );
3441
+ const sentComment = useCallback5(
3442
+ async ({ data }) => {
3443
+ const jsonData = {
3444
+ context: {
3445
+ tz: "Asia/Saigon",
3446
+ uid: 2,
3447
+ allowed_company_ids: [1],
3448
+ mail_post_autofollow: false,
3449
+ temporary_id: 142183.01
3450
+ },
3451
+ post_data: {
3452
+ body: data.message,
3453
+ message_type: "comment",
3454
+ attachment_ids: data.attachment_ids,
3455
+ attachment_tokens: [],
3456
+ subtype_xmlid: data.subtype
3457
+ },
3458
+ thread_id: Number(data.thread_id),
3459
+ thread_model: data.thread_model
3460
+ };
3461
+ return env.requests.post("/chatter/message/post" /* SENT_MESSAGE */, jsonData, {
3462
+ headers: {
3463
+ "Content-Type": "application/json"
3464
+ }
3465
+ });
3466
+ },
3467
+ [env]
3468
+ );
3469
+ const deleteComment = useCallback5(
3470
+ async ({ data }) => {
3471
+ const jsonData = {
3472
+ attachment_ids: [],
3473
+ attachment_tokens: [],
3474
+ body: "",
3475
+ message_id: data.message_id
3476
+ };
3477
+ return env.requests.post("/chatter/message/update_content" /* DELETE_MESSAGE */, jsonData, {
3478
+ headers: {
3479
+ "Content-Type": "application/json"
3480
+ }
3481
+ });
3482
+ },
3483
+ [env]
3484
+ );
3485
+ const getImage = useCallback5(
3486
+ async ({ data }) => {
3487
+ return env.requests.get(
3488
+ `${"/web/image" /* IMAGE_PATH */}?filename=${data.filename}&unique=${data.checksum}&width=1920&height=300`,
3489
+ {
3490
+ headers: {
3491
+ "Content-Type": "application/json"
3492
+ }
3493
+ }
3494
+ );
3495
+ },
3496
+ [env]
3497
+ );
3498
+ const uploadImage = useCallback5(
3499
+ async ({ data }) => {
3500
+ return env.requests.post("/mail/attachment/upload" /* UPLOAD_IMAGE */, data, {
3501
+ headers: {
3502
+ "Content-Type": "multipart/form-data"
3503
+ }
3504
+ });
3505
+ },
3506
+ [env]
3507
+ );
3508
+ const getFormView = useCallback5(
3509
+ async ({ data }) => {
3510
+ const jsonData = {
3511
+ model: data.model,
3512
+ method: "get_formview_action",
3513
+ ids: data.id ? [data.id] : [],
3514
+ with_context: data.context
3515
+ };
3516
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3517
+ headers: {
3518
+ "Content-Type": "application/json"
3519
+ }
3520
+ });
3521
+ },
3522
+ [env]
3523
+ );
3524
+ const changeStatus = useCallback5(
3525
+ async ({ data }) => {
3526
+ const vals = {
3527
+ [data.name]: data.stage_id
3528
+ };
3529
+ const jsonData = {
3530
+ model: data.model,
3531
+ method: "web_save",
3532
+ with_context: {
3533
+ lang: data.lang,
3534
+ allowed_company_ids: [1],
3535
+ uid: 2,
3536
+ search_default_my_ticket: true,
3537
+ search_default_is_open: true
3538
+ },
3539
+ ids: [data.id],
3540
+ kwargs: {
3541
+ vals,
3542
+ specification: {}
3543
+ }
3544
+ };
3545
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3546
+ headers: {
3547
+ "Content-Type": "application/json"
3548
+ }
3549
+ });
3550
+ },
3551
+ [env]
3552
+ );
3553
+ return {
3554
+ getComment,
3555
+ sentComment,
3556
+ deleteComment,
3557
+ getImage,
3558
+ uploadImage,
3559
+ getFormView,
3560
+ changeStatus
3561
+ };
3562
+ }
3563
+
3564
+ // src/services/kanban-service/index.ts
3565
+ import { useCallback as useCallback6 } from "react";
3566
+ function useKanbanService() {
3567
+ const { env } = useEnv();
3568
+ const getGroups = useCallback6(
3569
+ async ({ model, width_context }) => {
3570
+ const jsonData = {
3571
+ model,
3572
+ method: "web_read_group",
3573
+ kwargs: {
3574
+ domain: [["stage_id.fold", "=", false]],
3575
+ fields: ["color:sum"],
3576
+ groupby: ["stage_id"]
3577
+ },
3578
+ width_context
3579
+ };
3580
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3546
3581
  headers: {
3547
3582
  "Content-Type": "application/json"
3583
+ }
3584
+ });
3585
+ },
3586
+ [env]
3587
+ );
3588
+ const getProgressBar = useCallback6(
3589
+ async ({ field, color, model, width_context }) => {
3590
+ const jsonData = {
3591
+ model,
3592
+ method: "read_progress_bar",
3593
+ kwargs: {
3594
+ domain: [],
3595
+ group_by: "stage_id",
3596
+ progress_bar: {
3597
+ colors: color,
3598
+ field
3599
+ }
3548
3600
  },
3549
- useActionToken: true,
3550
- actionToken
3551
- }
3552
- );
3553
- },
3554
- async loginSocial({
3555
- db,
3556
- state,
3557
- access_token
3558
- }) {
3559
- const env2 = getEnv();
3560
- return env2?.requests?.post(
3561
- "/token/generate" /* GENTOKEN_SOCIAL */,
3562
- { state, access_token },
3563
- {
3601
+ width_context
3602
+ };
3603
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3564
3604
  headers: {
3565
3605
  "Content-Type": "application/json"
3566
3606
  }
3567
- }
3568
- );
3569
- },
3570
- async getProviders(db) {
3571
- const env2 = getEnv();
3572
- return env2?.requests?.get("/oauth/providers", { params: { db } });
3573
- },
3574
- async getAccessByCode(code) {
3575
- const env2 = getEnv();
3576
- const data = new URLSearchParams();
3577
- data.append("code", code);
3578
- data.append("grant_type", "authorization_code");
3579
- data.append("client_id", env2?.config?.clientId || "");
3580
- data.append("redirect_uri", env2?.config?.redirectUri || "");
3581
- return env2?.requests?.post(
3582
- `${env2?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
3583
- data,
3584
- {
3585
- headers: {
3586
- "Content-Type": "application/x-www-form-urlencoded"
3607
+ });
3608
+ },
3609
+ [env]
3610
+ );
3611
+ return {
3612
+ getGroups,
3613
+ getProgressBar
3614
+ };
3615
+ }
3616
+
3617
+ // src/services/model-service/index.ts
3618
+ import { useCallback as useCallback7 } from "react";
3619
+ var OBJECT_POSITION = 2;
3620
+ function useModelService() {
3621
+ const { env } = useEnv();
3622
+ const getListMyBankAccount = useCallback7(
3623
+ async ({
3624
+ domain,
3625
+ spectification,
3626
+ model
3627
+ }) => {
3628
+ const jsonData = {
3629
+ model,
3630
+ method: "web_search_read",
3631
+ kwargs: {
3632
+ specification: spectification,
3633
+ domain,
3634
+ limit: 100,
3635
+ offset: 0
3587
3636
  }
3588
- }
3589
- );
3590
- },
3591
- async logout(data) {
3592
- const env2 = getEnv();
3593
- console.log(data);
3594
- return env2?.requests?.post(
3595
- "/logout" /* LOGOUT */,
3596
- {},
3597
- {
3637
+ };
3638
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3598
3639
  headers: {
3599
3640
  "Content-Type": "application/json"
3600
- },
3601
- withCredentials: true,
3602
- useRefreshToken: true
3603
- }
3604
- );
3605
- }
3606
- };
3607
- var auth_service_default = AuthService;
3608
-
3609
- // src/services/company-service/index.ts
3610
- var CompanyService = {
3611
- async getCurrentCompany() {
3612
- const env2 = getEnv();
3613
- return await env2.requests.get("/company" /* COMPANY_PATH */, {
3614
- headers: {
3615
- "Content-Type": "application/json"
3616
- }
3617
- });
3618
- },
3619
- async getInfoCompany(id) {
3620
- const env2 = getEnv();
3641
+ }
3642
+ });
3643
+ },
3644
+ [env]
3645
+ );
3646
+ const getCurrency = useCallback7(async () => {
3621
3647
  const jsonData = {
3622
- ids: [id],
3623
- model: "res.company" /* COMPANY */,
3624
- method: "web_read" /* WEB_READ */,
3648
+ model: "res.currency",
3649
+ method: "web_search_read",
3625
3650
  kwargs: {
3626
3651
  specification: {
3627
- primary_color: {},
3628
- secondary_color: {},
3629
- logo: {},
3630
- display_name: {},
3631
- secondary_logo: {}
3632
- }
3652
+ icon_url: {},
3653
+ name: {}
3654
+ },
3655
+ domain: [["active", "=", true]],
3656
+ limit: 100,
3657
+ offset: 0
3633
3658
  }
3634
3659
  };
3635
- return await env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3660
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3636
3661
  headers: {
3637
3662
  "Content-Type": "application/json"
3638
3663
  }
3639
3664
  });
3640
- }
3641
- };
3642
- var company_service_default = CompanyService;
3643
-
3644
- // src/services/excel-service/index.ts
3645
- var ExcelService = {
3646
- async uploadFile({ formData }) {
3647
- const env2 = getEnv();
3648
- return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3649
- headers: {
3650
- "Content-Type": "multipart/form-data"
3651
- }
3652
- });
3653
- },
3654
- async uploadIdFile({ formData }) {
3655
- const env2 = getEnv();
3656
- return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3657
- headers: {
3658
- "Content-Type": "multipart/form-data"
3659
- }
3660
- });
3661
- },
3662
- async parsePreview({
3663
- id,
3664
- selectedSheet,
3665
- isHeader,
3666
- context
3667
- }) {
3668
- const env2 = getEnv();
3665
+ }, [env]);
3666
+ const getConversionRate = useCallback7(async () => {
3669
3667
  const jsonData = {
3670
- model: "base_import.import" /* BASE_IMPORT */,
3671
- method: "parse_preview",
3672
- ids: [id],
3668
+ model: "res.currency",
3669
+ method: "web_search_read",
3673
3670
  kwargs: {
3674
- options: {
3675
- import_skip_records: [],
3676
- import_set_empty_fields: [],
3677
- fallback_values: {},
3678
- name_create_enabled_fields: {},
3679
- encoding: "",
3680
- separator: "",
3681
- quoting: '"',
3682
- date_format: "",
3683
- datetime_format: "",
3684
- float_thousand_separator: ",",
3685
- float_decimal_separator: ".",
3686
- advanced: true,
3687
- has_headers: isHeader,
3688
- keep_matches: false,
3689
- limit: 2e3,
3690
- sheets: [],
3691
- sheet: selectedSheet,
3692
- skip: 0,
3693
- tracking_disable: true
3694
- }
3695
- },
3696
- with_context: context
3697
- };
3698
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3699
- headers: {
3700
- "Content-Type": "multipart/form-data"
3671
+ specification: {
3672
+ name: {},
3673
+ icon_url: {},
3674
+ rate_ids: {
3675
+ fields: {
3676
+ company_rate: {},
3677
+ sell: {}
3678
+ }
3679
+ }
3680
+ },
3681
+ domain: [["active", "=", true]],
3682
+ limit: 100,
3683
+ offset: 0
3701
3684
  }
3702
- });
3703
- },
3704
- async executeImport({
3705
- columns,
3706
- fields,
3707
- idFile,
3708
- options,
3709
- dryrun,
3710
- context
3711
- }) {
3712
- const env2 = getEnv();
3713
- const jsonData = {
3714
- model: "base_import.import" /* BASE_IMPORT */,
3715
- method: "execute_import",
3716
- ids: [idFile],
3717
- kwargs: {
3718
- fields,
3719
- columns,
3720
- options,
3721
- dryrun
3722
- },
3723
- with_context: context
3724
3685
  };
3725
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3686
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3726
3687
  headers: {
3727
- "Content-Type": "multipart/form-data"
3688
+ "Content-Type": "application/json"
3728
3689
  }
3729
3690
  });
3730
- },
3731
- async getFileExcel({ model }) {
3732
- const env2 = getEnv();
3733
- const jsonData = {
3691
+ }, [env]);
3692
+ const getAll = useCallback7(
3693
+ async ({ data }) => {
3694
+ const jsonReadGroup = data.type == "calendar" ? { fields: data?.fields } : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3695
+ fields: data.fields,
3696
+ groupby: data.groupby
3697
+ } : {
3698
+ count_limit: 10001,
3699
+ order: data.sort,
3700
+ specification: data.specification
3701
+ };
3702
+ const jsonData = {
3703
+ model: String(data.model),
3704
+ method: data.type == "calendar" ? "search_read" : jsonReadGroup.fields && jsonReadGroup.groupby ? "web_read_group" : "web_search_read",
3705
+ ids: data.ids,
3706
+ with_context: data.context,
3707
+ kwargs: {
3708
+ domain: data.domain,
3709
+ limit: data.limit,
3710
+ offset: data.offset,
3711
+ ...jsonReadGroup
3712
+ }
3713
+ };
3714
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3715
+ headers: {
3716
+ "Content-Type": "application/json"
3717
+ }
3718
+ });
3719
+ },
3720
+ [env]
3721
+ );
3722
+ const getListCalendar = useCallback7(
3723
+ async ({ data }) => {
3724
+ const jsonReadGroup = data.type == "calendar" ? data?.fields : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3725
+ fields: data.fields,
3726
+ groupby: data.groupby
3727
+ } : {
3728
+ count_limit: 10001,
3729
+ order: data.sort,
3730
+ specification: data.specification
3731
+ };
3732
+ const jsonData = {
3733
+ model: String(data.model),
3734
+ method: data.type == "calendar" ? "search_read" : jsonReadGroup.fields && jsonReadGroup.groupby ? "web_read_group" : "web_search_read",
3735
+ ids: data.ids,
3736
+ with_context: data.context,
3737
+ kwargs: {
3738
+ domain: data.domain,
3739
+ limit: data.limit,
3740
+ offset: data.offset,
3741
+ fields: data.fields,
3742
+ ...jsonReadGroup
3743
+ }
3744
+ };
3745
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3746
+ headers: {
3747
+ "Content-Type": "application/json"
3748
+ }
3749
+ });
3750
+ },
3751
+ [env]
3752
+ );
3753
+ const getList = useCallback7(
3754
+ async ({
3734
3755
  model,
3735
- method: "get_import_templates" /* GET_IMPORT */,
3736
- args: []
3737
- };
3738
- return env2.requests.post("/call" /* CALL_PATH */, jsonData);
3739
- },
3740
- async getFieldExport({
3741
- ids,
3742
- model,
3743
- isShow,
3744
- parentField,
3745
- fieldType,
3746
- parentName,
3747
- prefix,
3748
- name,
3749
- context,
3750
- importCompat
3751
- }) {
3752
- const env2 = getEnv();
3753
- const jsonData = {
3756
+ ids = [],
3757
+ specification = {},
3758
+ domain = [],
3759
+ offset,
3760
+ order,
3761
+ context = {},
3762
+ limit = 10
3763
+ }) => {
3764
+ const jsonData = {
3765
+ model,
3766
+ method: "web_search_read" /* WEB_SEARCH_READ */,
3767
+ ids,
3768
+ with_context: context,
3769
+ kwargs: {
3770
+ specification,
3771
+ domain,
3772
+ limit,
3773
+ offset,
3774
+ order
3775
+ }
3776
+ };
3777
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3778
+ headers: {
3779
+ "Content-Type": "application/json"
3780
+ }
3781
+ });
3782
+ },
3783
+ [env]
3784
+ );
3785
+ const getDetail = useCallback7(
3786
+ async ({ ids = [], model, specification, context }) => {
3787
+ const jsonData = {
3788
+ model,
3789
+ method: "web_read" /* WEB_READ */,
3790
+ ids,
3791
+ with_context: context,
3792
+ kwargs: {
3793
+ specification
3794
+ }
3795
+ };
3796
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3797
+ headers: {
3798
+ "Content-Type": "application/json"
3799
+ }
3800
+ });
3801
+ },
3802
+ [env]
3803
+ );
3804
+ const save = useCallback7(
3805
+ async ({
3754
3806
  model,
3755
- import_compat: importCompat,
3756
- domain: [["id", "in", ids]],
3757
- with_context: context
3758
- };
3759
- if (isShow) {
3760
- jsonData.parent_field = parentField;
3761
- jsonData.parent_field_type = fieldType;
3762
- jsonData.parent_name = parentName;
3763
- jsonData.name = name;
3764
- jsonData.prefix = prefix;
3765
- jsonData.exclude = [null];
3766
- }
3767
- return env2.requests.post("/export/get_fields", jsonData);
3768
- },
3769
- async exportExcel({
3770
- model,
3771
- domain,
3772
- ids,
3773
- fields,
3774
- type,
3775
- importCompat,
3776
- context,
3777
- groupby
3778
- }) {
3779
- const env2 = getEnv();
3780
- const jsonData = {
3807
+ ids = [],
3808
+ data = {},
3809
+ specification = {},
3810
+ context = {},
3811
+ path
3812
+ }) => {
3813
+ const jsonData = {
3814
+ model,
3815
+ method: "web_save" /* WEB_SAVE */,
3816
+ with_context: context,
3817
+ ids,
3818
+ kwargs: {
3819
+ vals: data,
3820
+ specification
3821
+ }
3822
+ };
3823
+ return env.requests.post(path ?? "/call" /* CALL_PATH */, jsonData, {
3824
+ headers: {
3825
+ "Content-Type": "application/json"
3826
+ }
3827
+ });
3828
+ },
3829
+ [env]
3830
+ );
3831
+ const deleteApi = useCallback7(
3832
+ async ({ ids = [], model }) => {
3833
+ const jsonData = {
3834
+ model,
3835
+ method: "unlink" /* UNLINK */,
3836
+ ids
3837
+ };
3838
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3839
+ headers: {
3840
+ "Content-Type": "application/json"
3841
+ }
3842
+ });
3843
+ },
3844
+ [env]
3845
+ );
3846
+ const onChange = useCallback7(
3847
+ async ({
3848
+ ids = [],
3781
3849
  model,
3782
- domain,
3783
- ids,
3784
- import_compat: importCompat,
3785
- fields,
3786
- with_context: context,
3787
- groupby: groupby ?? []
3788
- };
3789
- return env2.requests.post_excel(`/export/${type}`, jsonData);
3790
- }
3791
- };
3792
- var excel_service_default = ExcelService;
3850
+ object,
3851
+ specification,
3852
+ context,
3853
+ fieldChange
3854
+ }) => {
3855
+ const jsonData = {
3856
+ model,
3857
+ method: "onchange" /* ONCHANGE */,
3858
+ ids,
3859
+ with_context: context,
3860
+ args: [
3861
+ object ? object : {},
3862
+ fieldChange ? fieldChange : [],
3863
+ specification
3864
+ ]
3865
+ };
3866
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3867
+ headers: {
3868
+ "Content-Type": "application/json"
3869
+ }
3870
+ });
3871
+ },
3872
+ [env]
3873
+ );
3874
+ const getListFieldsOnchange = useCallback7(
3875
+ async ({ model }) => {
3876
+ const jsonData = {
3877
+ model,
3878
+ method: "get_fields_onchange" /* GET_ONCHANGE_FIELDS */
3879
+ };
3880
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3881
+ headers: {
3882
+ "Content-Type": "application/json"
3883
+ }
3884
+ });
3885
+ },
3886
+ [env]
3887
+ );
3888
+ const parseORMOdoo = useCallback7((data) => {
3889
+ for (const key in data) {
3890
+ if (key === "display_name") {
3891
+ delete data[key];
3892
+ }
3893
+ if (!data[key] && data[key] !== 0) {
3894
+ data[key] = false;
3895
+ } else if (data[key] === "Draft") {
3896
+ data[key] = "/";
3897
+ }
3898
+ }
3899
+ return { ...data };
3900
+ }, []);
3901
+ const toDataJS = useCallback7(
3902
+ (data, viewData, model) => {
3903
+ for (const key in data) {
3904
+ if (data[key] === false) {
3905
+ if (viewData && model) {
3906
+ if (viewData?.models?.[model]?.[key]?.type !== "boolean" /* BOOLEAN */) {
3907
+ data[key] = null;
3908
+ }
3909
+ } else {
3910
+ data[key] = null;
3911
+ }
3912
+ } else if (data[key] === "/") {
3913
+ data[key] = "Draft";
3914
+ } else if (data[key] !== false) {
3915
+ if (model !== void 0) {
3916
+ if (viewData?.models?.[model]?.[key]?.type === "one2many" /* ONE2MANY */ || viewData?.models?.[model]?.[key]?.type === "many2many" /* MANY2MANY */) {
3917
+ data[key] = (data[key] ??= [])?.map((item) => {
3918
+ const relation = viewData?.models?.[model]?.[key]?.relation;
3919
+ if (relation !== void 0) {
3920
+ if (viewData?.models?.[relation]) {
3921
+ if (item?.length >= 3) {
3922
+ return toDataJS(item[OBJECT_POSITION], viewData, relation);
3923
+ } else {
3924
+ return toDataJS(item, viewData, relation);
3925
+ }
3926
+ } else {
3927
+ if (item?.length >= 3) {
3928
+ return item[OBJECT_POSITION];
3929
+ } else {
3930
+ return item;
3931
+ }
3932
+ }
3933
+ }
3934
+ });
3935
+ }
3936
+ }
3937
+ }
3938
+ }
3939
+ return { ...data };
3940
+ },
3941
+ []
3942
+ );
3943
+ return {
3944
+ getListMyBankAccount,
3945
+ getCurrency,
3946
+ getConversionRate,
3947
+ getAll,
3948
+ getListCalendar,
3949
+ getList,
3950
+ getDetail,
3951
+ save,
3952
+ deleteApi,
3953
+ onChange,
3954
+ getListFieldsOnchange,
3955
+ parseORMOdoo,
3956
+ toDataJS
3957
+ };
3958
+ }
3793
3959
 
3794
- // src/services/form-service/index.ts
3795
- var FormService = {
3796
- async getComment({ data }) {
3797
- try {
3798
- const env2 = getEnv();
3960
+ // src/services/user-service/index.ts
3961
+ import { useCallback as useCallback8 } from "react";
3962
+ function useUserService() {
3963
+ const { env } = useEnv();
3964
+ const getProfile = useCallback8(
3965
+ async (path) => {
3966
+ return env?.requests?.get(path ?? "/userinfo" /* PROFILE_PATH */, {
3967
+ headers: {
3968
+ "Content-Type": "application/x-www-form-urlencoded"
3969
+ }
3970
+ });
3971
+ },
3972
+ [env]
3973
+ );
3974
+ const getUser = useCallback8(
3975
+ async ({ context, id }) => {
3799
3976
  const jsonData = {
3800
- thread_id: data.thread_id,
3801
- thread_model: data.thread_model,
3802
- limit: 100,
3803
- with_context: {
3804
- lang: data.lang
3977
+ model: "res.users",
3978
+ method: "web_read",
3979
+ ids: [id],
3980
+ with_context: context,
3981
+ kwargs: {
3982
+ specification: {
3983
+ display_name: {},
3984
+ image_1920: {},
3985
+ name: {},
3986
+ login: {},
3987
+ email: {},
3988
+ password: {},
3989
+ visible_group_id: {
3990
+ fields: {
3991
+ id: {},
3992
+ display_name: {}
3993
+ }
3994
+ },
3995
+ company_id: {
3996
+ fields: {
3997
+ id: {},
3998
+ display_name: {}
3999
+ }
4000
+ }
4001
+ }
3805
4002
  }
3806
4003
  };
3807
- return env2.requests.post("/chatter/thread/messages" /* GET_MESSAGE */, jsonData, {
4004
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3808
4005
  headers: {
3809
4006
  "Content-Type": "application/json"
3810
4007
  }
3811
4008
  });
3812
- } catch (error) {
3813
- console.error("Error when sending message:", error);
3814
- throw error;
3815
- }
3816
- },
3817
- async sentComment({ data }) {
3818
- try {
3819
- const env2 = getEnv();
4009
+ },
4010
+ [env]
4011
+ );
4012
+ const switchUserLocale = useCallback8(
4013
+ async ({ id, values }) => {
3820
4014
  const jsonData = {
3821
- context: {
3822
- tz: "Asia/Saigon",
3823
- uid: 2,
3824
- allowed_company_ids: [1],
3825
- mail_post_autofollow: false,
3826
- temporary_id: 142183.01
3827
- },
3828
- post_data: {
3829
- body: data.message,
3830
- message_type: "comment",
3831
- attachment_ids: data.attachment_ids,
3832
- attachment_tokens: [],
3833
- subtype_xmlid: data.subtype
4015
+ model: "res.users",
4016
+ domain: [["id", "=", id]],
4017
+ values
4018
+ };
4019
+ return env?.requests.post(UriConstants?.CREATE_UPDATE_PATH, jsonData, {
4020
+ headers: {
4021
+ "Content-Type": "application/json"
4022
+ }
4023
+ });
4024
+ },
4025
+ [env]
4026
+ );
4027
+ return {
4028
+ getProfile,
4029
+ getUser,
4030
+ switchUserLocale
4031
+ };
4032
+ }
4033
+
4034
+ // src/services/view-service/index.ts
4035
+ import { useCallback as useCallback9 } from "react";
4036
+ function useViewService() {
4037
+ const { env } = useEnv();
4038
+ const getView = useCallback9(
4039
+ async ({
4040
+ model,
4041
+ views,
4042
+ context = {},
4043
+ options = {},
4044
+ aid
4045
+ }) => {
4046
+ const defaultOptions = {
4047
+ load_filters: true,
4048
+ toolbar: true,
4049
+ action_id: aid
4050
+ };
4051
+ const jsonDataView = {
4052
+ model,
4053
+ method: "get_fields_view_v2" /* GET_FIELD_VIEW */,
4054
+ kwargs: {
4055
+ views,
4056
+ options: { ...options, ...defaultOptions }
3834
4057
  },
3835
- thread_id: Number(data.thread_id),
3836
- thread_model: data.thread_model
4058
+ with_context: context
3837
4059
  };
3838
- return env2.requests.post("/chatter/message/post" /* SENT_MESSAGE */, jsonData, {
4060
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
3839
4061
  headers: {
3840
4062
  "Content-Type": "application/json"
3841
4063
  }
3842
4064
  });
3843
- } catch (error) {
3844
- console.error("Error when sent message:", error);
3845
- throw error;
3846
- }
3847
- },
3848
- async deleteComment({ data }) {
3849
- try {
3850
- const env2 = getEnv();
4065
+ },
4066
+ [env]
4067
+ );
4068
+ const getMenu = useCallback9(
4069
+ async (context) => {
3851
4070
  const jsonData = {
3852
- attachment_ids: [],
3853
- attachment_tokens: [],
3854
- body: "",
3855
- message_id: data.message_id
4071
+ model: "ir.ui.menu" /* MENU */,
4072
+ method: "web_search_read" /* WEB_SEARCH_READ */,
4073
+ ids: [],
4074
+ with_context: context,
4075
+ kwargs: {
4076
+ specification: {
4077
+ active: {},
4078
+ name: {},
4079
+ is_display: {},
4080
+ sequence: {},
4081
+ complete_name: {},
4082
+ action: {
4083
+ fields: {
4084
+ display_name: {},
4085
+ type: {},
4086
+ binding_view_types: {}
4087
+ }
4088
+ },
4089
+ url_icon: {},
4090
+ web_icon: {},
4091
+ web_icon_data: {},
4092
+ groups_id: {
4093
+ fields: {
4094
+ full_name: {}
4095
+ },
4096
+ limit: 40,
4097
+ order: ""
4098
+ },
4099
+ display_name: {},
4100
+ child_id: {
4101
+ fields: {
4102
+ active: {},
4103
+ name: {},
4104
+ is_display: {},
4105
+ sequence: {},
4106
+ complete_name: {},
4107
+ action: {
4108
+ fields: {
4109
+ display_name: {},
4110
+ type: {},
4111
+ binding_view_types: {}
4112
+ }
4113
+ },
4114
+ url_icon: {},
4115
+ web_icon: {},
4116
+ web_icon_data: {},
4117
+ groups_id: {
4118
+ fields: {
4119
+ full_name: {}
4120
+ },
4121
+ limit: 40,
4122
+ order: ""
4123
+ },
4124
+ display_name: {},
4125
+ child_id: {
4126
+ fields: {
4127
+ active: {},
4128
+ name: {},
4129
+ is_display: {},
4130
+ sequence: {},
4131
+ complete_name: {},
4132
+ action: {
4133
+ fields: {
4134
+ display_name: {},
4135
+ type: {},
4136
+ binding_view_types: {}
4137
+ }
4138
+ },
4139
+ url_icon: {},
4140
+ web_icon: {},
4141
+ web_icon_data: {},
4142
+ groups_id: {
4143
+ fields: {
4144
+ full_name: {}
4145
+ },
4146
+ limit: 40,
4147
+ order: ""
4148
+ },
4149
+ display_name: {},
4150
+ child_id: {
4151
+ fields: {},
4152
+ limit: 40,
4153
+ order: ""
4154
+ }
4155
+ },
4156
+ limit: 40,
4157
+ order: ""
4158
+ }
4159
+ },
4160
+ limit: 40,
4161
+ order: ""
4162
+ }
4163
+ },
4164
+ domain: [
4165
+ "&",
4166
+ ["is_display", "=", true],
4167
+ "&",
4168
+ ["active", "=", true],
4169
+ ["parent_id", "=", false]
4170
+ ]
4171
+ }
3856
4172
  };
3857
- return env2.requests.post("/chatter/message/update_content" /* DELETE_MESSAGE */, jsonData, {
4173
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3858
4174
  headers: {
3859
4175
  "Content-Type": "application/json"
3860
4176
  }
3861
4177
  });
3862
- } catch (error) {
3863
- console.error("Error when sent message:", error);
3864
- throw error;
3865
- }
3866
- },
3867
- async getImage({ data }) {
3868
- try {
3869
- const env2 = getEnv();
3870
- return env2.requests.get(
3871
- `${"/web/image" /* IMAGE_PATH */}?filename=${data.filename}&unique=${data.checksum}&width=1920&height=300`,
3872
- {
3873
- headers: {
3874
- "Content-Type": "application/json"
4178
+ },
4179
+ [env]
4180
+ );
4181
+ const getActionDetail = useCallback9(
4182
+ async (aid, context) => {
4183
+ const jsonData = {
4184
+ model: "ir.actions.act_window" /* WINDOW_ACTION */,
4185
+ method: "web_read" /* WEB_READ */,
4186
+ ids: [aid],
4187
+ with_context: context,
4188
+ kwargs: {
4189
+ specification: {
4190
+ id: {},
4191
+ name: {},
4192
+ res_model: {},
4193
+ views: {},
4194
+ view_mode: {},
4195
+ mobile_view_mode: {},
4196
+ domain: {},
4197
+ context: {},
4198
+ groups_id: {},
4199
+ search_view_id: {}
3875
4200
  }
3876
4201
  }
3877
- );
3878
- } catch (error) {
3879
- console.error("Error when sent message:", error);
3880
- throw error;
3881
- }
3882
- },
3883
- async uploadImage({ data }) {
3884
- try {
3885
- const env2 = getEnv();
3886
- return env2.requests.post("/mail/attachment/upload" /* UPLOAD_IMAGE */, data, {
4202
+ };
4203
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4204
+ headers: {
4205
+ "Content-Type": "application/json"
4206
+ }
4207
+ });
4208
+ },
4209
+ [env]
4210
+ );
4211
+ const getResequence = useCallback9(
4212
+ async ({
4213
+ model,
4214
+ ids,
4215
+ context,
4216
+ offset
4217
+ }) => {
4218
+ const jsonData = {
4219
+ model,
4220
+ with_context: context,
4221
+ ids,
4222
+ field: "sequence",
4223
+ ...offset > 0 ? { offset } : {}
4224
+ };
4225
+ return env?.requests.post("/web/dataset/resequence", jsonData, {
3887
4226
  headers: {
3888
- "Content-Type": "multipart/form-data"
4227
+ "Content-Type": "application/json"
3889
4228
  }
3890
4229
  });
3891
- } catch (error) {
3892
- console.error("Error when sent message:", error);
3893
- throw error;
3894
- }
3895
- },
3896
- async getFormView({ data }) {
3897
- try {
3898
- const env2 = getEnv();
4230
+ },
4231
+ [env]
4232
+ );
4233
+ const getSelectionItem = useCallback9(
4234
+ async ({ data }) => {
3899
4235
  const jsonData = {
3900
4236
  model: data.model,
3901
- method: "get_formview_action",
3902
- ids: data.id ? [data.id] : [],
3903
- with_context: data.context
4237
+ ids: [],
4238
+ method: "get_data_select",
4239
+ with_context: data.context,
4240
+ kwargs: {
4241
+ count_limit: 10001,
4242
+ domain: data.domain ? data.domain : [],
4243
+ offset: 0,
4244
+ order: "",
4245
+ specification: data?.specification ?? {
4246
+ id: {},
4247
+ name: {},
4248
+ display_name: {}
4249
+ }
4250
+ }
3904
4251
  };
3905
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
4252
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3906
4253
  headers: {
3907
4254
  "Content-Type": "application/json"
3908
4255
  }
3909
4256
  });
3910
- } catch (error) {
3911
- console.error("Error when fetching form view:", error);
3912
- throw error;
3913
- }
3914
- },
3915
- async changeStatus({ data }) {
3916
- const env2 = getEnv();
3917
- const vals = {
3918
- [data.name]: data.stage_id
3919
- };
3920
- const jsonData = {
3921
- model: data.model,
3922
- method: "web_save",
3923
- with_context: {
3924
- lang: data.lang,
3925
- allowed_company_ids: [1],
3926
- uid: 2,
3927
- search_default_my_ticket: true,
3928
- search_default_is_open: true
3929
- },
3930
- ids: [data.id],
3931
- kwargs: {
3932
- vals,
3933
- specification: {}
3934
- }
3935
- };
3936
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3937
- headers: {
3938
- "Content-Type": "application/json"
3939
- }
3940
- });
3941
- }
3942
- };
3943
- var form_service_default = FormService;
3944
-
3945
- // src/services/model-service/index.ts
3946
- var OBJECT_POSITION = 2;
3947
- var ModelService = {
3948
- async getListMyBankAccount({
3949
- domain,
3950
- spectification,
3951
- model
3952
- }) {
3953
- const env2 = getEnv();
3954
- const jsonData = {
3955
- model,
3956
- method: "web_search_read",
3957
- kwargs: {
3958
- specification: spectification,
3959
- domain,
3960
- limit: 100,
3961
- offset: 0
3962
- }
3963
- };
3964
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3965
- headers: {
3966
- "Content-Type": "application/json"
3967
- }
3968
- });
3969
- },
3970
- async getCurrency() {
3971
- const env2 = getEnv();
3972
- const jsonData = {
3973
- model: "res.currency",
3974
- method: "web_search_read",
3975
- kwargs: {
3976
- specification: {
3977
- icon_url: {},
3978
- name: {}
3979
- },
3980
- domain: [["active", "=", true]],
3981
- limit: 100,
3982
- offset: 0
3983
- }
3984
- };
3985
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3986
- headers: {
3987
- "Content-Type": "application/json"
3988
- }
3989
- });
3990
- },
3991
- async getConversionRate() {
3992
- const env2 = getEnv();
3993
- const jsonData = {
3994
- model: "res.currency",
3995
- method: "web_search_read",
3996
- kwargs: {
3997
- specification: {
3998
- name: {},
3999
- icon_url: {},
4000
- rate_ids: {
4001
- fields: {
4002
- company_rate: {},
4003
- sell: {}
4004
- }
4005
- }
4006
- },
4007
- domain: [["active", "=", true]],
4008
- limit: 100,
4009
- offset: 0
4010
- }
4011
- };
4012
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4013
- headers: {
4014
- "Content-Type": "application/json"
4015
- }
4016
- });
4017
- },
4018
- async getAll({ data }) {
4019
- const env2 = getEnv();
4020
- const jsonReadGroup = data.type == "calendar" ? { fields: data?.fields } : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
4021
- fields: data.fields,
4022
- groupby: data.groupby
4023
- } : {
4024
- count_limit: 10001,
4025
- order: data.sort,
4026
- specification: data.specification
4027
- };
4028
- const jsonData = {
4029
- model: String(data.model),
4030
- method: data.type == "calendar" ? "search_read" : jsonReadGroup.fields && jsonReadGroup.groupby ? "web_read_group" : "web_search_read",
4031
- ids: data.ids,
4032
- with_context: data.context,
4033
- kwargs: {
4034
- domain: data.domain,
4035
- limit: data.limit,
4036
- offset: data.offset,
4037
- ...jsonReadGroup
4038
- }
4039
- };
4040
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4041
- headers: {
4042
- "Content-Type": "application/json"
4043
- }
4044
- });
4045
- },
4046
- async getListCalendar({ data }) {
4047
- const env2 = getEnv();
4048
- const jsonReadGroup = data.type == "calendar" ? data?.fields : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
4049
- fields: data.fields,
4050
- groupby: data.groupby
4051
- } : {
4052
- count_limit: 10001,
4053
- order: data.sort,
4054
- specification: data.specification
4055
- };
4056
- const jsonData = {
4057
- model: String(data.model),
4058
- method: data.type == "calendar" ? "search_read" : jsonReadGroup.fields && jsonReadGroup.groupby ? "web_read_group" : "web_search_read",
4059
- ids: data.ids,
4060
- with_context: data.context,
4061
- kwargs: {
4062
- domain: data.domain,
4063
- limit: data.limit,
4064
- offset: data.offset,
4065
- fields: data.fields,
4066
- ...jsonReadGroup
4067
- }
4068
- };
4069
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4070
- headers: {
4071
- "Content-Type": "application/json"
4072
- }
4073
- });
4074
- },
4075
- async getList({
4076
- model,
4077
- ids = [],
4078
- specification = {},
4079
- domain = [],
4080
- offset,
4081
- order,
4082
- context = {},
4083
- limit = 10
4084
- }) {
4085
- const env2 = getEnv();
4086
- const jsonData = {
4087
- model,
4088
- method: "web_search_read" /* WEB_SEARCH_READ */,
4089
- ids,
4090
- with_context: context,
4091
- kwargs: {
4092
- specification,
4093
- domain,
4094
- limit,
4095
- offset,
4096
- order
4097
- }
4098
- };
4099
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4100
- headers: {
4101
- "Content-Type": "application/json"
4102
- }
4103
- });
4104
- },
4105
- async getDetail({
4106
- ids = [],
4107
- model,
4108
- specification,
4109
- context
4110
- }) {
4111
- const env2 = getEnv();
4112
- const jsonData = {
4113
- model,
4114
- method: "web_read" /* WEB_READ */,
4115
- ids,
4116
- with_context: context,
4117
- kwargs: {
4118
- specification
4119
- }
4120
- };
4121
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4122
- headers: {
4123
- "Content-Type": "application/json"
4124
- }
4125
- });
4126
- },
4127
- async save({
4128
- model,
4129
- ids = [],
4130
- data = {},
4131
- specification = {},
4132
- context = {},
4133
- path
4134
- }) {
4135
- const env2 = getEnv();
4136
- const jsonData = {
4137
- model,
4138
- method: "web_save" /* WEB_SAVE */,
4139
- with_context: context,
4140
- ids,
4141
- kwargs: {
4142
- vals: data,
4143
- specification
4144
- }
4145
- };
4146
- return env2?.requests?.post(path ?? "/call" /* CALL_PATH */, jsonData, {
4147
- headers: {
4148
- "Content-Type": "application/json"
4149
- }
4150
- });
4151
- },
4152
- async delete({ ids = [], model }) {
4153
- const env2 = getEnv();
4154
- const jsonData = {
4155
- model,
4156
- method: "unlink" /* UNLINK */,
4157
- ids
4158
- };
4159
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4160
- headers: {
4161
- "Content-Type": "application/json"
4162
- }
4163
- });
4164
- },
4165
- async onChange({
4166
- ids = [],
4167
- model,
4168
- object,
4169
- specification,
4170
- context,
4171
- fieldChange
4172
- }) {
4173
- const env2 = getEnv();
4174
- const jsonData = {
4175
- model,
4176
- method: "onchange" /* ONCHANGE */,
4177
- ids,
4178
- with_context: context,
4179
- args: [
4180
- object ? object : {},
4181
- fieldChange ? fieldChange : [],
4182
- specification
4183
- ]
4184
- };
4185
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4186
- headers: {
4187
- "Content-Type": "application/json"
4188
- }
4189
- });
4190
- },
4191
- async getListFieldsOnchange({ model }) {
4192
- const env2 = getEnv();
4193
- const jsonData = {
4194
- model,
4195
- method: "get_fields_onchange" /* GET_ONCHANGE_FIELDS */
4196
- };
4197
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4198
- headers: {
4199
- "Content-Type": "application/json"
4200
- }
4201
- });
4202
- },
4203
- parseORMOdoo(data) {
4204
- for (const key in data) {
4205
- if (key === "display_name") {
4206
- delete data[key];
4207
- }
4208
- if (!data[key] && data[key] !== 0) {
4209
- data[key] = false;
4210
- } else if (data[key] === "Draft") {
4211
- data[key] = "/";
4212
- }
4213
- }
4214
- return { ...data };
4215
- },
4216
- toDataJS(data, viewData, model) {
4217
- for (const key in data) {
4218
- if (data[key] === false) {
4219
- if (viewData && model) {
4220
- if (viewData?.models?.[model]?.[key]?.type !== "boolean" /* BOOLEAN */) {
4221
- data[key] = null;
4222
- }
4223
- } else {
4224
- data[key] = null;
4225
- }
4226
- } else if (data[key] === "/") {
4227
- data[key] = "Draft";
4228
- } else if (data[key] !== false) {
4229
- if (model !== void 0) {
4230
- if (viewData?.models?.[model]?.[key]?.type === "one2many" /* ONE2MANY */ || viewData?.models?.[model]?.[key]?.type === "many2many" /* MANY2MANY */) {
4231
- data[key] = (data[key] ??= [])?.map((item) => {
4232
- const relation = viewData?.models?.[model]?.[key]?.relation;
4233
- if (relation !== void 0) {
4234
- if (viewData?.models?.[relation]) {
4235
- if (item?.length >= 3) {
4236
- return ModelService.toDataJS(
4237
- item[OBJECT_POSITION],
4238
- viewData,
4239
- relation
4240
- );
4241
- } else {
4242
- return ModelService.toDataJS(item, viewData, relation);
4243
- }
4244
- } else {
4245
- if (item?.length >= 3) {
4246
- return item[OBJECT_POSITION];
4247
- } else {
4248
- return item;
4249
- }
4250
- }
4251
- }
4252
- });
4253
- }
4254
- }
4255
- }
4256
- }
4257
- return { ...data };
4258
- }
4259
- };
4260
- var model_service_default = ModelService;
4261
-
4262
- // src/services/user-service/index.ts
4263
- var UserService = {
4264
- async getProfile(path) {
4265
- const env2 = getEnv();
4266
- return env2?.requests?.get(path ?? "/userinfo" /* PROFILE_PATH */, {
4267
- headers: {
4268
- "Content-Type": "application/x-www-form-urlencoded"
4269
- }
4270
- });
4271
- },
4272
- async getUser({ context, id }) {
4273
- const env2 = getEnv();
4274
- const jsonData = {
4275
- model: "res.users",
4276
- method: "web_read",
4277
- ids: [id],
4278
- with_context: context,
4279
- kwargs: {
4280
- specification: {
4281
- display_name: {},
4282
- image_1920: {},
4283
- name: {},
4284
- login: {},
4285
- email: {},
4286
- password: {},
4287
- visible_group_id: {
4288
- fields: {
4289
- id: {},
4290
- display_name: {}
4291
- }
4292
- },
4293
- company_id: {
4294
- fields: {
4295
- id: {},
4296
- display_name: {}
4297
- }
4298
- }
4299
- }
4300
- }
4301
- };
4302
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
4303
- headers: {
4304
- "Content-Type": "application/json"
4305
- }
4306
- });
4307
- },
4308
- switchUserLocale: async ({ id, values }) => {
4309
- const env2 = getEnv();
4310
- const jsonData = {
4311
- model: "res.users",
4312
- domain: [["id", "=", id]],
4313
- values
4314
- };
4315
- return env2?.requests.post(UriConstants?.CREATE_UPDATE_PATH, jsonData, {
4257
+ },
4258
+ [env]
4259
+ );
4260
+ const loadMessages = useCallback9(async () => {
4261
+ return env.requests.post(
4262
+ "/load_message_failures" /* LOAD_MESSAGE */,
4263
+ {},
4264
+ {
4265
+ headers: {
4266
+ "Content-Type": "application/json"
4267
+ }
4268
+ }
4269
+ );
4270
+ }, [env]);
4271
+ const getVersion = useCallback9(async () => {
4272
+ return env?.requests?.get("", {
4316
4273
  headers: {
4317
4274
  "Content-Type": "application/json"
4318
4275
  }
4319
4276
  });
4320
- }
4321
- };
4322
- var user_service_default = UserService;
4323
-
4324
- // src/hooks/auth/use-forgot-password.ts
4325
- var useForgotPassword = () => {
4326
- return useMutation({
4327
- mutationFn: (email) => {
4328
- return auth_service_default.forgotPassword(email);
4329
- }
4330
- });
4331
- };
4332
- var use_forgot_password_default = useForgotPassword;
4333
-
4334
- // src/hooks/auth/use-forgotpassword-sso.ts
4335
- import { useMutation as useMutation2 } from "@tanstack/react-query";
4336
- var useForgotPasswordSSO = () => {
4337
- return useMutation2({
4338
- mutationFn: ({
4339
- email,
4340
- with_context,
4341
- method
4277
+ }, [env]);
4278
+ const grantAccess = useCallback9(
4279
+ async ({
4280
+ redirect_uri,
4281
+ state,
4282
+ client_id,
4283
+ scopes
4342
4284
  }) => {
4343
- return auth_service_default.forgotPasswordSSO({ email, with_context, method });
4344
- }
4345
- });
4346
- };
4347
- var use_forgotpassword_sso_default = useForgotPasswordSSO;
4348
-
4349
- // src/hooks/auth/use-get-provider.ts
4350
- import { useMutation as useMutation3 } from "@tanstack/react-query";
4351
- var useGetProvider = () => {
4352
- return useMutation3({
4353
- mutationFn: (data) => {
4354
- return auth_service_default.getProviders(data?.db);
4355
- }
4356
- });
4357
- };
4358
- var use_get_provider_default = useGetProvider;
4359
-
4360
- // src/hooks/auth/use-isvalid-token.ts
4361
- import { useMutation as useMutation4 } from "@tanstack/react-query";
4362
- var useIsValidToken = () => {
4363
- return useMutation4({
4364
- mutationFn: (token) => {
4365
- return auth_service_default.isValidToken(token);
4366
- }
4367
- });
4368
- };
4369
- var use_isvalid_token_default = useIsValidToken;
4370
-
4371
- // src/hooks/auth/use-login-credential.tsx
4372
- import { useMutation as useMutation5 } from "@tanstack/react-query";
4373
-
4374
- // src/services/auth-service/backup.ts
4375
- import { useCallback as useCallback2 } from "react";
4376
- function useAuthService() {
4377
- const { env: env2 } = useEnv();
4378
- const login = useCallback2(
4379
- async (body) => {
4380
- const payload = Object.fromEntries(
4381
- Object.entries({
4382
- username: body.email,
4383
- password: body.password,
4384
- grant_type: env2?.config?.grantType || "",
4385
- client_id: env2?.config?.clientId || "",
4386
- client_secret: env2?.config?.clientSecret || ""
4387
- }).filter(([_, value]) => !!value)
4388
- );
4389
- const encodedData = new URLSearchParams(payload).toString();
4390
- return env2?.requests?.post(body.path, encodedData, {
4285
+ const jsonData = {
4286
+ redirect_uri,
4287
+ state,
4288
+ client_id,
4289
+ scopes
4290
+ };
4291
+ return env?.requests.post("/grant-access" /* GRANT_ACCESS */, jsonData, {
4391
4292
  headers: {
4392
- "Content-Type": "application/x-www-form-urlencoded"
4293
+ "Content-Type": "application/json"
4294
+ },
4295
+ withCredentials: true
4296
+ });
4297
+ },
4298
+ [env]
4299
+ );
4300
+ const removeTotpSetUp = useCallback9(
4301
+ async ({ method, token }) => {
4302
+ const jsonData = {
4303
+ method,
4304
+ with_context: {
4305
+ token
4306
+ }
4307
+ };
4308
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4309
+ headers: {
4310
+ "Content-Type": "application/json"
4393
4311
  }
4394
4312
  });
4395
4313
  },
4396
- [env2]
4314
+ [env]
4397
4315
  );
4398
- const forgotPassword = useCallback2(
4399
- async (email) => {
4400
- const bodyData = {
4401
- login: email,
4402
- url: `${window.location.origin}/reset-password`
4316
+ const requestSetupTotp = useCallback9(
4317
+ async ({ method, token }) => {
4318
+ const jsonData = {
4319
+ method,
4320
+ with_context: { token }
4403
4321
  };
4404
- return env2?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
4322
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4405
4323
  headers: {
4406
4324
  "Content-Type": "application/json"
4407
4325
  }
4408
4326
  });
4409
4327
  },
4410
- [env2]
4328
+ [env]
4411
4329
  );
4412
- const forgotPasswordSSO = useCallback2(
4330
+ const settingsWebRead2fa = useCallback9(
4413
4331
  async ({
4414
- email,
4415
- with_context,
4416
- method
4332
+ method,
4333
+ model,
4334
+ kwargs,
4335
+ token
4417
4336
  }) => {
4418
- const body = {
4337
+ const jsonData = {
4419
4338
  method,
4420
- kwargs: {
4421
- vals: {
4422
- email
4423
- }
4424
- },
4425
- with_context
4339
+ model,
4340
+ kwargs,
4341
+ with_context: {
4342
+ token
4343
+ }
4426
4344
  };
4427
- return env2?.requests?.post("/call" /* CALL_PATH */, body, {
4345
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4428
4346
  headers: {
4429
4347
  "Content-Type": "application/json"
4430
4348
  }
4431
4349
  });
4432
4350
  },
4433
- [env2]
4351
+ [env]
4434
4352
  );
4435
- const resetPassword = useCallback2(
4436
- async (data, token) => {
4437
- const bodyData = {
4438
- token,
4439
- password: data.password,
4440
- new_password: data.confirmPassword
4353
+ const signInSSO = useCallback9(
4354
+ async ({
4355
+ redirect_uri,
4356
+ state,
4357
+ client_id,
4358
+ response_type
4359
+ }) => {
4360
+ const jsonData = {
4361
+ redirect_uri,
4362
+ state,
4363
+ client_id,
4364
+ response_type
4441
4365
  };
4442
- return env2?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
4366
+ return env?.requests.get("/signin-sso/oauth" /* SIGNIN_SSO */, jsonData, {
4443
4367
  headers: {
4444
- "Content-Type": "application/json"
4368
+ credentials: "include"
4445
4369
  }
4446
4370
  });
4447
4371
  },
4448
- [env2]
4372
+ [env]
4449
4373
  );
4450
- const resetPasswordSSO = useCallback2(
4451
- async ({
4374
+ const verify2FA = useCallback9(
4375
+ ({
4452
4376
  method,
4453
- password,
4454
- with_context
4377
+ with_context,
4378
+ code,
4379
+ device,
4380
+ location
4455
4381
  }) => {
4456
- const bodyData = {
4382
+ const jsonData = {
4457
4383
  method,
4458
4384
  kwargs: {
4459
4385
  vals: {
4460
- password
4386
+ code,
4387
+ device,
4388
+ location
4461
4389
  }
4462
4390
  },
4463
4391
  with_context
4464
4392
  };
4465
- return env2?.requests?.post("/call" /* CALL_PATH */, bodyData, {
4393
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4466
4394
  headers: {
4467
4395
  "Content-Type": "application/json"
4468
- }
4396
+ },
4397
+ withCredentials: true
4469
4398
  });
4470
4399
  },
4471
- [env2]
4400
+ [env]
4472
4401
  );
4473
- const updatePassword = useCallback2(
4474
- async (data, token) => {
4475
- const bodyData = {
4476
- token,
4477
- old_password: data.oldPassword,
4478
- new_password: data.newPassword
4402
+ const get2FAMethods = useCallback9(
4403
+ ({ method, with_context }) => {
4404
+ const jsonData = {
4405
+ method,
4406
+ with_context
4479
4407
  };
4480
- return env2?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
4408
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4481
4409
  headers: {
4482
4410
  "Content-Type": "application/json"
4483
4411
  }
4484
4412
  });
4485
4413
  },
4486
- [env2]
4414
+ [env]
4487
4415
  );
4488
- const isValidToken = useCallback2(
4489
- async (token) => {
4490
- const bodyData = {
4491
- token
4416
+ const verifyTotp = useCallback9(
4417
+ ({
4418
+ method,
4419
+ action_token,
4420
+ code
4421
+ }) => {
4422
+ const jsonData = {
4423
+ method,
4424
+ kwargs: {
4425
+ vals: {
4426
+ code
4427
+ }
4428
+ },
4429
+ with_context: {
4430
+ action_token
4431
+ }
4492
4432
  };
4493
- return env2?.requests?.post("/check_token" /* TOKEN */, bodyData, {
4433
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4494
4434
  headers: {
4495
4435
  "Content-Type": "application/json"
4496
4436
  }
4497
4437
  });
4498
4438
  },
4499
- [env2]
4439
+ [env]
4500
4440
  );
4501
- const isValidActionToken = useCallback2(
4502
- async (actionToken, path) => {
4503
- return env2?.requests?.post(
4504
- path,
4505
- {},
4506
- {
4507
- headers: {
4508
- "Content-Type": "application/json"
4509
- },
4510
- useActionToken: true,
4511
- actionToken
4441
+ return {
4442
+ getView,
4443
+ getMenu,
4444
+ getActionDetail,
4445
+ getResequence,
4446
+ getSelectionItem,
4447
+ loadMessages,
4448
+ getVersion,
4449
+ grantAccess,
4450
+ removeTotpSetUp,
4451
+ requestSetupTotp,
4452
+ settingsWebRead2fa,
4453
+ signInSSO,
4454
+ verify2FA,
4455
+ get2FAMethods,
4456
+ verifyTotp
4457
+ };
4458
+ }
4459
+
4460
+ // src/provider/version-gate-provider.tsx
4461
+ import { Fragment, jsx as jsx4 } from "react/jsx-runtime";
4462
+ var VersionGate = ({ children }) => {
4463
+ const queryClient = useQueryClient();
4464
+ const [ready, setReady] = useState2(false);
4465
+ const { getVersion } = useViewService();
4466
+ useEffect2(() => {
4467
+ const clearVersion = () => {
4468
+ queryClient.clear();
4469
+ localStorage.removeItem("__api_version__");
4470
+ };
4471
+ const validateVersion = async () => {
4472
+ const serverVersion = await getVersion();
4473
+ const cached = localStorage.getItem("__api_version__");
4474
+ if (cached !== serverVersion?.api_version) {
4475
+ clearVersion();
4476
+ localStorage.setItem("__api_version__", serverVersion?.api_version);
4477
+ } else {
4478
+ console.log("Api version:", serverVersion?.api_version);
4479
+ }
4480
+ setReady(true);
4481
+ };
4482
+ validateVersion();
4483
+ if (typeof window !== "undefined") {
4484
+ const onKey = (e) => {
4485
+ const key = e.key.toLowerCase();
4486
+ const isHardRefresh = (key === "f5" || key === "r") && e.ctrlKey && (key !== "r" || e.shiftKey) || key === "r" && e.metaKey && e.shiftKey || key === "r" && e.metaKey && e.altKey;
4487
+ if (isHardRefresh) clearVersion();
4488
+ };
4489
+ window.addEventListener("keydown", onKey);
4490
+ return () => window.removeEventListener("keydown", onKey);
4491
+ }
4492
+ }, [queryClient]);
4493
+ return ready ? /* @__PURE__ */ jsx4(Fragment, { children }) : null;
4494
+ };
4495
+
4496
+ // src/provider/env-provider.tsx
4497
+ import { createContext, useContext, useState as useState3, useCallback as useCallback10 } from "react";
4498
+
4499
+ // src/configs/axios-client.ts
4500
+ import axios from "axios";
4501
+
4502
+ // src/utils/storage/local-storage.ts
4503
+ var localStorageUtils = () => {
4504
+ const setToken = async (access_token) => {
4505
+ localStorage.setItem("accessToken", access_token);
4506
+ };
4507
+ const setRefreshToken = async (refresh_token) => {
4508
+ localStorage.setItem("refreshToken", refresh_token);
4509
+ };
4510
+ const getAccessToken = async () => {
4511
+ return localStorage.getItem("accessToken");
4512
+ };
4513
+ const getRefreshToken = async () => {
4514
+ return localStorage.getItem("refreshToken");
4515
+ };
4516
+ const clearToken = async () => {
4517
+ localStorage.removeItem("accessToken");
4518
+ localStorage.removeItem("refreshToken");
4519
+ };
4520
+ return {
4521
+ setToken,
4522
+ setRefreshToken,
4523
+ getAccessToken,
4524
+ getRefreshToken,
4525
+ clearToken
4526
+ };
4527
+ };
4528
+
4529
+ // src/utils/storage/session-storage.ts
4530
+ var sessionStorageUtils = () => {
4531
+ const getBrowserSession = async () => {
4532
+ return sessionStorage.getItem("browserSession");
4533
+ };
4534
+ return {
4535
+ getBrowserSession
4536
+ };
4537
+ };
4538
+
4539
+ // src/configs/axios-client.ts
4540
+ var axiosClient = {
4541
+ init(config) {
4542
+ const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
4543
+ const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
4544
+ const db = config?.db;
4545
+ let isRefreshing = false;
4546
+ let failedQueue = [];
4547
+ const processQueue = (error, token = null) => {
4548
+ failedQueue?.forEach((prom) => {
4549
+ if (error) {
4550
+ prom.reject(error);
4551
+ } else {
4552
+ prom.resolve(token);
4512
4553
  }
4513
- );
4514
- },
4515
- [env2]
4516
- );
4517
- const loginSocial = useCallback2(
4518
- async ({
4519
- db,
4520
- state,
4521
- access_token
4522
- }) => {
4523
- return env2?.requests?.post(
4524
- "/token/generate" /* GENTOKEN_SOCIAL */,
4525
- { state, access_token },
4526
- {
4527
- headers: {
4528
- "Content-Type": "application/json"
4554
+ });
4555
+ failedQueue = [];
4556
+ };
4557
+ const instance = axios.create({
4558
+ adapter: axios.defaults.adapter,
4559
+ baseURL: config.baseUrl,
4560
+ timeout: 5e4,
4561
+ paramsSerializer: (params) => new URLSearchParams(params).toString()
4562
+ });
4563
+ instance.interceptors.request.use(async (config2) => {
4564
+ const { useRefreshToken, useActionToken, actionToken } = config2;
4565
+ if (useActionToken && actionToken) {
4566
+ config2.headers["Action-Token"] = actionToken;
4567
+ }
4568
+ const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
4569
+ const token = await getToken?.();
4570
+ if (token) config2.headers["Authorization"] = `Bearer ${token}`;
4571
+ return config2;
4572
+ }, Promise.reject);
4573
+ instance.interceptors.response.use(
4574
+ (response) => {
4575
+ return handleResponse(response);
4576
+ },
4577
+ async (error) => {
4578
+ const handleError3 = async (error2) => {
4579
+ if (!error2.response) {
4580
+ return error2;
4529
4581
  }
4530
- }
4531
- );
4532
- },
4533
- [env2]
4534
- );
4535
- const getProviders = useCallback2(
4536
- async (db) => {
4537
- return env2?.requests?.get("/oauth/providers", { params: { db } });
4538
- },
4539
- [env2]
4540
- );
4541
- const getAccessByCode = useCallback2(
4542
- async (code) => {
4543
- const data = new URLSearchParams();
4544
- data.append("code", code);
4545
- data.append("grant_type", "authorization_code");
4546
- data.append("client_id", env2?.config?.clientId || "");
4547
- data.append("redirect_uri", env2?.config?.redirectUri || "");
4548
- return env2?.requests?.post(
4549
- `${env2?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
4550
- data,
4551
- {
4552
- headers: {
4553
- "Content-Type": "application/x-www-form-urlencoded"
4582
+ const { data } = error2.response;
4583
+ if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
4584
+ await clearAuthToken();
4585
+ }
4586
+ return data;
4587
+ };
4588
+ const originalRequest = error.config;
4589
+ if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
4590
+ error.response.data.code
4591
+ )) {
4592
+ if (isRefreshing) {
4593
+ return new Promise(function(resolve, reject) {
4594
+ failedQueue.push({ resolve, reject });
4595
+ }).then((token) => {
4596
+ originalRequest.headers["Authorization"] = "Bearer " + token;
4597
+ originalRequest.data = updateTokenParamInOriginalRequest(
4598
+ originalRequest,
4599
+ token
4600
+ );
4601
+ return instance.request(originalRequest);
4602
+ }).catch(async (err) => {
4603
+ if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
4604
+ await clearAuthToken();
4605
+ }
4606
+ });
4607
+ }
4608
+ const browserSession = await sessionStorage2.getBrowserSession();
4609
+ const refreshToken = await localStorage2.getRefreshToken();
4610
+ const accessTokenExp = await localStorage2.getAccessToken();
4611
+ isRefreshing = true;
4612
+ if (!refreshToken && (!browserSession || browserSession == "unActive")) {
4613
+ await clearAuthToken();
4614
+ } else {
4615
+ const payload = Object.fromEntries(
4616
+ Object.entries({
4617
+ refresh_token: refreshToken,
4618
+ grant_type: "refresh_token",
4619
+ client_id: config.config.clientId,
4620
+ client_secret: config.config.clientSecret
4621
+ }).filter(([_, value]) => !!value)
4622
+ );
4623
+ return new Promise(function(resolve) {
4624
+ axios.post(
4625
+ `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
4626
+ payload,
4627
+ {
4628
+ headers: {
4629
+ "Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
4630
+ Authorization: `Bearer ${accessTokenExp}`
4631
+ }
4632
+ }
4633
+ ).then(async (res) => {
4634
+ const data = res.data;
4635
+ await localStorage2.setToken(data.access_token);
4636
+ await localStorage2.setRefreshToken(data.refresh_token);
4637
+ axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
4638
+ originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
4639
+ originalRequest.data = updateTokenParamInOriginalRequest(
4640
+ originalRequest,
4641
+ data.access_token
4642
+ );
4643
+ processQueue(null, data.access_token);
4644
+ resolve(instance.request(originalRequest));
4645
+ }).catch(async (err) => {
4646
+ if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST") || err?.error_code === "ERR_2FA_006") {
4647
+ await clearAuthToken();
4648
+ }
4649
+ if (err && err.response) {
4650
+ const { error_code } = err.response?.data || {};
4651
+ if (error_code === "AUTHEN_FAIL") {
4652
+ await clearAuthToken();
4653
+ }
4654
+ }
4655
+ processQueue(err, null);
4656
+ }).finally(() => {
4657
+ isRefreshing = false;
4658
+ });
4659
+ });
4554
4660
  }
4555
4661
  }
4556
- );
4557
- },
4558
- [env2]
4559
- );
4560
- const logout = useCallback2(
4561
- async (data) => {
4562
- console.log(data);
4563
- return env2?.requests?.post(
4564
- "/logout" /* LOGOUT */,
4565
- {},
4566
- {
4567
- headers: {
4568
- "Content-Type": "application/json"
4569
- },
4570
- withCredentials: true,
4571
- useRefreshToken: true
4662
+ return Promise.reject(await handleError3(error));
4663
+ }
4664
+ );
4665
+ const handleResponse = (res) => {
4666
+ if (res && res.data) {
4667
+ return res.data;
4668
+ }
4669
+ return res;
4670
+ };
4671
+ const handleError2 = (error) => {
4672
+ if (error.isAxiosError && error.code === "ECONNABORTED") {
4673
+ console.error("Request Timeout Error:", error);
4674
+ return "Request Timeout Error";
4675
+ } else if (error.isAxiosError && !error.response) {
4676
+ console.error("Network Error:", error);
4677
+ return "Network Error";
4678
+ } else {
4679
+ console.error("Other Error:", error?.response);
4680
+ const errorMessage = error?.response?.data?.message || "An error occurred";
4681
+ return { message: errorMessage, status: error?.response?.status };
4682
+ }
4683
+ };
4684
+ const clearAuthToken = async () => {
4685
+ await localStorage2.clearToken();
4686
+ if (typeof window !== "undefined") {
4687
+ window.location.href = `/login`;
4688
+ }
4689
+ };
4690
+ function formatUrl(url, db2) {
4691
+ return url + (db2 ? "?db=" + db2 : "");
4692
+ }
4693
+ const responseBody = (response) => response;
4694
+ const requests = {
4695
+ get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
4696
+ post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
4697
+ post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
4698
+ responseType: "arraybuffer",
4699
+ headers: {
4700
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
4701
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
4572
4702
  }
4573
- );
4574
- },
4575
- [env2]
4576
- );
4577
- return {
4578
- login,
4579
- forgotPassword,
4580
- forgotPasswordSSO,
4581
- resetPassword,
4582
- resetPasswordSSO,
4583
- updatePassword,
4584
- isValidToken,
4585
- isValidActionToken,
4586
- loginSocial,
4587
- getProviders,
4588
- getAccessByCode,
4589
- logout
4590
- };
4591
- }
4703
+ }).then(responseBody),
4704
+ put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
4705
+ patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
4706
+ delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
4707
+ };
4708
+ return requests;
4709
+ }
4710
+ };
4592
4711
 
4593
4712
  // src/provider/env-provider.tsx
4594
- import { createContext, useContext, useState as useState2, useCallback as useCallback3 } from "react";
4595
- import { jsx as jsx4 } from "react/jsx-runtime";
4713
+ import { jsx as jsx5 } from "react/jsx-runtime";
4596
4714
  var initialEnvState = {
4597
4715
  env: null,
4598
4716
  baseUrl: "",
@@ -4620,15 +4738,15 @@ function EnvProvider({
4620
4738
  localStorageUtils: localStorageUtil = localStorageUtils(),
4621
4739
  sessionStorageUtils: sessionStorageUtil = sessionStorageUtils()
4622
4740
  }) {
4623
- const [env2, setEnvState] = useState2({
4741
+ const [env, setEnvState] = useState3({
4624
4742
  ...initialEnvState,
4625
4743
  localStorageUtils: localStorageUtil,
4626
4744
  sessionStorageUtils: sessionStorageUtil
4627
4745
  });
4628
- const setupEnv = useCallback3(
4746
+ const setupEnv = useCallback10(
4629
4747
  (envConfig) => {
4630
4748
  const updatedEnv = {
4631
- ...env2,
4749
+ ...env,
4632
4750
  ...envConfig,
4633
4751
  localStorageUtils: localStorageUtil,
4634
4752
  sessionStorageUtils: sessionStorageUtil
@@ -4637,33 +4755,33 @@ function EnvProvider({
4637
4755
  setEnvState({ ...updatedEnv, requests });
4638
4756
  return updatedEnv;
4639
4757
  },
4640
- [env2, localStorageUtil, sessionStorageUtil]
4758
+ [env, localStorageUtil, sessionStorageUtil]
4641
4759
  );
4642
- const setUid2 = useCallback3((uid) => {
4760
+ const setUid2 = useCallback10((uid) => {
4643
4761
  setEnvState((prev) => ({
4644
4762
  ...prev,
4645
4763
  context: { ...prev.context, uid }
4646
4764
  }));
4647
4765
  }, []);
4648
- const setLang2 = useCallback3((lang) => {
4766
+ const setLang2 = useCallback10((lang) => {
4649
4767
  setEnvState((prev) => ({
4650
4768
  ...prev,
4651
4769
  context: { ...prev.context, lang }
4652
4770
  }));
4653
4771
  }, []);
4654
- const setAllowCompanies2 = useCallback3((allowed_company_ids) => {
4772
+ const setAllowCompanies2 = useCallback10((allowed_company_ids) => {
4655
4773
  setEnvState((prev) => ({
4656
4774
  ...prev,
4657
4775
  context: { ...prev.context, allowed_company_ids }
4658
4776
  }));
4659
4777
  }, []);
4660
- const setCompanies2 = useCallback3((companies) => {
4778
+ const setCompanies2 = useCallback10((companies) => {
4661
4779
  setEnvState((prev) => ({
4662
4780
  ...prev,
4663
4781
  companies
4664
4782
  }));
4665
4783
  }, []);
4666
- const setDefaultCompany2 = useCallback3(
4784
+ const setDefaultCompany2 = useCallback10(
4667
4785
  (defaultCompany) => {
4668
4786
  setEnvState((prev) => ({
4669
4787
  ...prev,
@@ -4672,29 +4790,29 @@ function EnvProvider({
4672
4790
  },
4673
4791
  []
4674
4792
  );
4675
- const setUserInfo = useCallback3((user) => {
4793
+ const setUserInfo = useCallback10((user) => {
4676
4794
  setEnvState((prev) => ({
4677
4795
  ...prev,
4678
4796
  user
4679
4797
  }));
4680
4798
  }, []);
4681
- const setConfig2 = useCallback3((config) => {
4799
+ const setConfig2 = useCallback10((config) => {
4682
4800
  setEnvState((prev) => ({
4683
4801
  ...prev,
4684
4802
  config
4685
4803
  }));
4686
4804
  }, []);
4687
- const setEnvFile2 = useCallback3((envFile) => {
4805
+ const setEnvFile2 = useCallback10((envFile) => {
4688
4806
  setEnvState((prev) => ({
4689
4807
  ...prev,
4690
4808
  envFile
4691
4809
  }));
4692
4810
  }, []);
4693
- return /* @__PURE__ */ jsx4(
4811
+ return /* @__PURE__ */ jsx5(
4694
4812
  EnvContext.Provider,
4695
4813
  {
4696
4814
  value: {
4697
- env: env2,
4815
+ env,
4698
4816
  setupEnv,
4699
4817
  setUid: setUid2,
4700
4818
  setLang: setLang2,
@@ -4717,10 +4835,64 @@ function useEnv() {
4717
4835
  return context;
4718
4836
  }
4719
4837
 
4838
+ // src/provider/service-provider.tsx
4839
+ import { createContext as createContext2, useContext as useContext2 } from "react";
4840
+
4841
+ // src/hooks/auth/use-forgot-password.ts
4842
+ import { useMutation } from "@tanstack/react-query";
4843
+ var useForgotPassword = () => {
4844
+ const { forgotPassword } = useAuthService();
4845
+ return useMutation({
4846
+ mutationFn: (email) => {
4847
+ return forgotPassword(email);
4848
+ }
4849
+ });
4850
+ };
4851
+ var use_forgot_password_default = useForgotPassword;
4852
+
4853
+ // src/hooks/auth/use-forgotpassword-sso.ts
4854
+ import { useMutation as useMutation2 } from "@tanstack/react-query";
4855
+ var useForgotPasswordSSO = () => {
4856
+ const { forgotPasswordSSO } = useAuthService();
4857
+ return useMutation2({
4858
+ mutationFn: ({
4859
+ email,
4860
+ with_context,
4861
+ method
4862
+ }) => {
4863
+ return forgotPasswordSSO({ email, with_context, method });
4864
+ }
4865
+ });
4866
+ };
4867
+ var use_forgotpassword_sso_default = useForgotPasswordSSO;
4868
+
4869
+ // src/hooks/auth/use-get-provider.ts
4870
+ import { useMutation as useMutation3 } from "@tanstack/react-query";
4871
+ var useGetProvider = () => {
4872
+ const { getProviders } = useAuthService();
4873
+ return useMutation3({
4874
+ mutationFn: (data) => {
4875
+ return getProviders(data?.db);
4876
+ }
4877
+ });
4878
+ };
4879
+ var use_get_provider_default = useGetProvider;
4880
+
4881
+ // src/hooks/auth/use-isvalid-token.ts
4882
+ import { useMutation as useMutation4 } from "@tanstack/react-query";
4883
+ var useIsValidToken = () => {
4884
+ const { isValidToken } = useAuthService();
4885
+ return useMutation4({
4886
+ mutationFn: (token) => {
4887
+ return isValidToken(token);
4888
+ }
4889
+ });
4890
+ };
4891
+ var use_isvalid_token_default = useIsValidToken;
4892
+
4720
4893
  // src/hooks/auth/use-login-credential.tsx
4894
+ import { useMutation as useMutation5 } from "@tanstack/react-query";
4721
4895
  var useLoginCredential = () => {
4722
- const { env: env2 } = useEnv();
4723
- console.log("useLoginCredential called", env2, new Error().stack);
4724
4896
  const { login } = useAuthService();
4725
4897
  return useMutation5({
4726
4898
  mutationFn: (data) => {
@@ -4733,9 +4905,10 @@ var use_login_credential_default = useLoginCredential;
4733
4905
  // src/hooks/auth/use-login-socical.ts
4734
4906
  import { useMutation as useMutation6 } from "@tanstack/react-query";
4735
4907
  var useLoginSocial = () => {
4908
+ const { loginSocial } = useAuthService();
4736
4909
  return useMutation6({
4737
4910
  mutationFn: (data) => {
4738
- return auth_service_default.loginSocial(data);
4911
+ return loginSocial(data);
4739
4912
  }
4740
4913
  });
4741
4914
  };
@@ -4744,9 +4917,10 @@ var use_login_socical_default = useLoginSocial;
4744
4917
  // src/hooks/auth/use-reset-password.ts
4745
4918
  import { useMutation as useMutation7 } from "@tanstack/react-query";
4746
4919
  var useResetPassword = () => {
4920
+ const { resetPassword } = useAuthService();
4747
4921
  return useMutation7({
4748
4922
  mutationFn: (request) => {
4749
- return auth_service_default.resetPassword(request.data, request.token);
4923
+ return resetPassword(request.data, request.token);
4750
4924
  }
4751
4925
  });
4752
4926
  };
@@ -4755,13 +4929,14 @@ var use_reset_password_default = useResetPassword;
4755
4929
  // src/hooks/auth/use-reset-password-sso.ts
4756
4930
  import { useMutation as useMutation8 } from "@tanstack/react-query";
4757
4931
  var useResetPasswordSSO = () => {
4932
+ const { resetPasswordSSO } = useAuthService();
4758
4933
  return useMutation8({
4759
4934
  mutationFn: ({
4760
4935
  method,
4761
4936
  password,
4762
4937
  with_context
4763
4938
  }) => {
4764
- return auth_service_default.resetPasswordSSO({
4939
+ return resetPasswordSSO({
4765
4940
  method,
4766
4941
  password,
4767
4942
  with_context
@@ -4774,9 +4949,10 @@ var use_reset_password_sso_default = useResetPasswordSSO;
4774
4949
  // src/hooks/auth/use-update-password.ts
4775
4950
  import { useMutation as useMutation9 } from "@tanstack/react-query";
4776
4951
  var useUpdatePassword = () => {
4952
+ const { updatePassword } = useAuthService();
4777
4953
  return useMutation9({
4778
4954
  mutationFn: (request) => {
4779
- return auth_service_default.updatePassword(request.data, request.token);
4955
+ return updatePassword(request.data, request.token);
4780
4956
  }
4781
4957
  });
4782
4958
  };
@@ -4785,9 +4961,10 @@ var use_update_password_default = useUpdatePassword;
4785
4961
  // src/hooks/auth/use-logout.ts
4786
4962
  import { useMutation as useMutation10 } from "@tanstack/react-query";
4787
4963
  var useLogout = () => {
4964
+ const { logout } = useAuthService();
4788
4965
  return useMutation10({
4789
4966
  mutationFn: (data) => {
4790
- return auth_service_default.logout(data);
4967
+ return logout(data);
4791
4968
  }
4792
4969
  });
4793
4970
  };
@@ -4796,9 +4973,10 @@ var use_logout_default = useLogout;
4796
4973
  // src/hooks/auth/use-get-access-by-code.ts
4797
4974
  import { useMutation as useMutation11 } from "@tanstack/react-query";
4798
4975
  var useGetAccessByCode = () => {
4976
+ const { getAccessByCode } = useAuthService();
4799
4977
  return useMutation11({
4800
4978
  mutationFn: ({ code }) => {
4801
- return auth_service_default.getAccessByCode(code);
4979
+ return getAccessByCode(code);
4802
4980
  }
4803
4981
  });
4804
4982
  };
@@ -4807,12 +4985,13 @@ var use_get_access_by_code_default = useGetAccessByCode;
4807
4985
  // src/hooks/auth/use-validate-action-token.ts
4808
4986
  import { useMutation as useMutation12 } from "@tanstack/react-query";
4809
4987
  var useValidateActionToken = () => {
4988
+ const { isValidActionToken } = useAuthService();
4810
4989
  return useMutation12({
4811
4990
  mutationFn: ({
4812
4991
  actionToken,
4813
4992
  path
4814
4993
  }) => {
4815
- return auth_service_default.isValidActionToken(actionToken, path);
4994
+ return isValidActionToken(actionToken, path);
4816
4995
  }
4817
4996
  });
4818
4997
  };
@@ -4821,8 +5000,9 @@ var use_validate_action_token_default = useValidateActionToken;
4821
5000
  // src/hooks/company/use-get-company-info.ts
4822
5001
  import { useMutation as useMutation13 } from "@tanstack/react-query";
4823
5002
  var useGetCompanyInfo = () => {
5003
+ const { getInfoCompany } = useCompanyService();
4824
5004
  return useMutation13({
4825
- mutationFn: (id) => company_service_default.getInfoCompany(id)
5005
+ mutationFn: (id) => getInfoCompany(id)
4826
5006
  });
4827
5007
  };
4828
5008
  var use_get_company_info_default = useGetCompanyInfo;
@@ -4830,8 +5010,9 @@ var use_get_company_info_default = useGetCompanyInfo;
4830
5010
  // src/hooks/company/use-get-current-company.ts
4831
5011
  import { useMutation as useMutation14 } from "@tanstack/react-query";
4832
5012
  var useGetCurrentCompany = () => {
5013
+ const { getCurrentCompany } = useCompanyService();
4833
5014
  return useMutation14({
4834
- mutationFn: () => company_service_default.getCurrentCompany()
5015
+ mutationFn: () => getCurrentCompany()
4835
5016
  });
4836
5017
  };
4837
5018
  var use_get_current_company_default = useGetCurrentCompany;
@@ -4839,6 +5020,7 @@ var use_get_current_company_default = useGetCurrentCompany;
4839
5020
  // src/hooks/company/use-get-list-company.ts
4840
5021
  import { useQuery } from "@tanstack/react-query";
4841
5022
  var useGetListCompany = (companyIDs = []) => {
5023
+ const { getList } = useModelService();
4842
5024
  const companySpec = {
4843
5025
  id: {},
4844
5026
  name: {}
@@ -4850,7 +5032,7 @@ var useGetListCompany = (companyIDs = []) => {
4850
5032
  };
4851
5033
  return useQuery({
4852
5034
  queryKey: ["list_company" /* LIST_COMPANY */, companyIDs],
4853
- queryFn: () => model_service_default.getList(getListParams),
5035
+ queryFn: () => getList(getListParams),
4854
5036
  refetchOnWindowFocus: false
4855
5037
  });
4856
5038
  };
@@ -4859,6 +5041,7 @@ var use_get_list_company_default = useGetListCompany;
4859
5041
  // src/hooks/excel/use-export-excel.ts
4860
5042
  import { useMutation as useMutation15 } from "@tanstack/react-query";
4861
5043
  var useExportExcel = () => {
5044
+ const { exportExcel } = useExcelService();
4862
5045
  return useMutation15({
4863
5046
  mutationFn: ({
4864
5047
  model,
@@ -4869,7 +5052,7 @@ var useExportExcel = () => {
4869
5052
  importCompat,
4870
5053
  context,
4871
5054
  groupby
4872
- }) => excel_service_default.exportExcel({
5055
+ }) => exportExcel({
4873
5056
  model,
4874
5057
  domain,
4875
5058
  ids,
@@ -4886,6 +5069,7 @@ var use_export_excel_default = useExportExcel;
4886
5069
  // src/hooks/excel/use-get-field-export.ts
4887
5070
  import { useMutation as useMutation16 } from "@tanstack/react-query";
4888
5071
  var useGetFieldExport = () => {
5072
+ const { getFieldExport } = useExcelService();
4889
5073
  return useMutation16({
4890
5074
  mutationFn: ({
4891
5075
  ids,
@@ -4898,7 +5082,7 @@ var useGetFieldExport = () => {
4898
5082
  name,
4899
5083
  context,
4900
5084
  importCompat
4901
- }) => excel_service_default.getFieldExport({
5085
+ }) => getFieldExport({
4902
5086
  ids,
4903
5087
  model,
4904
5088
  isShow,
@@ -4917,9 +5101,10 @@ var use_get_field_export_default = useGetFieldExport;
4917
5101
  // src/hooks/excel/use-get-file-excel.ts
4918
5102
  import { useQuery as useQuery2 } from "@tanstack/react-query";
4919
5103
  var useGetFileExcel = ({ model }) => {
5104
+ const { getFileExcel } = useExcelService();
4920
5105
  return useQuery2({
4921
5106
  queryKey: [],
4922
- queryFn: () => excel_service_default.getFileExcel({
5107
+ queryFn: () => getFileExcel({
4923
5108
  model
4924
5109
  }).then((res) => {
4925
5110
  if (res) {
@@ -4935,13 +5120,14 @@ var use_get_file_excel_default = useGetFileExcel;
4935
5120
  // src/hooks/excel/use-parse-preview.ts
4936
5121
  import { useMutation as useMutation17 } from "@tanstack/react-query";
4937
5122
  var useParsePreview = () => {
5123
+ const { parsePreview } = useExcelService();
4938
5124
  return useMutation17({
4939
5125
  mutationFn: ({
4940
5126
  id,
4941
5127
  selectedSheet,
4942
5128
  isHeader,
4943
5129
  context
4944
- }) => excel_service_default.parsePreview({
5130
+ }) => parsePreview({
4945
5131
  id,
4946
5132
  selectedSheet,
4947
5133
  isHeader,
@@ -4954,8 +5140,9 @@ var use_parse_preview_default = useParsePreview;
4954
5140
  // src/hooks/excel/use-upload-file.ts
4955
5141
  import { useMutation as useMutation18 } from "@tanstack/react-query";
4956
5142
  var useUploadFile = () => {
5143
+ const { uploadFile } = useExcelService();
4957
5144
  return useMutation18({
4958
- mutationFn: ({ formData }) => excel_service_default.uploadFile({
5145
+ mutationFn: ({ formData }) => uploadFile({
4959
5146
  formData
4960
5147
  })
4961
5148
  });
@@ -4965,8 +5152,9 @@ var use_upload_file_default = useUploadFile;
4965
5152
  // src/hooks/excel/use-upload-id-file.ts
4966
5153
  import { useMutation as useMutation19 } from "@tanstack/react-query";
4967
5154
  var useUploadIdFile = () => {
5155
+ const { uploadIdFile } = useExcelService();
4968
5156
  return useMutation19({
4969
- mutationFn: ({ formData }) => excel_service_default.uploadIdFile({
5157
+ mutationFn: ({ formData }) => uploadIdFile({
4970
5158
  formData
4971
5159
  })
4972
5160
  });
@@ -4976,6 +5164,7 @@ var use_upload_id_file_default = useUploadIdFile;
4976
5164
  // src/hooks/excel/uss-execute-import.ts
4977
5165
  import { useMutation as useMutation20 } from "@tanstack/react-query";
4978
5166
  var useExecuteImport = () => {
5167
+ const { executeImport } = useExcelService();
4979
5168
  return useMutation20({
4980
5169
  mutationFn: ({
4981
5170
  fields,
@@ -4984,7 +5173,7 @@ var useExecuteImport = () => {
4984
5173
  options,
4985
5174
  dryrun,
4986
5175
  context
4987
- }) => excel_service_default.executeImport({
5176
+ }) => executeImport({
4988
5177
  fields,
4989
5178
  columns,
4990
5179
  idFile,
@@ -4999,9 +5188,10 @@ var uss_execute_import_default = useExecuteImport;
4999
5188
  // src/hooks/form/use-change-status.ts
5000
5189
  import { useMutation as useMutation21 } from "@tanstack/react-query";
5001
5190
  var useChangeStatus = () => {
5191
+ const { changeStatus } = useFormService();
5002
5192
  return useMutation21({
5003
5193
  mutationFn: ({ data }) => {
5004
- return form_service_default.changeStatus({
5194
+ return changeStatus({
5005
5195
  data
5006
5196
  });
5007
5197
  }
@@ -5012,8 +5202,9 @@ var use_change_status_default = useChangeStatus;
5012
5202
  // src/hooks/form/use-delete-comment.ts
5013
5203
  import { useMutation as useMutation22 } from "@tanstack/react-query";
5014
5204
  var useDeleteComment = () => {
5205
+ const { deleteComment } = useFormService();
5015
5206
  return useMutation22({
5016
- mutationFn: ({ data }) => form_service_default.deleteComment({
5207
+ mutationFn: ({ data }) => deleteComment({
5017
5208
  data
5018
5209
  })
5019
5210
  });
@@ -5023,9 +5214,10 @@ var use_delete_comment_default = useDeleteComment;
5023
5214
  // src/hooks/form/use-get-comment.ts
5024
5215
  import { useQuery as useQuery3 } from "@tanstack/react-query";
5025
5216
  var useGetComment = ({ data, queryKey }) => {
5217
+ const { getComment } = useFormService();
5026
5218
  return useQuery3({
5027
5219
  queryKey,
5028
- queryFn: () => form_service_default.getComment({ data }).then((res) => {
5220
+ queryFn: () => getComment({ data }).then((res) => {
5029
5221
  if (res) {
5030
5222
  return res;
5031
5223
  }
@@ -5043,9 +5235,10 @@ var useGetFormView = ({
5043
5235
  queryKey,
5044
5236
  enabled
5045
5237
  }) => {
5238
+ const { getFormView } = useFormService();
5046
5239
  return useQuery4({
5047
5240
  queryKey,
5048
- queryFn: () => form_service_default.getFormView({ data }).then((res) => {
5241
+ queryFn: () => getFormView({ data }).then((res) => {
5049
5242
  if (res) {
5050
5243
  return res;
5051
5244
  }
@@ -5063,9 +5256,10 @@ var useGetImage = ({
5063
5256
  queryKey,
5064
5257
  src
5065
5258
  }) => {
5259
+ const { getImage } = useFormService();
5066
5260
  return useQuery5({
5067
5261
  queryKey,
5068
- queryFn: () => form_service_default.getImage({ data }).then((res) => {
5262
+ queryFn: () => getImage({ data }).then((res) => {
5069
5263
  if (res) {
5070
5264
  return res;
5071
5265
  }
@@ -5079,8 +5273,9 @@ var use_get_image_default = useGetImage;
5079
5273
  // src/hooks/form/use-send-comment.ts
5080
5274
  import { useMutation as useMutation23 } from "@tanstack/react-query";
5081
5275
  var useSendComment = () => {
5276
+ const { sentComment } = useFormService();
5082
5277
  return useMutation23({
5083
- mutationFn: ({ data }) => form_service_default.sentComment({
5278
+ mutationFn: ({ data }) => sentComment({
5084
5279
  data
5085
5280
  })
5086
5281
  });
@@ -5090,8 +5285,9 @@ var use_send_comment_default = useSendComment;
5090
5285
  // src/hooks/form/use-upload-image.ts
5091
5286
  import { useMutation as useMutation24 } from "@tanstack/react-query";
5092
5287
  var useUploadImage = () => {
5288
+ const { uploadImage } = useFormService();
5093
5289
  return useMutation24({
5094
- mutationFn: ({ data }) => form_service_default.uploadImage({
5290
+ mutationFn: ({ data }) => uploadImage({
5095
5291
  data
5096
5292
  })
5097
5293
  });
@@ -5101,8 +5297,9 @@ var use_upload_image_default = useUploadImage;
5101
5297
  // src/hooks/model/use-delete.ts
5102
5298
  import { useMutation as useMutation25 } from "@tanstack/react-query";
5103
5299
  var useDelete = () => {
5300
+ const { deleteApi } = useModelService();
5104
5301
  return useMutation25({
5105
- mutationFn: ({ ids, model }) => model_service_default.delete({ ids, model })
5302
+ mutationFn: ({ ids, model }) => deleteApi({ ids, model })
5106
5303
  });
5107
5304
  };
5108
5305
  var use_delete_default = useDelete;
@@ -5110,16 +5307,16 @@ var use_delete_default = useDelete;
5110
5307
  // src/hooks/model/use-get-all.ts
5111
5308
  import { useQuery as useQuery6 } from "@tanstack/react-query";
5112
5309
  var useGetAll = ({ data, queryKey, viewResponse }) => {
5310
+ const { getAll } = useModelService();
5113
5311
  return useQuery6({
5114
5312
  queryKey,
5115
- queryFn: () => model_service_default.getAll({ data }).then((res) => {
5313
+ queryFn: () => getAll({ data }).then((res) => {
5116
5314
  if (res) {
5117
5315
  return res;
5118
5316
  }
5119
5317
  }),
5120
5318
  enabled: !!data.specification && !!data.model && !!data.domain && !!viewResponse,
5121
5319
  refetchOnWindowFocus: false
5122
- // placeholderData: keepPreviousData,
5123
5320
  });
5124
5321
  };
5125
5322
  var use_get_all_default = useGetAll;
@@ -5127,9 +5324,10 @@ var use_get_all_default = useGetAll;
5127
5324
  // src/hooks/model/use-get-conversion-rate.ts
5128
5325
  import { useQuery as useQuery7 } from "@tanstack/react-query";
5129
5326
  var useGetConversionRate = () => {
5327
+ const { getConversionRate } = useModelService();
5130
5328
  return useQuery7({
5131
5329
  queryKey: ["currency-rate"],
5132
- queryFn: () => model_service_default.getConversionRate().then((res) => {
5330
+ queryFn: () => getConversionRate().then((res) => {
5133
5331
  if (res) {
5134
5332
  return res;
5135
5333
  }
@@ -5142,9 +5340,10 @@ var use_get_conversion_rate_default = useGetConversionRate;
5142
5340
  // src/hooks/model/use-get-currency.ts
5143
5341
  import { useQuery as useQuery8 } from "@tanstack/react-query";
5144
5342
  var useGetCurrency = () => {
5343
+ const { getCurrency } = useModelService();
5145
5344
  return useQuery8({
5146
5345
  queryKey: ["currency"],
5147
- queryFn: () => model_service_default.getCurrency().then((res) => {
5346
+ queryFn: () => getCurrency().then((res) => {
5148
5347
  if (res) {
5149
5348
  return res;
5150
5349
  }
@@ -5157,13 +5356,14 @@ var use_get_currency_default = useGetCurrency;
5157
5356
  // src/hooks/model/use-get-detail.ts
5158
5357
  import { useMutation as useMutation26 } from "@tanstack/react-query";
5159
5358
  var useGetDetail = () => {
5359
+ const { getDetail } = useModelService();
5160
5360
  return useMutation26({
5161
5361
  mutationFn: ({
5162
5362
  model,
5163
5363
  ids,
5164
5364
  specification,
5165
5365
  context
5166
- }) => model_service_default.getDetail({
5366
+ }) => getDetail({
5167
5367
  model,
5168
5368
  ids,
5169
5369
  specification,
@@ -5176,9 +5376,10 @@ var use_get_detail_default = useGetDetail;
5176
5376
  // src/hooks/model/use-get-field-onchange.ts
5177
5377
  import { useQuery as useQuery9 } from "@tanstack/react-query";
5178
5378
  var useGetFieldOnChange = ({ model }) => {
5379
+ const { getListFieldsOnchange } = useModelService();
5179
5380
  return useQuery9({
5180
5381
  queryKey: [`field-onchange-${model}`, model],
5181
- queryFn: () => model_service_default.getListFieldsOnchange({
5382
+ queryFn: () => getListFieldsOnchange({
5182
5383
  model
5183
5384
  }).then((res) => {
5184
5385
  if (res) {
@@ -5198,9 +5399,10 @@ var useGetListMyBankAccount = ({
5198
5399
  spectification,
5199
5400
  model
5200
5401
  }) => {
5402
+ const { getListMyBankAccount } = useModelService();
5201
5403
  return useQuery10({
5202
5404
  queryKey: ["bank-account", model, domain],
5203
- queryFn: () => model_service_default.getListMyBankAccount({
5405
+ queryFn: () => getListMyBankAccount({
5204
5406
  domain,
5205
5407
  spectification,
5206
5408
  model
@@ -5342,9 +5544,10 @@ var use_model_default = useModel;
5342
5544
 
5343
5545
  // src/hooks/model/use-odoo-data-transform.ts
5344
5546
  var useOdooDataTransform = () => {
5547
+ const { toDataJS, parseORMOdoo } = useModelService();
5345
5548
  return {
5346
- toDataJS: model_service_default.toDataJS,
5347
- parseORM: model_service_default.parseORMOdoo
5549
+ toDataJS,
5550
+ parseORM: parseORMOdoo
5348
5551
  };
5349
5552
  };
5350
5553
  var use_odoo_data_transform_default = useOdooDataTransform;
@@ -5352,6 +5555,7 @@ var use_odoo_data_transform_default = useOdooDataTransform;
5352
5555
  // src/hooks/model/use-onchange-form.ts
5353
5556
  import { useMutation as useMutation27 } from "@tanstack/react-query";
5354
5557
  var useOnChangeForm = () => {
5558
+ const { onChange } = useModelService();
5355
5559
  return useMutation27({
5356
5560
  mutationFn: ({
5357
5561
  ids,
@@ -5360,7 +5564,7 @@ var useOnChangeForm = () => {
5360
5564
  context,
5361
5565
  object,
5362
5566
  fieldChange
5363
- }) => model_service_default.onChange({
5567
+ }) => onChange({
5364
5568
  ids,
5365
5569
  model,
5366
5570
  specification,
@@ -5375,6 +5579,7 @@ var use_onchange_form_default = useOnChangeForm;
5375
5579
  // src/hooks/model/use-save.ts
5376
5580
  import { useMutation as useMutation28 } from "@tanstack/react-query";
5377
5581
  var useSave = () => {
5582
+ const { save } = useModelService();
5378
5583
  return useMutation28({
5379
5584
  mutationFn: ({
5380
5585
  ids,
@@ -5383,7 +5588,7 @@ var useSave = () => {
5383
5588
  specification,
5384
5589
  context,
5385
5590
  path
5386
- }) => model_service_default.save({ ids, model, data, specification, context, path })
5591
+ }) => save({ ids, model, data, specification, context, path })
5387
5592
  });
5388
5593
  };
5389
5594
  var use_save_default = useSave;
@@ -5391,8 +5596,9 @@ var use_save_default = useSave;
5391
5596
  // src/hooks/user/use-get-profile.ts
5392
5597
  import { useMutation as useMutation29 } from "@tanstack/react-query";
5393
5598
  var useGetProfile = (path) => {
5599
+ const { getProfile } = useUserService();
5394
5600
  return useMutation29({
5395
- mutationFn: () => user_service_default.getProfile(path)
5601
+ mutationFn: () => getProfile(path)
5396
5602
  });
5397
5603
  };
5398
5604
  var use_get_profile_default = useGetProfile;
@@ -5400,8 +5606,9 @@ var use_get_profile_default = useGetProfile;
5400
5606
  // src/hooks/user/use-get-user.ts
5401
5607
  import { useMutation as useMutation30 } from "@tanstack/react-query";
5402
5608
  var useGetUser = () => {
5609
+ const { getUser } = useUserService();
5403
5610
  return useMutation30({
5404
- mutationFn: ({ id, context }) => user_service_default.getUser({
5611
+ mutationFn: ({ id, context }) => getUser({
5405
5612
  id,
5406
5613
  context
5407
5614
  })
@@ -5412,9 +5619,10 @@ var use_get_user_default = useGetUser;
5412
5619
  // src/hooks/user/use-switch-locale.ts
5413
5620
  import { useMutation as useMutation31 } from "@tanstack/react-query";
5414
5621
  var useSwitchLocale = () => {
5622
+ const { switchUserLocale } = useUserService();
5415
5623
  return useMutation31({
5416
5624
  mutationFn: ({ data }) => {
5417
- return user_service_default.switchUserLocale({
5625
+ return switchUserLocale({
5418
5626
  id: data.id,
5419
5627
  values: data.values
5420
5628
  });
@@ -5425,121 +5633,488 @@ var use_switch_locale_default = useSwitchLocale;
5425
5633
 
5426
5634
  // src/hooks/view/use-button.ts
5427
5635
  import { useMutation as useMutation32 } from "@tanstack/react-query";
5636
+ var useButton = () => {
5637
+ const { callButton } = useActionService();
5638
+ return useMutation32({
5639
+ mutationFn: ({
5640
+ model,
5641
+ ids,
5642
+ context,
5643
+ method
5644
+ }) => callButton({
5645
+ model,
5646
+ ids,
5647
+ context,
5648
+ method
5649
+ }),
5650
+ onSuccess: (response) => {
5651
+ return response;
5652
+ }
5653
+ });
5654
+ };
5655
+ var use_button_default = useButton;
5428
5656
 
5429
5657
  // src/hooks/view/use-duplicate-record.ts
5430
5658
  import { useMutation as useMutation33 } from "@tanstack/react-query";
5659
+ var useDuplicateRecord = () => {
5660
+ const { duplicateRecord } = useActionService();
5661
+ return useMutation33({
5662
+ mutationFn: ({
5663
+ id,
5664
+ model,
5665
+ context
5666
+ }) => duplicateRecord({
5667
+ id,
5668
+ model,
5669
+ context
5670
+ })
5671
+ });
5672
+ };
5673
+ var use_duplicate_record_default = useDuplicateRecord;
5431
5674
 
5432
5675
  // src/hooks/view/use-get-action-detail.ts
5433
5676
  import { useQuery as useQuery11 } from "@tanstack/react-query";
5677
+ var useGetActionDetail = ({
5678
+ aid,
5679
+ context,
5680
+ enabled,
5681
+ id,
5682
+ model,
5683
+ queryKey
5684
+ }) => {
5685
+ const { getFormView } = useFormService();
5686
+ const { getActionDetail } = useViewService();
5687
+ const data = {
5688
+ id,
5689
+ model: model ?? "",
5690
+ context
5691
+ };
5692
+ return useQuery11({
5693
+ queryKey,
5694
+ queryFn: async () => {
5695
+ if (aid) {
5696
+ const res = await getActionDetail(aid, context);
5697
+ if (res && res.length > 0) {
5698
+ return res[0];
5699
+ }
5700
+ } else {
5701
+ const res = await getFormView({ data });
5702
+ return res;
5703
+ }
5704
+ },
5705
+ enabled,
5706
+ refetchOnWindowFocus: false,
5707
+ staleTime: Infinity
5708
+ });
5709
+ };
5710
+ var use_get_action_detail_default = useGetActionDetail;
5434
5711
 
5435
5712
  // src/hooks/view/use-get-calendar.ts
5436
5713
  import { useQuery as useQuery12 } from "@tanstack/react-query";
5714
+ var useGetCalendar = (listDataProps, queryKey, enabled) => {
5715
+ const { getListCalendar } = useModelService();
5716
+ return useQuery12({
5717
+ queryKey,
5718
+ queryFn: () => getListCalendar({ data: listDataProps }).then((res) => {
5719
+ if (res) {
5720
+ return res;
5721
+ }
5722
+ return [];
5723
+ }),
5724
+ enabled,
5725
+ refetchOnWindowFocus: false,
5726
+ staleTime: 0
5727
+ });
5728
+ };
5729
+ var use_get_calendar_default = useGetCalendar;
5437
5730
 
5438
5731
  // src/hooks/view/use-get-groups.ts
5439
5732
  import { useQuery as useQuery13 } from "@tanstack/react-query";
5733
+ var useGetGroups = ({
5734
+ model,
5735
+ width_context
5736
+ }) => {
5737
+ const { getGroups } = useKanbanService();
5738
+ return useQuery13({
5739
+ queryKey: [model, width_context],
5740
+ queryFn: () => getGroups({
5741
+ model,
5742
+ width_context
5743
+ }).then((res) => {
5744
+ if (res) {
5745
+ return res;
5746
+ }
5747
+ return [];
5748
+ }),
5749
+ refetchOnWindowFocus: false
5750
+ });
5751
+ };
5752
+ var use_get_groups_default = useGetGroups;
5440
5753
 
5441
5754
  // src/hooks/view/use-get-list-data.ts
5442
5755
  import { useQuery as useQuery14 } from "@tanstack/react-query";
5756
+ var useGetListData = (listDataProps, queryKey, enabled) => {
5757
+ const { getAll } = useModelService();
5758
+ return useQuery14({
5759
+ queryKey,
5760
+ queryFn: () => getAll({ data: listDataProps }).then((res) => {
5761
+ if (res) {
5762
+ return res;
5763
+ }
5764
+ return [];
5765
+ }),
5766
+ enabled,
5767
+ refetchOnWindowFocus: false,
5768
+ staleTime: 0
5769
+ });
5770
+ };
5771
+ var use_get_list_data_default = useGetListData;
5443
5772
 
5444
5773
  // src/hooks/view/use-get-menu.ts
5445
5774
  import { useQuery as useQuery15 } from "@tanstack/react-query";
5775
+ var useGetMenu = (context, enabled) => {
5776
+ const { getMenu } = useViewService();
5777
+ return useQuery15({
5778
+ queryKey: ["menus" /* MENU */, context],
5779
+ queryFn: () => getMenu(context).then((res) => {
5780
+ if (res && res?.records && res?.records?.length > 0) {
5781
+ return res?.records;
5782
+ }
5783
+ return [];
5784
+ }),
5785
+ refetchOnWindowFocus: false,
5786
+ staleTime: Infinity,
5787
+ enabled
5788
+ });
5789
+ };
5790
+ var use_get_menu_default = useGetMenu;
5446
5791
 
5447
5792
  // src/hooks/view/use-get-print-report.ts
5448
5793
  import { useMutation as useMutation34 } from "@tanstack/react-query";
5794
+ var useGetPrintReport = () => {
5795
+ const { getPrintReportName } = useActionService();
5796
+ return useMutation34({
5797
+ mutationFn: ({ id }) => getPrintReportName({
5798
+ id
5799
+ })
5800
+ });
5801
+ };
5802
+ var use_get_print_report_default = useGetPrintReport;
5449
5803
 
5450
5804
  // src/hooks/view/use-get-progress-bar.ts
5451
5805
  import { useQuery as useQuery16 } from "@tanstack/react-query";
5806
+ var useGetProGressBar = ({
5807
+ field,
5808
+ color,
5809
+ model,
5810
+ width_context
5811
+ }) => {
5812
+ const { getProgressBar } = useKanbanService();
5813
+ return useQuery16({
5814
+ queryKey: [],
5815
+ queryFn: () => getProgressBar({
5816
+ field,
5817
+ color,
5818
+ model,
5819
+ width_context
5820
+ }).then((res) => {
5821
+ if (res) {
5822
+ return res;
5823
+ }
5824
+ return [];
5825
+ }),
5826
+ refetchOnWindowFocus: false
5827
+ });
5828
+ };
5829
+ var use_get_progress_bar_default = useGetProGressBar;
5452
5830
 
5453
5831
  // src/hooks/view/use-get-selection.ts
5454
5832
  import { useQuery as useQuery17 } from "@tanstack/react-query";
5833
+ var useGetSelection = ({
5834
+ data,
5835
+ queryKey,
5836
+ enabled
5837
+ }) => {
5838
+ const { getSelectionItem } = useViewService();
5839
+ return useQuery17({
5840
+ queryKey,
5841
+ queryFn: () => getSelectionItem({ data }),
5842
+ enabled,
5843
+ refetchOnWindowFocus: false
5844
+ });
5845
+ };
5846
+ var use_get_selection_default = useGetSelection;
5455
5847
 
5456
5848
  // src/hooks/view/use-get-view.ts
5457
5849
  import { useQuery as useQuery18 } from "@tanstack/react-query";
5850
+ var useGetView = (viewParams, actData) => {
5851
+ const { getView } = useViewService();
5852
+ return useQuery18({
5853
+ queryKey: ["get_view_by_action" /* GET_VIEW_BY_ACTION */, viewParams],
5854
+ queryFn: () => getView(viewParams),
5855
+ enabled: !!actData,
5856
+ refetchOnWindowFocus: false,
5857
+ staleTime: Infinity
5858
+ });
5859
+ };
5860
+ var use_get_view_default = useGetView;
5458
5861
 
5459
5862
  // src/hooks/view/use-load-action.ts
5460
5863
  import { useMutation as useMutation35 } from "@tanstack/react-query";
5864
+ var useLoadAction = () => {
5865
+ const { loadAction } = useActionService();
5866
+ return useMutation35({
5867
+ mutationFn: ({
5868
+ idAction,
5869
+ context
5870
+ }) => {
5871
+ return loadAction({
5872
+ idAction,
5873
+ context
5874
+ });
5875
+ }
5876
+ });
5877
+ };
5878
+ var use_load_action_default = useLoadAction;
5461
5879
 
5462
5880
  // src/hooks/view/use-load-message.ts
5463
5881
  import { useQuery as useQuery19 } from "@tanstack/react-query";
5882
+ var useLoadMessage = () => {
5883
+ const { loadMessages } = useViewService();
5884
+ return useQuery19({
5885
+ queryKey: [`load-message-failure`],
5886
+ queryFn: () => loadMessages(),
5887
+ refetchOnWindowFocus: false
5888
+ });
5889
+ };
5890
+ var use_load_message_default = useLoadMessage;
5464
5891
 
5465
5892
  // src/hooks/view/use-print.ts
5466
5893
  import { useMutation as useMutation36 } from "@tanstack/react-query";
5894
+ var usePrint = () => {
5895
+ const { print } = useActionService();
5896
+ return useMutation36({
5897
+ mutationFn: ({ id, report, db }) => print({
5898
+ id,
5899
+ report,
5900
+ db
5901
+ })
5902
+ });
5903
+ };
5904
+ var use_print_default = usePrint;
5467
5905
 
5468
5906
  // src/hooks/view/use-remove-row.ts
5469
5907
  import { useMutation as useMutation37 } from "@tanstack/react-query";
5908
+ var useRemoveRow = () => {
5909
+ const { removeRows } = useActionService();
5910
+ return useMutation37({
5911
+ mutationFn: ({
5912
+ model,
5913
+ ids,
5914
+ context
5915
+ }) => removeRows({
5916
+ model,
5917
+ ids,
5918
+ context
5919
+ })
5920
+ });
5921
+ };
5922
+ var use_remove_row_default = useRemoveRow;
5470
5923
 
5471
5924
  // src/hooks/view/use-resequence.ts
5472
5925
  import { useQuery as useQuery20 } from "@tanstack/react-query";
5926
+ var useGetResequence = (model, resIds, context, offset) => {
5927
+ const { getResequence } = useViewService();
5928
+ return useQuery20({
5929
+ queryKey: [],
5930
+ queryFn: () => getResequence({
5931
+ model,
5932
+ ids: resIds,
5933
+ context,
5934
+ offset
5935
+ }),
5936
+ enabled: false,
5937
+ refetchOnWindowFocus: false
5938
+ });
5939
+ };
5940
+ var use_resequence_default = useGetResequence;
5473
5941
 
5474
5942
  // src/hooks/view/use-run-action.ts
5475
5943
  import { useMutation as useMutation38 } from "@tanstack/react-query";
5944
+ var useRunAction = () => {
5945
+ const { runAction } = useActionService();
5946
+ return useMutation38({
5947
+ mutationFn: ({
5948
+ idAction,
5949
+ context
5950
+ }) => runAction({
5951
+ idAction,
5952
+ context
5953
+ })
5954
+ });
5955
+ };
5956
+ var use_run_action_default = useRunAction;
5476
5957
 
5477
5958
  // src/hooks/view/use-signin-sso.ts
5478
5959
  import { useMutation as useMutation39 } from "@tanstack/react-query";
5960
+ var useSignInSSO = () => {
5961
+ const { signInSSO } = useViewService();
5962
+ return useMutation39({
5963
+ mutationFn: ({
5964
+ redirect_uri,
5965
+ state,
5966
+ client_id,
5967
+ response_type,
5968
+ path
5969
+ }) => {
5970
+ return signInSSO({
5971
+ redirect_uri,
5972
+ state,
5973
+ client_id,
5974
+ response_type
5975
+ });
5976
+ }
5977
+ });
5978
+ };
5979
+ var use_signin_sso_default = useSignInSSO;
5479
5980
 
5480
5981
  // src/hooks/view/use-verify-2FA.ts
5481
5982
  import { useMutation as useMutation40 } from "@tanstack/react-query";
5983
+ var useVerify2FA = () => {
5984
+ const { verify2FA } = useViewService();
5985
+ return useMutation40({
5986
+ mutationFn: ({
5987
+ method,
5988
+ with_context,
5989
+ code,
5990
+ device,
5991
+ location
5992
+ }) => {
5993
+ return verify2FA({
5994
+ method,
5995
+ with_context,
5996
+ code,
5997
+ device,
5998
+ location
5999
+ });
6000
+ }
6001
+ });
6002
+ };
6003
+ var use_verify_2FA_default = useVerify2FA;
5482
6004
 
5483
6005
  // src/hooks/view/uset-get-2FA-method.ts
5484
6006
  import { useMutation as useMutation41 } from "@tanstack/react-query";
5485
-
5486
- // src/hooks/view/use-get-fields-view-security.ts
5487
- import { useMutation as useMutation42 } from "@tanstack/react-query";
6007
+ var useGet2FAMethods = () => {
6008
+ const { get2FAMethods } = useViewService();
6009
+ return useMutation41({
6010
+ mutationFn: ({
6011
+ method,
6012
+ with_context
6013
+ }) => {
6014
+ return get2FAMethods({
6015
+ method,
6016
+ with_context
6017
+ });
6018
+ }
6019
+ });
6020
+ };
6021
+ var uset_get_2FA_method_default = useGet2FAMethods;
5488
6022
 
5489
6023
  // src/hooks/view/use-grant-access.ts
5490
- import { useMutation as useMutation43 } from "@tanstack/react-query";
6024
+ import { useMutation as useMutation42 } from "@tanstack/react-query";
6025
+ var useGrantAccess = () => {
6026
+ const { grantAccess } = useViewService();
6027
+ return useMutation42({
6028
+ mutationFn: ({
6029
+ redirect_uri,
6030
+ state,
6031
+ client_id,
6032
+ scopes
6033
+ }) => {
6034
+ return grantAccess({
6035
+ redirect_uri,
6036
+ state,
6037
+ client_id,
6038
+ scopes
6039
+ });
6040
+ }
6041
+ });
6042
+ };
6043
+ var use_grant_access_default = useGrantAccess;
5491
6044
 
5492
6045
  // src/hooks/view/use-remove-totp-setup.ts
5493
- import { useMutation as useMutation44 } from "@tanstack/react-query";
6046
+ import { useMutation as useMutation43 } from "@tanstack/react-query";
6047
+ var useRemoveTotpSetup = () => {
6048
+ const { removeTotpSetUp } = useViewService();
6049
+ return useMutation43({
6050
+ mutationFn: ({ method, token }) => {
6051
+ return removeTotpSetUp({
6052
+ method,
6053
+ token
6054
+ });
6055
+ }
6056
+ });
6057
+ };
6058
+ var use_remove_totp_setup_default = useRemoveTotpSetup;
5494
6059
 
5495
6060
  // src/hooks/view/use-request-setup-totp.ts
5496
- import { useMutation as useMutation45 } from "@tanstack/react-query";
6061
+ import { useMutation as useMutation44 } from "@tanstack/react-query";
6062
+ var useRequestSetupTotp = () => {
6063
+ const { requestSetupTotp } = useViewService();
6064
+ return useMutation44({
6065
+ mutationFn: ({ method, token }) => {
6066
+ return requestSetupTotp({
6067
+ method,
6068
+ token
6069
+ });
6070
+ }
6071
+ });
6072
+ };
6073
+ var use_request_setup_totp_default = useRequestSetupTotp;
5497
6074
 
5498
6075
  // src/hooks/view/use-settings-web-read-2fa.ts
5499
- import { useMutation as useMutation46 } from "@tanstack/react-query";
6076
+ import { useMutation as useMutation45 } from "@tanstack/react-query";
6077
+ var useSettingsWebRead2fa = () => {
6078
+ const { settingsWebRead2fa } = useViewService();
6079
+ return useMutation45({
6080
+ mutationFn: ({
6081
+ method,
6082
+ token,
6083
+ kwargs,
6084
+ model
6085
+ }) => {
6086
+ return settingsWebRead2fa({
6087
+ method,
6088
+ model,
6089
+ kwargs,
6090
+ token
6091
+ });
6092
+ }
6093
+ });
6094
+ };
6095
+ var use_settings_web_read_2fa_default = useSettingsWebRead2fa;
5500
6096
 
5501
6097
  // src/hooks/view/use-verify-totp.ts
5502
- import { useMutation as useMutation47 } from "@tanstack/react-query";
5503
-
5504
- // src/provider/version-gate-provider.tsx
5505
- import { Fragment, jsx as jsx5 } from "react/jsx-runtime";
5506
- var VersionGate = ({ children }) => {
5507
- const queryClient = useQueryClient();
5508
- const [ready, setReady] = useState3(false);
5509
- const { getVersion } = useViewService();
5510
- const login = use_login_credential_default();
5511
- useEffect2(() => {
5512
- const clearVersion = () => {
5513
- queryClient.clear();
5514
- localStorage.removeItem("__api_version__");
5515
- };
5516
- const validateVersion = async () => {
5517
- const serverVersion = await getVersion();
5518
- const cached = localStorage.getItem("__api_version__");
5519
- if (cached !== serverVersion?.api_version) {
5520
- clearVersion();
5521
- localStorage.setItem("__api_version__", serverVersion?.api_version);
5522
- } else {
5523
- console.log("Api version:", serverVersion?.api_version);
5524
- }
5525
- setReady(true);
5526
- };
5527
- validateVersion();
5528
- if (typeof window !== "undefined") {
5529
- const onKey = (e) => {
5530
- const key = e.key.toLowerCase();
5531
- const isHardRefresh = (key === "f5" || key === "r") && e.ctrlKey && (key !== "r" || e.shiftKey) || key === "r" && e.metaKey && e.shiftKey || key === "r" && e.metaKey && e.altKey;
5532
- if (isHardRefresh) clearVersion();
5533
- };
5534
- window.addEventListener("keydown", onKey);
5535
- return () => window.removeEventListener("keydown", onKey);
6098
+ import { useMutation as useMutation46 } from "@tanstack/react-query";
6099
+ var useVerifyTotp = () => {
6100
+ const { verifyTotp } = useViewService();
6101
+ return useMutation46({
6102
+ mutationFn: ({
6103
+ method,
6104
+ action_token,
6105
+ code
6106
+ }) => {
6107
+ return verifyTotp({
6108
+ method,
6109
+ action_token,
6110
+ code
6111
+ });
5536
6112
  }
5537
- }, [queryClient]);
5538
- return ready ? /* @__PURE__ */ jsx5(Fragment, { children }) : null;
6113
+ });
5539
6114
  };
6115
+ var use_verify_totp_default = useVerifyTotp;
5540
6116
 
5541
6117
  // src/provider/service-provider.tsx
5542
- import { createContext as createContext2, useContext as useContext2 } from "react";
5543
6118
  import { jsx as jsx6 } from "react/jsx-runtime";
5544
6119
  var ServiceContext = createContext2(null);
5545
6120
  var ServiceProvider = ({
@@ -5588,7 +6163,32 @@ var ServiceProvider = ({
5588
6163
  useSave: use_save_default,
5589
6164
  useGetProfile: use_get_profile_default,
5590
6165
  useGetUser: use_get_user_default,
5591
- useSwitchLocale: use_switch_locale_default
6166
+ useSwitchLocale: use_switch_locale_default,
6167
+ useButton: use_button_default,
6168
+ useDuplicateRecord: use_duplicate_record_default,
6169
+ useGet2FAMethods: uset_get_2FA_method_default,
6170
+ useGetActionDetail: use_get_action_detail_default,
6171
+ useGetCalendar: use_get_calendar_default,
6172
+ useGetGroups: use_get_groups_default,
6173
+ useGetListData: use_get_list_data_default,
6174
+ useGetMenu: use_get_menu_default,
6175
+ useGetPrintReport: use_get_print_report_default,
6176
+ useGetProGressBar: use_get_progress_bar_default,
6177
+ useGetResequence: use_resequence_default,
6178
+ useGetSelection: use_get_selection_default,
6179
+ useGetView: use_get_view_default,
6180
+ useLoadAction: use_load_action_default,
6181
+ useLoadMessage: use_load_message_default,
6182
+ usePrint: use_print_default,
6183
+ useRemoveRow: use_remove_row_default,
6184
+ useRunAction: use_run_action_default,
6185
+ useSignInSSO: use_signin_sso_default,
6186
+ useVerify2FA: use_verify_2FA_default,
6187
+ useGrantAccess: use_grant_access_default,
6188
+ useRemoveTotpSetup: use_remove_totp_setup_default,
6189
+ useRequestSetupTotp: use_request_setup_totp_default,
6190
+ useSettingsWebRead2fa: use_settings_web_read_2fa_default,
6191
+ useVerifyTotp: use_verify_totp_default
5592
6192
  };
5593
6193
  return /* @__PURE__ */ jsx6(ServiceContext.Provider, { value: services, children });
5594
6194
  };