2023-03-28 23:24:57 +00:00
|
|
|
import { getFeatureFlagMap } from "@calcom/features/flags/server/utils";
|
2023-03-23 22:10:01 +00:00
|
|
|
import {
|
|
|
|
AverageEventDurationChart,
|
|
|
|
BookingKPICards,
|
|
|
|
BookingStatusLineChart,
|
|
|
|
LeastBookedTeamMembersTable,
|
|
|
|
MostBookedTeamMembersTable,
|
|
|
|
PopularEventsTable,
|
|
|
|
} from "@calcom/features/insights/components";
|
|
|
|
import { FiltersProvider } from "@calcom/features/insights/context/FiltersProvider";
|
|
|
|
import { Filters } from "@calcom/features/insights/filters";
|
|
|
|
import Shell from "@calcom/features/shell/Shell";
|
|
|
|
import { UpgradeTip } from "@calcom/features/tips";
|
|
|
|
import { WEBAPP_URL } from "@calcom/lib/constants";
|
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
|
|
import { trpc } from "@calcom/trpc";
|
|
|
|
import { Button, ButtonGroup } from "@calcom/ui";
|
2023-04-12 15:26:31 +00:00
|
|
|
import { RefreshCcw, UserPlus, Users } from "@calcom/ui/components/icon";
|
2023-03-23 22:10:01 +00:00
|
|
|
|
|
|
|
const Heading = () => {
|
|
|
|
const { t } = useLocale();
|
2023-04-04 11:58:19 +00:00
|
|
|
|
2023-03-23 22:10:01 +00:00
|
|
|
return (
|
2023-04-04 11:58:19 +00:00
|
|
|
<div className="min-w-52 hidden md:block">
|
2023-04-05 18:14:46 +00:00
|
|
|
<h3 className="font-cal max-w-28 sm:max-w-72 md:max-w-80 text-emphasis truncate text-xl font-semibold tracking-wide xl:max-w-full">
|
2023-04-04 11:58:19 +00:00
|
|
|
{t("analytics_for_organisation")}
|
2023-03-23 23:17:12 +00:00
|
|
|
</h3>
|
2023-04-05 18:14:46 +00:00
|
|
|
<p className="text-default hidden text-sm md:block">{t("subtitle_analytics")}</p>
|
2023-03-23 22:10:01 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function InsightsPage() {
|
|
|
|
const { t } = useLocale();
|
|
|
|
const { data: user } = trpc.viewer.me.useQuery();
|
|
|
|
const features = [
|
|
|
|
{
|
2023-04-12 15:26:31 +00:00
|
|
|
icon: <Users className="h-5 w-5" />,
|
2023-03-23 22:10:01 +00:00
|
|
|
title: t("view_bookings_across"),
|
|
|
|
description: t("view_bookings_across_description"),
|
|
|
|
},
|
|
|
|
{
|
2023-04-12 15:26:31 +00:00
|
|
|
icon: <RefreshCcw className="h-5 w-5" />,
|
2023-03-23 22:10:01 +00:00
|
|
|
title: t("identify_booking_trends"),
|
|
|
|
description: t("identify_booking_trends_description"),
|
|
|
|
},
|
|
|
|
{
|
2023-04-12 15:26:31 +00:00
|
|
|
icon: <UserPlus className="h-5 w-5" />,
|
2023-03-23 22:10:01 +00:00
|
|
|
title: t("spot_popular_event_types"),
|
|
|
|
description: t("spot_popular_event_types_description"),
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Shell>
|
|
|
|
<UpgradeTip
|
|
|
|
title={t("make_informed_decisions")}
|
|
|
|
description={t("make_informed_decisions_description")}
|
|
|
|
features={features}
|
2023-04-10 21:14:28 +00:00
|
|
|
background="/tips/insights"
|
2023-03-23 22:10:01 +00:00
|
|
|
buttons={
|
|
|
|
<div className="space-y-2 rtl:space-x-reverse sm:space-x-2">
|
|
|
|
<ButtonGroup>
|
|
|
|
<Button color="primary" href={`${WEBAPP_URL}/settings/teams/new`}>
|
|
|
|
{t("create_team")}
|
|
|
|
</Button>
|
2023-04-10 21:14:28 +00:00
|
|
|
<Button color="minimal" href="https://go.cal.com/insights" target="_blank">
|
2023-03-23 22:10:01 +00:00
|
|
|
{t("learn_more")}
|
|
|
|
</Button>
|
|
|
|
</ButtonGroup>
|
|
|
|
</div>
|
|
|
|
}>
|
|
|
|
{!user ? (
|
|
|
|
<></>
|
|
|
|
) : (
|
|
|
|
<FiltersProvider>
|
2023-04-04 11:58:19 +00:00
|
|
|
<div className="mb-8 mt-0 ml-auto flex w-full flex-wrap justify-between md:-mt-8">
|
2023-03-23 22:10:01 +00:00
|
|
|
<Heading />
|
|
|
|
<Filters />
|
|
|
|
</div>
|
|
|
|
<div className="mb-4 space-y-6">
|
|
|
|
<BookingKPICards />
|
|
|
|
|
|
|
|
<BookingStatusLineChart />
|
|
|
|
|
|
|
|
<div className="grid grid-cols-1 gap-5 md:grid-cols-2">
|
|
|
|
<PopularEventsTable />
|
|
|
|
|
|
|
|
<AverageEventDurationChart />
|
|
|
|
</div>
|
|
|
|
<div className="grid grid-cols-1 gap-5 md:grid-cols-2">
|
|
|
|
<MostBookedTeamMembersTable />
|
|
|
|
<LeastBookedTeamMembersTable />
|
|
|
|
</div>
|
2023-04-05 18:14:46 +00:00
|
|
|
<small className="text-default block text-center">
|
|
|
|
{t("looking_for_more_insights")}{" "}
|
2023-03-23 22:10:01 +00:00
|
|
|
<a
|
|
|
|
className="text-blue-500 hover:underline"
|
|
|
|
href="mailto:updates@cal.com?subject=Feature%20Request%3A%20More%20Analytics&body=Hey%20Cal.com%20Team%2C%20I%20love%20the%20analytics%20page%20but%20I%20am%20looking%20for%20...">
|
|
|
|
{" "}
|
|
|
|
{t("contact_support")}
|
|
|
|
</a>
|
|
|
|
</small>
|
|
|
|
</div>
|
|
|
|
</FiltersProvider>
|
|
|
|
)}
|
|
|
|
</UpgradeTip>
|
|
|
|
</Shell>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2023-03-28 23:24:57 +00:00
|
|
|
|
|
|
|
// If feature flag is disabled, return not found on getServerSideProps
|
|
|
|
export const getServerSideProps = async () => {
|
|
|
|
const prisma = await import("@calcom/prisma").then((mod) => mod.default);
|
|
|
|
const flags = await getFeatureFlagMap(prisma);
|
|
|
|
|
|
|
|
if (flags.insights === false) {
|
|
|
|
return {
|
|
|
|
notFound: true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
props: {},
|
|
|
|
};
|
|
|
|
};
|