mirror of
https://github.com/hanzoai/calendar.git
synced 2026-09-24 22:42:24 +00:00
* feat: Cal.diy — community-driven MIT-licensed fork of Cal.com This squashed commit contains all Cal.diy changes applied on top of calcom/cal.com main: - Rebrand Cal.com to Cal.diy across the entire codebase - Remove Enterprise Edition (EE) features, license checks, and AGPL restrictions - Switch license from AGPL-3.0 to MIT - Remove docs/ directory (migrated to Nextra at cal.diy) - Remove dead code: org tests, EE tips, platform nav, premium username, SAML/SSO, etc. - Clean up .env.example for self-hosted Cal.diy - Update Docker image references to calcom/cal.diy - Update README, CONTRIBUTING.md, and issue templates for Cal.diy community fork - Add PR welcome bot for Cal.diy contributors - Fix API v2 breaking changes oasdiff ignore entries - Replace Blacksmith CI runners with default GitHub Actions 3893 files changed, 20789 insertions(+), 411020 deletions(-) Co-Authored-By: [email protected] <[email protected]> * refactor: remove org-specific /organizations/:orgId endpoints from API v2 atoms controllers (#1701) Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: revert Cal.diy Inc to Cal.com, Inc. in license files, copyright notices, and package metadata (#1702) Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * rip out org related comments in api v2 --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
110 lines
3.3 KiB
TypeScript
110 lines
3.3 KiB
TypeScript
"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>
|
||
);
|
||
};
|