diff --git a/packages/features/troubleshooter/components/LargeCalendar.tsx b/packages/features/troubleshooter/components/LargeCalendar.tsx
index f1bbf529f2..dc43ac879c 100644
--- a/packages/features/troubleshooter/components/LargeCalendar.tsx
+++ b/packages/features/troubleshooter/components/LargeCalendar.tsx
@@ -1,22 +1,57 @@
+import { useSession } from "next-auth/react";
+import { useMemo } from "react";
+
import dayjs from "@calcom/dayjs";
import { Calendar } from "@calcom/features/calendars/weeklyview";
+import { trpc } from "@calcom/trpc/react";
import { useTroubleshooterStore } from "../store";
export const LargeCalendar = ({ extraDays }: { extraDays: number }) => {
const selectedDate = useTroubleshooterStore((state) => state.selectedDate);
- const date = selectedDate || dayjs().format("YYYY-MM-DD");
+ const { data: session } = useSession();
+ const date = selectedDate ? dayjs(selectedDate) : dayjs();
+
+ const { data, isLoading } = trpc.viewer.availability.user.useQuery(
+ {
+ username: session?.user?.username || "",
+ dateFrom: date.startOf("day").utc().format(),
+ dateTo: date.endOf("day").utc().format(),
+ withSource: true,
+ },
+ {
+ enabled: !!session?.user?.username,
+ }
+ );
const startDate = selectedDate ? dayjs(selectedDate).toDate() : dayjs().toDate();
const endDate = dayjs(startDate)
.add(extraDays - 1, "day")
.toDate();
+ const events = useMemo(() => {
+ if (!data?.busy) return [];
+ return data?.busy.map((event) => {
+ const id = typeof event.start === "string" ? event.start : event.start.toISOString();
+
+ return {
+ id,
+ title: event.title ?? "Busy",
+ start: new Date(event.start),
+ end: new Date(event.end),
+ options: {
+ borderColor: "#F97417",
+ status: "ACCEPTED",
+ },
+ };
+ });
+ }, [data]);
+
return (
+
{prefixSlot}
-
{title}
-
{subtitle}
+
{title}
+ {subtitle &&
{subtitle}
}
{suffixSlot}
diff --git a/packages/features/troubleshooter/components/TroubleshooterSidebar.tsx b/packages/features/troubleshooter/components/TroubleshooterSidebar.tsx
index 8b0a7fdad0..6838c5179e 100644
--- a/packages/features/troubleshooter/components/TroubleshooterSidebar.tsx
+++ b/packages/features/troubleshooter/components/TroubleshooterSidebar.tsx
@@ -4,6 +4,8 @@ import Link from "next/link";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Skeleton } from "@calcom/ui";
+import { CalendarToggleContainer } from "./CalendarToggleContainer";
+import { EventScheduleItem } from "./EventScheduleItem";
import { EventTypeSelect } from "./EventTypeSelect";
const BackButtonInSidebar = ({ name }: { name: string }) => {
@@ -30,6 +32,8 @@ export const TroubleshooterSidebar = () => {
+
+
);
};
diff --git a/packages/trpc/server/routers/viewer/availability/schedule/getScheduleByEventTypeSlug.handler.ts b/packages/trpc/server/routers/viewer/availability/schedule/getScheduleByEventTypeSlug.handler.ts
index fcf69731c5..50457eff3a 100644
--- a/packages/trpc/server/routers/viewer/availability/schedule/getScheduleByEventTypeSlug.handler.ts
+++ b/packages/trpc/server/routers/viewer/availability/schedule/getScheduleByEventTypeSlug.handler.ts
@@ -28,6 +28,24 @@ export const getScheduleByEventSlugHandler = async ({ ctx, input }: GetOptions)
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({
@@ -37,6 +55,7 @@ export const getScheduleByEventSlugHandler = async ({ ctx, input }: GetOptions)
},
});
} catch (e) {
+ console.log(e);
return {
id: -1,
name: "No schedules found",
@@ -45,7 +64,6 @@ export const getScheduleByEventSlugHandler = async ({ ctx, input }: GetOptions)
timeZone: ctx.user.timeZone || "Europe/London",
workingHours: [],
isDefault: true,
- hasDefaultSchedule: false, // This is the path that we take if the user has not completed onboarding
};
}
};