* feat(db): add new col: user appTheme * feat(event-types page): apply appTheme color * add appTheme for trpc * feat: mutate main page theme * feat: add english translation for app theme update section * modify keys in common (en) * add woring * Revert yarn.lock to its state before unintended changes * feat(i18n): add back the i18n string (for dark/light mode switching) * refactor: refactor ThemeLabel * fix: add new user field "appTheme" to test files * chore: modify TODO comment * chore: update common.json (en) for "theme" since we had appTheme now, I think it's better to update the wording here to avoid confusion * fix: update button's data-testid to fix e2e test error * chore: remove comment * fix: fix brand-color-not-apply bug * solve type error * fix: fix type error * fix: use correct storageKey for booker / dashboard * fix: tidy up * fix: skeleton --------- Co-authored-by: swh00tw <a6140000@gmail.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Keith Williams <keithwillcode@gmail.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Udit Takkar <udit222001@gmail.com>
71 lines
2.3 KiB
TypeScript
71 lines
2.3 KiB
TypeScript
import type { Session } from "next-auth";
|
|
|
|
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
|
|
import { ProfileRepository } from "@calcom/lib/server/repository/profile";
|
|
import { UserRepository } from "@calcom/lib/server/repository/user";
|
|
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";
|
|
|
|
type MeOptions = {
|
|
ctx: {
|
|
user: NonNullable<TrpcSessionUser>;
|
|
session: Session;
|
|
};
|
|
};
|
|
|
|
export const meHandler = async ({ ctx }: MeOptions) => {
|
|
const crypto = await import("crypto");
|
|
|
|
const { user: sessionUser, session } = ctx;
|
|
|
|
const allUserEnrichedProfiles = await ProfileRepository.findAllProfilesForUserIncludingMovedUser(
|
|
sessionUser
|
|
);
|
|
|
|
const user = await UserRepository.enrichUserWithTheProfile({
|
|
user: sessionUser,
|
|
upId: session.upId,
|
|
});
|
|
|
|
// Destructuring here only makes it more illegible
|
|
// pick only the part we want to expose in the API
|
|
return {
|
|
id: user.id,
|
|
name: user.name,
|
|
email: user.email,
|
|
emailMd5: crypto.createHash("md5").update(user.email).digest("hex"),
|
|
startTime: user.startTime,
|
|
endTime: user.endTime,
|
|
bufferTime: user.bufferTime,
|
|
locale: user.locale,
|
|
timeFormat: user.timeFormat,
|
|
timeZone: user.timeZone,
|
|
avatar: getUserAvatarUrl(user),
|
|
avatarUrl: user.avatarUrl,
|
|
createdDate: user.createdDate,
|
|
trialEndsAt: user.trialEndsAt,
|
|
defaultScheduleId: user.defaultScheduleId,
|
|
completedOnboarding: user.completedOnboarding,
|
|
twoFactorEnabled: user.twoFactorEnabled,
|
|
disableImpersonation: user.disableImpersonation,
|
|
identityProvider: user.identityProvider,
|
|
brandColor: user.brandColor,
|
|
darkBrandColor: user.darkBrandColor,
|
|
away: user.away,
|
|
bio: user.bio,
|
|
weekStart: user.weekStart,
|
|
theme: user.theme,
|
|
appTheme: user.appTheme,
|
|
hideBranding: user.hideBranding,
|
|
metadata: user.metadata,
|
|
defaultBookerLayouts: user.defaultBookerLayouts,
|
|
allowDynamicBooking: user.allowDynamicBooking,
|
|
allowSEOIndexing: user.allowSEOIndexing,
|
|
receiveMonthlyDigestEmail: user.receiveMonthlyDigestEmail,
|
|
organizationId: user.profile?.organizationId ?? null,
|
|
organization: user.organization,
|
|
username: user.profile?.username ?? user.username ?? null,
|
|
profile: user.profile ?? null,
|
|
profiles: allUserEnrichedProfiles,
|
|
};
|
|
};
|