fix: wrong-event-type-link-for-org-user with same username (#26884)

This commit is contained in:
Dhairyashil Shinde
2026-01-15 22:55:34 +05:30
committed by GitHub
parent 5364655f14
commit d68ae41eed
3 changed files with 17 additions and 2 deletions
@@ -947,11 +947,16 @@ async function fetchEventTypes(): Promise<unknown[]> {
const userData = await userResponse.json();
const username = userData?.data?.username as string | undefined;
// For org users, include org slug to avoid username collisions across orgs
const orgSlug = userData?.data?.organization?.slug as string | undefined;
const params = new URLSearchParams();
if (username) {
params.append("username", username);
}
if (orgSlug) {
params.append("orgSlug", orgSlug);
}
const queryString = params.toString();
const endpoint = `${API_BASE_URL}/event-types${queryString ? `?${queryString}` : ""}`;
+10 -2
View File
@@ -862,21 +862,29 @@ async function getTranscripts(bookingUid: string): Promise<BookingTranscript[]>
}
async function getEventTypes(): Promise<EventType[]> {
// Get cached user profile to extract username (uses in-flight deduplication)
// Get cached user profile to extract username and org slug (uses in-flight deduplication)
let username: string | undefined;
let orgSlug: string | undefined;
try {
const userProfile = await getUserProfile();
// Extract username from response
if (userProfile?.username) {
username = userProfile.username;
}
// For org users, include org slug to avoid username collisions across orgs
if (userProfile?.organization?.slug) {
orgSlug = userProfile.organization.slug;
}
} catch (_error) {}
// Build query string with username and sorting
// Build query string with username, orgSlug, and sorting
const params = new URLSearchParams();
if (username) {
params.append("username", username);
}
if (orgSlug) {
params.append("orgSlug", orgSlug);
}
// Sort by creation date descending (newer first) to match main codebase behavior
// Main codebase uses position: "desc", id: "desc" - since API doesn't expose position,
// we use sortCreatedAt: "desc" for similar behavior (newer event types first)
+2
View File
@@ -13,6 +13,8 @@ export interface UserProfile {
organizationId?: number;
organization?: {
id: number;
slug?: string;
name?: string;
isPlatform: boolean;
};
metadata?: Record<string, unknown>;