Tasks: level badge (Client/Policy/Group) on task cards, fetch policyGroup data

This commit is contained in:
lorentz 2026-03-31 18:08:08 +00:00
parent 0d8edc97da
commit 0ac872a4da
3 changed files with 24 additions and 0 deletions

View file

@ -42,6 +42,7 @@ interface Task {
notes: string | null
client: { id: string; name: string } | null
policy: { id: string; policyNumber: string | null; policyType: string | null; expirationDate: string | Date } | null
policyGroup: { id: string; name: string | null; renewalDate: string | Date | null } | null
assignments: TaskAssignment[]
taskNotes: TaskNote[]
}
@ -158,6 +159,13 @@ function TaskCard({ task: initial }: { task: Task }) {
</h3>
<StatusBadge status={task.status} />
<PriorityDot priority={task.priority} />
{task.policyGroup ? (
<span className="inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium bg-purple-500/10 text-purple-700 dark:text-purple-400">Group</span>
) : task.policy ? (
<span className="inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium bg-blue-500/10 text-blue-700 dark:text-blue-400">Policy</span>
) : (
<span className="inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium bg-muted text-muted-foreground">Client</span>
)}
{notes.length > 0 && (
<span className="inline-flex items-center gap-1 text-xs text-muted-foreground">
<MessageSquare className="h-3 w-3" />{notes.length}
@ -177,6 +185,14 @@ function TaskCard({ task: initial }: { task: Task }) {
<span className="font-medium">{task.client.name}</span>
</span>
)}
{task.policyGroup && (
<span>
<span className="text-muted-foreground">Group:</span>{' '}
<span className="font-medium">
{task.policyGroup.name ?? (task.policyGroup.renewalDate ? formatDate(task.policyGroup.renewalDate) : task.policyGroup.id)}
</span>
</span>
)}
{task.policy && (
<span>
<span className="text-muted-foreground">Policy:</span>{' '}

View file

@ -20,6 +20,7 @@ export default async function TasksPage() {
include: {
client: { select: { id: true, name: true } },
policy: { select: { id: true, policyNumber: true, policyType: true, expirationDate: true } },
policyGroup: { select: { id: true, name: true, renewalDate: true } },
assignments: {
include: { user: { select: { displayName: true, email: true } } },
},

View file

@ -64,6 +64,13 @@ export async function GET(request: NextRequest) {
expirationDate: true,
},
},
policyGroup: {
select: {
id: true,
name: true,
renewalDate: true,
},
},
assignments: {
include: {
user: {