New alert system and panel de control page
This commit is contained in:
@@ -20,11 +20,13 @@ import { apiClient } from '../client';
|
||||
// ============================================================
|
||||
|
||||
export interface HealthChecklistItem {
|
||||
icon: 'check' | 'warning' | 'alert';
|
||||
icon: 'check' | 'warning' | 'alert' | 'ai_handled';
|
||||
text?: string; // Deprecated: Use textKey instead
|
||||
textKey?: string; // i18n key for translation
|
||||
textParams?: Record<string, any>; // Parameters for i18n translation
|
||||
actionRequired: boolean;
|
||||
status: 'good' | 'ai_handled' | 'needs_you'; // Tri-state status
|
||||
actionPath?: string; // Optional path to navigate for action
|
||||
}
|
||||
|
||||
export interface HeadlineData {
|
||||
@@ -40,6 +42,7 @@ export interface BakeryHealthStatus {
|
||||
checklistItems: HealthChecklistItem[];
|
||||
criticalIssues: number;
|
||||
pendingActions: number;
|
||||
aiPreventedIssues: number; // Count of issues AI prevented
|
||||
}
|
||||
|
||||
export interface ReasoningInputs {
|
||||
@@ -127,6 +130,53 @@ export interface ActionQueue {
|
||||
importantCount: number;
|
||||
}
|
||||
|
||||
// New unified action queue with time-based grouping
|
||||
export interface EnrichedAlert {
|
||||
id: string;
|
||||
alert_type: string;
|
||||
type_class: string;
|
||||
priority_level: string;
|
||||
priority_score: number;
|
||||
title: string;
|
||||
message: string;
|
||||
actions: Array<{
|
||||
type: string;
|
||||
label: string;
|
||||
variant: 'primary' | 'secondary' | 'ghost';
|
||||
metadata?: Record<string, any>;
|
||||
disabled?: boolean;
|
||||
estimated_time_minutes?: number;
|
||||
}>;
|
||||
urgency_context?: {
|
||||
deadline?: string;
|
||||
time_until_consequence_hours?: number;
|
||||
};
|
||||
alert_metadata?: {
|
||||
escalation?: {
|
||||
original_score: number;
|
||||
boost_applied: number;
|
||||
escalated_at: string;
|
||||
reason: string;
|
||||
};
|
||||
};
|
||||
business_impact?: {
|
||||
financial_impact_eur?: number;
|
||||
affected_orders?: number;
|
||||
};
|
||||
ai_reasoning_summary?: string;
|
||||
hidden_from_ui?: boolean;
|
||||
}
|
||||
|
||||
export interface UnifiedActionQueue {
|
||||
urgent: EnrichedAlert[]; // <6h to deadline or CRITICAL
|
||||
today: EnrichedAlert[]; // <24h to deadline
|
||||
week: EnrichedAlert[]; // <7d to deadline or escalated
|
||||
totalActions: number;
|
||||
urgentCount: number;
|
||||
todayCount: number;
|
||||
weekCount: number;
|
||||
}
|
||||
|
||||
export interface ProductionTimelineItem {
|
||||
id: string;
|
||||
batchNumber: string;
|
||||
@@ -234,7 +284,7 @@ export function useOrchestrationSummary(tenantId: string, runId?: string) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action queue
|
||||
* Get action queue (LEGACY - use useUnifiedActionQueue for new implementation)
|
||||
*
|
||||
* Prioritized list of what requires user attention right now.
|
||||
* This is the core JTBD dashboard feature.
|
||||
@@ -254,6 +304,31 @@ export function useActionQueue(tenantId: string) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get unified action queue with time-based grouping
|
||||
*
|
||||
* Returns all action-needed alerts grouped by urgency:
|
||||
* - URGENT: <6h to deadline or CRITICAL priority
|
||||
* - TODAY: <24h to deadline
|
||||
* - THIS WEEK: <7d to deadline or escalated (>48h pending)
|
||||
*
|
||||
* This is the NEW implementation for the redesigned Action Queue Card.
|
||||
*/
|
||||
export function useUnifiedActionQueue(tenantId: string) {
|
||||
return useQuery<UnifiedActionQueue>({
|
||||
queryKey: ['unified-action-queue', tenantId],
|
||||
queryFn: async () => {
|
||||
return await apiClient.get(
|
||||
`/tenants/${tenantId}/dashboard/unified-action-queue`
|
||||
);
|
||||
},
|
||||
enabled: !!tenantId,
|
||||
refetchInterval: 30000, // Refresh every 30 seconds (more frequent than legacy)
|
||||
staleTime: 15000,
|
||||
retry: 2,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get production timeline
|
||||
*
|
||||
@@ -294,6 +369,31 @@ export function useInsights(tenantId: string) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get execution progress - plan vs actual for today
|
||||
*
|
||||
* Shows how today's execution is progressing:
|
||||
* - Production: batches completed/in-progress/pending
|
||||
* - Deliveries: received/pending/overdue
|
||||
* - Approvals: pending count
|
||||
*
|
||||
* This is the NEW implementation for the ExecutionProgressTracker component.
|
||||
*/
|
||||
export function useExecutionProgress(tenantId: string) {
|
||||
return useQuery({
|
||||
queryKey: ['execution-progress', tenantId],
|
||||
queryFn: async () => {
|
||||
return await apiClient.get(
|
||||
`/tenants/${tenantId}/dashboard/execution-progress`
|
||||
);
|
||||
},
|
||||
enabled: !!tenantId,
|
||||
refetchInterval: 60000, // Refresh every minute
|
||||
staleTime: 30000,
|
||||
retry: 2,
|
||||
});
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Action Mutations
|
||||
// ============================================================
|
||||
|
||||
Reference in New Issue
Block a user