fix: translate location dropdown group labels and options in event-type settings (#26784)
* fix: translate location dropdown group labels in event-type settings Co-Authored-By: morgan@cal.com <morgan@cal.com> * fix: use requesting user's locale for team event type translations For team event types, the current user might not be in eventType.users, causing translations to default to English. This fix queries the user's locale directly from the database when not found in the event type users. Co-Authored-By: morgan@cal.com <morgan@cal.com> * refactor: pass userLocale as parameter instead of database call Per PR feedback, pass the authenticated user's locale as an optional parameter to getEventTypeById instead of making an extra database call. The locale is passed from ctx.user.locale in the tRPC handler. Co-Authored-By: morgan@cal.com <morgan@cal.com> * fix: provide userLocale in apiv2 getEventTypeById * fix: remove unused ts comments --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
7 files changed
+87
-82
No files matched your search
@@ -1,12 +1,11 @@
|
||||
import { getEventTypeById } from "@calcom/platform-libraries/event-types";
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { CreateEventTypeInput_2024_04_15 } from "@/ee/event-types/event-types_2024_04_15/inputs/create-event-type.input";
|
||||
import { PrismaReadService } from "@/modules/prisma/prisma-read.service";
|
||||
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
|
||||
import { UsersService } from "@/modules/users/services/users.service";
|
||||
import { UserWithProfile } from "@/modules/users/users.repository";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
|
||||
import { getEventTypeById } from "@calcom/platform-libraries/event-types";
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
|
||||
@Injectable()
|
||||
export class EventTypesRepository_2024_04_15 {
|
||||
@@ -54,6 +53,7 @@ export class EventTypesRepository_2024_04_15 {
|
||||
currentOrganizationId: this.usersService.getUserMainOrgId(user),
|
||||
eventTypeId,
|
||||
userId: user.id,
|
||||
userLocale: user.locale ?? "en",
|
||||
prisma: this.dbRead.prisma as unknown as PrismaClient,
|
||||
isUserOrganizationAdmin,
|
||||
isTrpcCall: true,
|
||||
|
||||
@@ -1,3 +1,32 @@
|
||||
import type { TeamQuery } from "@calcom/platform-libraries";
|
||||
import { checkAdminOrOwner, getClientSecretFromPayment } from "@calcom/platform-libraries";
|
||||
import type {
|
||||
App,
|
||||
CredentialDataWithTeamName,
|
||||
CredentialOwner,
|
||||
CredentialPayload,
|
||||
LocationOption,
|
||||
TDependencyData,
|
||||
} from "@calcom/platform-libraries/app-store";
|
||||
import {
|
||||
enrichUserWithDelegationConferencingCredentialsWithoutOrgId,
|
||||
getAppFromSlug,
|
||||
getEnabledAppsFromCredentials,
|
||||
} from "@calcom/platform-libraries/app-store";
|
||||
import {
|
||||
bulkUpdateEventsToDefaultLocation,
|
||||
bulkUpdateTeamEventsToDefaultLocation,
|
||||
EventTypeMetaDataSchema,
|
||||
getBulkTeamEventTypes,
|
||||
getBulkUserEventTypes,
|
||||
getEventTypeById,
|
||||
getPublicEvent,
|
||||
type PublicEventType,
|
||||
TUpdateEventTypeInputSchema,
|
||||
updateEventType,
|
||||
} from "@calcom/platform-libraries/event-types";
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
import { BadRequestException, ForbiddenException, Injectable, NotFoundException } from "@nestjs/common";
|
||||
import { EventTypesService_2024_06_14 } from "@/ee/event-types/event-types_2024_06_14/services/event-types.service";
|
||||
import { systemBeforeFieldEmail } from "@/ee/event-types/event-types_2024_06_14/transformers";
|
||||
import { AtomsRepository } from "@/modules/atoms/atoms.repository";
|
||||
@@ -9,34 +38,6 @@ import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
|
||||
import { TeamsEventTypesService } from "@/modules/teams/event-types/services/teams-event-types.service";
|
||||
import { UsersService } from "@/modules/users/services/users.service";
|
||||
import { UserWithProfile } from "@/modules/users/users.repository";
|
||||
import { Injectable, NotFoundException, ForbiddenException, BadRequestException } from "@nestjs/common";
|
||||
|
||||
import { checkAdminOrOwner, getClientSecretFromPayment } from "@calcom/platform-libraries";
|
||||
import type { TeamQuery } from "@calcom/platform-libraries";
|
||||
import { enrichUserWithDelegationConferencingCredentialsWithoutOrgId } from "@calcom/platform-libraries/app-store";
|
||||
import { getEnabledAppsFromCredentials, getAppFromSlug } from "@calcom/platform-libraries/app-store";
|
||||
import type {
|
||||
App,
|
||||
TDependencyData,
|
||||
CredentialOwner,
|
||||
CredentialPayload,
|
||||
CredentialDataWithTeamName,
|
||||
LocationOption,
|
||||
} from "@calcom/platform-libraries/app-store";
|
||||
import { type PublicEventType, getPublicEvent } from "@calcom/platform-libraries/event-types";
|
||||
import {
|
||||
getEventTypeById,
|
||||
bulkUpdateEventsToDefaultLocation,
|
||||
bulkUpdateTeamEventsToDefaultLocation,
|
||||
getBulkUserEventTypes,
|
||||
getBulkTeamEventTypes,
|
||||
} from "@calcom/platform-libraries/event-types";
|
||||
import {
|
||||
updateEventType,
|
||||
TUpdateEventTypeInputSchema,
|
||||
EventTypeMetaDataSchema,
|
||||
} from "@calcom/platform-libraries/event-types";
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
|
||||
type EnabledAppType = App & {
|
||||
credential: CredentialDataWithTeamName;
|
||||
@@ -81,6 +82,7 @@ export class EventTypesAtomService {
|
||||
currentOrganizationId: this.usersService.getUserMainOrgId(user),
|
||||
eventTypeId,
|
||||
userId: user.id,
|
||||
userLocale: user.locale ?? "en",
|
||||
prisma: this.dbRead.prisma as unknown as PrismaClient,
|
||||
isUserOrganizationAdmin,
|
||||
isTrpcCall: true,
|
||||
@@ -136,8 +138,6 @@ export class EventTypesAtomService {
|
||||
input: { ...body, id: eventTypeId, bookingFields },
|
||||
ctx: {
|
||||
user: eventTypeUser,
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
prisma: this.dbWrite.prisma,
|
||||
},
|
||||
});
|
||||
@@ -166,8 +166,6 @@ export class EventTypesAtomService {
|
||||
input: { ...body, id: eventTypeId, bookingFields },
|
||||
ctx: {
|
||||
user: eventTypeUser,
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
prisma: this.dbWrite.prisma,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user