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

export function buildStaffTemplate(entities: ExtractedEntities): ReportPart {
  return {
    type: 'report',
    title: `Staff Roster & Productivity Report`,
    summary: `Roster analysis for **"${entities.query}"**. **35 of 49** floor staff are currently checked in across all outlets. **Sneha R** leads network productivity with 312 transactions.`,
    kpis: [
      {id: 'stk1', title: 'Active Floor Staff', value: '35 / 49', trend: '14 Absent', iconName: 'staff'},
      {id: 'stk2', title: 'Network Avg Score', value: '88.4', trend: '+2.1', trendDirection: 'up', iconName: 'leaderboard'},
      {id: 'stk3', title: 'Shift Transactions', value: '1,240', iconName: 'purchases'},
    ],
    tables: [
      {
        title: 'Top Staff Performance Leaderboard',
        columns: [
          {key: 'name', header: 'Staff Member'},
          {key: 'store', header: 'Assigned Outlet'},
          {key: 'txns', header: 'Transactions', align: 'end'},
          {key: 'score', header: 'Score', align: 'end'},
          {key: 'status', header: 'Shift Status', align: 'center'},
        ],
        rows: [
          {name: 'Sneha R', store: 'Indiranagar Flagship', txns: '312', score: '94', status: 'active'},
          {name: 'Rohit K', store: 'Koramangala 80ft', txns: '287', score: '91', status: 'active'},
          {name: 'Ravi M', store: 'Jayanagar 4th Block', txns: '264', score: '88', status: 'active'},
          {name: 'Priya Sharma', store: 'Whitefield Main', txns: '198', score: '82', status: 'active'},
        ],
      },
    ],
    insights: [
      {
        id: 'sti1',
        type: 'risk',
        title: 'Whitefield Shift Roster Coverage Shortage',
        explanation: 'Absence is concentrated at Whitefield Main (4 staff members missing during peak evening hours).',
        confidence: 93,
        recommendedAction: 'Reassign 2 floaters from Koramangala shift roster.',
      },
    ],
    actions: [
      {id: 'sta1', label: 'Open Staff Roster Manager', actionType: 'open_dashboard', iconName: 'staff'},
    ],
  };
}
