// Zoho People API Response Types

export interface ZohoPeopleApiResponse<T> {
  status: string;
  message: string;
  data: T;
  timestamp: string;
}

export interface ApiInfo {
  count: number;
  moreRecords: boolean;
  page: number;
  message?: string;
  status?: number;
}

// Attendance Report Types
export interface AttendanceDetails {
  [date: string]: {
    ShiftStartTime: string;
    Status: string;
    FirstIn_Building: string;
    LastOut_Location: string;
    ShiftName: string;
    FirstIn_Latitude: string;
    FirstIn: string;
    LastOut_Latitude: string;
    FirstIn_Longitude: string;
    FirstIn_Location: string;
    TotalHours: string;
    LastOut_Longitude: string;
    WorkingHours: string;
    LastOut_Building: string;
    LastOut: string;
    ShiftEndTime: string;
    DeviationTime?: string;
    OverTime?: string;
  };
}

export interface EmployeeDetails {
  'mail id': string;
  erecno: string;
  'last name': string;
  'first name': string;
  id: string;
}

export interface AttendanceReportData {
  attendanceDetails: AttendanceDetails;
  employeeDetails: EmployeeDetails;
}

export interface AttendanceReportResponse {
  data: AttendanceReportData[];
  info: ApiInfo;
}

// Employee Forms Types
export interface EducationDetails {
  Specialization: string;
  Degree: string;
  College: string;
  Yearofgraduation: string;
  'tabular.ROWID': string;
}

export interface WorkExperience {
  Jobtitle: string;
  Employer: string;
  RELEVANCE: string;
  Previous_JobDesc: string;
  FromDate: string;
  Todate: string;
  'tabular.ROWID': string;
  'RELEVANCE.id': string;
}

export interface DependentDetails {
  [key: string]: any;
}

export interface TabularSections {
  'Education Details': EducationDetails[];
  'Work experience': WorkExperience[];
  'Dependent Details': DependentDetails[];
}

export interface PresentAddressChildValues {
  CITY: string;
  COUNTRY: string;
  STATE: string;
  ADDRESS1: string;
  PINCODE: string;
  ADDRESS2: string;
  STATE_CODE: string;
  COUNTRY_CODE: string;
}

export interface EmployeeFormData {
  EmailID: string;
  CreatedTime: string;
  'Employee_type.id': string;
  Date_of_birth: string;
  UAN_Number: string;
  AddedTime: string;
  Photo: string;
  Gender: string;
  Marital_status: string;
  ModifiedBy: string;
  ApprovalStatus: string;
  Department: string;
  'LocationName.ID': string;
  tabularSections: TabularSections;
  AddedBy: string;
  'Mobile.country_code': string;
  Tags: string;
  Reporting_To: string;
  Photo_downloadUrl: string;
  'Source_of_hire.id': string;
  'total_experience.displayValue': string;
  Employeestatus: string;
  Role: string;
  Experience: string;
  Employee_type: string;
  'AddedBy.ID': string;
  'Role.ID': string;
  LastName: string;
  Pan_Number: string;
  EmployeeID: string;
  ZUID: string;
  Aadhaar_Number: string;
  Dateofexit: string;
  Permanent_Address: string;
  Other_Email: string;
  LocationName: string;
  Work_location: string;
  Present_Address: string;
  Nick_Name: string;
  total_experience: string;
  ModifiedTime: string;
  'Reporting_To.MailID': string;
  Zoho_ID: number;
  'Designation.ID': string;
  Source_of_hire: string;
  Age: string;
  Designation: string;
  'Age.displayValue': string;
  'Marital_status.id': string;
  FirstName: string;
  AboutMe: string;
  Dateofjoining: string;
  'Experience.displayValue': string;
  Mobile: string;
  Extension: string;
  'ModifiedBy.ID': string;
  'Reporting_To.ID': string;
  Work_phone: string;
  'Employeestatus.type': number;
  'Department.ID': string;
  'Present_Address.childValues': PresentAddressChildValues;
  Expertise: string;
}

export interface EmployeeFormsResponse {
  data: { [employeeId: string]: EmployeeFormData[] }[];
  info: ApiInfo;
}

// Holidays Types
export interface HolidayData {
  ShiftName: string;
  LocationId: string;
  classificationType: number;
  ShiftId: string;
  classification: string;
  Date: string;
  Name: string;
  LocationName: string;
  isRestrictedHoliday: boolean;
  Remarks: string;
  Id: string;
  isHalfday: boolean;
  Session: number;
}

export interface HolidaysResponse {
  data: HolidayData[];
  info: ApiInfo;
}

// Leave Tracker Report Types
export interface LeaveType {
  unit: string;
  code: string;
  name: string;
  type: string;
}

export interface LeaveBalance {
  balance: number;
}

export interface LeaveTotals {
  unpaidBooked: number;
  unpaidBalance: number;
  paidBalance: number;
  paidBooked: number;
}

export interface EmployeeLeaveInfo {
  name: string;
  id: string;
}

export interface EmployeeLeaveReport {
  [leaveTypeId: string]: LeaveBalance;
  totals: LeaveTotals;
  employee: EmployeeLeaveInfo;
}

export interface LeaveTrackerReportData {
  leavetypes: { [leaveTypeId: string]: LeaveType };
  report: { [employeeId: string]: EmployeeLeaveReport };
  employees: string[];
}

export interface LeaveTrackerReportResponse {
  data: LeaveTrackerReportData[];
  info: ApiInfo;
}

// Leave Data Types
export interface LeaveDataItem {
  CreatedTime: string;
  Employee_ID: string;
  AddedTime: string;
  'Leavetype.ID': string;
  From: string;
  Unit: string;
  ModifiedBy: string;
  ApprovalStatus: string;
  Daystaken: string;
  Reasonforleave: string;
  'ModifiedBy.ID': string;
  TeamEmailID: string;
  Leavetype: string;
  ModifiedTime: string;
  Zoho_ID: number;
  'AddedBy.ID': string;
  To: string;
  AddedBy: string;
  'Employee_ID.ID': string;
  DateOfRequest: string;
}

export interface LeaveDataResponse {
  data: { [leaveId: string]: LeaveDataItem[] }[];
  info: ApiInfo;
}

// Dashboard State Types
export interface ZohoPeopleState {
  attendanceReport: AttendanceReportData[] | null;
  employeeForms: EmployeeFormData[] | null;
  holidays: HolidayData[] | null;
  leaveTracker: LeaveTrackerReportData | null;
  leaveData: LeaveDataItem[] | null;
  loading: boolean;
  error: string | null;
  lastUpdated: string | null;
}

// Dashboard Analytics Types
export interface AttendanceAnalytics {
  totalEmployees: number;
  presentToday: number;
  absentToday: number;
  weekendToday: number;
  averageWorkingHours: number;
  attendanceRate: number;
}

export interface EmployeeAnalytics {
  totalEmployees: number;
  activeEmployees: number;
  departmentDistribution: { [department: string]: number };
  genderDistribution: { [gender: string]: number };
  averageAge: number;
  averageExperience: number;
}

export interface LeaveAnalytics {
  totalLeaveBalance: number;
  paidLeaveBalance: number;
  unpaidLeaveBalance: number;
  upcomingLeaves: LeaveDataItem[];
  leaveUtilizationRate: number;
}

export interface HolidayAnalytics {
  upcomingHolidays: HolidayData[];
  totalHolidays: number;
  restrictedHolidays: number;
  halfDayHolidays: number;
}
