feat: cal ai promo design (#23651)

Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: CarinaWolli <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-09-14 12:00:12 -03:00
1 parent 3aab13b4da
commit cfadd2e892
28 files changed
+884 -214

No files matched your search

@@ -708,11 +708,41 @@ export function AgentConfigurationSheet({
)}
</SheetBody>
<SheetFooter>
<Button type="button" color="secondary" onClick={() => onOpenChange(false)}>
<div className="mr-auto">
<Dropdown>
<DropdownMenuTrigger asChild>
<Button
color="secondary"
className="rounded-[10px]"
disabled={readOnly}
EndIcon="chevron-down">
{t("test_agent")}
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuItem>
<DropdownItem
type="button"
StartIcon="monitor"
onClick={() => {
setIsWebCallDialogOpen(true);
}}>
{t("web_call")}
</DropdownItem>
</DropdownMenuItem>
</DropdownMenuContent>
</Dropdown>
</div>
<Button
className="justify-center"
type="button"
color="secondary"
onClick={() => onOpenChange(false)}>
{t("cancel")}
</Button>
<Button
type="button"
className="justify-center"
onClick={agentForm.handleSubmit(handleAgentUpdate)}
disabled={!agentForm.formState.isDirty || readOnly || updateAgentMutation.isPending}
loading={updateAgentMutation.isPending}>
@@ -877,7 +907,7 @@ export function AgentConfigurationSheet({
</div>
{showAdvancedFields && (
<div className="space-y-5 rounded-lg bg-white p-4">
<div className="bg-default space-y-5 rounded-lg p-4">
<Controller
name="sipTrunkAuthUsername"
control={phoneNumberForm.control}
@@ -1,32 +1,48 @@
import { useRouter } from "next/navigation";
import { CreateButtonWithTeamsList } from "@calcom/features/ee/teams/components/createButton/CreateButtonWithTeamsList";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { HttpError } from "@calcom/lib/http-error";
import { trpc } from "@calcom/trpc/react";
import cn from "@calcom/ui/classNames";
import { EmptyScreen as ClassicEmptyScreen } from "@calcom/ui/components/empty-screen";
import { Icon } from "@calcom/ui/components/icon";
import type { IconName } from "@calcom/ui/components/icon";
import { showToast } from "@calcom/ui/components/toast";
import { WorkflowCreationDialog, useWorkflowCreation } from "./WorkflowCreationDialog";
type WorkflowExampleType = {
Icon: IconName;
text: string;
icon: IconName;
iconWrapperClassName?: string;
title: string;
description: string;
image?: string;
};
function WorkflowExample(props: WorkflowExampleType) {
const { Icon: iconName, text } = props;
const { icon: iconName, title, description, iconWrapperClassName, image } = props;
return (
<div className="border-subtle mx-2 my-2 max-h-24 max-w-[600px] rounded-md border border-solid p-6">
<div className="flex ">
<div className="bg-default border-subtle max-h-24 max-w-[600px] rounded-xl border border-solid p-2.5">
<div className="flex">
<div className="flex items-center justify-center">
<div className="bg-emphasis dark:bg-default mr-4 flex h-10 w-10 items-center justify-center rounded-full">
<Icon name={iconName} className="text-default h-6 w-6 stroke-[2px]" />
<div
className={cn(
"bg-emphasis dark:bg-default mr-4 flex h-10 w-10 items-center justify-center rounded-[10px]",
iconWrapperClassName
)}>
{image ? (
<img
src={image}
alt=""
role="presentation"
aria-hidden="true"
className={cn("text-default h-5 w-5")}
/>
) : (
<Icon name={iconName} className={cn("text-default h-5 w-5")} aria-hidden="true" />
)}
</div>
</div>
<div className="m-auto w-full flex-grow items-center justify-center ">
<div className="text-semibold text-emphasis line-clamp-2 w-full text-sm font-medium">{text}</div>
<div className="text-semibold text-emphasis line-clamp-2 w-full text-sm font-semibold">{title}</div>
<div className="text-default text-sm font-normal leading-none">{description}</div>
</div>
</div>
</div>
@@ -35,33 +51,60 @@ function WorkflowExample(props: WorkflowExampleType) {
export default function EmptyScreen(props: { isFilteredView: boolean }) {
const { t } = useLocale();
const router = useRouter();
const { showDialog, setShowDialog, pendingTeamId, openDialog } = useWorkflowCreation();
const createMutation = trpc.viewer.workflows.create.useMutation({
onSuccess: async ({ workflow }) => {
await router.replace(`/workflows/${workflow.id}`);
const workflowsExamples: WorkflowExampleType[] = [
{ icon: "smartphone", title: t("send_sms_reminder"), description: t("send_sms_reminder_description") },
{
icon: "smartphone",
title: t("follow_up_with_no_shows"),
description: t("follow_up_with_no_shows_description"),
},
onError: (err) => {
if (err instanceof HttpError) {
const message = `${err.statusCode}: ${err.message}`;
showToast(message, "error");
}
if (err.data?.code === "UNAUTHORIZED") {
const message = `${err.data.code}: ${t("unauthorized_create_workflow")}`;
showToast(message, "error");
}
{
icon: "mail",
title: t("remind_attendees_to_bring_id"),
description: t("remind_attendees_to_bring_id_description"),
},
});
{
icon: "mail",
title: t("email_to_remind_booking"),
description: t("email_to_remind_booking_description"),
},
{
icon: "mail",
title: t("custom_email_reminder"),
description: t("custom_email_reminder_description"),
},
{
icon: "smartphone",
title: t("custom_sms_reminder"),
description: t("custom_sms_reminder_description"),
},
];
const workflowsExamples = [
{ icon: "smartphone", text: t("workflow_example_1") },
{ icon: "smartphone", text: t("workflow_example_2") },
{ icon: "mail", text: t("workflow_example_3") },
{ icon: "mail", text: t("workflow_example_4") },
{ icon: "mail", text: t("workflow_example_5") },
{ icon: "smartphone", text: t("workflow_example_6") },
] as const;
const calAITemplates: WorkflowExampleType[] = [
{
icon: "phone-outgoing",
title: t("call_to_confirm_booking"),
description: t("cal_ai_phone_call_action_description"),
iconWrapperClassName: "bg-[#2A2947]",
image: "/call-outgoing.svg",
},
{
icon: "phone-outgoing",
title: t("follow_up_with_no_shows"),
description: t("follow_up_with_no_shows_description"),
iconWrapperClassName: "bg-[#2A2947]",
image: "/call-outgoing.svg",
},
{
icon: "phone-outgoing",
title: t("remind_attendees_to_bring_id"),
description: t("remind_attendees_to_bring_id_description"),
iconWrapperClassName: "bg-[#2A2947]",
image: "/call-outgoing.svg",
},
];
// new workflow example when 'after meetings ends' trigger is implemented: Send custom thank you email to attendee after event (Smile icon),
if (props.isFilteredView) {
@@ -82,21 +125,42 @@ export default function EmptyScreen(props: { isFilteredView: boolean }) {
<div className="mt-8 ">
<CreateButtonWithTeamsList
subtitle={t("new_workflow_subtitle").toUpperCase()}
createFunction={(teamId?: number) => createMutation.mutate({ teamId })}
createFunction={openDialog}
buttonText={t("create_workflow")}
isPending={createMutation.isPending}
includeOrg={true}
/>
</div>
</div>
</div>
<div className="flex flex-row items-center justify-center">
<div className="grid-cols-none items-center lg:grid lg:grid-cols-3 xl:mx-20">
{workflowsExamples.map((example, index) => (
<WorkflowExample key={index} Icon={example.icon} text={example.text} />
))}
</div>
<div className="flex flex-col gap-4">
<TemplateSection title={t("cal_ai_templates")} examples={calAITemplates} />
<TemplateSection title={t("standard_templates")} examples={workflowsExamples} />
</div>
<WorkflowCreationDialog open={showDialog} onOpenChange={setShowDialog} teamId={pendingTeamId} />
</>
);
}
const TemplateSection = ({ title, examples }: { title: string; examples: WorkflowExampleType[] }) => {
return (
<div className="flex items-center justify-center">
<div className="bg-muted flex max-w-5xl flex-col rounded-md p-2">
<h2 className="text-emphasis mb-2 text-base font-semibold">{title}</h2>
<div className="grid-cols-none items-center gap-2 lg:grid lg:grid-cols-3">
{examples.map((example: WorkflowExampleType, index: number) => (
<WorkflowExample
key={index}
icon={example.icon}
title={example.title}
description={example.description}
iconWrapperClassName={example.iconWrapperClassName}
image={example.image}
/>
))}
</div>
</div>
</div>
);
};
@@ -0,0 +1,193 @@
import { useRouter } from "next/navigation";
import { useState } from "react";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { HttpError } from "@calcom/lib/http-error";
import { trpc } from "@calcom/trpc/react";
import cn from "@calcom/ui/classNames";
import { Button } from "@calcom/ui/components/button";
import { Dialog, DialogContent, DialogFooter } from "@calcom/ui/components/dialog";
import { Icon } from "@calcom/ui/components/icon";
import type { IconName } from "@calcom/ui/components/icon";
import { RadioGroup, Radio, RadioIndicator } from "@calcom/ui/components/radio";
import { showToast } from "@calcom/ui/components/toast";
type WorkflowOptionCardProps = {
title: string;
description: string;
icon?: IconName;
isSelected: boolean;
onClick: () => void;
iconWrapperClassName?: string;
image?: string;
value: "scratch" | "calai";
};
function WorkflowOptionCard(props: WorkflowOptionCardProps) {
const { title, description, icon, isSelected, onClick, image, iconWrapperClassName, value } = props;
return (
<div
data-testid={`workflow-option-card-${value}`}
onClick={onClick}
className={cn(
`relative flex flex-1 cursor-pointer flex-col rounded-lg border p-4 transition-colors`,
isSelected ? "border-brand-default" : "border-subtle hover:border-emphasis"
)}>
<div className="absolute right-3 top-3">
<Radio value={value} aria-label={title}>
<RadioIndicator />
</Radio>
</div>
<div className="flex flex-col">
<div
className={cn(
"mb-5 flex h-10 w-10 items-center justify-center rounded-lg border",
iconWrapperClassName
)}>
{image ? (
<img
src={image}
alt=""
role="presentation"
aria-hidden="true"
className={cn("text-default h-5 w-5")}
/>
) : (
<Icon name={icon || "circle-plus"} className={cn("text-default h-5 w-5")} aria-hidden="true" />
)}
</div>
<h3 className="text-emphasis text-sm font-semibold">{title}</h3>
<p className="text-subtle text-sm">{description}</p>
</div>
</div>
);
}
type WorkflowCreationDialogProps = {
open: boolean;
onOpenChange: (open: boolean) => void;
teamId?: number;
onSuccess?: () => void;
};
export function WorkflowCreationDialog({
open,
onOpenChange,
teamId,
onSuccess,
}: WorkflowCreationDialogProps) {
const { t } = useLocale();
const router = useRouter();
const [selectedOption, setSelectedOption] = useState<"scratch" | "calai">("scratch");
const [isLoading, setIsLoading] = useState(false);
const handleOptionChange = (value: string) => {
if (value === "scratch" || value === "calai") {
setSelectedOption(value);
}
};
const createMutation = trpc.viewer.workflows.create.useMutation({
onSuccess: async ({ workflow }) => {
onOpenChange(false);
if (onSuccess) {
onSuccess();
} else {
router.replace(`/workflows/${workflow.id}`);
}
},
onError: (err) => {
if (err instanceof HttpError) {
const message = `${err.statusCode}: ${err.message}`;
showToast(message, "error");
}
if (err.data?.code === "UNAUTHORIZED") {
const message = `${err.data.code}: ${t("unauthorized_create_workflow")}`;
showToast(message, "error");
}
},
});
const handleContinue = () => {
if (selectedOption === "scratch") {
createMutation.mutate({ teamId });
} else if (selectedOption === "calai") {
setIsLoading(true);
const queryParams = new URLSearchParams({
action: "calAi",
templateWorkflowId: "wf-11",
...(teamId && { teamId: teamId.toString() }),
});
router.push(`/workflow/new?${queryParams.toString()}`);
setIsLoading(false);
}
};
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent
title={t("new_workflow_btn")}
description={t("how_would_you_like_to_start")}
type="creation"
enableOverflow
Icon="zap">
<RadioGroup
value={selectedOption}
onValueChange={handleOptionChange}
aria-label={t("new_workflow_btn")}>
<div className="mt-6 flex gap-4">
<WorkflowOptionCard
title={t("start_from_scratch_title")}
description={t("start_from_scratch_description")}
icon="circle-plus"
isSelected={selectedOption === "scratch"}
onClick={() => setSelectedOption("scratch")}
iconWrapperClassName="bg-muted"
value="scratch"
/>
<WorkflowOptionCard
title={t("cal_ai_template_title")}
description={t("cal_ai_template_description")}
image="/call-outgoing.svg"
isSelected={selectedOption === "calai"}
onClick={() => setSelectedOption("calai")}
iconWrapperClassName="bg-[#2A2947]"
value="calai"
/>
</div>
</RadioGroup>
<DialogFooter className="relative" showDivider>
<Button type="button" color="minimal" onClick={() => onOpenChange(false)}>
{t("cancel")}
</Button>
<Button
data-testid="continue-button"
type="button"
onClick={handleContinue}
loading={createMutation.isPending || isLoading}>
{t("continue")}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
}
export function useWorkflowCreation() {
const [showDialog, setShowDialog] = useState(false);
const [pendingTeamId, setPendingTeamId] = useState<number | undefined>(undefined);
const openDialog = (teamId?: number) => {
setPendingTeamId(teamId);
setShowDialog(true);
};
return {
showDialog,
setShowDialog,
pendingTeamId,
openDialog,
};
}
@@ -1,7 +1,7 @@
import { type TFunction } from "i18next";
import { useParams, useRouter, useSearchParams } from "next/navigation";
import type { Dispatch, SetStateAction } from "react";
import { useEffect, useRef, useState } from "react";
import { useEffect, useRef, useState, useCallback } from "react";
import type { UseFormReturn } from "react-hook-form";
import { Controller } from "react-hook-form";
import "react-phone-number-input/style.css";
@@ -190,6 +190,11 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
onSuccess: async (data) => {
showToast(t("agent_created_successfully"), "success");
const url = new URL(window.location.href);
url.searchParams.delete("autoCreateAgent");
url.searchParams.delete("templateWorkflowId");
router.replace(url.pathname + url.search);
if (step) {
const stepIndex = step.stepNumber - 1;
form.setValue(`steps.${stepIndex}.agentId`, data.id);
@@ -250,7 +255,7 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
const senderNeeded =
step?.action === WorkflowActions.SMS_NUMBER || step?.action === WorkflowActions.SMS_ATTENDEE;
const [, setIsSenderIsNeeded] = useState(senderNeeded);
const [_isSenderIsNeeded, setIsSenderIsNeeded] = useState(senderNeeded);
const [isEmailAddressNeeded, setIsEmailAddressNeeded] = useState(
step?.action === WorkflowActions.EMAIL_ADDRESS ? true : false
@@ -265,65 +270,79 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
);
const [timeSectionText, setTimeSectionText] = useState(getTimeSectionText(form.getValues("trigger"), t));
const [autoAgentCreationAttempted, setAutoAgentCreationAttempted] = useState(false);
const isCreatingAgent = useRef(false);
const hasAutoCreated = useRef(false);
const handleCreateAgent = useCallback(
async (templateWorkflowId?: string) => {
if (isCreatingAgent.current || createAgentMutation.isPending) {
console.log("Agent creation already in progress, skipping...");
return;
}
isCreatingAgent.current = true;
try {
// Save workflow first to ensure we have step ID
if (onSaveWorkflow) {
await onSaveWorkflow();
}
const updatedSteps = form.getValues("steps");
const currentStepIndex = step ? step.stepNumber - 1 : 0;
const updatedStep = updatedSteps[currentStepIndex];
if (updatedStep?.action !== WorkflowActions.CAL_AI_PHONE_CALL) {
form.setValue(`steps.${currentStepIndex}.action`, WorkflowActions.CAL_AI_PHONE_CALL);
}
if (updatedStep?.id) {
createAgentMutation.mutate({
teamId,
workflowStepId: updatedStep.id,
...(templateWorkflowId && { templateWorkflowId }),
});
} else {
showToast(t("failed_to_get_workflow_step_id"), "error");
}
} catch (error) {
console.error("Failed to create agent:", error);
showToast(t("failed_to_create_agent"), "error");
} finally {
isCreatingAgent.current = false;
}
},
[createAgentMutation, onSaveWorkflow, form, step, teamId, t]
);
const autoCreateAgent = searchParams?.get("autoCreateAgent");
const templateWorkflowId = searchParams?.get("templateWorkflowId");
useEffect(() => {
const autoCreateAgent = searchParams?.get("autoCreateAgent");
const templateWorkflowId = searchParams?.get("templateWorkflowId");
if (
const shouldAutoCreate =
autoCreateAgent === "true" &&
!autoAgentCreationAttempted &&
templateWorkflowId &&
step &&
step?.id &&
step.action === WorkflowActions.CAL_AI_PHONE_CALL &&
!stepAgentId &&
step.id &&
onSaveWorkflow
) {
setAutoAgentCreationAttempted(true);
!hasAutoCreated.current &&
!createAgentMutation.isPending &&
!createAgentMutation.isSuccess;
const createAgent = async () => {
try {
await onSaveWorkflow?.();
const updatedSteps = form.getValues("steps");
const currentStepIndex = step.stepNumber - 1;
const updatedStep = updatedSteps[currentStepIndex];
if (updatedStep?.id) {
createAgentMutation.mutate({
teamId,
workflowStepId: updatedStep.id,
templateWorkflowId,
});
const url = new URL(window.location.href);
url.searchParams.delete("autoCreateAgent");
url.searchParams.delete("templateWorkflowId");
router.replace(url.pathname + url.search);
} else {
showToast(t("failed_to_get_workflow_step_id"), "error");
}
} catch (error) {
console.error("Failed to auto-create agent:", error);
showToast(t("failed_to_create_agent"), "error");
}
};
createAgent();
if (shouldAutoCreate && onSaveWorkflow) {
hasAutoCreated.current = true;
handleCreateAgent(templateWorkflowId);
}
}, [
searchParams,
autoAgentCreationAttempted,
step,
autoCreateAgent,
templateWorkflowId,
step?.id,
step?.action,
stepAgentId,
teamId,
createAgentMutation.isPending,
createAgentMutation.isSuccess,
onSaveWorkflow,
createAgentMutation,
form,
t,
router,
handleCreateAgent,
]);
const { data: actionOptions } = trpc.viewer.workflows.getWorkflowActionOptions.useQuery();
@@ -619,6 +638,7 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
label: actionString.charAt(0).toUpperCase() + actionString.slice(1),
value: step.action,
needsCredits: isSMSOrWhatsappAction(step.action),
isCalAi: isCalAIAction(step.action),
creditsTeamId: teamId ?? creditsTeamId,
isOrganization: props.isOrganization,
};
@@ -743,7 +763,7 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
</div>
{isCalAIAction(form.getValues(`steps.${step.stepNumber - 1}.action`)) && !stepAgentId && (
<div className="bg-muted border-muted mt-2 rounded-2xl border p-3">
<div className="flex items-center justify-between">
<div className="flex flex-col justify-between gap-4 sm:flex-row sm:items-center sm:gap-0">
<div>
<h2 className="text-emphasis text-sm font-medium leading-none">
{t("cal_ai_agent")}
@@ -757,34 +777,10 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
</div>
<Button
color="primary"
disabled={props.readOnly}
onClick={async () => {
// save the workflow first to get the step id
if (onSaveWorkflow) {
await onSaveWorkflow();
// After saving, get the updated step ID from the form
const updatedSteps = form.getValues("steps");
const currentStepIndex = step.stepNumber - 1;
const updatedStep = updatedSteps[currentStepIndex];
// Ensure the action is still set correctly after save
if (updatedStep.action !== WorkflowActions.CAL_AI_PHONE_CALL) {
form.setValue(`steps.${currentStepIndex}.action`, WorkflowActions.CAL_AI_PHONE_CALL);
}
if (updatedStep && updatedStep.id) {
// Create agent with the workflow step ID
createAgentMutation.mutate({
teamId,
workflowStepId: updatedStep.id,
});
} else {
showToast(t("failed_to_get_workflow_step_id"), "error");
}
}
}}
loading={createAgentMutation.isPending}>
disabled={props.readOnly || isCreatingAgent.current || hasAutoCreated.current}
className="flex items-center justify-center"
onClick={() => handleCreateAgent()}
loading={createAgentMutation.isPending || isCreatingAgent.current}>
{t("set_up_agent")}
</Button>
</div>
@@ -25,6 +25,7 @@ export function getWorkflowActionOptions(t: TFunction, isOrgsPlan?: boolean) {
label: actionString.charAt(0).toUpperCase() + actionString.slice(1),
value: action,
needsCredits: (!isOrgsPlan && isSMSOrWhatsappAction(action)) || isCalAIAction(action),
isCalAi: isCalAIAction(action),
};
});
}
+5 -25
View File
@@ -10,13 +10,11 @@ import Shell, { ShellMain } from "@calcom/features/shell/Shell";
import { WEBAPP_URL } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { useRouterQuery } from "@calcom/lib/hooks/useRouterQuery";
import { HttpError } from "@calcom/lib/http-error";
import type { WorkflowRepository } from "@calcom/lib/server/repository/workflow";
import { trpc } from "@calcom/trpc/react";
import classNames from "@calcom/ui/classNames";
import { Avatar } from "@calcom/ui/components/avatar";
import { AnimatedPopover } from "@calcom/ui/components/popover";
import { showToast } from "@calcom/ui/components/toast";
import { FilterResults } from "../../../filters/components/FilterResults";
import { TeamsFilter } from "../../../filters/components/TeamsFilter";
@@ -24,6 +22,7 @@ import { getTeamsFiltersFromQuery } from "../../../filters/lib/getTeamsFiltersFr
import LicenseRequired from "../../common/components/LicenseRequired";
import EmptyScreen from "../components/EmptyScreen";
import SkeletonLoader from "../components/SkeletonLoaderList";
import { WorkflowCreationDialog, useWorkflowCreation } from "../components/WorkflowCreationDialog";
import WorkflowList from "../components/WorkflowListPage";
type PageProps = {
@@ -36,6 +35,7 @@ function WorkflowsPage({ filteredList }: PageProps) {
const router = useRouter();
const routerQuery = useRouterQuery();
const filters = getTeamsFiltersFromQuery(routerQuery);
const { showDialog, setShowDialog, pendingTeamId, openDialog } = useWorkflowCreation();
const { data, isPending: _isPending } = trpc.viewer.workflows.filteredList.useQuery(
{
@@ -48,23 +48,6 @@ function WorkflowsPage({ filteredList }: PageProps) {
const filteredWorkflows = filteredList ?? data;
const isPending = filteredList ? false : _isPending;
const createMutation = trpc.viewer.workflows.create.useMutation({
onSuccess: async ({ workflow }) => {
await router.replace(`/workflows/${workflow.id}`);
},
onError: (err) => {
if (err instanceof HttpError) {
const message = `${err.statusCode}: ${err.message}`;
showToast(message, "error");
}
if (err.data?.code === "UNAUTHORIZED") {
const message = `${err.data.code}: ${t("error_workflow_unauthorized_create")}`;
showToast(message, "error");
}
},
});
return (
<Shell withoutMain>
<LicenseRequired>
@@ -77,10 +60,7 @@ function WorkflowsPage({ filteredList }: PageProps) {
session.data?.hasValidLicense ? (
<CreateButtonWithTeamsList
subtitle={t("new_workflow_subtitle").toUpperCase()}
createFunction={(teamId?: number) => {
createMutation.mutate({ teamId });
}}
isPending={createMutation.isPending}
createFunction={openDialog}
disableMobileButton={true}
onlyShowWithNoTeams={true}
includeOrg={true}
@@ -98,8 +78,7 @@ function WorkflowsPage({ filteredList }: PageProps) {
<div className="mb-4 ml-auto">
<CreateButtonWithTeamsList
subtitle={t("new_workflow_subtitle").toUpperCase()}
createFunction={(teamId?: number) => createMutation.mutate({ teamId })}
isPending={createMutation.isPending}
createFunction={openDialog}
disableMobileButton={true}
onlyShowWithTeams={true}
includeOrg={true}
@@ -120,6 +99,7 @@ function WorkflowsPage({ filteredList }: PageProps) {
</FilterResults>
</>
</ShellMain>
<WorkflowCreationDialog open={showDialog} onOpenChange={setShowDialog} teamId={pendingTeamId} />
</LicenseRequired>
</Shell>
);
@@ -2,6 +2,7 @@
import { zodResolver } from "@hookform/resolvers/zod";
import { useSession } from "next-auth/react";
import { useSearchParams } from "next/navigation";
import { useEffect, useState } from "react";
import { useForm } from "react-hook-form";
import { Toaster } from "sonner";
@@ -66,6 +67,7 @@ function WorkflowPage({
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
const [isEditingName, setIsEditingName] = useState(false);
const [nameValue, setNameValue] = useState("");
const searchParams = useSearchParams();
const form = useForm<FormValues>({
mode: "onBlur",
@@ -283,12 +285,16 @@ function WorkflowPage({
onSuccess: async ({ workflow }) => {
utils.viewer.workflows.get.setData({ id: +workflow.id }, workflow);
setFormData(workflow);
showToast(
t("workflow_updated_successfully", {
workflowName: workflow.name,
}),
"success"
);
const autoCreateAgent = searchParams?.get("autoCreateAgent");
if (!autoCreateAgent) {
showToast(
t("workflow_updated_successfully", {
workflowName: workflow.name,
}),
"success"
);
}
},
onError: (err) => {
if (err instanceof HttpError) {
+59
View File
@@ -0,0 +1,59 @@
"use client";
import { usePathname } from "next/navigation";
import { useState } from "react";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { localStorage } from "@calcom/lib/webstorage";
import { Icon } from "@calcom/ui/components/icon";
export function CalAiBanner() {
const { t } = useLocale();
const pathname = usePathname();
const [isVisible, setIsVisible] = useState(() => {
if (typeof window === "undefined") return true;
return !localStorage.getItem("calai-banner-dismissed");
});
const handleDismiss = () => {
localStorage.setItem("calai-banner-dismissed", "true");
setIsVisible(false);
};
const handleTryNow = () => {
window.open("/workflow/new?action=calAi&templateWorkflowId=wf-11", "_blank");
};
if (!isVisible) return null;
if (!(pathname === "/workflows" || pathname === "/event-types" || pathname === "/bookings/upcoming"))
return null;
return (
<div className="bg-launch-dark relative mb-6 w-full overflow-hidden rounded-lg text-white">
<button
onClick={handleDismiss}
className="bg-brand-default absolute right-2 top-2 z-10 rounded-[10px] p-2"
aria-label="Close banner">
<Icon name="x" className="h-4 w-4 text-white" />
</button>
<div className="flex flex-col md:flex-row">
<div className="flex-1 p-6 pr-6 lg:p-8">
<h2 className="font-cal font-subtle text-lg">{t("supercharge_your_workflows_with_cal_ai")}</h2>
<p className="text-subtle mb-4 text-sm">
{t("supercharge_your_workflows_with_cal_ai_description")}
</p>
<button
onClick={handleTryNow}
className="rounded-[10px] bg-gradient-to-b from-[#6349EA] to-[#875FE0] px-5 py-2 text-sm font-medium text-white hover:from-[#5A42D1] hover:to-[#7B6FD7]">
{t("try_now")}
</button>
</div>
<img src="/cal-ai-banner.svg" alt="Cal.ai Banner" className="mt-auto hidden h-40 md:block" />
</div>
</div>
);
}
+2
View File
@@ -17,6 +17,7 @@ import { Button } from "@calcom/ui/components/button";
import { ErrorBoundary } from "@calcom/ui/components/errorBoundary";
import { SkeletonText } from "@calcom/ui/components/skeleton";
import { CalAiBanner } from "./CalAiBanner";
import { SideBarContainer } from "./SideBar";
import { TopNavContainer } from "./TopNav";
import { BannerContainer } from "./banners/LayoutBanner";
@@ -205,6 +206,7 @@ function MainContainer({
{/* show top navigation for md and smaller (tablet and phones) */}
{TopNavContainerProp}
<div className="max-w-full p-2 sm:py-4 lg:px-6">
<CalAiBanner />
<ErrorBoundary>
{!props.withoutMain ? <ShellMain {...props}>{props.children}</ShellMain> : props.children}
</ErrorBoundary>
@@ -5,6 +5,7 @@ import React, { Fragment, useState, useEffect } from "react";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import useMediaQuery from "@calcom/lib/hooks/useMediaQuery";
import classNames from "@calcom/ui/classNames";
import { Badge } from "@calcom/ui/components/badge";
import { Icon } from "@calcom/ui/components/icon";
import type { IconName } from "@calcom/ui/components/icon";
import { SkeletonText } from "@calcom/ui/components/skeleton";
@@ -215,6 +216,11 @@ export const NavigationItem: React.FC<{
) : (
<SkeletonText className="h-[20px] w-full" />
)}
{item.name === "workflows" && (
<Badge startIcon="sparkles" variant="purple">
Cal.ai
</Badge>
)}
</Link>
</Tooltip>
)}
+77 -42
View File
@@ -6,7 +6,18 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import { localStorage } from "@calcom/lib/webstorage";
import { Card } from "@calcom/ui/components/card";
export const tips = [
type Tip = {
id: number;
thumbnailUrl: string;
mediaLink?: string;
title: string;
description: string;
href: string;
coverPhoto?: string;
variant?: "SidebarCard" | "NewLaunchSidebarCard";
};
export const tips: Tip[] = [
{
id: 17,
thumbnailUrl: "https://img.youtube.com/vi/fMHW6jYPIb8/0.jpg",
@@ -145,12 +156,22 @@ export const tips = [
},
];
const reversedTips = shuffle(tips).slice(0).reverse();
const CalAIWorkflowsTip: Tip = {
id: 18,
thumbnailUrl: "https://img.youtube.com/vi/fMHW6jYPIb8/0.jpg",
title: "cal_ai_workflows",
description: "supercharge_your_workflows_with_cal_ai_description",
href: "/workflows",
coverPhoto: "/cal-ai-workflow-sidebar.jpg",
variant: "NewLaunchSidebarCard",
};
const reversedTips = [...shuffle(tips).slice(0).reverse(), CalAIWorkflowsTip];
function Tips() {
const { t } = useLocale();
const [list, setList] = useState<typeof tips>(() => {
const [list, setList] = useState<Tip[]>(() => {
if (typeof window === "undefined") {
return reversedTips;
}
@@ -186,49 +207,63 @@ function Tips() {
const baseOriginalList = list.slice(0).reverse();
return (
<div
className="hidden pb-4 pt-8 lg:grid"
/* ref={animationRef} */
style={{
gridTemplateColumns: "1fr",
}}>
{list.map((tip) => {
const isTopTip = baseOriginalList.indexOf(tip) === 0;
return (
<div
className="relative"
style={{
gridRowStart: 1,
gridColumnStart: 1,
}}
key={tip.id}>
<>
<div
className="hidden pb-4 pt-8 lg:grid"
/* ref={animationRef} */
style={{
gridTemplateColumns: "1fr",
}}>
{list.map((tip) => {
const isTopTip = baseOriginalList.indexOf(tip) === 0;
const isCalAIWorkflowsTip = tip.title === "cal_ai_workflows";
return (
<div
className="relative"
style={{
transform: `scale(${1 - baseOriginalList.indexOf(tip) / 20})`,
top: -baseOriginalList.indexOf(tip) * 10,
opacity: `${1 - baseOriginalList.indexOf(tip) / 7}`,
}}>
<Card
variant="SidebarCard"
thumbnailUrl={tip.thumbnailUrl}
mediaLink={isTopTip ? tip.mediaLink : undefined}
title={tip.title}
description={tip.description}
learnMore={isTopTip ? { href: tip.href, text: t("learn_more") } : undefined}
actionButton={
isTopTip ? { onClick: () => handleRemoveItem(tip.id), child: t("dismiss") } : undefined
}
containerProps={{
tabIndex: isTopTip ? undefined : -1,
"aria-hidden": isTopTip ? undefined : "true",
}}
/>
gridRowStart: 1,
gridColumnStart: 1,
}}
key={tip.id}>
<div
className="relative"
style={{
transform: `scale(${1 - baseOriginalList.indexOf(tip) / 20})`,
top: -baseOriginalList.indexOf(tip) * 10,
opacity: `${1 - baseOriginalList.indexOf(tip) / 7}`,
}}>
<Card
variant={tip.variant ?? "SidebarCard"}
thumbnailUrl={tip.thumbnailUrl}
coverPhoto={tip.coverPhoto}
mediaLink={isTopTip ? tip.mediaLink : undefined}
title={t(tip.title)}
description={t(tip.description)}
learnMore={
isTopTip
? {
href: isCalAIWorkflowsTip
? "/workflow/new?action=calAi&templateWorkflowId=wf-11"
: tip.href,
text: isCalAIWorkflowsTip ? t("try_now") : t("learn_more"),
}
: undefined
}
actionButton={
isTopTip ? { onClick: () => handleRemoveItem(tip.id), child: t("dismiss") } : undefined
}
containerProps={{
tabIndex: isTopTip ? undefined : -1,
"aria-hidden": isTopTip ? undefined : "true",
}}
buttonClassName={isCalAIWorkflowsTip ? "text-white" : undefined}
/>
</div>
</div>
</div>
);
})}
</div>
);
})}
</div>
</>
);
}