From 6b6e9dba2beff8df48868abd39bc7382393f964f Mon Sep 17 00:00:00 2001 From: Sean Brydon Date: Wed, 25 Oct 2023 14:18:29 +0100 Subject: [PATCH] Calendar toggle --- .../components/CalendarToggleContainer.tsx | 98 ++++++++++++++++--- 1 file changed, 86 insertions(+), 12 deletions(-) diff --git a/packages/features/troubleshooter/components/CalendarToggleContainer.tsx b/packages/features/troubleshooter/components/CalendarToggleContainer.tsx index b4064b88a3..354ccbabb0 100644 --- a/packages/features/troubleshooter/components/CalendarToggleContainer.tsx +++ b/packages/features/troubleshooter/components/CalendarToggleContainer.tsx @@ -1,13 +1,60 @@ import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { trpc } from "@calcom/trpc/react"; import { Badge, Button, Switch } from "@calcom/ui"; import { TroubleshooterListItemContainer } from "./TroubleshooterListItemContainer"; -function CalendarToggleItem() { +const SELECTION_COLORS = ["#f97316", "#84cc16", "#06b6d4", "#8b5cf6", "#ec4899", "#f43f5e"]; + +interface CalendarToggleItemProps { + title: string; + subtitle: string; + colorDot?: string; + status: "connected" | "not_found"; + calendars?: { + active?: boolean; + name?: string; + }[]; +} +function CalendarToggleItem(props: CalendarToggleItemProps) { + const badgeStatus = props.status === "connected" ? "green" : "orange"; + const badgeText = props.status === "connected" ? "Connected" : "Not found"; return ( +
+ + } + suffixSlot={ +
+ + {badgeText} + +
+ }> +
+ {props.calendars?.map((calendar) => { + return ; + })} +
+ + ); +} + +function EmptyCalendarToggleItem() { + const { t } = useLocale(); + + return ( +
@@ -15,14 +62,15 @@ function CalendarToggleItem() { } suffixSlot={
- - Connected + + Not found
}>
- - +
); @@ -30,14 +78,40 @@ function CalendarToggleItem() { export function CalendarToggleContainer() { const { t } = useLocale(); + const { data, isLoading } = trpc.viewer.connectedCalendars.useQuery(); + + const hasConnectedCalendars = data && data?.connectedCalendars.length > 0; + return (

{t("calendars_were_checking_for_conflicts")}

- - - + {hasConnectedCalendars && !isLoading ? ( + <> + {data.connectedCalendars.map((calendar, idx) => { + const foundPrimary = calendar.calendars?.find((item) => item.primary); + return ( + { + return { + active: item.isSelected, + name: item.name, + }; + })} + /> + ); + })} + + + ) : ( + + )}
); }