chore: Removing away (DB related, not slot related) from code (#14673)
* chore: Removing away (DB related, not slot related) from code * Remove more isAway/away, eg. references
This commit is contained in:
@@ -82,7 +82,6 @@ export const schemaUserBaseBodyParams = User.pick({
|
||||
brandColor: true,
|
||||
darkBrandColor: true,
|
||||
allowDynamicBooking: true,
|
||||
away: true,
|
||||
role: true,
|
||||
// @note: disallowing avatar changes via API for now. We can add it later if needed. User should upload image via UI.
|
||||
// avatar: true,
|
||||
@@ -171,7 +170,6 @@ export const schemaUserReadPublic = User.pick({
|
||||
brandColor: true,
|
||||
darkBrandColor: true,
|
||||
allowDynamicBooking: true,
|
||||
away: true,
|
||||
createdDate: true,
|
||||
verified: true,
|
||||
invitedTo: true,
|
||||
|
||||
@@ -52,7 +52,6 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
|
||||
});
|
||||
|
||||
let name: string;
|
||||
let isAway = false;
|
||||
let hideBranding = false;
|
||||
|
||||
const notFound = {
|
||||
@@ -96,7 +95,6 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
|
||||
}
|
||||
|
||||
name = username;
|
||||
isAway = user.away;
|
||||
hideBranding = user.hideBranding;
|
||||
}
|
||||
|
||||
@@ -129,7 +127,6 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
|
||||
eventData.length
|
||||
),
|
||||
booking,
|
||||
away: isAway,
|
||||
user: name,
|
||||
slug,
|
||||
trpcState: ssr.dehydrate(),
|
||||
|
||||
@@ -89,7 +89,6 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
||||
metadata: eventData.metadata,
|
||||
},
|
||||
booking,
|
||||
away: false,
|
||||
user: teamSlug,
|
||||
teamId: team.id,
|
||||
slug: meetingSlug,
|
||||
|
||||
@@ -39,7 +39,7 @@ export type UserPageProps = {
|
||||
allowSEOIndexing: boolean;
|
||||
username: string | null;
|
||||
};
|
||||
users: (Pick<User, "away" | "name" | "username" | "bio" | "verified" | "avatarUrl"> & {
|
||||
users: (Pick<User, "name" | "username" | "bio" | "verified" | "avatarUrl"> & {
|
||||
profile: UserProfile;
|
||||
})[];
|
||||
themeBasis: string | null;
|
||||
@@ -177,7 +177,6 @@ export const getServerSideProps: GetServerSideProps<UserPageProps> = async (cont
|
||||
avatarUrl: user.avatarUrl,
|
||||
verified: user.verified,
|
||||
profile: user.profile,
|
||||
away: user.away,
|
||||
})),
|
||||
entity: {
|
||||
...(org?.logoUrl ? { logoUrl: org?.logoUrl } : {}),
|
||||
|
||||
@@ -86,7 +86,6 @@ async function getDynamicGroupPageProps(context: GetServerSidePropsContext) {
|
||||
booking,
|
||||
user: usernames.join("+"),
|
||||
slug,
|
||||
away: false,
|
||||
trpcState: ssr.dehydrate(),
|
||||
isBrandingHidden: false,
|
||||
isSEOIndexable: true,
|
||||
@@ -165,7 +164,6 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
|
||||
},
|
||||
user: username,
|
||||
slug,
|
||||
away: false,
|
||||
trpcState: ssr.dehydrate(),
|
||||
isBrandingHidden: user?.hideBranding,
|
||||
isSEOIndexable: user?.allowSEOIndexing,
|
||||
|
||||
@@ -23,7 +23,6 @@ export default function Type({
|
||||
user,
|
||||
isEmbed,
|
||||
booking,
|
||||
away,
|
||||
isBrandingHidden,
|
||||
isSEOIndexable,
|
||||
rescheduleUid,
|
||||
@@ -47,7 +46,6 @@ export default function Type({
|
||||
username={user}
|
||||
eventSlug={slug}
|
||||
bookingData={booking}
|
||||
isAway={away}
|
||||
hideBranding={isBrandingHidden}
|
||||
entity={eventData.entity}
|
||||
durationConfig={eventData.metadata?.multipleDuration}
|
||||
|
||||
@@ -13,7 +13,6 @@ export default function Type({
|
||||
isEmbed,
|
||||
user,
|
||||
booking,
|
||||
away,
|
||||
isBrandingHidden,
|
||||
isTeamEvent,
|
||||
entity,
|
||||
@@ -33,7 +32,6 @@ export default function Type({
|
||||
username={user}
|
||||
eventSlug={slug}
|
||||
bookingData={booking}
|
||||
isAway={away}
|
||||
hideBranding={isBrandingHidden}
|
||||
isTeamEvent={isTeamEvent}
|
||||
entity={entity}
|
||||
|
||||
@@ -21,7 +21,6 @@ export default function Type({
|
||||
slug,
|
||||
user,
|
||||
booking,
|
||||
away,
|
||||
isEmbed,
|
||||
isBrandingHidden,
|
||||
entity,
|
||||
@@ -42,7 +41,6 @@ export default function Type({
|
||||
username={user}
|
||||
eventSlug={slug}
|
||||
bookingData={booking}
|
||||
isAway={away}
|
||||
hideBranding={isBrandingHidden}
|
||||
isTeamEvent
|
||||
isInstantMeeting
|
||||
@@ -110,7 +108,6 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
||||
eventData.length
|
||||
),
|
||||
booking: null,
|
||||
away: false,
|
||||
user: teamSlug,
|
||||
teamId: team.id,
|
||||
slug: meetingSlug,
|
||||
|
||||
@@ -30,7 +30,6 @@ export default function Type({
|
||||
slug,
|
||||
user,
|
||||
booking,
|
||||
away,
|
||||
isEmbed,
|
||||
isBrandingHidden,
|
||||
eventData,
|
||||
@@ -54,7 +53,6 @@ export default function Type({
|
||||
username={user}
|
||||
eventSlug={slug}
|
||||
bookingData={booking}
|
||||
isAway={away}
|
||||
isInstantMeeting={isInstantMeeting}
|
||||
hideBranding={isBrandingHidden}
|
||||
isTeamEvent
|
||||
|
||||
@@ -31,7 +31,6 @@ export const getSampleUserInSession = function () {
|
||||
identityProvider: IdentityProvider.CAL,
|
||||
brandColor: "#292929",
|
||||
darkBrandColor: "#fafafa",
|
||||
away: false,
|
||||
metadata: null,
|
||||
role: UserPermissionRole.USER,
|
||||
disableImpersonation: false,
|
||||
|
||||
@@ -51,11 +51,6 @@ export interface BookerProps {
|
||||
selectedDate?: Date;
|
||||
|
||||
hideBranding?: boolean;
|
||||
/**
|
||||
* Sets the Booker component to the away state.
|
||||
* This is NOT revalidated by calling the API.
|
||||
*/
|
||||
isAway?: boolean;
|
||||
/**
|
||||
* If false and the current username indicates a dynamic booking,
|
||||
* the Booker will immediately show an error.
|
||||
|
||||
@@ -28,7 +28,6 @@ const userBodySchema = User.pick({
|
||||
// darkBrandColor: true,
|
||||
allowDynamicBooking: true,
|
||||
identityProvider: true,
|
||||
// away: true,
|
||||
role: true,
|
||||
avatarUrl: true,
|
||||
});
|
||||
|
||||
@@ -397,29 +397,7 @@ function UserDropdown({ small }: UserDropdownProps) {
|
||||
screenResolution: `${screen.width}x${screen.height}`,
|
||||
});
|
||||
});
|
||||
const mutation = trpc.viewer.away.useMutation({
|
||||
onMutate: async ({ away }) => {
|
||||
await utils.viewer.me.cancel();
|
||||
|
||||
const previousValue = utils.viewer.me.getData();
|
||||
|
||||
if (previousValue) {
|
||||
utils.viewer.me.setData(undefined, { ...previousValue, away });
|
||||
}
|
||||
|
||||
return { previousValue };
|
||||
},
|
||||
onError: (_, __, context) => {
|
||||
if (context?.previousValue) {
|
||||
utils.viewer.me.setData(undefined, context.previousValue);
|
||||
}
|
||||
|
||||
showToast(t("toggle_away_error"), "error");
|
||||
},
|
||||
onSettled() {
|
||||
utils.viewer.me.invalidate();
|
||||
},
|
||||
});
|
||||
const [helpOpen, setHelpOpen] = useState(false);
|
||||
const [menuOpen, setMenuOpen] = useState(false);
|
||||
|
||||
|
||||
@@ -50,7 +50,6 @@ const userSelect = Prisma.validator<Prisma.UserSelect>()({
|
||||
invitedTo: true,
|
||||
brandColor: true,
|
||||
darkBrandColor: true,
|
||||
away: true,
|
||||
allowDynamicBooking: true,
|
||||
allowSEOIndexing: true,
|
||||
receiveMonthlyDigestEmail: true,
|
||||
|
||||
@@ -207,7 +207,6 @@ type UserPayload = Prisma.UserGetPayload<{
|
||||
selectedCalendars: true;
|
||||
schedules: true;
|
||||
avatarUrl: true;
|
||||
away: true;
|
||||
backupCodes: true;
|
||||
bio: true;
|
||||
brandColor: true;
|
||||
@@ -255,7 +254,6 @@ export const buildUser = <T extends Partial<UserPayload>>(
|
||||
allowDynamicBooking: true,
|
||||
availability: [],
|
||||
avatarUrl: "",
|
||||
away: false,
|
||||
backupCodes: null,
|
||||
bio: null,
|
||||
brandColor: "#292929",
|
||||
|
||||
@@ -54,7 +54,6 @@ export async function getUserFromSession(ctx: TRPCContextInner, session: Maybe<S
|
||||
identityProviderId: true,
|
||||
brandColor: true,
|
||||
darkBrandColor: true,
|
||||
away: true,
|
||||
movedToProfileId: true,
|
||||
selectedCalendars: {
|
||||
select: {
|
||||
|
||||
@@ -3,7 +3,6 @@ import { router } from "../../trpc";
|
||||
import { ZAddSecondaryEmailInputSchema } from "./addSecondaryEmail.schema";
|
||||
import { ZAppByIdInputSchema } from "./appById.schema";
|
||||
import { ZAppCredentialsByTypeInputSchema } from "./appCredentialsByType.schema";
|
||||
import { ZAwayInputSchema } from "./away.schema";
|
||||
import { ZConnectAndJoinInputSchema } from "./connectAndJoin.schema";
|
||||
import { ZConnectedCalendarsInputSchema } from "./connectedCalendars.schema";
|
||||
import { ZDeleteCredentialInputSchema } from "./deleteCredential.schema";
|
||||
@@ -28,7 +27,6 @@ type AppsRouterHandlerCache = {
|
||||
shouldVerifyEmail?: typeof import("./shouldVerifyEmail.handler").shouldVerifyEmailHandler;
|
||||
deleteMe?: typeof import("./deleteMe.handler").deleteMeHandler;
|
||||
deleteMeWithoutPassword?: typeof import("./deleteMeWithoutPassword.handler").deleteMeWithoutPasswordHandler;
|
||||
away?: typeof import("./away.handler").awayHandler;
|
||||
connectedCalendars?: typeof import("./connectedCalendars.handler").connectedCalendarsHandler;
|
||||
setDestinationCalendar?: typeof import("./setDestinationCalendar.handler").setDestinationCalendarHandler;
|
||||
integrations?: typeof import("./integrations.handler").integrationsHandler;
|
||||
@@ -91,19 +89,6 @@ export const loggedInViewerRouter = router({
|
||||
return UNSTABLE_HANDLER_CACHE.deleteMeWithoutPassword({ ctx });
|
||||
}),
|
||||
|
||||
away: authedProcedure.input(ZAwayInputSchema).mutation(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.away) {
|
||||
UNSTABLE_HANDLER_CACHE.away = (await import("./away.handler")).awayHandler;
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.away) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.away({ ctx, input });
|
||||
}),
|
||||
|
||||
connectedCalendars: authedProcedure.input(ZConnectedCalendarsInputSchema).query(async ({ ctx, input }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.connectedCalendars) {
|
||||
UNSTABLE_HANDLER_CACHE.connectedCalendars = (
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
import { prisma } from "@calcom/prisma";
|
||||
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";
|
||||
|
||||
import type { TAwayInputSchema } from "./away.schema";
|
||||
|
||||
type AwayOptions = {
|
||||
ctx: {
|
||||
user: NonNullable<TrpcSessionUser>;
|
||||
};
|
||||
input: TAwayInputSchema;
|
||||
};
|
||||
|
||||
export const awayHandler = async ({ ctx, input }: AwayOptions) => {
|
||||
await prisma.user.update({
|
||||
where: {
|
||||
email: ctx.user.email,
|
||||
},
|
||||
data: {
|
||||
away: input.away,
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -1,7 +0,0 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const ZAwayInputSchema = z.object({
|
||||
away: z.boolean(),
|
||||
});
|
||||
|
||||
export type TAwayInputSchema = z.infer<typeof ZAwayInputSchema>;
|
||||
@@ -97,7 +97,6 @@ export const meHandler = async ({ ctx, input }: MeOptions) => {
|
||||
identityProviderEmail,
|
||||
brandColor: user.brandColor,
|
||||
darkBrandColor: user.darkBrandColor,
|
||||
away: user.away,
|
||||
bio: user.bio,
|
||||
weekStart: user.weekStart,
|
||||
theme: user.theme,
|
||||
|
||||
Reference in New Issue
Block a user