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:
1 parent
8904f20eb8
commit
a15cad4d03
20 files changed
+1
-97
No files matched your search
@@ -82,7 +82,6 @@ export const schemaUserBaseBodyParams = User.pick({
|
|||||||
brandColor: true,
|
brandColor: true,
|
||||||
darkBrandColor: true,
|
darkBrandColor: true,
|
||||||
allowDynamicBooking: true,
|
allowDynamicBooking: true,
|
||||||
away: true,
|
|
||||||
role: true,
|
role: true,
|
||||||
// @note: disallowing avatar changes via API for now. We can add it later if needed. User should upload image via UI.
|
// @note: disallowing avatar changes via API for now. We can add it later if needed. User should upload image via UI.
|
||||||
// avatar: true,
|
// avatar: true,
|
||||||
@@ -171,7 +170,6 @@ export const schemaUserReadPublic = User.pick({
|
|||||||
brandColor: true,
|
brandColor: true,
|
||||||
darkBrandColor: true,
|
darkBrandColor: true,
|
||||||
allowDynamicBooking: true,
|
allowDynamicBooking: true,
|
||||||
away: true,
|
|
||||||
createdDate: true,
|
createdDate: true,
|
||||||
verified: true,
|
verified: true,
|
||||||
invitedTo: true,
|
invitedTo: true,
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let name: string;
|
let name: string;
|
||||||
let isAway = false;
|
|
||||||
let hideBranding = false;
|
let hideBranding = false;
|
||||||
|
|
||||||
const notFound = {
|
const notFound = {
|
||||||
@@ -96,7 +95,6 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
name = username;
|
name = username;
|
||||||
isAway = user.away;
|
|
||||||
hideBranding = user.hideBranding;
|
hideBranding = user.hideBranding;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +127,6 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
|
|||||||
eventData.length
|
eventData.length
|
||||||
),
|
),
|
||||||
booking,
|
booking,
|
||||||
away: isAway,
|
|
||||||
user: name,
|
user: name,
|
||||||
slug,
|
slug,
|
||||||
trpcState: ssr.dehydrate(),
|
trpcState: ssr.dehydrate(),
|
||||||
|
|||||||
@@ -89,7 +89,6 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
|||||||
metadata: eventData.metadata,
|
metadata: eventData.metadata,
|
||||||
},
|
},
|
||||||
booking,
|
booking,
|
||||||
away: false,
|
|
||||||
user: teamSlug,
|
user: teamSlug,
|
||||||
teamId: team.id,
|
teamId: team.id,
|
||||||
slug: meetingSlug,
|
slug: meetingSlug,
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export type UserPageProps = {
|
|||||||
allowSEOIndexing: boolean;
|
allowSEOIndexing: boolean;
|
||||||
username: string | null;
|
username: string | null;
|
||||||
};
|
};
|
||||||
users: (Pick<User, "away" | "name" | "username" | "bio" | "verified" | "avatarUrl"> & {
|
users: (Pick<User, "name" | "username" | "bio" | "verified" | "avatarUrl"> & {
|
||||||
profile: UserProfile;
|
profile: UserProfile;
|
||||||
})[];
|
})[];
|
||||||
themeBasis: string | null;
|
themeBasis: string | null;
|
||||||
@@ -177,7 +177,6 @@ export const getServerSideProps: GetServerSideProps<UserPageProps> = async (cont
|
|||||||
avatarUrl: user.avatarUrl,
|
avatarUrl: user.avatarUrl,
|
||||||
verified: user.verified,
|
verified: user.verified,
|
||||||
profile: user.profile,
|
profile: user.profile,
|
||||||
away: user.away,
|
|
||||||
})),
|
})),
|
||||||
entity: {
|
entity: {
|
||||||
...(org?.logoUrl ? { logoUrl: org?.logoUrl } : {}),
|
...(org?.logoUrl ? { logoUrl: org?.logoUrl } : {}),
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ async function getDynamicGroupPageProps(context: GetServerSidePropsContext) {
|
|||||||
booking,
|
booking,
|
||||||
user: usernames.join("+"),
|
user: usernames.join("+"),
|
||||||
slug,
|
slug,
|
||||||
away: false,
|
|
||||||
trpcState: ssr.dehydrate(),
|
trpcState: ssr.dehydrate(),
|
||||||
isBrandingHidden: false,
|
isBrandingHidden: false,
|
||||||
isSEOIndexable: true,
|
isSEOIndexable: true,
|
||||||
@@ -165,7 +164,6 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
|
|||||||
},
|
},
|
||||||
user: username,
|
user: username,
|
||||||
slug,
|
slug,
|
||||||
away: false,
|
|
||||||
trpcState: ssr.dehydrate(),
|
trpcState: ssr.dehydrate(),
|
||||||
isBrandingHidden: user?.hideBranding,
|
isBrandingHidden: user?.hideBranding,
|
||||||
isSEOIndexable: user?.allowSEOIndexing,
|
isSEOIndexable: user?.allowSEOIndexing,
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ export default function Type({
|
|||||||
user,
|
user,
|
||||||
isEmbed,
|
isEmbed,
|
||||||
booking,
|
booking,
|
||||||
away,
|
|
||||||
isBrandingHidden,
|
isBrandingHidden,
|
||||||
isSEOIndexable,
|
isSEOIndexable,
|
||||||
rescheduleUid,
|
rescheduleUid,
|
||||||
@@ -47,7 +46,6 @@ export default function Type({
|
|||||||
username={user}
|
username={user}
|
||||||
eventSlug={slug}
|
eventSlug={slug}
|
||||||
bookingData={booking}
|
bookingData={booking}
|
||||||
isAway={away}
|
|
||||||
hideBranding={isBrandingHidden}
|
hideBranding={isBrandingHidden}
|
||||||
entity={eventData.entity}
|
entity={eventData.entity}
|
||||||
durationConfig={eventData.metadata?.multipleDuration}
|
durationConfig={eventData.metadata?.multipleDuration}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ export default function Type({
|
|||||||
isEmbed,
|
isEmbed,
|
||||||
user,
|
user,
|
||||||
booking,
|
booking,
|
||||||
away,
|
|
||||||
isBrandingHidden,
|
isBrandingHidden,
|
||||||
isTeamEvent,
|
isTeamEvent,
|
||||||
entity,
|
entity,
|
||||||
@@ -33,7 +32,6 @@ export default function Type({
|
|||||||
username={user}
|
username={user}
|
||||||
eventSlug={slug}
|
eventSlug={slug}
|
||||||
bookingData={booking}
|
bookingData={booking}
|
||||||
isAway={away}
|
|
||||||
hideBranding={isBrandingHidden}
|
hideBranding={isBrandingHidden}
|
||||||
isTeamEvent={isTeamEvent}
|
isTeamEvent={isTeamEvent}
|
||||||
entity={entity}
|
entity={entity}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ export default function Type({
|
|||||||
slug,
|
slug,
|
||||||
user,
|
user,
|
||||||
booking,
|
booking,
|
||||||
away,
|
|
||||||
isEmbed,
|
isEmbed,
|
||||||
isBrandingHidden,
|
isBrandingHidden,
|
||||||
entity,
|
entity,
|
||||||
@@ -42,7 +41,6 @@ export default function Type({
|
|||||||
username={user}
|
username={user}
|
||||||
eventSlug={slug}
|
eventSlug={slug}
|
||||||
bookingData={booking}
|
bookingData={booking}
|
||||||
isAway={away}
|
|
||||||
hideBranding={isBrandingHidden}
|
hideBranding={isBrandingHidden}
|
||||||
isTeamEvent
|
isTeamEvent
|
||||||
isInstantMeeting
|
isInstantMeeting
|
||||||
@@ -110,7 +108,6 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
|||||||
eventData.length
|
eventData.length
|
||||||
),
|
),
|
||||||
booking: null,
|
booking: null,
|
||||||
away: false,
|
|
||||||
user: teamSlug,
|
user: teamSlug,
|
||||||
teamId: team.id,
|
teamId: team.id,
|
||||||
slug: meetingSlug,
|
slug: meetingSlug,
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ export default function Type({
|
|||||||
slug,
|
slug,
|
||||||
user,
|
user,
|
||||||
booking,
|
booking,
|
||||||
away,
|
|
||||||
isEmbed,
|
isEmbed,
|
||||||
isBrandingHidden,
|
isBrandingHidden,
|
||||||
eventData,
|
eventData,
|
||||||
@@ -54,7 +53,6 @@ export default function Type({
|
|||||||
username={user}
|
username={user}
|
||||||
eventSlug={slug}
|
eventSlug={slug}
|
||||||
bookingData={booking}
|
bookingData={booking}
|
||||||
isAway={away}
|
|
||||||
isInstantMeeting={isInstantMeeting}
|
isInstantMeeting={isInstantMeeting}
|
||||||
hideBranding={isBrandingHidden}
|
hideBranding={isBrandingHidden}
|
||||||
isTeamEvent
|
isTeamEvent
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ export const getSampleUserInSession = function () {
|
|||||||
identityProvider: IdentityProvider.CAL,
|
identityProvider: IdentityProvider.CAL,
|
||||||
brandColor: "#292929",
|
brandColor: "#292929",
|
||||||
darkBrandColor: "#fafafa",
|
darkBrandColor: "#fafafa",
|
||||||
away: false,
|
|
||||||
metadata: null,
|
metadata: null,
|
||||||
role: UserPermissionRole.USER,
|
role: UserPermissionRole.USER,
|
||||||
disableImpersonation: false,
|
disableImpersonation: false,
|
||||||
|
|||||||
@@ -51,11 +51,6 @@ export interface BookerProps {
|
|||||||
selectedDate?: Date;
|
selectedDate?: Date;
|
||||||
|
|
||||||
hideBranding?: boolean;
|
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,
|
* If false and the current username indicates a dynamic booking,
|
||||||
* the Booker will immediately show an error.
|
* the Booker will immediately show an error.
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ const userBodySchema = User.pick({
|
|||||||
// darkBrandColor: true,
|
// darkBrandColor: true,
|
||||||
allowDynamicBooking: true,
|
allowDynamicBooking: true,
|
||||||
identityProvider: true,
|
identityProvider: true,
|
||||||
// away: true,
|
|
||||||
role: true,
|
role: true,
|
||||||
avatarUrl: true,
|
avatarUrl: true,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -397,29 +397,7 @@ function UserDropdown({ small }: UserDropdownProps) {
|
|||||||
screenResolution: `${screen.width}x${screen.height}`,
|
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 [helpOpen, setHelpOpen] = useState(false);
|
||||||
const [menuOpen, setMenuOpen] = useState(false);
|
const [menuOpen, setMenuOpen] = useState(false);
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ const userSelect = Prisma.validator<Prisma.UserSelect>()({
|
|||||||
invitedTo: true,
|
invitedTo: true,
|
||||||
brandColor: true,
|
brandColor: true,
|
||||||
darkBrandColor: true,
|
darkBrandColor: true,
|
||||||
away: true,
|
|
||||||
allowDynamicBooking: true,
|
allowDynamicBooking: true,
|
||||||
allowSEOIndexing: true,
|
allowSEOIndexing: true,
|
||||||
receiveMonthlyDigestEmail: true,
|
receiveMonthlyDigestEmail: true,
|
||||||
|
|||||||
@@ -207,7 +207,6 @@ type UserPayload = Prisma.UserGetPayload<{
|
|||||||
selectedCalendars: true;
|
selectedCalendars: true;
|
||||||
schedules: true;
|
schedules: true;
|
||||||
avatarUrl: true;
|
avatarUrl: true;
|
||||||
away: true;
|
|
||||||
backupCodes: true;
|
backupCodes: true;
|
||||||
bio: true;
|
bio: true;
|
||||||
brandColor: true;
|
brandColor: true;
|
||||||
@@ -255,7 +254,6 @@ export const buildUser = <T extends Partial<UserPayload>>(
|
|||||||
allowDynamicBooking: true,
|
allowDynamicBooking: true,
|
||||||
availability: [],
|
availability: [],
|
||||||
avatarUrl: "",
|
avatarUrl: "",
|
||||||
away: false,
|
|
||||||
backupCodes: null,
|
backupCodes: null,
|
||||||
bio: null,
|
bio: null,
|
||||||
brandColor: "#292929",
|
brandColor: "#292929",
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ export async function getUserFromSession(ctx: TRPCContextInner, session: Maybe<S
|
|||||||
identityProviderId: true,
|
identityProviderId: true,
|
||||||
brandColor: true,
|
brandColor: true,
|
||||||
darkBrandColor: true,
|
darkBrandColor: true,
|
||||||
away: true,
|
|
||||||
movedToProfileId: true,
|
movedToProfileId: true,
|
||||||
selectedCalendars: {
|
selectedCalendars: {
|
||||||
select: {
|
select: {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { router } from "../../trpc";
|
|||||||
import { ZAddSecondaryEmailInputSchema } from "./addSecondaryEmail.schema";
|
import { ZAddSecondaryEmailInputSchema } from "./addSecondaryEmail.schema";
|
||||||
import { ZAppByIdInputSchema } from "./appById.schema";
|
import { ZAppByIdInputSchema } from "./appById.schema";
|
||||||
import { ZAppCredentialsByTypeInputSchema } from "./appCredentialsByType.schema";
|
import { ZAppCredentialsByTypeInputSchema } from "./appCredentialsByType.schema";
|
||||||
import { ZAwayInputSchema } from "./away.schema";
|
|
||||||
import { ZConnectAndJoinInputSchema } from "./connectAndJoin.schema";
|
import { ZConnectAndJoinInputSchema } from "./connectAndJoin.schema";
|
||||||
import { ZConnectedCalendarsInputSchema } from "./connectedCalendars.schema";
|
import { ZConnectedCalendarsInputSchema } from "./connectedCalendars.schema";
|
||||||
import { ZDeleteCredentialInputSchema } from "./deleteCredential.schema";
|
import { ZDeleteCredentialInputSchema } from "./deleteCredential.schema";
|
||||||
@@ -28,7 +27,6 @@ type AppsRouterHandlerCache = {
|
|||||||
shouldVerifyEmail?: typeof import("./shouldVerifyEmail.handler").shouldVerifyEmailHandler;
|
shouldVerifyEmail?: typeof import("./shouldVerifyEmail.handler").shouldVerifyEmailHandler;
|
||||||
deleteMe?: typeof import("./deleteMe.handler").deleteMeHandler;
|
deleteMe?: typeof import("./deleteMe.handler").deleteMeHandler;
|
||||||
deleteMeWithoutPassword?: typeof import("./deleteMeWithoutPassword.handler").deleteMeWithoutPasswordHandler;
|
deleteMeWithoutPassword?: typeof import("./deleteMeWithoutPassword.handler").deleteMeWithoutPasswordHandler;
|
||||||
away?: typeof import("./away.handler").awayHandler;
|
|
||||||
connectedCalendars?: typeof import("./connectedCalendars.handler").connectedCalendarsHandler;
|
connectedCalendars?: typeof import("./connectedCalendars.handler").connectedCalendarsHandler;
|
||||||
setDestinationCalendar?: typeof import("./setDestinationCalendar.handler").setDestinationCalendarHandler;
|
setDestinationCalendar?: typeof import("./setDestinationCalendar.handler").setDestinationCalendarHandler;
|
||||||
integrations?: typeof import("./integrations.handler").integrationsHandler;
|
integrations?: typeof import("./integrations.handler").integrationsHandler;
|
||||||
@@ -91,19 +89,6 @@ export const loggedInViewerRouter = router({
|
|||||||
return UNSTABLE_HANDLER_CACHE.deleteMeWithoutPassword({ ctx });
|
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 }) => {
|
connectedCalendars: authedProcedure.input(ZConnectedCalendarsInputSchema).query(async ({ ctx, input }) => {
|
||||||
if (!UNSTABLE_HANDLER_CACHE.connectedCalendars) {
|
if (!UNSTABLE_HANDLER_CACHE.connectedCalendars) {
|
||||||
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,
|
identityProviderEmail,
|
||||||
brandColor: user.brandColor,
|
brandColor: user.brandColor,
|
||||||
darkBrandColor: user.darkBrandColor,
|
darkBrandColor: user.darkBrandColor,
|
||||||
away: user.away,
|
|
||||||
bio: user.bio,
|
bio: user.bio,
|
||||||
weekStart: user.weekStart,
|
weekStart: user.weekStart,
|
||||||
theme: user.theme,
|
theme: user.theme,
|
||||||
|
|||||||
Reference in new issue
Block a user