* chore: Disables syncing of calendarList on overlay calendar fetch * Unwrap ToggledConnectedCalendars * Pick the right type for connectedCalendars * further type amends * Type fixes, tons of em * Some further fixups consistent with what was before * fix: resolve type incompatibility in getConnectedDestinationCalendars return type Co-Authored-By: alex@cal.com <me@alexvanandel.com> * fix: update DestinationCalendarProps to accept tRPC handler return type Co-Authored-By: alex@cal.com <me@alexvanandel.com> * fix: use generic type for DestinationCalendarProps to accept tRPC enriched types Co-Authored-By: alex@cal.com <me@alexvanandel.com> * fix: simplify DestinationCalendarProps type for better compatibility Co-Authored-By: alex@cal.com <me@alexvanandel.com> * fix: export ConnectedCalendar type for consistent type inference Co-Authored-By: alex@cal.com <me@alexvanandel.com> * fix: use permissive type for connectedCalendars to accept tRPC enriched types Co-Authored-By: alex@cal.com <me@alexvanandel.com> * fix: export ConnectedCalendar and ConnectedDestinationCalendars types from platform-libraries Co-Authored-By: alex@cal.com <me@alexvanandel.com> * fix: update ConnectedCalendar type to use boolean | null for primary field Co-Authored-By: alex@cal.com <me@alexvanandel.com> * Update ConnectedCalendarItem * Undo some of Devins fixes, more fixes * Fixup the destination calendar return type, historically not null * Change init to undefined to deal with null * Approach to connect selected calendars with the right credential * This return type is used way too much everywhere, not refactoring * Add the selectedCalendars to the type * Actually fix overlay calendar * set calendarsToLoad param as required * Apply suggestion from @cubic-dev-ai[bot] Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> * Add new translation for 'Calendar Settings' --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
88 lines
3.2 KiB
TypeScript
88 lines
3.2 KiB
TypeScript
import cx from "@calcom/ui/classNames";
|
|
import { useId } from "@radix-ui/react-id";
|
|
import * as Label from "@radix-ui/react-label";
|
|
import * as PrimitiveSwitch from "@radix-ui/react-switch";
|
|
import type React from "react";
|
|
import type { ReactNode } from "react";
|
|
import { Tooltip } from "../../tooltip";
|
|
|
|
const Wrapper = ({ children, tooltip }: { tooltip?: string; children: React.ReactNode }) => {
|
|
if (!tooltip) {
|
|
return <>{children}</>;
|
|
}
|
|
return <Tooltip content={tooltip}>{children}</Tooltip>;
|
|
};
|
|
export const Switch = (
|
|
props: React.ComponentProps<typeof PrimitiveSwitch.Root> & {
|
|
label?: string | ReactNode;
|
|
fitToHeight?: boolean;
|
|
disabled?: boolean;
|
|
tooltip?: string;
|
|
labelOnLeading?: boolean;
|
|
size?: "base" | "sm";
|
|
classNames?: {
|
|
container?: string;
|
|
thumb?: string;
|
|
};
|
|
LockedIcon?: React.ReactNode;
|
|
padding?: boolean;
|
|
}
|
|
) => {
|
|
const {
|
|
label,
|
|
fitToHeight,
|
|
classNames,
|
|
labelOnLeading,
|
|
LockedIcon,
|
|
padding,
|
|
size = "base",
|
|
...primitiveProps
|
|
} = props;
|
|
const id = useId();
|
|
return (
|
|
<Wrapper tooltip={props.tooltip}>
|
|
<div
|
|
className={cx(
|
|
"flex h-auto w-fit flex-row items-center",
|
|
fitToHeight && "h-fit",
|
|
labelOnLeading && "flex-row-reverse justify-between",
|
|
padding && "hover:bg-subtle rounded-md p-1.5",
|
|
classNames?.container
|
|
)}>
|
|
{LockedIcon && <div className="mr-2">{LockedIcon}</div>}
|
|
<PrimitiveSwitch.Root
|
|
{...primitiveProps}
|
|
id={id}
|
|
className={cx(
|
|
size === "sm" ? "h-3 w-[20px]" : "h-4 w-[28px]",
|
|
"focus:ring-brand-default data-[state=checked]:bg-brand-default dark:data-[state=checked]:bg-brand-emphasis data-[state=unchecked]:bg-emphasis peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-inner transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
size === "sm" ? "h-4 w-7" : "h-6 w-11",
|
|
classNames?.container
|
|
)}>
|
|
<PrimitiveSwitch.Thumb
|
|
className={cx(
|
|
"bg-default data-[state=checked]:bg-brand-accent shadow-switch-thumb pointer-events-none block rounded-full shadow-lg ring-0 transition-transform",
|
|
size === "sm"
|
|
? "h-3 w-3 data-[state=checked]:translate-x-3 data-[state=unchecked]:translate-x-0 rtl:data-[state=checked]:-translate-x-3"
|
|
: "h-5 w-5 data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0 rtl:data-[state=checked]:-translate-x-5",
|
|
classNames?.thumb
|
|
)}
|
|
/>
|
|
</PrimitiveSwitch.Root>
|
|
{label && (
|
|
<Label.Root
|
|
htmlFor={id}
|
|
className={cx(
|
|
"text-emphasis font-medium",
|
|
size === "sm" ? "m-1 text-xs" : labelOnLeading ? "mr-2 text-sm" : "ml-2 text-sm",
|
|
primitiveProps.disabled ? "cursor-not-allowed opacity-25" : "cursor-pointer",
|
|
labelOnLeading && "flex-1"
|
|
)}>
|
|
{label}
|
|
</Label.Root>
|
|
)}
|
|
</div>
|
|
</Wrapper>
|
|
);
|
|
};
|