import { WebhookAnalyticsTooltip } from '@/analytics/components/WebhookAnalyticsTooltip'; import { ANALYTICS_GRAPH_DESCRIPTION_MAP } from '@/analytics/constants/AnalyticsGraphDescriptionMap'; import { ANALYTICS_GRAPH_TITLE_MAP } from '@/analytics/constants/AnalyticsGraphTitleMap'; import { useGraphData } from '@/analytics/hooks/useGraphData'; import { analyticsGraphDataComponentState } from '@/analytics/states/analyticsGraphDataComponentState'; import { AnalyticsComponentProps as AnalyticsActivityGraphProps } from '@/analytics/types/AnalyticsComponentProps'; import { computeAnalyticsGraphDataFunction } from '@/analytics/utils/computeAnalyticsGraphDataFunction'; import { Select } from '@/ui/input/components/Select'; import { useRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentStateV2'; import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; import { ResponsiveLine } from '@nivo/line'; import { Section } from '@react-email/components'; import { useId, useState } from 'react'; import { H2Title } from 'twenty-ui'; const StyledGraphContainer = styled.div` background-color: ${({ theme }) => theme.background.secondary}; border: 1px solid ${({ theme }) => theme.border.color.medium}; border-radius: ${({ theme }) => theme.border.radius.md}; height: 199px; padding: ${({ theme }) => theme.spacing(4, 2, 2, 2)}; width: 496px; `; const StyledTitleContainer = styled.div` align-items: flex-start; display: flex; justify-content: space-between; `; export const AnalyticsActivityGraph = ({ recordId, endpointName, }: AnalyticsActivityGraphProps) => { const [analyticsGraphData, setAnalyticsGraphData] = useRecoilComponentStateV2( analyticsGraphDataComponentState, ); const theme = useTheme(); const [windowLengthGraphOption, setWindowLengthGraphOption] = useState< '7D' | '1D' | '12H' | '4H' >('7D'); const { fetchGraphData } = useGraphData({ recordId, endpointName, }); const transformDataFunction = computeAnalyticsGraphDataFunction(endpointName); const dropdownId = useId(); return ( <> {analyticsGraphData.length ? (