Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 0 additions & 85 deletions src/app/member/[id]/_components/member-role-card.tsx

This file was deleted.

68 changes: 68 additions & 0 deletions src/app/member/[id]/_components/role-kpi-pair.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"use client";

import { KpiCard } from "@/components/metric/kpi-card";
import { RoleCard, type RoleCardData } from "@/components/role/role-card";
import { cn } from "@/lib/utils";
import { type RouterOutputs } from "@/trpc/react";

type Role = RouterOutputs["role"]["getByUser"][number];
type DashboardChart = RouterOutputs["dashboard"]["getDashboardCharts"][number];

interface RoleKpiPairProps {
role: Role;
dashboardChart?: DashboardChart;
teamId: string;
}

export function RoleKpiPair({
role,
dashboardChart,
teamId,
}: RoleKpiPairProps) {
const roleCardData: RoleCardData = {
id: role.id,
title: role.title,
purpose: role.purpose,
color: role.color ?? "#3b82f6",
effortPoints: role.effortPoints,
assignedUserId: role.assignedUserId,
assignedUserName: role.assignedUserName,
metric: role.metric
? {
name: role.metric.name,
dashboardCharts: role.metric.dashboardCharts,
}
: null,
};

const hasKpi = !!dashboardChart;
const hasMetricButNoChart = !!role.metricId && !dashboardChart;

return (
<div
className={cn(
"grid items-stretch gap-3",
hasKpi || hasMetricButNoChart
? "grid-cols-1 lg:grid-cols-2"
: "grid-cols-1",
)}
>
<RoleCard role={roleCardData} readOnly className="h-full" />

{hasKpi && (
<KpiCard
dashboardChart={dashboardChart}
teamId={teamId}
showSettings={false}
enableDragDrop={false}
/>
)}

{hasMetricButNoChart && (
<div className="border-border/60 text-muted-foreground flex items-center justify-center rounded-lg border border-dashed p-6">
<span className="text-sm">KPI data loading...</span>
</div>
)}
Comment on lines +61 to +65
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Clarify the loading state message.

The message "KPI data loading..." might be misleading. This condition fires when role.metricId exists but no corresponding dashboardChart was found in the map. This could indicate:

  • The chart data hasn't been fetched yet
  • The metric exists but has no chart configured
  • A data inconsistency

Consider a more accurate message like "No KPI data available" or adding actual loading state tracking if the data is genuinely loading.

💬 Suggested alternative
 {hasMetricButNoChart && (
   <div className="border-border/60 text-muted-foreground flex items-center justify-center rounded-lg border border-dashed p-6">
-    <span className="text-sm">KPI data loading...</span>
+    <span className="text-sm">No KPI data available</span>
   </div>
 )}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{hasMetricButNoChart && (
<div className="border-border/60 text-muted-foreground flex items-center justify-center rounded-lg border border-dashed p-6">
<span className="text-sm">KPI data loading...</span>
</div>
)}
{hasMetricButNoChart && (
<div className="border-border/60 text-muted-foreground flex items-center justify-center rounded-lg border border-dashed p-6">
<span className="text-sm">No KPI data available</span>
</div>
)}
🤖 Prompt for AI Agents
In @src/app/member/[id]/_components/role-kpi-pair.tsx around lines 61 - 65, The
current placeholder shown when hasMetricButNoChart is true is ambiguous; update
the UI to distinguish between "no chart configured" and "still loading" by
either changing the message in the hasMetricButNoChart branch to a clearer
statement like "No KPI data available" (or "KPI chart not configured") and/or
wire in an explicit loading flag from where dashboardChart is populated;
specifically, update the JSX branch that checks hasMetricButNoChart (and
references role.metricId and the dashboardChart lookup) to show the clearer
static message or conditionalize on a new loading boolean so genuine loading
uses "Loading KPI data…" while missing chart shows "No KPI data available."

</div>
);
}
29 changes: 14 additions & 15 deletions src/app/member/[id]/_components/team-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from "@/components/ui/collapsible";
import { type RouterOutputs } from "@/trpc/react";

import { MemberRoleCard } from "./member-role-card";
import { RoleKpiPair } from "./role-kpi-pair";

type Role = RouterOutputs["role"]["getByUser"][number];
type DashboardMetrics = RouterOutputs["dashboard"]["getDashboardCharts"];
Expand Down Expand Up @@ -74,20 +74,19 @@ export function TeamSection({
</CollapsibleTrigger>

<CollapsibleContent>
<div className="border-border/60 border-t px-4 py-3">
<div className="grid grid-cols-1 gap-3 lg:grid-cols-2">
{roles.map((role) => (
<MemberRoleCard
key={role.id}
role={role}
dashboardChart={
role.metricId
? chartsByMetricId.get(role.metricId)
: undefined
}
/>
))}
</div>
<div className="border-border/60 space-y-4 border-t px-4 py-4">
{roles.map((role) => (
<RoleKpiPair
key={role.id}
role={role}
dashboardChart={
role.metricId
? chartsByMetricId.get(role.metricId)
: undefined
}
teamId={team.id}
/>
))}
</div>
</CollapsibleContent>
</div>
Expand Down