feat: troubleshooter with weekly view (V2) (#12280)
* Inital UI + layout setup * use booker approach of grid * event-select - sidebar + store work * adds get schedule by event-type-slug * Calendar toggle * Load schedule from event slug * Add busy events to calendar * useschedule * Store more event info than just slug * Add date override to calendar * Changes sizes on smaller screens * add event title as a tooltip * Ensure header navigation works * Stop navigator throwing errors on inital render * Correct br * Event duration fixes * Add getMoreInfo if user is authed with current request.username * Add calendar color map wip * Add WIP comments for coloured outlines * Revert more info changes * Calculate date override correctly * Add description option * Fix inital schedule data not being populated * Nudge overlap over to make it clearer * Fix disabled state * WIP on math logic * Event list overlapping events logic * NIT about width * i18n + manage calendars link * Delete old troubleshooter * Update packages/features/calendars/weeklyview/components/event/EventList.tsx * Remove t-slots * Fix i18n & install calendar action * sm:imrovments * NITS * Fix types * fix: back button * Month prop null as we control from query param * Add head SEO * Fix headseo import * Fix date override tests
This commit is contained in:
1 parent
9a4c20cca4
commit
bdd3b132d4
26 files changed
+1038
-189
No files matched your search
@@ -4,6 +4,7 @@ import { ZCreateInputSchema } from "./create.schema";
|
||||
import { ZDeleteInputSchema } from "./delete.schema";
|
||||
import { ZScheduleDuplicateSchema } from "./duplicate.schema";
|
||||
import { ZGetInputSchema } from "./get.schema";
|
||||
import { ZGetByEventSlugInputSchema } from "./getScheduleByEventTypeSlug.schema";
|
||||
import { ZGetByUserIdInputSchema } from "./getScheduleByUserId.schema";
|
||||
import { ZUpdateInputSchema } from "./update.schema";
|
||||
|
||||
@@ -14,6 +15,7 @@ type ScheduleRouterHandlerCache = {
|
||||
update?: typeof import("./update.handler").updateHandler;
|
||||
duplicate?: typeof import("./duplicate.handler").duplicateHandler;
|
||||
getScheduleByUserId?: typeof import("./getScheduleByUserId.handler").getScheduleByUserIdHandler;
|
||||
getScheduleByEventSlug?: typeof import("./getScheduleByEventTypeSlug.handler").getScheduleByEventSlugHandler;
|
||||
};
|
||||
|
||||
const UNSTABLE_HANDLER_CACHE: ScheduleRouterHandlerCache = {};
|
||||
@@ -118,4 +120,21 @@ export const scheduleRouter = router({
|
||||
input,
|
||||
});
|
||||
}),
|
||||
getScheduleByEventSlug: authedProcedure.input(ZGetByEventSlugInputSchema).query(async ({ input, ctx }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.getScheduleByEventSlug) {
|
||||
UNSTABLE_HANDLER_CACHE.getScheduleByEventSlug = await import(
|
||||
"./getScheduleByEventTypeSlug.handler"
|
||||
).then((mod) => mod.getScheduleByEventSlugHandler);
|
||||
}
|
||||
|
||||
// Unreachable code but required for type safety
|
||||
if (!UNSTABLE_HANDLER_CACHE.getScheduleByEventSlug) {
|
||||
throw new Error("Failed to load handler");
|
||||
}
|
||||
|
||||
return UNSTABLE_HANDLER_CACHE.getScheduleByEventSlug({
|
||||
ctx,
|
||||
input,
|
||||
});
|
||||
}),
|
||||
});
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
|
||||
import type { TrpcSessionUser } from "../../../../trpc";
|
||||
import { getHandler } from "./get.handler";
|
||||
import type { TGetByEventSlugInputSchema } from "./getScheduleByEventTypeSlug.schema";
|
||||
|
||||
type GetOptions = {
|
||||
ctx: {
|
||||
user: NonNullable<TrpcSessionUser>;
|
||||
prisma: PrismaClient;
|
||||
};
|
||||
input: TGetByEventSlugInputSchema;
|
||||
};
|
||||
|
||||
const EMPTY_SCHEDULE = [[], [], [], [], [], [], []];
|
||||
|
||||
export const getScheduleByEventSlugHandler = async ({ ctx, input }: GetOptions) => {
|
||||
const foundScheduleForSlug = await ctx.prisma.eventType.findFirst({
|
||||
where: {
|
||||
slug: input.eventSlug,
|
||||
userId: ctx.user.id,
|
||||
},
|
||||
select: {
|
||||
scheduleId: true,
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
// This looks kinda weird that we throw straight in the catch - its so that we can return a default schedule if the user has not completed onboarding @shiraz will loveme for this
|
||||
if (!foundScheduleForSlug?.scheduleId) {
|
||||
const foundUserDefaultId = await ctx.prisma.user.findUnique({
|
||||
where: {
|
||||
id: ctx.user.id,
|
||||
},
|
||||
select: {
|
||||
defaultScheduleId: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (foundUserDefaultId?.defaultScheduleId) {
|
||||
return await getHandler({
|
||||
ctx,
|
||||
input: {
|
||||
scheduleId: foundUserDefaultId?.defaultScheduleId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
throw new Error("NOT_FOUND");
|
||||
}
|
||||
return await getHandler({
|
||||
ctx,
|
||||
input: {
|
||||
scheduleId: foundScheduleForSlug?.scheduleId,
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return {
|
||||
id: -1,
|
||||
name: "No schedules found",
|
||||
availability: EMPTY_SCHEDULE,
|
||||
dateOverrides: [],
|
||||
timeZone: ctx.user.timeZone || "Europe/London",
|
||||
workingHours: [],
|
||||
isDefault: true,
|
||||
};
|
||||
}
|
||||
};
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const ZGetByEventSlugInputSchema = z.object({
|
||||
eventSlug: z.string(),
|
||||
});
|
||||
|
||||
export type TGetByEventSlugInputSchema = z.infer<typeof ZGetByEventSlugInputSchema>;
|
||||
@@ -1,12 +1,15 @@
|
||||
import { getUserAvailability } from "@calcom/core/getUserAvailability";
|
||||
|
||||
import type { TrpcSessionUser } from "../../../trpc";
|
||||
import type { TUserInputSchema } from "./user.schema";
|
||||
|
||||
type UserOptions = {
|
||||
ctx: Record<string, unknown>;
|
||||
ctx: {
|
||||
user: NonNullable<TrpcSessionUser>;
|
||||
};
|
||||
input: TUserInputSchema;
|
||||
};
|
||||
|
||||
export const userHandler = async ({ input }: UserOptions) => {
|
||||
return getUserAvailability(input);
|
||||
return getUserAvailability(input, undefined);
|
||||
};
|
||||
Reference in new issue
Block a user