import { useAutoAnimate } from "@formkit/auto-animate/react"; import Link from "next/link"; import { useAppContextWithSchema } from "@calcom/app-store/EventTypeAppContext"; import { useIsPlatform } from "@calcom/atoms/hooks/useIsPlatform"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import type { RouterOutputs } from "@calcom/trpc/react"; import classNames from "@calcom/ui/classNames"; import { Button } from "@calcom/ui/components/button"; import { Switch } from "@calcom/ui/components/form"; import { Icon } from "@calcom/ui/components/icon"; import { Section } from "@calcom/ui/components/section"; 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"]["apps"]["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 } = useLocale(); const [animationRef] = useAutoAnimate(); const { setAppData, LockedIcon, disabled: managedDisabled } = useAppContextWithSchema(); const isPlatform = useIsPlatform(); return (
{app?.name} {!app?.isInstalled && ( {app?.categories[0].charAt(0).toUpperCase() + app?.categories[0].slice(1)} )}
{app?.description} } iconSlot={ {app?.name} }>
{/* {app.credentialOwner && !isPlatform && (
{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.isSetupAlready === undefined || app.isSetupAlready ? (
{!hideSettingsIcon && !isPlatform && (
) : (

{t("this_app_is_not_setup_already")}

)}
)}
); }