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