feat: add timezone indicator on insights for unmatched timezone (#21568)
* feat: adds timezone indicator on insights informing user that user settings timezone is used instead of browser timezone * added i18 helper for translation * chore: use entities.decodeHTML instead of custom decoder * feat(insights): align TimezoneBadge with new timeZone prop flow * chore * chore: smaller icon * do not escape value --------- Co-authored-by: Kartik Saini <[email protected]> Co-authored-by: Eunjae Lee <[email protected]>
This commit is contained in:
4 files changed
+59
No files matched your search
@@ -0,0 +1,55 @@
|
||||
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>
|
||||
);
|
||||
};
|
||||
@@ -13,3 +13,4 @@ export { RecentFeedbackTable } from "./RecentFeedbackTable";
|
||||
export { RoutedToPerPeriod } from "./RoutedToPerPeriod";
|
||||
export { RoutingFormResponsesTable, type RoutingFormTableType } from "./RoutingFormResponsesTable";
|
||||
export { RoutingKPICards } from "./RoutingKPICards";
|
||||
export { TimezoneBadge } from "./TimezoneBadge";
|
||||
Reference in new issue
Block a user