@vtex/faststore-plugin-buyer-portal 1.1.116-poc-2 → 1.1.116-poc-3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/faststore-plugin-buyer-portal",
3
- "version": "1.1.116-poc-2",
3
+ "version": "1.1.116-poc-3",
4
4
  "description": "A plugin for faststore with buyer portal",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -3,8 +3,7 @@ import { useEffect, useState } from "react";
3
3
  import { useRouter } from "next/router";
4
4
 
5
5
  import { authClient } from "../clients/Auth";
6
-
7
- import { useBuyerPortal } from "./useBuyerPortal";
6
+ import { ClientContext } from "../utils";
8
7
 
9
8
  export type UseAuthResult = {
10
9
  isAuthenticated: boolean | null;
@@ -17,8 +16,7 @@ export type UseAuthResult = {
17
16
  *
18
17
  * @returns Object containing authentication status and loading state
19
18
  */
20
- export const useAuth = (): UseAuthResult => {
21
- const { clientContext } = useBuyerPortal();
19
+ export const useAuth = (clientContext: ClientContext): UseAuthResult => {
22
20
  const [isAuthenticated, setIsAuthenticated] = useState<boolean | null>(null);
23
21
  const [isLoading, setIsLoading] = useState(true);
24
22
  const router = useRouter();
@@ -36,6 +36,7 @@ const loaderFunction = async (
36
36
  const { orgUnitId } = data.query;
37
37
 
38
38
  const { cookie, userId, ...clientContext } = await getClientContext(data);
39
+ console.log(">>> Org Unit Loader", cookie);
39
40
 
40
41
  return {
41
42
  data: {
@@ -55,6 +56,7 @@ export const loader = withLoaderErrorBoundary(loaderFunction, {
55
56
 
56
57
  const OrgUnitDetailsPage = ({
57
58
  data,
59
+ context,
58
60
  hasError,
59
61
  error,
60
62
  }: OrgUnitDetailsPageData) => {
@@ -62,7 +64,8 @@ const OrgUnitDetailsPage = ({
62
64
  return <ErrorTabsLayout error={error} />;
63
65
  }
64
66
 
65
- const { isAuthenticated, isLoading } = useAuth();
67
+ const { isAuthenticated, isLoading } = useAuth(context.clientContext);
68
+ console.log(">> Org Unit Details, auth", isAuthenticated, isLoading);
66
69
 
67
70
  if (isLoading || isAuthenticated === null) {
68
71
  return <PageLoader />;
@@ -57,12 +57,12 @@ export const loader = withLoaderErrorBoundary(loaderFunction, {
57
57
  redirectToError: true,
58
58
  });
59
59
 
60
- const ProfilePage = ({ data, hasError, error }: ProfilePageData) => {
60
+ const ProfilePage = ({ data, context, hasError, error }: ProfilePageData) => {
61
61
  if (hasError) {
62
62
  return <ErrorTabsLayout error={error} />;
63
63
  }
64
64
 
65
- const { isAuthenticated, isLoading } = useAuth();
65
+ const { isAuthenticated, isLoading } = useAuth(context.clientContext);
66
66
 
67
67
  if (isLoading || isAuthenticated === null) {
68
68
  return <PageLoader />;