import { useAutoAnimate } from "@formkit/auto-animate/react"; import Link from "next/link"; import { useTranslation } from "react-i18next"; import { useAppContextWithSchema } from "@calcom/app-store/EventTypeAppContext"; import { classNames } from "@calcom/lib"; import type { RouterOutputs } from "@calcom/trpc/react"; import { Switch, Badge, Avatar, Button, Icon } from "@calcom/ui"; import type { CredentialOwner } from "../types"; import OmniInstallAppButton from "./OmniInstallAppButton"; export default function AppCard({ app, description, switchOnClick, switchChecked, children, returnTo, teamId, disableSwitch, switchTooltip, hideSettingsIcon = false, hideAppCardOptions = false, }: { app: RouterOutputs["viewer"]["integrations"]["items"][number] & { credentialOwner?: CredentialOwner }; description?: React.ReactNode; switchChecked?: boolean; switchOnClick?: (e: boolean) => void; children?: React.ReactNode; returnTo?: string; teamId?: number; LockedIcon?: React.ReactNode; disableSwitch?: boolean; switchTooltip?: string; hideSettingsIcon?: boolean; hideAppCardOptions?: boolean; }) { const { t } = useTranslation(); const [animationRef] = useAutoAnimate(); const { setAppData, LockedIcon, disabled: managedDisabled } = useAppContextWithSchema(); return (
{/* Don't know why but w-[42px] isn't working, started happening when I started using next/dynamic */} {app?.name}
{app?.name} {!app?.isInstalled && ( {app?.categories[0].charAt(0).toUpperCase() + app?.categories[0].slice(1)} )}

{description || app?.description}

{app.credentialOwner && (
{app.credentialOwner.name}
)} {app?.isInstalled || app.credentialOwner ? (
{ if (switchOnClick) { switchOnClick(enabled); } setAppData("enabled", enabled); }} checked={switchChecked} LockedIcon={LockedIcon} data-testid={`${app.slug}-app-switch`} tooltip={switchTooltip} />
) : ( )}
{hideAppCardOptions ? null : (
{app?.isInstalled && switchChecked &&
} {app?.isInstalled && switchChecked ? ( app.isSetupAlready === undefined || app.isSetupAlready ? (
{!hideSettingsIcon && (
) : (

{t("this_app_is_not_setup_already")}

) ) : null}
)}
); }