feat: create new markNoShow endpoint (#15738)
* feat: create new markNoShow endpoint * chore: add schema * chore: update name * chore: save progress * refactor: improve code and types * fix: unit test * chore: improvements * chore: move query to booking repository * fix: type error
This commit is contained in:
1 parent
3ab735ba9c
commit
e075dcdeaa
13 files changed
+263
-115
No files matched your search
@@ -12,6 +12,7 @@ import { ZGetCalVideoRecordingsInputSchema } from "./getCalVideoRecordings.schem
|
||||
import { ZGetDownloadLinkOfCalVideoRecordingsInputSchema } from "./getDownloadLinkOfCalVideoRecordings.schema";
|
||||
import { ZIntegrationsInputSchema } from "./integrations.schema";
|
||||
import { ZLocationOptionsInputSchema } from "./locationOptions.schema";
|
||||
import { ZNoShowInputSchema } from "./markNoShow.schema";
|
||||
import { ZOutOfOfficeInputSchema, ZOutOfOfficeDelete } from "./outOfOffice.schema";
|
||||
import { me } from "./procedures/me";
|
||||
import { teamsAndUserProfilesQuery } from "./procedures/teamsAndUserProfilesQuery";
|
||||
@@ -58,6 +59,7 @@ type AppsRouterHandlerCache = {
|
||||
addSecondaryEmail?: typeof import("./addSecondaryEmail.handler").addSecondaryEmailHandler;
|
||||
getTravelSchedules?: typeof import("./getTravelSchedules.handler").getTravelSchedulesHandler;
|
||||
outOfOfficeReasonList?: typeof import("./outOfOfficeReasons.handler").outOfOfficeReasonList;
|
||||
markNoShow?: typeof import("./markNoShow.handler").markNoShow;
|
||||
};
|
||||
|
||||
const UNSTABLE_HANDLER_CACHE: AppsRouterHandlerCache = {};
|
||||
@@ -497,4 +499,16 @@ export const loggedInViewerRouter = router({
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.outOfOfficeReasonList();
|
||||
}),
|
||||
markNoShow: authedProcedure.input(ZNoShowInputSchema).mutation(async (opts) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.markNoShow) {
|
||||
UNSTABLE_HANDLER_CACHE.markNoShow = (await import("./markNoShow.handler")).markNoShow;
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.markNoShow) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.markNoShow(opts);
|
||||
}),
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import handleMarkNoShow from "@calcom/features/handleMarkNoShow";
|
||||
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";
|
||||
|
||||
import type { TNoShowInputSchema } from "./markNoShow.schema";
|
||||
|
||||
type NoShowOptions = {
|
||||
input: TNoShowInputSchema;
|
||||
ctx: {
|
||||
user: NonNullable<TrpcSessionUser>;
|
||||
};
|
||||
};
|
||||
|
||||
export const markNoShow = async ({ ctx, input }: NoShowOptions) => {
|
||||
const { bookingUid, attendees, noShowHost } = input;
|
||||
|
||||
return handleMarkNoShow({
|
||||
bookingUid,
|
||||
attendees,
|
||||
noShowHost,
|
||||
userId: ctx.user.id,
|
||||
locale: ctx.user.locale,
|
||||
});
|
||||
};
|
||||
File renamed without changes.
@@ -3,7 +3,7 @@ import { importHandler, router } from "../../trpc";
|
||||
import { slotsRouter } from "../viewer/slots/_router";
|
||||
import { ZUserEmailVerificationRequiredSchema } from "./checkIfUserEmailVerificationRequired.schema";
|
||||
import { i18nInputSchema } from "./i18n.schema";
|
||||
import { ZNoShowInputSchema } from "./noShow.schema";
|
||||
import { ZMarkHostAsNoShowInputSchema } from "./markHostAsNoShow.schema";
|
||||
import { event } from "./procedures/event";
|
||||
import { session } from "./procedures/session";
|
||||
import { ZSamlTenantProductInputSchema } from "./samlTenantProduct.schema";
|
||||
@@ -29,8 +29,11 @@ export const publicViewerRouter = router({
|
||||
const handler = await importHandler(namespaced("submitRating"), () => import("./submitRating.handler"));
|
||||
return handler(opts);
|
||||
}),
|
||||
noShow: publicProcedure.input(ZNoShowInputSchema).mutation(async (opts) => {
|
||||
const handler = await importHandler(namespaced("noShow"), () => import("./noShow.handler"));
|
||||
markHostAsNoShow: publicProcedure.input(ZMarkHostAsNoShowInputSchema).mutation(async (opts) => {
|
||||
const handler = await importHandler(
|
||||
namespaced("markHostAsNoShow"),
|
||||
() => import("./markHostAsNoShow.handler")
|
||||
);
|
||||
return handler(opts);
|
||||
}),
|
||||
samlTenantProduct: publicProcedure.input(ZSamlTenantProductInputSchema).mutation(async (opts) => {
|
||||
|
||||
+3
-3
@@ -1,15 +1,15 @@
|
||||
import handleMarkNoShow from "@calcom/features/handleMarkNoShow";
|
||||
|
||||
import type { TNoShowInputSchema } from "./noShow.schema";
|
||||
import type { TNoShowInputSchema } from "./markHostAsNoShow.schema";
|
||||
|
||||
type NoShowOptions = {
|
||||
input: TNoShowInputSchema;
|
||||
};
|
||||
|
||||
export const noShowHandler = async ({ input }: NoShowOptions) => {
|
||||
const { bookingUid, attendees, noShowHost } = input;
|
||||
const { bookingUid, noShowHost } = input;
|
||||
|
||||
return handleMarkNoShow({ bookingUid, attendees, noShowHost });
|
||||
return handleMarkNoShow({ bookingUid, noShowHost });
|
||||
};
|
||||
|
||||
export default noShowHandler;
|
||||
@@ -0,0 +1,8 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const ZMarkHostAsNoShowInputSchema = z.object({
|
||||
bookingUid: z.string(),
|
||||
noShowHost: z.boolean(),
|
||||
});
|
||||
|
||||
export type TNoShowInputSchema = z.infer<typeof ZMarkHostAsNoShowInputSchema>;
|
||||
Reference in new issue
Block a user