feat: CalendarSettings atom (#16120)

* dumb components for calendar settings

* shadcn switch

* update exports

* update packages

* add calendar settings atom to examples app

* init calendar settings atom

* refactors

* fix import path

* export type for calendar switch props

* invalidate queries on deleting calendar credentials

* replace calendars list with calendar settings wrapper

* cleanup

* update styling

* refactors

* cleanup

* fix: missing key prop CalendarSettingsPlatformWrapper

* Label as client components

* Address client component build errors

* Move QueryCell out of packages/lib

* PR feedback

* more feedback

---------

Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: Morgan <[email protected]>
Co-authored-by: Morgan Vernay <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-08-13 21:51:29 +05:30
1 parent b09b32b121
commit 0b03bcb90e
54 files changed
+781 -258

No files matched your search

@@ -1,47 +1,24 @@
import { Navbar } from "@/components/Navbar";
import { Inter } from "next/font/google";
import { useConnectedCalendars } from "@calcom/atoms";
import { useConnectedCalendars, CalendarSettings } from "@calcom/atoms";
const inter = Inter({ subsets: ["latin"] });
export default function Calendars(props: { calUsername: string; calEmail: string }) {
const { isLoading, data: calendars } = useConnectedCalendars();
const { isLoading, data: calendars } = useConnectedCalendars({});
const connectedCalendars = calendars?.connectedCalendars ?? [];
const destinationCalendar = calendars?.destinationCalendar ?? {};
return (
<main className={`flex min-h-screen flex-col ${inter.className}`}>
<Navbar username={props.calUsername} />
<div className="p-4">
{!!connectedCalendars?.length ? (
<h1 className="my-4 text-lg font-bold">Your Connected Calendars</h1>
) : (
<h1 className="mx-10 my-4 text-xl font-bold">
You have not connected any calendars yet, please connect your Google calendar.
</h1>
)}
{isLoading ? (
<div>Loading...</div>
) : (
Boolean(connectedCalendars?.length) &&
connectedCalendars.map((connectedCalendar) => (
<div key={connectedCalendar.credentialId}>
<h1 className="text-md font-bold">{connectedCalendar.integration.name}</h1>
{connectedCalendar.calendars?.map((calendar) => (
<div key={calendar.id}>
<h2>{calendar.name}</h2>
</div>
))}
</div>
))
)}
{!!connectedCalendars?.length && <hr className="my-4" />}
{!isLoading && destinationCalendar.id && (
<div className="">
<h2 className="text-md font-bold">Destination Calendar: {destinationCalendar.name}</h2>
<p>{destinationCalendar.integrationTitle}</p>
</div>
)}
{!isLoading && !connectedCalendars?.length && (
<h1 className="mx-10 my-4 text-xl font-bold">
You have not connected any calendars yet, please connect your Google, Outlook or Apple calendar.
</h1>
)}
<div className="mx-10 my-4">
<CalendarSettings />
</div>
</main>
);