umami/pages/realtime/[id]/index.js

27 lines
865 B
JavaScript
Raw Normal View History

2023-02-15 11:27:18 +01:00
import { useRouter } from 'next/router';
import AppLayout from 'components/layout/AppLayout';
import RealtimeDashboard from 'components/pages/realtime/RealtimeDashboard';
2023-04-21 04:58:16 +02:00
import useMessages from 'hooks/useMessages';
import useApi from 'hooks/useApi';
2023-02-15 11:27:18 +01:00
export default function RealtimeDetailsPage() {
const router = useRouter();
const { id: websiteId } = router.query;
2023-04-21 04:58:16 +02:00
const { formatMessage, labels } = useMessages();
const { get, useQuery } = useApi();
2023-05-17 04:40:02 +02:00
const { data: website } = useQuery(['websites', websiteId], () => get(`/websites/${websiteId}`), {
enabled: !!websiteId,
});
2023-04-22 00:14:30 +02:00
const title = `${formatMessage(labels.realtime)}${website?.name ? ` - ${website.name}` : ''}`;
2023-02-15 11:27:18 +01:00
if (!websiteId) {
return null;
}
return (
2023-04-21 04:58:16 +02:00
<AppLayout title={title}>
2023-02-18 06:42:42 +01:00
<RealtimeDashboard key={websiteId} websiteId={websiteId} />
2023-02-15 11:27:18 +01:00
</AppLayout>
);
}