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:
Alex van Andel authored and GitHub committed 2024-04-20 02:23:34 +01:00
1 parent 8904f20eb8
commit a15cad4d03
20 files changed
+1 -97

No files matched your search

@@ -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,
});
-22
View File
@@ -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);
-1
View File
@@ -50,7 +50,6 @@ const userSelect = Prisma.validator<Prisma.UserSelect>()({
invitedTo: true,
brandColor: true,
darkBrandColor: true,
away: true,
allowDynamicBooking: true,
allowSEOIndexing: true,
receiveMonthlyDigestEmail: true,
-2
View File
@@ -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,