fix: Autodetection of time zone only updated default time zone (#15392)
* fix: Autodetection of time zone only updated default time zone * fix: description text --------- Co-authored-by: sean-brydon <[email protected]>
This commit is contained in:
1 parent
c458b297ae
commit
285d1ec4c9
8 files changed
+148
-139
No files matched your search
@@ -24,7 +24,6 @@ import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";
|
||||
|
||||
import { TRPCError } from "@trpc/server";
|
||||
|
||||
import { getDefaultScheduleId } from "../viewer/availability/util";
|
||||
import { updateUserMetadataAllowedKeys, type TUpdateProfileInputSchema } from "./updateProfile.schema";
|
||||
|
||||
const log = logger.getSubLogger({ prefix: ["updateProfile"] });
|
||||
@@ -42,7 +41,7 @@ export const updateProfileHandler = async ({ ctx, input }: UpdateProfileOptions)
|
||||
const locale = input.locale || user.locale;
|
||||
const emailVerification = await getFeatureFlag(prisma, "email-verification");
|
||||
|
||||
const { travelSchedules, ...rest } = input;
|
||||
const { travelSchedules, availabilityIds, ...rest } = input;
|
||||
|
||||
const secondaryEmails = input?.secondaryEmails || [];
|
||||
delete input.secondaryEmails;
|
||||
@@ -257,24 +256,11 @@ export const updateProfileHandler = async ({ ctx, input }: UpdateProfileOptions)
|
||||
}
|
||||
|
||||
if (user.timeZone !== data.timeZone && updatedUser.schedules.length > 0) {
|
||||
// on timezone change update timezone of default schedule
|
||||
const defaultScheduleId = await getDefaultScheduleId(user.id, prisma);
|
||||
|
||||
if (!user.defaultScheduleId) {
|
||||
// set default schedule if not already set
|
||||
await prisma.user.update({
|
||||
where: {
|
||||
id: user.id,
|
||||
},
|
||||
data: {
|
||||
defaultScheduleId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
await prisma.schedule.updateMany({
|
||||
where: {
|
||||
id: defaultScheduleId,
|
||||
id: {
|
||||
in: input.availabilityIds,
|
||||
},
|
||||
},
|
||||
data: {
|
||||
timeZone: data.timeZone,
|
||||
|
||||
@@ -15,6 +15,7 @@ export const ZUpdateProfileInputSchema = z.object({
|
||||
bio: z.string().optional(),
|
||||
avatarUrl: z.string().nullable().optional(),
|
||||
timeZone: z.string().optional(),
|
||||
availabilityIds: z.array(z.number()).optional(),
|
||||
weekStart: z.string().optional(),
|
||||
hideBranding: z.boolean().optional(),
|
||||
allowDynamicBooking: z.boolean().optional(),
|
||||
|
||||
Reference in new issue
Block a user