3.03 Registratura Termene Legale recipient registration, audit log, expiry tracking
- Added recipientRegNumber/recipientRegDate fields for outgoing docs (deadline triggers from recipient registration date) - Added prelungire-CU deadline type in catalog (15 calendar days, tacit approval) - CU category already first in catalog verified - DeadlineAuditEntry interface + audit log on TrackedDeadline (created/resolved entries) - Document expiry tracking: expiryDate + expiryAlertDays with live countdown - Web scraping prep fields: externalStatusUrl + externalTrackingId - Dashboard: 6 stat cards (added missing recipient + expiring soon) - Alert banners for missing recipient data and expiring documents - Version bump to 0.2.0
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
'use client';
|
||||
"use client";
|
||||
|
||||
import { Clock, CheckCircle2, X } from 'lucide-react';
|
||||
import { Badge } from '@/shared/components/ui/badge';
|
||||
import { Button } from '@/shared/components/ui/button';
|
||||
import type { TrackedDeadline } from '../types';
|
||||
import { getDeadlineType } from '../services/deadline-catalog';
|
||||
import { getDeadlineDisplayStatus } from '../services/deadline-service';
|
||||
import { cn } from '@/shared/lib/utils';
|
||||
import { useState } from "react";
|
||||
import { Clock, CheckCircle2, X, History } from "lucide-react";
|
||||
import { Badge } from "@/shared/components/ui/badge";
|
||||
import { Button } from "@/shared/components/ui/button";
|
||||
import type { TrackedDeadline } from "../types";
|
||||
import { getDeadlineType } from "../services/deadline-catalog";
|
||||
import { getDeadlineDisplayStatus } from "../services/deadline-service";
|
||||
import { cn } from "@/shared/lib/utils";
|
||||
|
||||
interface DeadlineCardProps {
|
||||
deadline: TrackedDeadline;
|
||||
@@ -15,78 +16,156 @@ interface DeadlineCardProps {
|
||||
}
|
||||
|
||||
const VARIANT_CLASSES: Record<string, string> = {
|
||||
green: 'border-green-500/30 bg-green-50 dark:bg-green-950/20',
|
||||
yellow: 'border-yellow-500/30 bg-yellow-50 dark:bg-yellow-950/20',
|
||||
red: 'border-red-500/30 bg-red-50 dark:bg-red-950/20',
|
||||
blue: 'border-blue-500/30 bg-blue-50 dark:bg-blue-950/20',
|
||||
gray: 'border-muted bg-muted/30',
|
||||
green: "border-green-500/30 bg-green-50 dark:bg-green-950/20",
|
||||
yellow: "border-yellow-500/30 bg-yellow-50 dark:bg-yellow-950/20",
|
||||
red: "border-red-500/30 bg-red-50 dark:bg-red-950/20",
|
||||
blue: "border-blue-500/30 bg-blue-50 dark:bg-blue-950/20",
|
||||
gray: "border-muted bg-muted/30",
|
||||
};
|
||||
|
||||
const BADGE_CLASSES: Record<string, string> = {
|
||||
green: 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200',
|
||||
yellow: 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200',
|
||||
red: 'bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200',
|
||||
blue: 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200',
|
||||
gray: 'bg-muted text-muted-foreground',
|
||||
green: "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",
|
||||
yellow:
|
||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",
|
||||
red: "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",
|
||||
blue: "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",
|
||||
gray: "bg-muted text-muted-foreground",
|
||||
};
|
||||
|
||||
export function DeadlineCard({ deadline, onResolve, onRemove }: DeadlineCardProps) {
|
||||
export function DeadlineCard({
|
||||
deadline,
|
||||
onResolve,
|
||||
onRemove,
|
||||
}: DeadlineCardProps) {
|
||||
const def = getDeadlineType(deadline.typeId);
|
||||
const status = getDeadlineDisplayStatus(deadline);
|
||||
const [showAudit, setShowAudit] = useState(false);
|
||||
const auditLog = deadline.auditLog ?? [];
|
||||
|
||||
return (
|
||||
<div className={cn('flex items-center gap-3 rounded-lg border p-3', VARIANT_CLASSES[status.variant] ?? '')}>
|
||||
<Clock className="h-4 w-4 shrink-0 text-muted-foreground" />
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-sm font-medium truncate">{def?.label ?? deadline.typeId}</span>
|
||||
<Badge className={cn('text-[10px] border-0', BADGE_CLASSES[status.variant] ?? '')}>
|
||||
{status.label}
|
||||
{status.daysRemaining !== null && status.variant !== 'blue' && (
|
||||
<span className="ml-1">
|
||||
({status.daysRemaining < 0 ? `${Math.abs(status.daysRemaining)}z depășit` : `${status.daysRemaining}z`})
|
||||
</span>
|
||||
<div
|
||||
className={cn(
|
||||
"rounded-lg border p-3",
|
||||
VARIANT_CLASSES[status.variant] ?? "",
|
||||
)}
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<Clock className="h-4 w-4 shrink-0 text-muted-foreground" />
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-sm font-medium truncate">
|
||||
{def?.label ?? deadline.typeId}
|
||||
</span>
|
||||
<Badge
|
||||
className={cn(
|
||||
"text-[10px] border-0",
|
||||
BADGE_CLASSES[status.variant] ?? "",
|
||||
)}
|
||||
>
|
||||
{status.label}
|
||||
{status.daysRemaining !== null && status.variant !== "blue" && (
|
||||
<span className="ml-1">
|
||||
(
|
||||
{status.daysRemaining < 0
|
||||
? `${Math.abs(status.daysRemaining)}z depășit`
|
||||
: `${status.daysRemaining}z`}
|
||||
)
|
||||
</span>
|
||||
)}
|
||||
</Badge>
|
||||
</div>
|
||||
<div className="text-xs text-muted-foreground mt-0.5">
|
||||
{def?.isBackwardDeadline ? "Termen limită" : "Start"}:{" "}
|
||||
{formatDate(deadline.startDate)}
|
||||
{" → "}
|
||||
{def?.isBackwardDeadline ? "Depunere până la" : "Termen"}:{" "}
|
||||
{formatDate(deadline.dueDate)}
|
||||
{def?.dayType === "working" && (
|
||||
<span className="ml-1">(zile lucrătoare)</span>
|
||||
)}
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-xs text-muted-foreground mt-0.5">
|
||||
{def?.isBackwardDeadline ? 'Termen limită' : 'Start'}: {formatDate(deadline.startDate)}
|
||||
{' → '}
|
||||
{def?.isBackwardDeadline ? 'Depunere până la' : 'Termen'}: {formatDate(deadline.dueDate)}
|
||||
{def?.dayType === 'working' && <span className="ml-1">(zile lucrătoare)</span>}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-1 shrink-0">
|
||||
{deadline.resolution === 'pending' && (
|
||||
<div className="flex gap-1 shrink-0">
|
||||
{auditLog.length > 0 && (
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7 text-muted-foreground"
|
||||
onClick={() => setShowAudit(!showAudit)}
|
||||
title="Istoric modificări"
|
||||
>
|
||||
<History className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
)}
|
||||
{deadline.resolution === "pending" && (
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7 text-green-600"
|
||||
onClick={() => onResolve(deadline)}
|
||||
title="Rezolvă"
|
||||
>
|
||||
<CheckCircle2 className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7 text-green-600"
|
||||
onClick={() => onResolve(deadline)}
|
||||
title="Rezolvă"
|
||||
className="h-7 w-7 text-destructive"
|
||||
onClick={() => onRemove(deadline.id)}
|
||||
title="Șterge"
|
||||
>
|
||||
<CheckCircle2 className="h-3.5 w-3.5" />
|
||||
<X className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7 text-destructive"
|
||||
onClick={() => onRemove(deadline.id)}
|
||||
title="Șterge"
|
||||
>
|
||||
<X className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{/* Audit log */}
|
||||
{showAudit && auditLog.length > 0 && (
|
||||
<div className="mt-2 border-t pt-2 space-y-1">
|
||||
<p className="text-[10px] font-medium text-muted-foreground uppercase tracking-wider">
|
||||
Istoric modificări
|
||||
</p>
|
||||
{auditLog.map((entry, i) => (
|
||||
<div key={i} className="flex items-start gap-2 text-[11px]">
|
||||
<span className="text-muted-foreground whitespace-nowrap">
|
||||
{formatDateTime(entry.timestamp)}
|
||||
</span>
|
||||
{entry.actor && (
|
||||
<span className="font-medium">{entry.actor}</span>
|
||||
)}
|
||||
<span className="text-muted-foreground">{entry.detail}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function formatDate(iso: string): string {
|
||||
try {
|
||||
return new Date(iso).toLocaleDateString('ro-RO', { day: '2-digit', month: '2-digit', year: 'numeric' });
|
||||
return new Date(iso).toLocaleDateString("ro-RO", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
});
|
||||
} catch {
|
||||
return iso;
|
||||
}
|
||||
}
|
||||
|
||||
function formatDateTime(iso: string): string {
|
||||
try {
|
||||
return new Date(iso).toLocaleString("ro-RO", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
});
|
||||
} catch {
|
||||
return iso;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user