import type { SelectOption } from '@rocket.chat/fuselage'; import { Box, Select, Margins, Field, FieldLabel, FieldRow, Label, Option } from '@rocket.chat/fuselage'; import { Page, PageHeader, PageScrollableContentWithShadow } from '@rocket.chat/ui-client'; import { useMemo, useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import AgentOverview from './AgentOverview'; import DateRangePicker from './DateRangePicker'; import InterchangeableChart from './InterchangeableChart'; import Overview from './Overview'; import AutoCompleteDepartment from '../components/AutoCompleteDepartment'; const useOptions = (type: string): SelectOption[] => { const { t } = useTranslation(); return useMemo(() => { if (type === 'Conversations') { return [ ['Total_conversations', t('Total_conversations')], ['Avg_chat_duration', t('Avg_chat_duration')], ['Total_messages', t('Total_messages')], ]; } return [ ['Avg_first_response_time', t('Avg_first_response_time')], ['Best_first_response_time', t('Best_first_response_time')], ['Avg_response_time', t('Avg_response_time')], ['Avg_reaction_time', t('Avg_reaction_time')], ]; }, [t, type]); }; const AnalyticsPage = () => { const { t } = useTranslation(); const [type, setType] = useState('Conversations'); const [department, setDepartment] = useState(null); const [dateRange, setDateRange] = useState({ start: '', end: '' }); const [chartName, setChartName] = useState(); const typeOptions: SelectOption[] = useMemo( () => [ ['Conversations', t('Conversations')], ['Productivity', t('Productivity')], ], [t], ); const graphOptions: SelectOption[] = useOptions(type); useEffect(() => { setChartName(graphOptions[0][0]); }, [graphOptions]); return ( setChartName(String(value))} /> ); }; export default AnalyticsPage;