Files
calendar/apps/web/modules/onboarding/components/onboarding-calendar-browser-view.tsx
Eunjae LeeGitHubClaude Opus 4.5Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
81e4241f85 refactor: apply biome formatting to apps/web (#27692)
* refactor: apply biome formatting to apps/web (batch 1)

Formats apps/web non-modules directories:
- apps/web/app
- apps/web/lib
- apps/web/pages
- apps/web/styles
- apps/web/server
- apps/web/test
- Root-level .ts and .mjs files

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* refactor: apply biome formatting to apps/web/modules (batch 2)

Formats smaller apps/web/modules directories:
- onboarding, data-table, users, apps, auth
- integration-attribute-sync, shell, availability
- feature-flags, team, webhooks, getting-started
- feature-opt-in, troubleshooter, schedules, notifications
- signup-view.tsx

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* refactor: apply biome formatting to apps/web/modules (batch 3)

Formats medium apps/web/modules directories:
- bookings
- event-types
- insights
- embed

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* refactor: apply biome formatting to apps/web/modules/ee (batch 4)

Formats apps/web/modules/ee directory.

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* refactor: apply biome formatting to apps/web (batch 5)

Formats remaining apps/web directories:
- apps/web/modules/settings
- apps/web/modules/booking-audit
- apps/web/playwright

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* refactor: apply biome formatting to apps/web/components (batch 6)

Formats remaining apps/web/components files.

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* refactor: apply biome formatting to new apps/web files from main

Formats newly added/modified files from main merge:
- WorkflowStepContainer.tsx (resolved merge conflicts)
- Newly moved files (blocklist, form-builder, schedules, etc.)
- Other files modified in main

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* refactor: apply biome formatting to new apps/web files from main

Co-Authored-By: Claude Opus 4.5 <[email protected]>

---------

Co-authored-by: Claude Opus 4.5 <[email protected]>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-02-10 23:25:24 +05:30

110 lines
3.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
import { AnimatePresence, motion } from "framer-motion";
import { usePathname } from "next/navigation";
import { useMemo } from "react";
import dayjs from "@calcom/dayjs";
import { Calendar } from "@calcom/web/modules/calendars/weeklyview/components/Calendar";
import type { CalendarComponentProps, Hours } from "@calcom/features/calendars/weeklyview/types/state";
import { weekdayDates } from "@calcom/features/calendars/weeklyview/utils";
import { CURRENT_TIMEZONE } from "@calcom/lib/timezoneConstants";
import { useOnboardingCalendarEvents } from "../hooks/useOnboardingCalendarEvents";
// Helper function to ensure a number is a valid Hours type
const toHours = (value: number): Hours => {
const clamped = Math.max(0, Math.min(23, value));
return clamped as Hours;
};
export const OnboardingCalendarBrowserView = () => {
const pathname = usePathname();
const { startDate, endDate } = useMemo(() => {
return weekdayDates(0, new Date(), 6);
}, []);
const { events } = useOnboardingCalendarEvents({ startDate, endDate });
// Calculate startHour and endHour based on current time
const hours = useMemo((): { startHour: Hours; endHour: Hours } => {
const currentHour = dayjs().tz(CURRENT_TIMEZONE).hour();
return {
startHour: toHours(Math.max(0, currentHour - 2)),
endHour: toHours(Math.min(23, currentHour + 6)),
};
}, []);
// Animation variants for entry and exit
const containerVariants = {
initial: {
opacity: 0,
y: -20,
},
animate: {
opacity: 1,
y: 0,
},
exit: {
opacity: 0,
y: 20,
},
};
// Memoize calendar props to prevent unnecessary re-initializations
const calendarProps = useMemo(
() =>
({
timezone: CURRENT_TIMEZONE,
startDate,
endDate,
events: events || [],
startHour: hours.startHour,
endHour: hours.endHour,
gridCellsPerHour: 4,
hoverEventDuration: 0,
showBackgroundPattern: false,
showBorder: false,
borderColor: "subtle" as const,
hideHeader: true,
eventsDisabled: true,
sortEvents: true,
isPending: false, // Explicitly set to false to prevent loading spinner
loading: false, // Also set loading to false just in case
onEventClick: () => {},
onEmptyCellClick: () => {},
onDateChange: () => {},
showTimezone: true,
}) satisfies CalendarComponentProps,
[startDate, endDate, events, hours]
);
return (
<AnimatePresence mode="wait">
<motion.div
key={pathname}
className="bg-default border-muted flex h-full w-full flex-col overflow-hidden rounded-xl border"
variants={containerVariants}
initial="initial"
animate="animate"
exit="exit"
transition={{
duration: 0.5,
ease: "backOut",
}}>
<div className="flex items-center gap-2 px-4 py-3">
<span className="text-default text-sm font-semibold">
{dayjs(startDate).format("MMM D")}
<span className="mx-1">–</span>
{dayjs(endDate).format("MMM D, YYYY")}
</span>
</div>
{/* Calendar View */}
<div className="flex h-full flex-col overflow-hidden">
<Calendar {...calendarProps} />
</div>
</motion.div>
</AnimatePresence>
);
};