mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-06 22:16:28 +00:00
Add assignment validation and attention alerts
Validate project years and Work Order code availability, confirm before discarding unsaved changes, and surface critical or behind-schedule assignments in dashboard warnings and stats. Also update assignment form and dashboard labels.
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
Tooltip, TooltipContent, TooltipTrigger,
|
||||
} from '@/components/ui/tooltip';
|
||||
import { LazyImage } from '@/components/ui/lazy-image';
|
||||
import { Calendar, MoreVertical, ArrowUpRight, Clock } from 'lucide-react';
|
||||
import { Calendar, MoreVertical, ArrowUpRight, Clock, AlertTriangle } from 'lucide-react';
|
||||
import Link from 'next/link';
|
||||
import { cn } from '@/lib/utils';
|
||||
import ConvertedAssignmentBadge from './ConvertedAssignmentBadge';
|
||||
@@ -289,9 +289,54 @@ export default function AssignmentGrid({
|
||||
<div className="space-y-2 pt-2 border-t border-border/60">
|
||||
{/* Actual Progress (Real Work) matching detail page styling */}
|
||||
<div className="flex items-center justify-between text-xs font-mono font-medium">
|
||||
<span className="text-[10px] tracking-wider font-semibold text-his bg-his/10 px-1.5 py-0.5 rounded font-sans shrink-0">
|
||||
Actual
|
||||
</span>
|
||||
<div className="flex items-center gap-1.5 shrink-0">
|
||||
<span className="text-[10px] tracking-wider font-semibold text-his bg-his/10 px-1.5 py-0.5 rounded font-sans shrink-0">
|
||||
Actual
|
||||
</span>
|
||||
{item.hasWarning && (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<span
|
||||
tabIndex={0}
|
||||
role="button"
|
||||
aria-label={item.warningTitle}
|
||||
className={cn(
|
||||
"cursor-help inline-flex items-center justify-center transition-all focus:outline-none",
|
||||
item.isCriticalOrOffTrack
|
||||
? "text-rose-500 hover:text-rose-600 dark:text-rose-400"
|
||||
: "text-amber-500 hover:text-amber-600 dark:text-amber-400"
|
||||
)}
|
||||
>
|
||||
<AlertTriangle className="w-3.5 h-3.5 animate-pulse" />
|
||||
</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top" className="max-w-xs p-3 space-y-1.5 text-xs shadow-lg border border-border/80">
|
||||
<div className={cn(
|
||||
"flex items-center gap-1.5 font-semibold",
|
||||
item.isCriticalOrOffTrack
|
||||
? "text-rose-600 dark:text-rose-400"
|
||||
: "text-amber-600 dark:text-amber-400"
|
||||
)}>
|
||||
<AlertTriangle className="w-4 h-4 shrink-0" />
|
||||
<span>{item.warningTitle}</span>
|
||||
</div>
|
||||
<p className="text-[11px] text-muted-foreground leading-relaxed">
|
||||
{item.warningReason}
|
||||
</p>
|
||||
{item.warningDetails.length > 0 && (
|
||||
<div className="pt-1.5 border-t border-border/50 space-y-0.5 text-[10px] text-foreground font-mono">
|
||||
{item.warningDetails.map((detail, idx) => (
|
||||
<div key={idx} className="flex items-center gap-1.5">
|
||||
<span className={item.isCriticalOrOffTrack ? "text-rose-500 font-bold" : "text-amber-500 font-bold"}>•</span>
|
||||
<span>{detail}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
<div className="h-1.5 rounded-full bg-zinc-200 dark:bg-zinc-700/60 flex-1 mx-2.5 overflow-hidden">
|
||||
<div
|
||||
className="h-full rounded-full bg-his transition-all duration-700 ease-out"
|
||||
@@ -322,13 +367,6 @@ export default function AssignmentGrid({
|
||||
{/* Footer: Delivery Health Badge, Schedule, Latest Activity & Team Avatars */}
|
||||
<div className="pt-3 border-t border-border/60 flex items-center justify-between gap-2 text-xs">
|
||||
<div className="space-y-1 min-w-0 flex-1">
|
||||
<span className={cn(
|
||||
"inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-[11px] font-medium",
|
||||
item.healthBadgeClass
|
||||
)}>
|
||||
<span className={cn("h-1.5 w-1.5 rounded-full", item.healthDotClass)} />
|
||||
<span>{item.healthStatus}</span>
|
||||
</span>
|
||||
<p className="text-[11px] text-muted-foreground truncate">{item.remainingText}</p>
|
||||
<p
|
||||
className="text-[10px] text-muted-foreground/75 truncate flex items-center gap-1 font-sans"
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
Tooltip, TooltipContent, TooltipTrigger,
|
||||
} from '@/components/ui/tooltip';
|
||||
import { LazyImage } from '@/components/ui/lazy-image';
|
||||
import { Calendar, MoreVertical, ArrowUpRight, Clock, FolderGit2 } from 'lucide-react';
|
||||
import { Calendar, MoreVertical, ArrowUpRight, Clock, FolderGit2, AlertTriangle } from 'lucide-react';
|
||||
import Link from 'next/link';
|
||||
import { cn } from '@/lib/utils';
|
||||
import ConvertedAssignmentBadge from './ConvertedAssignmentBadge';
|
||||
@@ -155,8 +155,6 @@ export default function AssignmentList({
|
||||
<span>{item.assignmentType}</span>
|
||||
</span>
|
||||
|
||||
{/* Project Status Badge matching technical status badge colors */}
|
||||
<BadgeStatus status={assignment.project_assignment_status.name} />
|
||||
|
||||
{/* Code Pill with Tooltip */}
|
||||
{item.code ? (
|
||||
@@ -245,10 +243,58 @@ export default function AssignmentList({
|
||||
{/* 2. CENTER: Progress Bars (Actual Progress & Timeline) & 5-Node Stepper Track */}
|
||||
<div className="w-full xl:w-72 2xl:w-80 shrink-0 space-y-2 pt-2 xl:pt-0 border-t xl:border-t-0 border-border/60">
|
||||
{/* Actual Progress (Real Work) matching detail page styling */}
|
||||
<div className="flex items-center justify-between text-xs font-mono font-medium">
|
||||
<span className="text-[10px] tracking-wider font-semibold text-his bg-his/10 px-1.5 py-0.5 rounded font-sans shrink-0">
|
||||
Actual
|
||||
</span>
|
||||
<div className="flex items-center justify-between text-xs font-mono font-medium relative">
|
||||
<div className="flex items-center gap-1.5 shrink-0">
|
||||
<span className="text-[10px] tracking-wider font-semibold text-his bg-his/10 px-1.5 py-0.5 rounded font-sans shrink-0">
|
||||
Actual
|
||||
</span>
|
||||
{item.hasWarning && (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div
|
||||
tabIndex={0}
|
||||
role="button"
|
||||
aria-label={item.warningTitle}
|
||||
className={cn(
|
||||
"cursor-help absolute -right-6 flex items-center justify-center transition-all focus:outline-none",
|
||||
item.isCriticalOrOffTrack
|
||||
? "text-rose-500 hover:text-rose-600 dark:text-rose-400"
|
||||
: "text-amber-500 hover:text-amber-600 dark:text-amber-400"
|
||||
)}
|
||||
>
|
||||
<div className={`absolute rounded-full animate-pulse w-5 h-5 ${item.isCriticalOrOffTrack ? 'bg-rose-600/20 dark:bg-rose-400/20' : 'bg-amber-600/20 dark:bg-amber-400/20'}`}>
|
||||
|
||||
</div>
|
||||
<AlertTriangle className="w-3.5 h-3.5" />
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top" className="max-w-xs p-3 space-y-1.5 text-xs shadow-lg border border-border/80">
|
||||
<div className={cn(
|
||||
"flex items-center gap-1.5 font-semibold",
|
||||
item.isCriticalOrOffTrack
|
||||
? "text-rose-600 dark:text-rose-400"
|
||||
: "text-amber-600 dark:text-amber-400"
|
||||
)}>
|
||||
<AlertTriangle className="w-4 h-4 shrink-0" />
|
||||
<span>{item.warningTitle}</span>
|
||||
</div>
|
||||
<p className="text-[11px] text-muted-foreground leading-relaxed">
|
||||
{item.warningReason}
|
||||
</p>
|
||||
{item.warningDetails.length > 0 && (
|
||||
<div className="pt-1.5 border-t border-border/50 space-y-0.5 text-[10px] text-foreground font-mono">
|
||||
{item.warningDetails.map((detail, idx) => (
|
||||
<div key={idx} className="flex items-center gap-1.5">
|
||||
<span className={item.isCriticalOrOffTrack ? "text-rose-500 font-bold" : "text-amber-500 font-bold"}>•</span>
|
||||
<span>{detail}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
<div className="h-1.5 rounded-full bg-zinc-200 dark:bg-zinc-700/60 flex-1 mx-2.5 overflow-hidden">
|
||||
<div
|
||||
className="h-full rounded-full bg-his transition-all duration-700 ease-out"
|
||||
@@ -317,16 +363,8 @@ export default function AssignmentList({
|
||||
{/* 4. RIGHT: Delivery Health Badge, Schedule, Next Step & Updated */}
|
||||
<div className="flex items-center justify-between xl:justify-end gap-4 w-full xl:w-auto shrink-0 pt-2 xl:pt-0 border-t xl:border-t-0 border-border/60">
|
||||
<div className="space-y-1.5 min-w-0 xl:w-48 2xl:w-56 text-left">
|
||||
{/* Health Badge */}
|
||||
<div>
|
||||
<span className={cn(
|
||||
"inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0 text-[11px] font-semibold",
|
||||
item.healthBadgeClass
|
||||
)}>
|
||||
<span className={cn("h-1.5 w-1.5 rounded-full", item.healthDotClass)} />
|
||||
<span>{item.healthStatus}</span>
|
||||
</span>
|
||||
</div>
|
||||
{/* Project Status Badge matching technical status badge colors */}
|
||||
<BadgeStatus status={assignment.project_assignment_status.name} />
|
||||
|
||||
{/* Remaining days or completion date */}
|
||||
<p className="text-xs text-muted-foreground flex items-center gap-1.5 truncate">
|
||||
|
||||
+11
-35
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useMemo } from 'react';
|
||||
import { motion } from 'motion/react';
|
||||
import { Briefcase, FileText, Users, TrendingUp, CheckCircle2, AlertTriangle } from 'lucide-react';
|
||||
import { Briefcase, FileText, Users, AlertCircle, CheckCircle2, AlertTriangle } from 'lucide-react';
|
||||
import { Card900 } from '@/components/ui/card';
|
||||
import { IProjectAssignment } from '../../type.assignment';
|
||||
import { calculateDashboardStats } from '../../utils/assignment-overview-helpers';
|
||||
@@ -24,7 +24,7 @@ export default function ProjectAssignmentDashboardStats({
|
||||
Project Assignment Dashboard
|
||||
</h2>
|
||||
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 xl:grid-cols-6 gap-3 sm:gap-4">
|
||||
<div className="grid grid-cols-2 sm:grid-cols-4 xl:grid-cols-4 gap-3 sm:gap-4">
|
||||
{/* 1. Total Projects */}
|
||||
<motion.div initial={{ opacity: 0, y: 6 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.2 }}>
|
||||
<Card900 className="p-3.5 sm:p-5 rounded-2xl border border-border/80 bg-card hover:border-blue-500/30 transition-all flex flex-row items-center gap-3 md:gap-3.5 min-w-0 shadow-2xs">
|
||||
@@ -45,7 +45,7 @@ export default function ProjectAssignmentDashboardStats({
|
||||
<Briefcase className="w-5 h-5" />
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-xs text-muted-foreground truncate">Active Work Orders</p>
|
||||
<p className="text-xs text-muted-foreground truncate">Work Orders</p>
|
||||
<p className="text-lg sm:text-xl font-bold tracking-tight text-foreground">{stats.activeWorkOrders}</p>
|
||||
</div>
|
||||
</Card900>
|
||||
@@ -64,41 +64,17 @@ export default function ProjectAssignmentDashboardStats({
|
||||
</Card900>
|
||||
</motion.div>
|
||||
|
||||
{/* 4. Average Progress */}
|
||||
{/* 4. Needs Attention / Behind Schedule (Replaces Average Progress) */}
|
||||
<motion.div initial={{ opacity: 0, y: 6 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.2, delay: 0.09 }}>
|
||||
<Card900 className="p-3.5 sm:p-5 rounded-2xl border border-border/80 bg-card hover:border-orange-500/30 transition-all flex flex-row items-center gap-3 md:gap-3.5 min-w-0 shadow-2xs">
|
||||
<div className="h-10 w-10 sm:h-11 sm:w-11 rounded-xl bg-orange-500/10 dark:bg-orange-500/15 border border-orange-500/20 flex items-center justify-center shrink-0 text-orange-500 dark:text-orange-400">
|
||||
<TrendingUp className="w-5 h-5" />
|
||||
<Card900 className="p-3.5 sm:p-5 rounded-2xl border border-border/80 bg-card hover:border-amber-500/30 transition-all flex flex-row items-center gap-3 md:gap-3.5 min-w-0 shadow-2xs">
|
||||
<div className="h-10 w-10 sm:h-11 sm:w-11 rounded-xl bg-amber-500/10 dark:bg-amber-500/15 border border-amber-500/20 flex items-center justify-center shrink-0 text-amber-500 dark:text-amber-400">
|
||||
<AlertCircle className="w-5 h-5" />
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-xs text-muted-foreground truncate">Average Progress</p>
|
||||
<p className="text-lg sm:text-xl font-bold tracking-tight text-foreground">{stats.averageProgress}%</p>
|
||||
</div>
|
||||
</Card900>
|
||||
</motion.div>
|
||||
|
||||
{/* 5. On-Time Projects */}
|
||||
<motion.div initial={{ opacity: 0, y: 6 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.2, delay: 0.12 }}>
|
||||
<Card900 className="p-3.5 sm:p-5 rounded-2xl border border-border/80 bg-card hover:border-emerald-500/30 transition-all flex flex-row items-center gap-3 md:gap-3.5 min-w-0 shadow-2xs">
|
||||
<div className="h-10 w-10 sm:h-11 sm:w-11 rounded-xl bg-emerald-500/10 dark:bg-emerald-500/15 border border-emerald-500/20 flex items-center justify-center shrink-0 text-emerald-500 dark:text-emerald-400">
|
||||
<CheckCircle2 className="w-5 h-5" />
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-xs text-muted-foreground truncate">On-Time Projects</p>
|
||||
<p className="text-lg sm:text-xl font-bold tracking-tight text-foreground">{stats.onTimeRatio}</p>
|
||||
</div>
|
||||
</Card900>
|
||||
</motion.div>
|
||||
|
||||
{/* 6. At Risk / Delayed */}
|
||||
<motion.div initial={{ opacity: 0, y: 6 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.2, delay: 0.15 }}>
|
||||
<Card900 className="p-3.5 sm:p-5 rounded-2xl border border-border/80 bg-card hover:border-rose-500/30 transition-all flex flex-row items-center gap-3 md:gap-3.5 min-w-0 shadow-2xs">
|
||||
<div className="h-10 w-10 sm:h-11 sm:w-11 rounded-xl bg-rose-500/10 dark:bg-rose-500/15 border border-rose-500/20 flex items-center justify-center shrink-0 text-rose-500 dark:text-rose-400">
|
||||
<AlertTriangle className="w-5 h-5" />
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-xs text-muted-foreground truncate">At Risk / Delayed</p>
|
||||
<p className="text-lg sm:text-xl font-bold tracking-tight text-foreground">{stats.atRiskDelayed}</p>
|
||||
<p className="text-xs text-muted-foreground truncate" title="Assignments with Critical/Off Track status or actual progress lagging behind timeline">
|
||||
Needs Attention
|
||||
</p>
|
||||
<p className="text-lg sm:text-xl font-bold tracking-tight text-foreground">{stats.needsAttention}</p>
|
||||
</div>
|
||||
</Card900>
|
||||
</motion.div>
|
||||
|
||||
Reference in New Issue
Block a user