* refactor: update PopuplarEvents chart to use InsightsBookingService * use buildHashMapForUsers * refactor least booked * refactor charts * combine methods * refactor booking kpi cards * remove unused code * fix booking kpi cards * restore code that was removed accidentally * Revert "restore code that was removed accidentally" This reverts commit 0c0b444b02498b94fb29ef470da065bad3ad7ece. * Revert "fix booking kpi cards" This reverts commit b1e8e9afbd3632a5239495566551ae12bd926b66. * refactor booking kpi cards * revert method and remove unused code * fix previous period * fix metrics * clean up trpc call params * clean up Download.tsx * split utils * restructure folders for components * clean up imports * rename TotalUserFeedbackTable to UserStatsTable * add guide * use client * add curly braces to case * fix tests
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
"use client";
|
|
|
|
import { useMemo } from "react";
|
|
|
|
import { useDataTable } from "@calcom/features/data-table";
|
|
import NoSSR from "@calcom/lib/components/NoSSR";
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { CURRENT_TIMEZONE } from "@calcom/lib/timezoneConstants";
|
|
import { Badge } from "@calcom/ui/components/badge";
|
|
import { Icon } from "@calcom/ui/components/icon";
|
|
import { Tooltip } from "@calcom/ui/components/tooltip";
|
|
|
|
const TimezoneBadgeContent = () => {
|
|
const { t } = useLocale();
|
|
const { timeZone: userTimezone } = useDataTable();
|
|
|
|
const timezoneData = useMemo(() => {
|
|
// Use Cal's standard CURRENT_TIMEZONE constant
|
|
const browserTimezone = CURRENT_TIMEZONE;
|
|
|
|
if (!browserTimezone || !userTimezone || browserTimezone === userTimezone) return null;
|
|
|
|
const tooltipContent = t("timezone_mismatch_tooltip", {
|
|
browserTimezone,
|
|
userTimezone,
|
|
interpolation: { escapeValue: false },
|
|
});
|
|
|
|
return {
|
|
browser: browserTimezone,
|
|
user: userTimezone,
|
|
tooltipContent,
|
|
badgeContent: userTimezone,
|
|
};
|
|
}, [userTimezone, t]);
|
|
|
|
// Don't render anything if no timezone mismatch
|
|
if (!timezoneData) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<Tooltip content={timezoneData.tooltipContent}>
|
|
<Badge variant="gray" size="sm" data-testid="timezone-mismatch-badge">
|
|
<Icon name="info" />
|
|
</Badge>
|
|
</Tooltip>
|
|
);
|
|
};
|
|
|
|
export const TimezoneBadge = () => {
|
|
return (
|
|
<NoSSR fallback={null}>
|
|
<TimezoneBadgeContent />
|
|
</NoSSR>
|
|
);
|
|
};
|