Skip to content

Commit ee3fa37

Browse files
authored
revert: 627 yanked
Related to telesales flow #inc-4753-esc
1 parent e584ef1 commit ee3fa37

6 files changed

Lines changed: 44 additions & 134 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10-
## [2.146.0] - 2025-12-18
10+
## [2.146.0] - 2025-12-18 [YANKED]
1111

1212
### Added
1313

manifest.json

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@
9090
"type": "string"
9191
}
9292
},
93-
"required": [
94-
"rel",
95-
"href"
96-
]
93+
"required": ["rel", "href"]
9794
},
9895
"description": "admin/store.faviconLinks.description"
9996
},
@@ -261,10 +258,7 @@
261258
"description": "admin/store.advancedSettings.customHeader.value.description"
262259
}
263260
},
264-
"required": [
265-
"key",
266-
"value"
267-
]
261+
"required": ["key", "value"]
268262
}
269263
},
270264
"useDefaultBrowserNavigation": {
@@ -282,18 +276,14 @@
282276
{
283277
"properties": {
284278
"requiresAuthorization": {
285-
"enum": [
286-
false
287-
]
279+
"enum": [false]
288280
}
289281
}
290282
},
291283
{
292284
"properties": {
293285
"requiresAuthorization": {
294-
"enum": [
295-
true
296-
]
286+
"enum": [true]
297287
},
298288
"b2bEnabled": {
299289
"title": "admin/store.b2benabled.title",
@@ -314,12 +304,7 @@
314304
"b2bEnabled": {
315305
"ui:disabled": "true"
316306
},
317-
"ui:order": [
318-
"storeName",
319-
"requiresAuthorization",
320-
"b2bEnabled",
321-
"*"
322-
]
307+
"ui:order": ["storeName", "requiresAuthorization", "b2bEnabled", "*"]
323308
},
324309
"$schema": "https://raw.githubusercontent.com/vtex/node-vtex-api/master/gen/manifest.schema"
325310
}

react/ProfileChallenge.tsx

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
import React, { useEffect, FC } from 'react'
2-
import { useQuery } from 'react-apollo'
3-
import { useRuntime, canUseDOM, Loading } from 'vtex.render-runtime'
1+
import React, { useState, useEffect, FC } from 'react'
2+
import {
3+
useRuntime,
4+
canUseDOM,
5+
Loading,
6+
SessionResponse,
7+
Session,
8+
} from 'vtex.render-runtime'
49

5-
import getAuthenticatedUser from './graphql/getAuthenticatedUser.graphql'
10+
import { getSession } from './modules/session'
611

712
const loginPath = '/login'
813

@@ -16,18 +21,35 @@ const getLocation = () =>
1621
pathName: window.location.pathname,
1722
}
1823
: {
19-
url: (global as any).__pathname__, // eslint-disable-line @typescript-eslint/no-explicit-any
20-
pathName: (global as any).__pathname__, // eslint-disable-line @typescript-eslint/no-explicit-any
24+
url: (global as any).__pathname__,
25+
pathName: (global as any).__pathname__,
2126
}
2227

23-
const useStoreGraphqlSession = () => {
24-
const shouldRunQuery = canUseDOM
28+
const useSessionResponse = () => {
29+
const [session, setSession] = useState<SessionResponse>()
30+
const sessionPromise = getSession()
2531

26-
const { data, loading, error } = useQuery(getAuthenticatedUser, {
27-
skip: !shouldRunQuery,
28-
})
32+
useEffect(() => {
33+
if (!sessionPromise) {
34+
return
35+
}
36+
37+
sessionPromise.then(sessionResponse => {
38+
const response = sessionResponse.response as SessionResponse
39+
40+
setSession(response)
41+
})
42+
}, [sessionPromise])
2943

30-
return { data, loading, error }
44+
return session
45+
}
46+
47+
function hasSession(session: SessionResponse | undefined): session is Session {
48+
return (
49+
session !== undefined &&
50+
session.type !== 'Unauthorized' &&
51+
session.type !== 'Forbidden'
52+
)
3153
}
3254

3355
const useLoginRedirect = (isLoggedIn: boolean | null, page: string) => {
@@ -53,12 +75,10 @@ interface Props {
5375
}
5476

5577
const ProfileChallenge: FC<Props> = ({ children, page }) => {
56-
const storeGraphqlSession = useStoreGraphqlSession()
57-
58-
const isLoggedIn =
59-
storeGraphqlSession.loading === false
60-
? !!storeGraphqlSession.data?.authenticatedUser?.id
61-
: null
78+
const session = useSessionResponse()
79+
const isLoggedIn = hasSession(session)
80+
? session.namespaces?.profile?.isAuthenticated?.value === 'true'
81+
: null
6282

6383
useLoginRedirect(isLoggedIn, page)
6484

react/__tests__/ProfileChallenge.test.tsx

Lines changed: 0 additions & 84 deletions
This file was deleted.

react/graphql/getAuthenticatedUser.graphql

Lines changed: 0 additions & 7 deletions
This file was deleted.

react/typings/graphql.d.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)