Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VTEX] feat: add vtex telephone #1021

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions commerce/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ export interface Person extends Omit<Thing, "@type"> {
image?: ImageObject[] | null;
/** The Tax / Fiscal ID of the organization or person, e.g. the TIN in the US or the CIF/NIF in Spain. */
taxID?: string;
/** The telephone number. */
telephone?: string;
}
// NON SCHEMA.ORG Compliant. Should be removed ASAP
export interface Author extends Omit<Thing, "@type"> {
Expand Down
13 changes: 9 additions & 4 deletions vtex/loaders/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ interface User {
profilePicture?: string;
gender?: string;
document?: string;
homePhone?: string;
businessPhone?: string;
}

async function loader(
Expand All @@ -26,7 +28,7 @@ async function loader(
}

const query =
"query getUserProfile { profile { id userId email firstName lastName profilePicture gender document }}";
"query getUserProfile { profile { id userId email firstName lastName profilePicture gender document homePhone businessPhone }}";

try {
const { profile: user } = await io.query<{ profile: User }, null>(
Expand All @@ -40,9 +42,12 @@ async function loader(
givenName: user.firstName,
familyName: user.lastName,
taxID: user?.document?.replace(/[^\d]/g, ""),
gender: user.gender === "f"
? "https://schema.org/Female"
: "https://schema.org/Male",
gender: user.gender
? user.gender === "f"
? "https://schema.org/Female"
: "https://schema.org/Male"
: undefined,
telephone: user.homePhone ?? user.businessPhone,
};
} catch (_) {
return null;
Expand Down
Loading