2023-02-27 07:24:43 +00:00
|
|
|
import { useRouter } from "next/router";
|
2022-08-31 19:42:37 +00:00
|
|
|
|
2022-09-06 21:30:03 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2023-02-27 07:24:43 +00:00
|
|
|
import { HttpError } from "@calcom/lib/http-error";
|
|
|
|
import { trpc } from "@calcom/trpc/react";
|
|
|
|
import type { SVGComponent } from "@calcom/types/SVGComponent";
|
|
|
|
import { CreateButton, showToast, EmptyScreen as ClassicEmptyScreen } from "@calcom/ui";
|
2023-04-12 15:26:31 +00:00
|
|
|
import { Smartphone, Mail, Zap } from "@calcom/ui/components/icon";
|
2022-08-31 19:42:37 +00:00
|
|
|
|
|
|
|
type WorkflowExampleType = {
|
2022-12-18 10:44:44 +00:00
|
|
|
Icon: SVGComponent;
|
2022-08-31 19:42:37 +00:00
|
|
|
text: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
function WorkflowExample(props: WorkflowExampleType) {
|
|
|
|
const { Icon, text } = props;
|
|
|
|
|
|
|
|
return (
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="border-subtle mx-2 my-2 max-h-24 max-w-[600px] rounded-md border border-solid p-6">
|
2022-09-06 21:30:03 +00:00
|
|
|
<div className="flex ">
|
2022-09-13 18:57:23 +00:00
|
|
|
<div className="flex items-center justify-center">
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="bg-emphasis dark:bg-default mr-4 flex h-10 w-10 items-center justify-center rounded-full">
|
|
|
|
<Icon className="text-default h-6 w-6 stroke-[2px]" />
|
2022-08-31 19:42:37 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-09-13 18:57:23 +00:00
|
|
|
<div className="m-auto w-full flex-grow items-center justify-center ">
|
2023-04-12 12:15:08 +00:00
|
|
|
<div className="line-clamp-2 text-semibold text-emphasis w-full text-sm font-medium">{text}</div>
|
2022-08-31 19:42:37 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-02-27 07:24:43 +00:00
|
|
|
export default function EmptyScreen(props: {
|
|
|
|
profileOptions: {
|
|
|
|
label: string | null;
|
|
|
|
image?: string | null;
|
|
|
|
teamId: number | null | undefined;
|
2023-03-06 10:47:57 +00:00
|
|
|
slug: string | null;
|
2023-02-27 07:24:43 +00:00
|
|
|
}[];
|
|
|
|
isFilteredView: boolean;
|
2022-08-31 19:42:37 +00:00
|
|
|
}) {
|
2022-09-06 21:30:03 +00:00
|
|
|
const { t } = useLocale();
|
2023-02-27 07:24:43 +00:00
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
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}: You are not authorized to create this workflow`;
|
|
|
|
showToast(message, "error");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
2022-09-06 21:30:03 +00:00
|
|
|
|
|
|
|
const workflowsExamples = [
|
2023-04-12 15:26:31 +00:00
|
|
|
{ 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") },
|
2022-09-06 21:30:03 +00:00
|
|
|
];
|
2023-04-12 15:26:31 +00:00
|
|
|
// new workflow example when 'after meetings ends' trigger is implemented: Send custom thank you email to attendee after event (Smile icon),
|
2022-09-06 21:30:03 +00:00
|
|
|
|
2023-02-27 07:24:43 +00:00
|
|
|
if (props.isFilteredView) {
|
2023-04-12 15:26:31 +00:00
|
|
|
return <ClassicEmptyScreen Icon={Zap} headline={t("no_workflows")} description={t("change_filter")} />;
|
2023-02-27 07:24:43 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 19:42:37 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className="min-h-80 flex w-full flex-col items-center justify-center rounded-md ">
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="bg-emphasis flex h-[72px] w-[72px] items-center justify-center rounded-full">
|
2023-04-12 15:26:31 +00:00
|
|
|
<Zap className="dark:text-default inline-block h-10 w-10 stroke-[1.3px]" />
|
2022-08-31 19:42:37 +00:00
|
|
|
</div>
|
|
|
|
<div className="max-w-[420px] text-center">
|
2023-02-27 07:24:43 +00:00
|
|
|
<h2 className="text-semibold font-cal mt-6 text-xl dark:text-gray-300">{t("workflows")}</h2>
|
2023-04-05 18:14:46 +00:00
|
|
|
<p className="line-clamp-2 text-default mt-3 text-sm font-normal leading-6 dark:text-gray-300">
|
2023-02-27 07:24:43 +00:00
|
|
|
{t("no_workflows_description")}
|
2022-08-31 19:42:37 +00:00
|
|
|
</p>
|
2023-02-27 07:24:43 +00:00
|
|
|
<div className="mt-8 ">
|
|
|
|
<CreateButton
|
|
|
|
subtitle={t("new_workflow_subtitle").toUpperCase()}
|
|
|
|
options={props.profileOptions}
|
|
|
|
createFunction={(teamId?: number) => createMutation.mutate({ teamId })}
|
|
|
|
buttonText={t("create_workflow")}
|
|
|
|
isLoading={createMutation.isLoading}
|
|
|
|
/>
|
|
|
|
</div>
|
2022-08-31 19:42:37 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-02-27 07:24:43 +00:00
|
|
|
<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} />
|
|
|
|
))}
|
2022-08-31 19:42:37 +00:00
|
|
|
</div>
|
2023-02-27 07:24:43 +00:00
|
|
|
</div>
|
2022-08-31 19:42:37 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|