wip
This commit is contained in:
@@ -2,8 +2,11 @@ import { useSuspenseQuery } from '@tanstack/react-query';
|
||||
import { createFileRoute, Link } from '@tanstack/react-router';
|
||||
import { UsersIcon } from 'lucide-react';
|
||||
import FullPageLoadingState from '@/components/full-page-loading-state';
|
||||
import { GroupMemberGrowth } from '@/components/groups/group-member-growth';
|
||||
import { OverviewMetricCard } from '@/components/overview/overview-metric-card';
|
||||
import { WidgetHead, WidgetTitle } from '@/components/overview/overview-widget';
|
||||
import { MostEvents } from '@/components/profiles/most-events';
|
||||
import { PopularRoutes } from '@/components/profiles/popular-routes';
|
||||
import { ProfileActivity } from '@/components/profiles/profile-activity';
|
||||
import { KeyValueGrid } from '@/components/ui/key-value-grid';
|
||||
import { Widget, WidgetBody } from '@/components/widget';
|
||||
@@ -50,6 +53,15 @@ function Component() {
|
||||
const members = useSuspenseQuery(
|
||||
trpc.group.members.queryOptions({ id: groupId, projectId })
|
||||
);
|
||||
const mostEvents = useSuspenseQuery(
|
||||
trpc.group.mostEvents.queryOptions({ id: groupId, projectId })
|
||||
);
|
||||
const popularRoutes = useSuspenseQuery(
|
||||
trpc.group.popularRoutes.queryOptions({ id: groupId, projectId })
|
||||
);
|
||||
const memberGrowth = useSuspenseQuery(
|
||||
trpc.group.memberGrowth.queryOptions({ id: groupId, projectId })
|
||||
);
|
||||
|
||||
const g = group.data;
|
||||
const m = metrics.data?.[0];
|
||||
@@ -142,8 +154,23 @@ function Component() {
|
||||
<ProfileActivity data={activity.data} />
|
||||
</div>
|
||||
|
||||
{/* Members preview */}
|
||||
{/* Member growth */}
|
||||
<div className="col-span-1">
|
||||
<GroupMemberGrowth data={memberGrowth.data} />
|
||||
</div>
|
||||
|
||||
{/* Top events */}
|
||||
<div className="col-span-1">
|
||||
<MostEvents data={mostEvents.data} />
|
||||
</div>
|
||||
|
||||
{/* Popular routes */}
|
||||
<div className="col-span-1">
|
||||
<PopularRoutes data={popularRoutes.data} />
|
||||
</div>
|
||||
|
||||
{/* Members preview */}
|
||||
<div className="col-span-1 md:col-span-2">
|
||||
<Widget className="w-full">
|
||||
<WidgetHead>
|
||||
<WidgetTitle icon={UsersIcon}>Members</WidgetTitle>
|
||||
|
||||
@@ -104,20 +104,16 @@ function Component() {
|
||||
<ProfileMetrics data={metrics.data} />
|
||||
</div>
|
||||
{/* Profile properties - full width */}
|
||||
<div className="col-span-1 md:col-span-2">
|
||||
<div className="col-span-1 flex flex-col gap-3 md:col-span-2">
|
||||
<ProfileProperties profile={profile.data!} />
|
||||
</div>
|
||||
|
||||
{/* Groups - full width, only if profile belongs to groups */}
|
||||
{profile.data?.groups?.length ? (
|
||||
<div className="col-span-1 md:col-span-2">
|
||||
{profile.data?.groups?.length ? (
|
||||
<ProfileGroups
|
||||
profileId={profileId}
|
||||
projectId={projectId}
|
||||
groups={profile.data.groups}
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{/* Heatmap / Activity */}
|
||||
<div className="col-span-1">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { IServiceEvent, IServiceSession } from '@openpanel/db';
|
||||
import { useSuspenseQuery } from '@tanstack/react-query';
|
||||
import { useSuspenseQuery, useQuery } from '@tanstack/react-query';
|
||||
import { createFileRoute, Link } from '@tanstack/react-router';
|
||||
import { EventIcon } from '@/components/events/event-icon';
|
||||
import FullPageLoadingState from '@/components/full-page-loading-state';
|
||||
@@ -165,6 +165,14 @@ function Component() {
|
||||
})
|
||||
);
|
||||
|
||||
const { data: sessionGroups } = useQuery({
|
||||
...trpc.group.listByIds.queryOptions({
|
||||
projectId,
|
||||
ids: session.groups ?? [],
|
||||
}),
|
||||
enabled: (session.groups?.length ?? 0) > 0,
|
||||
});
|
||||
|
||||
const fakeEvent = sessionToFakeEvent(session);
|
||||
|
||||
return (
|
||||
@@ -324,6 +332,35 @@ function Component() {
|
||||
</Widget>
|
||||
)}
|
||||
|
||||
{/* Group cards */}
|
||||
{sessionGroups && sessionGroups.length > 0 && (
|
||||
<Widget className="w-full">
|
||||
<WidgetHead>
|
||||
<WidgetTitle>Groups</WidgetTitle>
|
||||
</WidgetHead>
|
||||
<WidgetBody className="p-0">
|
||||
{sessionGroups.map((group) => (
|
||||
<Link
|
||||
key={group.id}
|
||||
className="row items-center gap-3 p-4 transition-colors hover:bg-accent"
|
||||
params={{ organizationId, projectId, groupId: group.id }}
|
||||
to="/$organizationId/$projectId/groups/$groupId"
|
||||
>
|
||||
<div className="col min-w-0 flex-1 gap-0.5">
|
||||
<span className="truncate font-medium">{group.name}</span>
|
||||
<span className="truncate text-muted-foreground text-sm font-mono">
|
||||
{group.id}
|
||||
</span>
|
||||
</div>
|
||||
<span className="shrink-0 rounded border px-1.5 py-0.5 text-muted-foreground text-xs">
|
||||
{group.type}
|
||||
</span>
|
||||
</Link>
|
||||
))}
|
||||
</WidgetBody>
|
||||
</Widget>
|
||||
)}
|
||||
|
||||
{/* Visited pages */}
|
||||
<VisitedRoutes
|
||||
paths={events
|
||||
|
||||
Reference in New Issue
Block a user