Pass domain to realtime components.

This commit is contained in:
Mike Cao 2023-02-24 02:41:02 -08:00
parent 7d3334ccce
commit 5657a64c77
8 changed files with 9 additions and 75 deletions

View file

@ -32,11 +32,12 @@ export default function RealtimeDashboard({ websiteId }) {
const router = useRouter();
const [currentData, setCurrentData] = useState();
const { get, useQuery } = useApi();
const { data: website } = useQuery(['websites', websiteId], () => get(`/websites/${websiteId}`));
const { data, isLoading, error } = useQuery(
['realtime', websiteId],
() => get(`/realtime/${websiteId}`, { startAt: currentData?.timestamp || 0 }),
{
enabled: !!websiteId,
enabled: !!(websiteId && website),
refetchInterval: REALTIME_INTERVAL,
cache: false,
},
@ -111,10 +112,10 @@ export default function RealtimeDashboard({ websiteId }) {
</div>
<GridRow>
<GridColumn xs={12} sm={12} md={12} lg={4} xl={4}>
<RealtimeUrls websiteId={websiteId} data={realtimeData} />
<RealtimeUrls websiteId={websiteId} websiteDomain={website?.domain} data={realtimeData} />
</GridColumn>
<GridColumn xs={12} sm={12} md={12} lg={8} xl={8}>
<RealtimeLog websiteId={websiteId} data={realtimeData} />
<RealtimeLog websiteId={websiteId} websiteDomain={website?.domain} data={realtimeData} />
</GridColumn>
</GridRow>
<GridRow>

View file

@ -17,10 +17,10 @@ export default function RealtimeHome() {
if (data?.length) {
router.push(`realtime/${data[0].id}`);
}
}, [data]);
}, [data, router]);
return (
<Page loading={isLoading || !data} error={error}>
<Page loading={isLoading || data?.length > 0} error={error}>
<PageHeader title={formatMessage(labels.realtime)} />
{data?.length === 0 && <EmptyPlaceholder message={formatMessage(messages.noWebsites)} />}
</Page>