import type {ExtractedEntities} from '../promptRouter';
import type {ReportPart} from '@/features/loyaly-ai/types/chat';

export function buildGeneralTemplate(entities: ExtractedEntities): ReportPart {
  const query = entities.query;

  return {
    type: 'report',
    title: `AI Business Assistance: ${query.length > 30 ? query.slice(0, 30) + '...' : query}`,
    summary: `I analyzed your inquiry: **"${query}"** against active network store data. Here is an overview of relevant metrics and recommended operational next steps.`,
    kpis: [
      {id: 'gk1', title: 'Network Stores', value: '4 Active', iconName: 'stores'},
      {id: 'gk2', title: 'Monthly Revenue', value: '₹14.99L', trend: '+4.8%', iconName: 'revenue'},
      {id: 'gk3', title: 'Active Customers', value: '14,250', iconName: 'visitors'},
    ],
    insights: [
      {
        id: 'gi1',
        type: 'growth',
        title: 'Contextual AI Assistance',
        explanation: `Based on your request regarding "${query}", you can inspect performance directly across your dashboard or run targeted store comparisons.`,
        confidence: 90,
        recommendedAction: 'Explore store analytics or loyalty reward settings.',
      },
    ],
    actions: [
      {id: 'ga1', label: 'Open Main Dashboard', actionType: 'open_dashboard', iconName: 'dashboard'},
      {id: 'ga2', label: 'Compare Stores', actionType: 'compare_stores', iconName: 'stores'},
    ],
  };
}
