@fctc/interface-logic 1.10.2 → 1.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/provider.mjs CHANGED
@@ -648,7 +648,7 @@ var MainProvider = ({ children }) => {
648
648
  };
649
649
 
650
650
  // src/provider/version-gate-provider.tsx
651
- import { useEffect, useState } from "react";
651
+ import { useEffect as useEffect2, useState as useState3 } from "react";
652
652
  import { useQueryClient } from "@tanstack/react-query";
653
653
 
654
654
  // src/services/view-service/backup.ts
@@ -902,45 +902,8 @@ function useViewService() {
902
902
  };
903
903
  }
904
904
 
905
- // src/provider/version-gate-provider.tsx
906
- import { Fragment, jsx as jsx4 } from "react/jsx-runtime";
907
- var VersionGate = ({ children }) => {
908
- const queryClient = useQueryClient();
909
- const [ready, setReady] = useState(false);
910
- const { getVersion } = useViewService();
911
- useEffect(() => {
912
- const clearVersion = () => {
913
- queryClient.clear();
914
- localStorage.removeItem("__api_version__");
915
- };
916
- const validateVersion = async () => {
917
- const serverVersion = await getVersion();
918
- console.log("serverVersion", serverVersion);
919
- const cached = localStorage.getItem("__api_version__");
920
- if (cached !== serverVersion?.api_version) {
921
- clearVersion();
922
- localStorage.setItem("__api_version__", serverVersion?.api_version);
923
- } else {
924
- console.log("Api version:", serverVersion?.api_version);
925
- }
926
- setReady(true);
927
- };
928
- validateVersion();
929
- if (typeof window !== "undefined") {
930
- const onKey = (e) => {
931
- const key = e.key.toLowerCase();
932
- const isHardRefresh = (key === "f5" || key === "r") && e.ctrlKey && (key !== "r" || e.shiftKey) || key === "r" && e.metaKey && e.shiftKey || key === "r" && e.metaKey && e.altKey;
933
- if (isHardRefresh) clearVersion();
934
- };
935
- window.addEventListener("keydown", onKey);
936
- return () => window.removeEventListener("keydown", onKey);
937
- }
938
- }, [queryClient]);
939
- return ready ? /* @__PURE__ */ jsx4(Fragment, { children }) : null;
940
- };
941
-
942
- // src/provider/env-provider.tsx
943
- import { createContext, useContext, useState as useState3, useCallback as useCallback2 } from "react";
905
+ // src/hooks/auth/use-forgot-password.ts
906
+ import { useMutation } from "@tanstack/react-query";
944
907
 
945
908
  // src/configs/axios-client.ts
946
909
  import axios from "axios";
@@ -3055,7 +3018,7 @@ function matchDomain(record, domain) {
3055
3018
  }
3056
3019
 
3057
3020
  // src/utils/function.ts
3058
- import { useEffect as useEffect2, useState as useState2 } from "react";
3021
+ import { useEffect, useState } from "react";
3059
3022
  var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
3060
3023
  if (!originalRequest.data) return originalRequest.data;
3061
3024
  if (typeof originalRequest.data === "string") {
@@ -3286,8 +3249,241 @@ var axiosClient = {
3286
3249
  }
3287
3250
  };
3288
3251
 
3252
+ // src/services/auth-service/backup.ts
3253
+ import { useCallback as useCallback2 } from "react";
3254
+ function useAuthService() {
3255
+ const { env } = useEnv();
3256
+ console.log("auth env", env);
3257
+ const login = useCallback2(
3258
+ async (body) => {
3259
+ const payload = Object.fromEntries(
3260
+ Object.entries({
3261
+ username: body.email,
3262
+ password: body.password,
3263
+ grant_type: env?.config?.grantType || "",
3264
+ client_id: env?.config?.clientId || "",
3265
+ client_secret: env?.config?.clientSecret || ""
3266
+ }).filter(([_, value]) => !!value)
3267
+ );
3268
+ const encodedData = new URLSearchParams(payload).toString();
3269
+ return env?.requests?.post(body.path, encodedData, {
3270
+ headers: {
3271
+ "Content-Type": "application/x-www-form-urlencoded"
3272
+ }
3273
+ });
3274
+ },
3275
+ [env]
3276
+ );
3277
+ const forgotPassword = useCallback2(
3278
+ async (email) => {
3279
+ const bodyData = {
3280
+ login: email,
3281
+ url: `${window.location.origin}/reset-password`
3282
+ };
3283
+ return env?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
3284
+ headers: {
3285
+ "Content-Type": "application/json"
3286
+ }
3287
+ });
3288
+ },
3289
+ [env]
3290
+ );
3291
+ const forgotPasswordSSO = useCallback2(
3292
+ async ({
3293
+ email,
3294
+ with_context,
3295
+ method
3296
+ }) => {
3297
+ const body = {
3298
+ method,
3299
+ kwargs: {
3300
+ vals: {
3301
+ email
3302
+ }
3303
+ },
3304
+ with_context
3305
+ };
3306
+ return env?.requests?.post("/call" /* CALL_PATH */, body, {
3307
+ headers: {
3308
+ "Content-Type": "application/json"
3309
+ }
3310
+ });
3311
+ },
3312
+ [env]
3313
+ );
3314
+ const resetPassword = useCallback2(
3315
+ async (data, token) => {
3316
+ const bodyData = {
3317
+ token,
3318
+ password: data.password,
3319
+ new_password: data.confirmPassword
3320
+ };
3321
+ return env?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
3322
+ headers: {
3323
+ "Content-Type": "application/json"
3324
+ }
3325
+ });
3326
+ },
3327
+ [env]
3328
+ );
3329
+ const resetPasswordSSO = useCallback2(
3330
+ async ({
3331
+ method,
3332
+ password,
3333
+ with_context
3334
+ }) => {
3335
+ const bodyData = {
3336
+ method,
3337
+ kwargs: {
3338
+ vals: {
3339
+ password
3340
+ }
3341
+ },
3342
+ with_context
3343
+ };
3344
+ return env?.requests?.post("/call" /* CALL_PATH */, bodyData, {
3345
+ headers: {
3346
+ "Content-Type": "application/json"
3347
+ }
3348
+ });
3349
+ },
3350
+ [env]
3351
+ );
3352
+ const updatePassword = useCallback2(
3353
+ async (data, token) => {
3354
+ const bodyData = {
3355
+ token,
3356
+ old_password: data.oldPassword,
3357
+ new_password: data.newPassword
3358
+ };
3359
+ return env?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
3360
+ headers: {
3361
+ "Content-Type": "application/json"
3362
+ }
3363
+ });
3364
+ },
3365
+ [env]
3366
+ );
3367
+ const isValidToken = useCallback2(
3368
+ async (token) => {
3369
+ const bodyData = {
3370
+ token
3371
+ };
3372
+ return env?.requests?.post("/check_token" /* TOKEN */, bodyData, {
3373
+ headers: {
3374
+ "Content-Type": "application/json"
3375
+ }
3376
+ });
3377
+ },
3378
+ [env]
3379
+ );
3380
+ const isValidActionToken = useCallback2(
3381
+ async (actionToken, path) => {
3382
+ return env?.requests?.post(
3383
+ path,
3384
+ {},
3385
+ {
3386
+ headers: {
3387
+ "Content-Type": "application/json"
3388
+ },
3389
+ useActionToken: true,
3390
+ actionToken
3391
+ }
3392
+ );
3393
+ },
3394
+ [env]
3395
+ );
3396
+ const loginSocial = useCallback2(
3397
+ async ({
3398
+ db,
3399
+ state,
3400
+ access_token
3401
+ }) => {
3402
+ return env?.requests?.post(
3403
+ "/token/generate" /* GENTOKEN_SOCIAL */,
3404
+ { state, access_token },
3405
+ {
3406
+ headers: {
3407
+ "Content-Type": "application/json"
3408
+ }
3409
+ }
3410
+ );
3411
+ },
3412
+ [env]
3413
+ );
3414
+ const getProviders = useCallback2(
3415
+ async (db) => {
3416
+ return env?.requests?.get("/oauth/providers", { params: { db } });
3417
+ },
3418
+ [env]
3419
+ );
3420
+ const getAccessByCode = useCallback2(
3421
+ async (code) => {
3422
+ const data = new URLSearchParams();
3423
+ data.append("code", code);
3424
+ data.append("grant_type", "authorization_code");
3425
+ data.append("client_id", env?.config?.clientId || "");
3426
+ data.append("redirect_uri", env?.config?.redirectUri || "");
3427
+ return env?.requests?.post(
3428
+ `${env?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
3429
+ data,
3430
+ {
3431
+ headers: {
3432
+ "Content-Type": "application/x-www-form-urlencoded"
3433
+ }
3434
+ }
3435
+ );
3436
+ },
3437
+ [env]
3438
+ );
3439
+ const logout = useCallback2(
3440
+ async (data) => {
3441
+ console.log(data);
3442
+ return env?.requests?.post(
3443
+ "/logout" /* LOGOUT */,
3444
+ {},
3445
+ {
3446
+ headers: {
3447
+ "Content-Type": "application/json"
3448
+ },
3449
+ withCredentials: true,
3450
+ useRefreshToken: true
3451
+ }
3452
+ );
3453
+ },
3454
+ [env]
3455
+ );
3456
+ return {
3457
+ login,
3458
+ forgotPassword,
3459
+ forgotPasswordSSO,
3460
+ resetPassword,
3461
+ resetPasswordSSO,
3462
+ updatePassword,
3463
+ isValidToken,
3464
+ isValidActionToken,
3465
+ loginSocial,
3466
+ getProviders,
3467
+ getAccessByCode,
3468
+ logout
3469
+ };
3470
+ }
3471
+
3472
+ // src/hooks/auth/use-forgotpassword-sso.ts
3473
+ import { useMutation as useMutation2 } from "@tanstack/react-query";
3474
+
3475
+ // src/hooks/auth/use-get-provider.ts
3476
+ import { useMutation as useMutation3 } from "@tanstack/react-query";
3477
+
3478
+ // src/hooks/auth/use-isvalid-token.ts
3479
+ import { useMutation as useMutation4 } from "@tanstack/react-query";
3480
+
3481
+ // src/hooks/auth/use-login-credential.tsx
3482
+ import { useMutation as useMutation5 } from "@tanstack/react-query";
3483
+
3289
3484
  // src/provider/env-provider.tsx
3290
- import { jsx as jsx5 } from "react/jsx-runtime";
3485
+ import { createContext, useContext, useState as useState2, useCallback as useCallback3 } from "react";
3486
+ import { jsx as jsx4 } from "react/jsx-runtime";
3291
3487
  var initialEnvState = {
3292
3488
  env: null,
3293
3489
  baseUrl: "",
@@ -3315,12 +3511,12 @@ function EnvProvider({
3315
3511
  localStorageUtils: localStorageUtil = localStorageUtils(),
3316
3512
  sessionStorageUtils: sessionStorageUtil = sessionStorageUtils()
3317
3513
  }) {
3318
- const [env, setEnvState] = useState3({
3514
+ const [env, setEnvState] = useState2({
3319
3515
  ...initialEnvState,
3320
3516
  localStorageUtils: localStorageUtil,
3321
3517
  sessionStorageUtils: sessionStorageUtil
3322
3518
  });
3323
- const setupEnv = useCallback2(
3519
+ const setupEnv = useCallback3(
3324
3520
  (envConfig) => {
3325
3521
  const updatedEnv = {
3326
3522
  ...env,
@@ -3334,31 +3530,31 @@ function EnvProvider({
3334
3530
  },
3335
3531
  [env, localStorageUtil, sessionStorageUtil]
3336
3532
  );
3337
- const setUid2 = useCallback2((uid) => {
3533
+ const setUid2 = useCallback3((uid) => {
3338
3534
  setEnvState((prev) => ({
3339
3535
  ...prev,
3340
3536
  context: { ...prev.context, uid }
3341
3537
  }));
3342
3538
  }, []);
3343
- const setLang2 = useCallback2((lang) => {
3539
+ const setLang2 = useCallback3((lang) => {
3344
3540
  setEnvState((prev) => ({
3345
3541
  ...prev,
3346
3542
  context: { ...prev.context, lang }
3347
3543
  }));
3348
3544
  }, []);
3349
- const setAllowCompanies2 = useCallback2((allowed_company_ids) => {
3545
+ const setAllowCompanies2 = useCallback3((allowed_company_ids) => {
3350
3546
  setEnvState((prev) => ({
3351
3547
  ...prev,
3352
3548
  context: { ...prev.context, allowed_company_ids }
3353
3549
  }));
3354
3550
  }, []);
3355
- const setCompanies2 = useCallback2((companies) => {
3551
+ const setCompanies2 = useCallback3((companies) => {
3356
3552
  setEnvState((prev) => ({
3357
3553
  ...prev,
3358
3554
  companies
3359
3555
  }));
3360
3556
  }, []);
3361
- const setDefaultCompany2 = useCallback2(
3557
+ const setDefaultCompany2 = useCallback3(
3362
3558
  (defaultCompany) => {
3363
3559
  setEnvState((prev) => ({
3364
3560
  ...prev,
@@ -3367,25 +3563,25 @@ function EnvProvider({
3367
3563
  },
3368
3564
  []
3369
3565
  );
3370
- const setUserInfo = useCallback2((user) => {
3566
+ const setUserInfo = useCallback3((user) => {
3371
3567
  setEnvState((prev) => ({
3372
3568
  ...prev,
3373
3569
  user
3374
3570
  }));
3375
3571
  }, []);
3376
- const setConfig2 = useCallback2((config) => {
3572
+ const setConfig2 = useCallback3((config) => {
3377
3573
  setEnvState((prev) => ({
3378
3574
  ...prev,
3379
3575
  config
3380
3576
  }));
3381
3577
  }, []);
3382
- const setEnvFile2 = useCallback2((envFile) => {
3578
+ const setEnvFile2 = useCallback3((envFile) => {
3383
3579
  setEnvState((prev) => ({
3384
3580
  ...prev,
3385
3581
  envFile
3386
3582
  }));
3387
3583
  }, []);
3388
- return /* @__PURE__ */ jsx5(
3584
+ return /* @__PURE__ */ jsx4(
3389
3585
  EnvContext.Provider,
3390
3586
  {
3391
3587
  value: {
@@ -3413,6 +3609,255 @@ function useEnv() {
3413
3609
  return context;
3414
3610
  }
3415
3611
 
3612
+ // src/hooks/auth/use-login-credential.tsx
3613
+ var useLoginCredential = () => {
3614
+ const { env } = useEnv();
3615
+ console.log("useLoginCredential called", env, new Error().stack);
3616
+ const { login } = useAuthService();
3617
+ return useMutation5({
3618
+ mutationFn: (data) => {
3619
+ return login(data);
3620
+ }
3621
+ });
3622
+ };
3623
+ var use_login_credential_default = useLoginCredential;
3624
+
3625
+ // src/hooks/auth/use-login-socical.ts
3626
+ import { useMutation as useMutation6 } from "@tanstack/react-query";
3627
+
3628
+ // src/hooks/auth/use-reset-password.ts
3629
+ import { useMutation as useMutation7 } from "@tanstack/react-query";
3630
+
3631
+ // src/hooks/auth/use-reset-password-sso.ts
3632
+ import { useMutation as useMutation8 } from "@tanstack/react-query";
3633
+
3634
+ // src/hooks/auth/use-update-password.ts
3635
+ import { useMutation as useMutation9 } from "@tanstack/react-query";
3636
+
3637
+ // src/hooks/auth/use-logout.ts
3638
+ import { useMutation as useMutation10 } from "@tanstack/react-query";
3639
+
3640
+ // src/hooks/auth/use-get-access-by-code.ts
3641
+ import { useMutation as useMutation11 } from "@tanstack/react-query";
3642
+
3643
+ // src/hooks/auth/use-validate-action-token.ts
3644
+ import { useMutation as useMutation12 } from "@tanstack/react-query";
3645
+
3646
+ // src/hooks/company/use-get-company-info.ts
3647
+ import { useMutation as useMutation13 } from "@tanstack/react-query";
3648
+
3649
+ // src/hooks/company/use-get-current-company.ts
3650
+ import { useMutation as useMutation14 } from "@tanstack/react-query";
3651
+
3652
+ // src/hooks/company/use-get-list-company.ts
3653
+ import { useQuery } from "@tanstack/react-query";
3654
+
3655
+ // src/hooks/excel/use-export-excel.ts
3656
+ import { useMutation as useMutation15 } from "@tanstack/react-query";
3657
+
3658
+ // src/hooks/excel/use-get-field-export.ts
3659
+ import { useMutation as useMutation16 } from "@tanstack/react-query";
3660
+
3661
+ // src/hooks/excel/use-get-file-excel.ts
3662
+ import { useQuery as useQuery2 } from "@tanstack/react-query";
3663
+
3664
+ // src/hooks/excel/use-parse-preview.ts
3665
+ import { useMutation as useMutation17 } from "@tanstack/react-query";
3666
+
3667
+ // src/hooks/excel/use-upload-file.ts
3668
+ import { useMutation as useMutation18 } from "@tanstack/react-query";
3669
+
3670
+ // src/hooks/excel/use-upload-id-file.ts
3671
+ import { useMutation as useMutation19 } from "@tanstack/react-query";
3672
+
3673
+ // src/hooks/excel/uss-execute-import.ts
3674
+ import { useMutation as useMutation20 } from "@tanstack/react-query";
3675
+
3676
+ // src/hooks/form/use-change-status.ts
3677
+ import { useMutation as useMutation21 } from "@tanstack/react-query";
3678
+
3679
+ // src/hooks/form/use-delete-comment.ts
3680
+ import { useMutation as useMutation22 } from "@tanstack/react-query";
3681
+
3682
+ // src/hooks/form/use-get-comment.ts
3683
+ import { useQuery as useQuery3 } from "@tanstack/react-query";
3684
+
3685
+ // src/hooks/form/use-get-form-view.ts
3686
+ import { useQuery as useQuery4 } from "@tanstack/react-query";
3687
+
3688
+ // src/hooks/form/use-get-image.ts
3689
+ import { useQuery as useQuery5 } from "@tanstack/react-query";
3690
+
3691
+ // src/hooks/form/use-send-comment.ts
3692
+ import { useMutation as useMutation23 } from "@tanstack/react-query";
3693
+
3694
+ // src/hooks/form/use-upload-image.ts
3695
+ import { useMutation as useMutation24 } from "@tanstack/react-query";
3696
+
3697
+ // src/hooks/model/use-delete.ts
3698
+ import { useMutation as useMutation25 } from "@tanstack/react-query";
3699
+
3700
+ // src/hooks/model/use-get-all.ts
3701
+ import { useQuery as useQuery6 } from "@tanstack/react-query";
3702
+
3703
+ // src/hooks/model/use-get-conversion-rate.ts
3704
+ import { useQuery as useQuery7 } from "@tanstack/react-query";
3705
+
3706
+ // src/hooks/model/use-get-currency.ts
3707
+ import { useQuery as useQuery8 } from "@tanstack/react-query";
3708
+
3709
+ // src/hooks/model/use-get-detail.ts
3710
+ import { useMutation as useMutation26 } from "@tanstack/react-query";
3711
+
3712
+ // src/hooks/model/use-get-field-onchange.ts
3713
+ import { useQuery as useQuery9 } from "@tanstack/react-query";
3714
+
3715
+ // src/hooks/model/use-get-list-my-bank-account.ts
3716
+ import { useQuery as useQuery10 } from "@tanstack/react-query";
3717
+
3718
+ // src/hooks/model/use-onchange-form.ts
3719
+ import { useMutation as useMutation27 } from "@tanstack/react-query";
3720
+
3721
+ // src/hooks/model/use-save.ts
3722
+ import { useMutation as useMutation28 } from "@tanstack/react-query";
3723
+
3724
+ // src/hooks/user/use-get-profile.ts
3725
+ import { useMutation as useMutation29 } from "@tanstack/react-query";
3726
+
3727
+ // src/hooks/user/use-get-user.ts
3728
+ import { useMutation as useMutation30 } from "@tanstack/react-query";
3729
+
3730
+ // src/hooks/user/use-switch-locale.ts
3731
+ import { useMutation as useMutation31 } from "@tanstack/react-query";
3732
+
3733
+ // src/hooks/view/use-button.ts
3734
+ import { useMutation as useMutation32 } from "@tanstack/react-query";
3735
+
3736
+ // src/hooks/view/use-duplicate-record.ts
3737
+ import { useMutation as useMutation33 } from "@tanstack/react-query";
3738
+
3739
+ // src/hooks/view/use-get-action-detail.ts
3740
+ import { useQuery as useQuery11 } from "@tanstack/react-query";
3741
+
3742
+ // src/hooks/view/use-get-calendar.ts
3743
+ import { useQuery as useQuery12 } from "@tanstack/react-query";
3744
+
3745
+ // src/hooks/view/use-get-groups.ts
3746
+ import { useQuery as useQuery13 } from "@tanstack/react-query";
3747
+
3748
+ // src/hooks/view/use-get-list-data.ts
3749
+ import { useQuery as useQuery14 } from "@tanstack/react-query";
3750
+
3751
+ // src/hooks/view/use-get-menu.ts
3752
+ import { useQuery as useQuery15 } from "@tanstack/react-query";
3753
+
3754
+ // src/hooks/view/use-get-print-report.ts
3755
+ import { useMutation as useMutation34 } from "@tanstack/react-query";
3756
+
3757
+ // src/hooks/view/use-get-progress-bar.ts
3758
+ import { useQuery as useQuery16 } from "@tanstack/react-query";
3759
+
3760
+ // src/hooks/view/use-get-selection.ts
3761
+ import { useQuery as useQuery17 } from "@tanstack/react-query";
3762
+
3763
+ // src/hooks/view/use-get-view.ts
3764
+ import { useQuery as useQuery18 } from "@tanstack/react-query";
3765
+
3766
+ // src/hooks/view/use-load-action.ts
3767
+ import { useMutation as useMutation35 } from "@tanstack/react-query";
3768
+
3769
+ // src/hooks/view/use-load-message.ts
3770
+ import { useQuery as useQuery19 } from "@tanstack/react-query";
3771
+
3772
+ // src/hooks/view/use-print.ts
3773
+ import { useMutation as useMutation36 } from "@tanstack/react-query";
3774
+
3775
+ // src/hooks/view/use-remove-row.ts
3776
+ import { useMutation as useMutation37 } from "@tanstack/react-query";
3777
+
3778
+ // src/hooks/view/use-resequence.ts
3779
+ import { useQuery as useQuery20 } from "@tanstack/react-query";
3780
+
3781
+ // src/hooks/view/use-run-action.ts
3782
+ import { useMutation as useMutation38 } from "@tanstack/react-query";
3783
+
3784
+ // src/hooks/view/use-signin-sso.ts
3785
+ import { useMutation as useMutation39 } from "@tanstack/react-query";
3786
+
3787
+ // src/hooks/view/use-verify-2FA.ts
3788
+ import { useMutation as useMutation40 } from "@tanstack/react-query";
3789
+
3790
+ // src/hooks/view/uset-get-2FA-method.ts
3791
+ import { useMutation as useMutation41 } from "@tanstack/react-query";
3792
+
3793
+ // src/hooks/view/use-get-fields-view-security.ts
3794
+ import { useMutation as useMutation42 } from "@tanstack/react-query";
3795
+
3796
+ // src/hooks/view/use-grant-access.ts
3797
+ import { useMutation as useMutation43 } from "@tanstack/react-query";
3798
+
3799
+ // src/hooks/view/use-remove-totp-setup.ts
3800
+ import { useMutation as useMutation44 } from "@tanstack/react-query";
3801
+
3802
+ // src/hooks/view/use-request-setup-totp.ts
3803
+ import { useMutation as useMutation45 } from "@tanstack/react-query";
3804
+
3805
+ // src/hooks/view/use-settings-web-read-2fa.ts
3806
+ import { useMutation as useMutation46 } from "@tanstack/react-query";
3807
+
3808
+ // src/hooks/view/use-verify-totp.ts
3809
+ import { useMutation as useMutation47 } from "@tanstack/react-query";
3810
+
3811
+ // src/provider/version-gate-provider.tsx
3812
+ import { Fragment, jsx as jsx5 } from "react/jsx-runtime";
3813
+ var VersionGate = ({ children }) => {
3814
+ const queryClient = useQueryClient();
3815
+ const [ready, setReady] = useState3(false);
3816
+ const { getVersion } = useViewService();
3817
+ const login = use_login_credential_default();
3818
+ useEffect2(() => {
3819
+ const clearVersion = () => {
3820
+ queryClient.clear();
3821
+ localStorage.removeItem("__api_version__");
3822
+ };
3823
+ const validateVersion = async () => {
3824
+ const serverVersion = await getVersion();
3825
+ console.log("serverVersion", serverVersion);
3826
+ login.mutate(
3827
+ {
3828
+ email: "admin",
3829
+ password: "admin",
3830
+ path: "/authentication/oauth2/token"
3831
+ },
3832
+ {
3833
+ onSuccess: (res) => {
3834
+ console.log("res login", res);
3835
+ }
3836
+ }
3837
+ );
3838
+ const cached = localStorage.getItem("__api_version__");
3839
+ if (cached !== serverVersion?.api_version) {
3840
+ clearVersion();
3841
+ localStorage.setItem("__api_version__", serverVersion?.api_version);
3842
+ } else {
3843
+ console.log("Api version:", serverVersion?.api_version);
3844
+ }
3845
+ setReady(true);
3846
+ };
3847
+ validateVersion();
3848
+ if (typeof window !== "undefined") {
3849
+ const onKey = (e) => {
3850
+ const key = e.key.toLowerCase();
3851
+ const isHardRefresh = (key === "f5" || key === "r") && e.ctrlKey && (key !== "r" || e.shiftKey) || key === "r" && e.metaKey && e.shiftKey || key === "r" && e.metaKey && e.altKey;
3852
+ if (isHardRefresh) clearVersion();
3853
+ };
3854
+ window.addEventListener("keydown", onKey);
3855
+ return () => window.removeEventListener("keydown", onKey);
3856
+ }
3857
+ }, [queryClient]);
3858
+ return ready ? /* @__PURE__ */ jsx5(Fragment, { children }) : null;
3859
+ };
3860
+
3416
3861
  // src/provider/env-share.tsx
3417
3862
  import { createContext as createContext2, useContext as useContext2 } from "react";
3418
3863
  import { jsx as jsx6 } from "react/jsx-runtime";
@@ -253,4 +253,31 @@ declare const ViewService: {
253
253
  }): Promise<any>;
254
254
  };
255
255
 
256
- export { ActionService, AuthService, CompanyService, ExcelService, FormService, KanbanServices as KanbanService, ModelService, UserService, ViewService };
256
+ declare function useAuthService(): {
257
+ login: (body: LoginCredentialBody) => Promise<any>;
258
+ forgotPassword: (email: string) => Promise<any>;
259
+ forgotPasswordSSO: ({ email, with_context, method, }: {
260
+ email: string;
261
+ with_context: any;
262
+ method: string;
263
+ }) => Promise<any>;
264
+ resetPassword: (data: ResetPasswordRequest, token: string | null) => Promise<any>;
265
+ resetPasswordSSO: ({ method, password, with_context, }: {
266
+ method: any;
267
+ password: string;
268
+ with_context: any;
269
+ }) => Promise<any>;
270
+ updatePassword: (data: UpdatePasswordRequest, token: string | null) => Promise<any>;
271
+ isValidToken: (token: string | null) => Promise<any>;
272
+ isValidActionToken: (actionToken: string | null, path: string) => Promise<any>;
273
+ loginSocial: ({ db, state, access_token, }: {
274
+ db: string;
275
+ state: object;
276
+ access_token: string;
277
+ }) => Promise<any>;
278
+ getProviders: (db?: string) => Promise<any>;
279
+ getAccessByCode: (code: string) => Promise<any>;
280
+ logout: (data: string) => Promise<any>;
281
+ };
282
+
283
+ export { ActionService, AuthService, CompanyService, ExcelService, FormService, KanbanServices as KanbanService, ModelService, UserService, ViewService, useAuthService };