Skip to content

feat: user details adjusts - SFS-2950 - #3306

Merged
eduardoformiga merged 3 commits into
devfrom
feat/user-details-adjusts
May 11, 2026
Merged

eduardoformiga merged 3 commits into
devfrom
feat/user-details-adjusts

Conversation

@eduardoformiga

@eduardoformiga eduardoformiga commented May 7, 2026 •

Copy link
Copy Markdown
Member

What's the purpose of this pull request?

This pull request enhances the user details functionality by adding support for displaying and handling a user's phone number and username throughout the stack. It updates the GraphQL schema, backend resolvers, and frontend components to ensure these fields are retrieved, stored, and shown in the UI. Additionally, user roles are now dynamically fetched from the license manager service.

example:

Before After
Screenshot 2026-04-20 at 14 56 43 Screenshot 2026-05-07 at 18 46 04

Summary by CodeRabbit

  • New Features
    • User account details now display comprehensive profile information including username, email, phone number, and assigned roles.
    • Improved role management system that retrieves user roles from the license manager for more accurate permissions.
    • Enhanced user contact information visibility in account settings.

Extends the commerce client surface with two B2B-related additions
needed by the userDetails resolver:

- `commerce.licenseManager.getUserRoles({ userId })` calls
  /api/license-manager/storefront/users/{userId}/roles and returns the
  user roles (`Roles: [{ Id, Name }]`) and email.
- `profile.phone` is now requested from the VTEX Sessions API and
  reflected in the `Profile` type, providing a fallback phone source
  for users that don't have a record on the B2B `shopper` Master Data
  entity.

Refs SFS-2950
Replaces the mocked role and partial user data with real values
sourced from existing commerce client methods, aligning the My
Account user details page with the data model used by the Buyer
Portal Organization Account page.

- `StoreUserDetails` is extended with `username` and `phone`.
- `userDetails` resolver now resolves the JWT user id and fans out
  in parallel to `commerce.session`,
  `commerce.masterData.getShopperById`, and the new
  `commerce.licenseManager.getUserRoles`.
- Real role names (`Roles[].Name`) replace the previous
  `['Admin']` mock.
- Phone falls back from the B2B `shopper` Master Data entity to the
  standard VTEX `profile.phone` when the shopper record does not
  exist or does not contain a phone.
- Name is composed from `firstName + lastName` (Master Data, with
  session profile fallback), fixing the previous behavior that
  dropped `lastName`.

Refs SFS-2950
Updates the My Account User Details page to match the data model and
layout of the Buyer Portal Organization Account page (PRD REQ 1):

- Adds `username` and `phone` fields to the
  `ServerUserDetailsQuery` and the page-level types.
- Adds `Username` and `Phone number` rows to the `AccountTable`,
  preserving the existing component (no layout rewrite).
- Wraps role tags inside a single
  `[data-fs-user-details-row-tags]` container so multiple roles
  flow with `flex-wrap` instead of forcing horizontal scroll on
  narrow viewports.
- Organizational unit row remains text-only (no Change button), as
  specified by the PRD.

Refs SFS-2950
@eduardoformiga
eduardoformiga requested a review from a team as a code owner May 7, 2026 21:53
@eduardoformiga
eduardoformiga requested review from lariciamota and lemagnetic and removed request for a team May 7, 2026 21:53
@coderabbitai

coderabbitai Bot commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR expands the user details feature by introducing phone and username fields across the backend and frontend. The backend now fetches user roles from VTEX License Manager instead of hard-coding them, while the frontend displays the additional contact fields in the account details table.

Changes

User Details Expansion with License Manager Roles

Layer / File(s) Summary
Data Contracts & Types
packages/api/src/platforms/vtex/clients/commerce/types/Session.ts, packages/api/src/platforms/vtex/typeDefs/query.graphql
Session Profile interface adds optional phone?: Value; GraphQL StoreUserDetails type adds username: String and phone: String fields.
Commerce API Client
packages/api/src/platforms/vtex/clients/commerce/index.ts
New licenseManager.getUserRoles method fetches user roles via GET to /api/license-manager/storefront/users/{userId}/roles; session items projection adjusted.
Query Resolver
packages/api/src/platforms/vtex/resolvers/query.ts
Query.userDetails refactored to extract userId from JWT cookie, concurrently fetch session/shopper/roles via Promise.all, and map role data from License Manager instead of hard-coded ['Admin'].
Frontend Integration
packages/core/src/pages/pvt/account/user-details.tsx, packages/core/src/components/account/MyAccountUserDetails/MyAccountUserDetails.tsx
Page component updates ServerUserDetailsQuery to request username and phone; component renders expanded fields in table rows with refactored role tag wrapper (<span data-fs-user-details-row-tags>).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • gabpaladino
  • lariciamota
  • hellofanny
  • lemagnetic

Poem

🔐 JWT flows through the resolver's veins,
Roles whisper from License Manager's domains,
Phone and username join the table's display,
User details now painted in a brighter way. ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'user details adjusts' is vague and uses generic phrasing that doesn't clearly convey the main changes (adding phone/username fields, dynamic role fetching from license manager). Consider using a more specific title like 'feat: add username and phone to user details with dynamic role fetching' to better reflect the primary changes.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/user-details-adjusts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codesandbox-ci

codesandbox-ci Bot commented May 7, 2026

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/core/src/pages/pvt/account/user-details.tsx (1)

179-179: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

?? {} doesn't satisfy the extended UserDetailsPagePros.userDetails type — TypeScript strict mode violation.

UserDetailsPagePros.userDetails now requires six non-optional fields (username, name, email, phone, role, orgUnit). Passing {} as a fallback is a type error under strict mode and is only reachable in a path that should have already been redirected. Provide a complete default to keep the compiler happy and the type contract explicit.

🛡️ Proposed fix
-      userDetails: userDetails.data?.userDetails ?? {},
+      userDetails: userDetails.data?.userDetails ?? {
+        username: '',
+        name: '',
+        email: '',
+        phone: '',
+        role: [],
+        orgUnit: '',
+      },

As per coding guidelines: "Ensure type safety and avoid type assertions when possible" and "Use TypeScript strict mode for all TypeScript files in the project".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/src/pages/pvt/account/user-details.tsx` at line 179, The
fallback for userDetails (currently "userDetails: userDetails.data?.userDetails
?? {}") violates the UserDetailsPagePros.userDetails type because {} lacks the
required fields; replace the empty-object fallback with a complete default
object matching the six required properties (username, name, email, phone, role,
orgUnit) so the expression becomes userDetails: userDetails.data?.userDetails ??
{ username: '', name: '', email: '', phone: '', role: '', orgUnit: '' } (or
other sensible defaults), ensuring the type contract is satisfied without using
type assertions; update the code that reads userDetails (the
userDetails.data?.userDetails usage) accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/api/src/platforms/vtex/clients/commerce/index.ts`:
- Around line 707-723: The resolver that calls the getUserRoles client currently
swallows all errors with .catch(() => null); update the resolver to handle
failures explicitly: call getUserRoles (the method defined in this file) and
replace the blanket .catch with logic that inspects the error (e.g., check
status or error code), emits a processLogger/telemetry event for authorization
failures (403) and other errors, and then returns an appropriate fallback (empty
Roles array or null) instead of silently swallowing; ensure you reference the
getUserRoles call site in the resolver and add logging/telemetry for both
expected auth errors and unexpected failures.

In `@packages/api/src/platforms/vtex/resolvers/query.ts`:
- Around line 595-603: The resolver is not using the VTEX session fallbacks for
name and phone; update the construction of fullName and the phone return to fall
back to session profile values when shopper/shopperResult fields are missing:
for fullName (variable fullName) use shopper?.firstName/lastName, then
shopperResult's names if available, then sessions.profile.firstName/lastName
before defaulting to '', and for phone use shopper?.phone then
shopperResult?.phone then sessions.profile.phone before ''. Locate these in the
query resolver where fullName, shopper (and any shopperResult) and the returned
phone value are defined and wire the session.profile fallbacks accordingly while
keeping authentication?.storeUserEmail usage unchanged for username/email.

---

Outside diff comments:
In `@packages/core/src/pages/pvt/account/user-details.tsx`:
- Line 179: The fallback for userDetails (currently "userDetails:
userDetails.data?.userDetails ?? {}") violates the
UserDetailsPagePros.userDetails type because {} lacks the required fields;
replace the empty-object fallback with a complete default object matching the
six required properties (username, name, email, phone, role, orgUnit) so the
expression becomes userDetails: userDetails.data?.userDetails ?? { username: '',
name: '', email: '', phone: '', role: '', orgUnit: '' } (or other sensible
defaults), ensuring the type contract is satisfied without using type
assertions; update the code that reads userDetails (the
userDetails.data?.userDetails usage) accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b33d04a6-b14c-49e2-8eaa-38e8b58aa2b4

📥 Commits

Reviewing files that changed from the base of the PR and between de1a5b1 and 07cc959.

⛔ Files ignored due to path filters (3)
  • packages/api/src/__generated__/schema.ts is excluded by !**/__generated__/** and included by packages/**
  • packages/core/@generated/gql.ts is excluded by !**/@generated/**, !**/@generated/** and included by packages/**
  • packages/core/@generated/graphql.ts is excluded by !**/@generated/**, !**/@generated/** and included by packages/**
📒 Files selected for processing (6)
  • packages/api/src/platforms/vtex/clients/commerce/index.ts
  • packages/api/src/platforms/vtex/clients/commerce/types/Session.ts
  • packages/api/src/platforms/vtex/resolvers/query.ts
  • packages/api/src/platforms/vtex/typeDefs/query.graphql
  • packages/core/src/components/account/MyAccountUserDetails/MyAccountUserDetails.tsx
  • packages/core/src/pages/pvt/account/user-details.tsx

Comment on lines +707 to +723
getUserRoles: ({
userId,
}: { userId: string }): Promise<{
Email: string
Roles: Array<{ Id: number; Name: string }>
}> => {
const headers: HeadersInit = withAutCookie(forwardedHost, account)

return fetchAPI(
`${base}/api/license-manager/storefront/users/${userId}/roles`,
{
method: 'GET',
headers,
},
{}
)
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify that View_Storefront_User_Permissions is documented as auto-granted
# to storefront users and search for any error-handling pattern for 403 on this path.
rg -n "View_Storefront_User_Permissions\|getUserRoles\|licenseManager" --type ts -A3 -B3

Repository: vtex/faststore

Length of output: 40


🏁 Script executed:

fd -type f "index.ts" | grep -E "commerce|vtex" | head -20

Repository: vtex/faststore

Length of output: 229


🏁 Script executed:

find . -path "*/vtex/clients/commerce/index.ts" 2>/dev/null

Repository: vtex/faststore

Length of output: 118


🏁 Script executed:

git ls-files | grep -i "vtex.*commerce" | head -20

Repository: vtex/faststore

Length of output: 1316


🏁 Script executed:

wc -l packages/api/src/platforms/vtex/clients/commerce/index.ts

Repository: vtex/faststore

Length of output: 120


🏁 Script executed:

sed -n '700,730p' packages/api/src/platforms/vtex/clients/commerce/index.ts

Repository: vtex/faststore

Length of output: 850


🏁 Script executed:

rg -n "getUserRoles" packages/api/src/platforms/vtex/clients/commerce/index.ts -A5 -B5

Repository: vtex/faststore

Length of output: 334


🏁 Script executed:

rg -n "getUserRoles" packages/api/src/platforms/vtex --type ts -A10 -B2 | head -100

Repository: vtex/faststore

Length of output: 2355


🏁 Script executed:

rg -n "\.catch.*null\|\.catch\(\)" packages/api/src/platforms/vtex --type ts -A2 -B2 | grep -A3 -B3 "getUserRoles\|licenseManager"

Repository: vtex/faststore

Length of output: 40


🏁 Script executed:

find packages/api/src -name "*.graphql" -o -name "*.ts" | xargs grep -l "getUserRoles" 2>/dev/null

Repository: vtex/faststore

Length of output: 167


🏁 Script executed:

sed -n '580,610p' packages/api/src/platforms/vtex/resolvers/query.ts

Repository: vtex/faststore

Length of output: 1175


🏁 Script executed:

sed -n '570,620p' packages/api/src/platforms/vtex/resolvers/query.ts

Repository: vtex/faststore

Length of output: 1622


🏁 Script executed:

rg -n "View_Storefront_User_Permissions\|license.manager\|licenseManager" packages/api/src/platforms/vtex -A2 -B2

Repository: vtex/faststore

Length of output: 40


🏁 Script executed:

sed -n '550,595p' packages/api/src/platforms/vtex/resolvers/query.ts

Repository: vtex/faststore

Length of output: 1573


🏁 Script executed:

rg -n "\.catch\(\(\) => null\)" packages/api/src/platforms/vtex/resolvers/query.ts | head -20

Repository: vtex/faststore

Length of output: 372


Consider explicit error handling at the resolver level for getUserRoles failures.

The getUserRoles client method is correctly implemented, but the resolver's error handling at line 588 uses .catch(() => null), which silently swallows all errors including 403 responses. This is consistent with other API calls in the resolver (session, getShopperById), but if authorization failures are expected or should be tracked, add explicit logging or error telemetry instead of silent degradation to an empty roles array.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/api/src/platforms/vtex/clients/commerce/index.ts` around lines 707 -
723, The resolver that calls the getUserRoles client currently swallows all
errors with .catch(() => null); update the resolver to handle failures
explicitly: call getUserRoles (the method defined in this file) and replace the
blanket .catch with logic that inspects the error (e.g., check status or error
code), emits a processLogger/telemetry event for authorization failures (403)
and other errors, and then returns an appropriate fallback (empty Roles array or
null) instead of silently swallowing; ensure you reference the getUserRoles call
site in the resolver and add logging/telemetry for both expected auth errors and
unexpected failures.

@hellofanny hellofanny added the enhancement New feature or request label May 11, 2026
@eduardoformiga
eduardoformiga merged commit 70b018d into dev May 11, 2026
5 checks passed
@eduardoformiga
eduardoformiga deleted the feat/user-details-adjusts branch May 11, 2026 17:03
eduardoformiga added a commit that referenced this pull request May 11, 2026
## What's the purpose of this pull request?

Bring `dev` into `main` so the next CD run on `main` cuts and publishes
`@faststore/*@4.1.0`. Includes the publish-pipeline fix from #3309, so
this is also the first release that exercises the `pnpm -r publish` flow
end-to-end (broken `4.0.0` is superseded by `4.1.0` as `latest`).

## What's included since v4.0.0

- #3308 — fix: PLP "Load more products" overwriting list instead of
appending
- #3306 — feat: user details adjusts — SFS-2950
- #3304 — fix: updates schemas vtex.faststore
- #3301 — fix: localization selector stale and reset selection for
unsaved changes
- `d1e40abe7` — fix: add repository field to diagnostics package for
OIDC provenance
- #3309 — fix: publish releases with pnpm to resolve workspace and
catalog protocols (already on `main`, kept by 3-way merge)

## How CD will behave on merge

1. `lerna version --conventional-commits --conventional-graduate --yes`
graduates `4.1.0-dev.1` → `4.1.0`, creates tag `v4.1.0`, and pushes the
`[no ci] Release: 4.1.0` commit.
2. `pnpm release:verify` packs every public package and asserts no
`workspace:` / `catalog:` literal survives the pack step.
3. `pnpm -r publish --access public --no-git-checks` uploads the 8
public packages with all `workspace:*` / `catalog:` references rewritten
to concrete versions.

## Sanity checks already performed locally

- `git merge-tree` between `origin/main` and `origin/dev`: clean, no
conflicts.
- `pnpm install --frozen-lockfile` on the merged tree: no lockfile
drift.
- `pnpm release:verify` on `release/4.1.0`: all 8 public packages clean
at `4.1.0-dev.1` (the same manifests that will be bumped to `4.1.0`).

## Follow-ups (not blocking)

- Once `4.1.0` is on `latest`, consider `npm deprecate
@faststore/<pkg>@4.0.0 "Broken release: workspace:/catalog: not
resolved. Use 4.1.0+"` for `cli`, `core`, `api`, `ui`, `components`,
`sdk`, `diagnostics`, `lighthouse`.
- Optional: add `workflow_dispatch` to `release.yml` so future hotfix
releases without `packages/*` changes can be triggered manually with
`--force-publish`.

Made with [Cursor](https://cursor.com)

---------

Co-authored-by: Larícia Mota <[email protected]>
Co-authored-by: Matheus P. Silva <[email protected]>
Co-authored-by: Leandro Rodrigues <[email protected]>
Co-authored-by: vtexgithubbot <[email protected]>
Co-authored-by: Lucas Feijó <[email protected]>
Co-authored-by: Luiz Falcão <[email protected]>
Co-authored-by: Artur Santiago <[email protected]>
Co-authored-by: Sahan Jayawardana <[email protected]>
Co-authored-by: Mateus Pontes <[email protected]>
Co-authored-by: Matheus Martins <[email protected]>
Co-authored-by: renatomaurovtex <[email protected]>
Co-authored-by: Leandro Rodrigues <[email protected]>
Co-authored-by: Fanny Chien <[email protected]>
Co-authored-by: Arthur Andrade <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Thiago Pereira <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Giuliana Rigaud <[email protected]>
Co-authored-by: renato <[email protected]>
Co-authored-by: Bruna Santos <[email protected]>
Co-authored-by: BrunaCubos <[email protected]>
Co-authored-by: Ícaro Oliveira <[email protected]>
Co-authored-by: Bruna Santos <[email protected]>
Co-authored-by: Everton Ataide <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Otavio Moreira Meirelles <[email protected]>
Co-authored-by: Marco Cardoso <[email protected]>
Co-authored-by: Gabriel Paladino <[email protected]>
Co-authored-by: CodeRabbit <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants