'use client'

import { Card } from '@/components/ui/card'

import { EmployeeCalendar } from './employee-calendar'
import { EmployeeCard } from './employee-card'
import { EmployeeStats } from './employee-stats'

interface Employee {
  id: string
  firstName: string
  lastName: string
  middleName?: string
  position: string
  phone: string
  email?: string
  avatar?: string
  hireDate: string
  status: 'ACTIVE' | 'VACATION' | 'SICK' | 'FIRED'
  salary?: number
  address?: string
  birthDate?: string
  passportSeries?: string
  passportNumber?: string
  passportIssued?: string
  passportDate?: string
  emergencyContact?: string
  emergencyPhone?: string
  telegram?: string
  whatsapp?: string
  passportPhoto?: string
  createdAt: string
  updatedAt: string
}

interface ScheduleRecord {
  id: string
  date: string
  status: string
  hoursWorked?: number
  overtimeHours?: number
  notes?: string
  employee: {
    id: string
    firstName: string
    lastName: string
  }
}

interface EmployeeItemProps {
  employee: Employee
  employeeSchedules: { [key: string]: ScheduleRecord[] }
  currentYear: number
  currentMonth: number
  onEdit: (employee: Employee) => void
  onDelete: (employeeId: string) => void
  onDayStatusChange: (employeeId: string, day: number, currentStatus: string) => void
  deletingEmployeeId: string | null
}

export function EmployeeItem({
  employee,
  employeeSchedules,
  currentYear,
  currentMonth,
  onEdit,
  onDelete,
  onDayStatusChange,
  deletingEmployeeId,
}: EmployeeItemProps) {
  return (
    <Card key={employee.id} className="glass-card p-6">
      <div className="flex flex-col lg:flex-row gap-6">
        {/* Информация о сотруднике */}
        <EmployeeCard employee={employee} onEdit={onEdit} onDelete={onDelete} deletingEmployeeId={deletingEmployeeId} />

        {/* Табель работы и статистика */}
        <div className="flex-1 space-y-4">
          <EmployeeCalendar
            employeeId={employee.id}
            employeeSchedules={employeeSchedules}
            currentYear={currentYear}
            currentMonth={currentMonth}
            onDayStatusChange={onDayStatusChange}
            onDayUpdate={() => {}} // Заглушка - функционал будет реализован позже
            employeeName={`${employee.firstName} ${employee.lastName}`}
          />

          {/* Статистика за месяц */}
          <EmployeeStats currentYear={currentYear} currentMonth={currentMonth} />
        </div>
      </div>
    </Card>
  )
}
