Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 2s
111 lines
3.8 KiB
TypeScript
111 lines
3.8 KiB
TypeScript
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<string | null>(null);
|
|
const [dateRange, setDateRange] = useState({ start: '', end: '' });
|
|
const [chartName, setChartName] = useState<string | undefined>();
|
|
|
|
const typeOptions: SelectOption[] = useMemo(
|
|
() => [
|
|
['Conversations', t('Conversations')],
|
|
['Productivity', t('Productivity')],
|
|
],
|
|
[t],
|
|
);
|
|
|
|
const graphOptions: SelectOption[] = useOptions(type);
|
|
|
|
useEffect(() => {
|
|
setChartName(graphOptions[0][0]);
|
|
}, [graphOptions]);
|
|
|
|
return (
|
|
<Page>
|
|
<PageHeader title={t('Analytics')} />
|
|
<PageScrollableContentWithShadow display='flex' flexDirection='column'>
|
|
<Margins block={4}>
|
|
<Box display='flex' marginInline='neg-x4' flexWrap='wrap' flexGrow={1}>
|
|
<Box display='flex' flexWrap='wrap' flexGrow={1}>
|
|
<Box display='flex' marginInline={4} flexDirection='column' flexGrow={1}>
|
|
<Label marginBlock={4}>{t('Type')}</Label>
|
|
<Select options={typeOptions} value={type} onChange={(value) => setType(String(value))} />
|
|
</Box>
|
|
<Box display='flex' marginInline={4} flexDirection='column' flexGrow={1}>
|
|
<Label marginBlock={4}>{t('Departments')}</Label>
|
|
<AutoCompleteDepartment
|
|
value={department || undefined}
|
|
onChange={setDepartment}
|
|
onlyMyDepartments
|
|
withTitle={false}
|
|
renderItem={({ label, ...props }) => <Option {...props} label={<span style={{ whiteSpace: 'normal' }}>{label}</span>} />}
|
|
/>
|
|
</Box>
|
|
</Box>
|
|
<DateRangePicker flexGrow={1} marginInline={4} onChange={setDateRange} />
|
|
</Box>
|
|
<Box>
|
|
<Overview type={type} dateRange={dateRange} departmentId={department || ''} />
|
|
</Box>
|
|
<Box display='flex'>
|
|
<Margins inline={2}>
|
|
<Field>
|
|
<FieldLabel>{t('Chart')}</FieldLabel>
|
|
<FieldRow>
|
|
<Select options={graphOptions} value={chartName} onChange={(value) => setChartName(String(value))} />
|
|
</FieldRow>
|
|
</Field>
|
|
</Margins>
|
|
</Box>
|
|
<Box display='flex' flexGrow={1} flexShrink={1}>
|
|
<InterchangeableChart
|
|
flexShrink={1}
|
|
width='66%'
|
|
height='100%'
|
|
chartName={chartName || ''}
|
|
departmentId={department || ''}
|
|
dateRange={dateRange}
|
|
alignSelf='stretch'
|
|
/>
|
|
<Box display='flex' width='33%' justifyContent='stretch' padding={10} marginInlineStart={4}>
|
|
<AgentOverview type={chartName || ''} dateRange={dateRange} departmentId={department || ''} />
|
|
</Box>
|
|
</Box>
|
|
</Margins>
|
|
</PageScrollableContentWithShadow>
|
|
</Page>
|
|
);
|
|
};
|
|
|
|
export default AnalyticsPage;
|