@vtex/faststore-plugin-buyer-portal 1.1.116-poc-9 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +42 -42
- package/src/features/addresses/layouts/AddressDetailsLayout/AddressDetailsLayout.tsx +0 -1
- package/src/features/addresses/layouts/AddressesLayout/AddressesLayout.tsx +0 -1
- package/src/features/budgets/layouts/BudgetsDetailsLayout/BudgetsDetailsLayout.tsx +0 -1
- package/src/features/collections/layouts/CollectionsLayout/CollectionsLayout.tsx +0 -1
- package/src/features/contracts/hooks/index.ts +0 -2
- package/src/features/contracts/services/get-contract-details.service.ts +0 -4
- package/src/features/credit-cards/layouts/CreditCardsLayout/CreditCardLayout.tsx +0 -1
- package/src/features/custom-fields/layouts/CustomFieldsLayout/CustomFieldsLayout.tsx +0 -1
- package/src/features/org-units/clients/OrgUnitClient.ts +15 -2
- package/src/features/org-units/components/OrgUnitBreadcrumb/OrgUnitBreadcrumbLink.tsx +0 -1
- package/src/features/org-units/hooks/index.ts +0 -1
- package/src/features/org-units/layouts/OrgUnitDetailsLayout/OrgUnitDetailsLayout.tsx +29 -32
- package/src/features/org-units/services/get-org-unit-basic-data.service.ts +0 -4
- package/src/features/org-units/services/get-org-unit-by-user-id.service.ts +0 -4
- package/src/features/org-units/types/OrgUnitSummaryData.ts +0 -18
- package/src/features/org-units/types/index.ts +0 -2
- package/src/features/payment-methods/layouts/PaymentMethodsLayout/PaymentMethodsLayout.tsx +0 -1
- package/src/features/profile/layouts/ProfileLayout/ProfileLayout.tsx +16 -46
- package/src/features/shared/components/Error/Error.tsx +13 -12
- package/src/features/shared/components/index.ts +0 -1
- package/src/features/shared/components/withErrorBoundary/withErrorBoundary.tsx +1 -0
- package/src/features/shared/hooks/index.ts +0 -2
- package/src/features/shared/layouts/ContractTabsLayout/ContractTabsLayout.tsx +9 -14
- package/src/features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout.tsx +0 -1
- package/src/features/shared/layouts/LoadingTabsLayout/LoadingTabsLayout.tsx +27 -6
- package/src/features/shared/utils/withAuthLoader.ts +1 -1
- package/src/features/shared/utils/withAuthProvider.tsx +0 -1
- package/src/features/shared/utils/withProviders.tsx +2 -1
- package/src/features/users/services/get-user-by-id.service.ts +0 -4
- package/src/pages/org-unit-details.tsx +62 -42
- package/src/pages/profile.tsx +64 -48
- package/src/themes/index.scss +0 -1
- package/src/features/contracts/hooks/useContractDetails.ts +0 -22
- package/src/features/contracts/hooks/useContractsByOrgUnitId.ts +0 -20
- package/src/features/org-units/hooks/useOrgUnitBasicData.ts +0 -20
- package/src/features/shared/components/PageLoader/PageLoader.tsx +0 -47
- package/src/features/shared/components/PageLoader/index.ts +0 -1
- package/src/features/shared/components/PageLoader/page-loader.scss +0 -22
- package/src/features/shared/hooks/useAuth.ts +0 -50
- package/src/features/shared/hooks/useCookieMonitor.ts +0 -73
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
|
|
3
|
-
import storeConfig from "discovery.config";
|
|
4
|
-
|
|
5
|
-
import { AUT_COOKIE_KEY } from "../utils/constants";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Hook to monitor when authentication cookie becomes available.
|
|
9
|
-
* Used to detect when cookies load after pre-fetch scenarios.
|
|
10
|
-
*
|
|
11
|
-
* @returns boolean indicating if auth cookie is present
|
|
12
|
-
*/
|
|
13
|
-
export const useCookieMonitor = () => {
|
|
14
|
-
const [hasCookie, setHasCookie] = useState(false);
|
|
15
|
-
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
const checkCookie = () => {
|
|
18
|
-
if (typeof document === "undefined") return false;
|
|
19
|
-
|
|
20
|
-
const cookieName = `${AUT_COOKIE_KEY}_${storeConfig?.api.storeId}`;
|
|
21
|
-
const cookies = document.cookie.split(";");
|
|
22
|
-
|
|
23
|
-
const authCookie = cookies.find((cookie) =>
|
|
24
|
-
cookie.trim().startsWith(`${cookieName}=`)
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
const hasCookieValue =
|
|
28
|
-
!!authCookie && authCookie.split("=")[1]?.trim() !== "";
|
|
29
|
-
|
|
30
|
-
console.log("[useCookieMonitor] Checking cookie:", {
|
|
31
|
-
cookieName,
|
|
32
|
-
hasCookie: hasCookieValue,
|
|
33
|
-
cookieValue: authCookie
|
|
34
|
-
? authCookie.split("=")[1]?.substring(0, 10) + "..."
|
|
35
|
-
: "none",
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
return hasCookieValue;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// Check immediately
|
|
42
|
-
const initialCheck = checkCookie();
|
|
43
|
-
console.log("[useCookieMonitor] Initial check:", initialCheck);
|
|
44
|
-
setHasCookie(initialCheck);
|
|
45
|
-
|
|
46
|
-
// If no cookie yet, poll for it
|
|
47
|
-
if (!initialCheck) {
|
|
48
|
-
console.log("[useCookieMonitor] Starting cookie polling...");
|
|
49
|
-
const interval = setInterval(() => {
|
|
50
|
-
const hasAuthCookie = checkCookie();
|
|
51
|
-
|
|
52
|
-
if (hasAuthCookie) {
|
|
53
|
-
console.log("[useCookieMonitor] Cookie found! Stopping poll.");
|
|
54
|
-
setHasCookie(true);
|
|
55
|
-
clearInterval(interval);
|
|
56
|
-
}
|
|
57
|
-
}, 100); // Check every 100ms
|
|
58
|
-
|
|
59
|
-
// Cleanup after 5 seconds max
|
|
60
|
-
const timeout = setTimeout(() => {
|
|
61
|
-
console.log("[useCookieMonitor] Polling timeout reached (5s)");
|
|
62
|
-
clearInterval(interval);
|
|
63
|
-
}, 5000);
|
|
64
|
-
|
|
65
|
-
return () => {
|
|
66
|
-
clearInterval(interval);
|
|
67
|
-
clearTimeout(timeout);
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
}, []);
|
|
71
|
-
|
|
72
|
-
return hasCookie;
|
|
73
|
-
};
|