export type EventType = "clock_in" | "clock_out" | "break_start" | "break_end";

export interface Employee {
  id: number;
  email: string;
  name: string | null;
  active: 0 | 1;
  created_at: string;
}

export interface AttendanceEvent {
  id: number;
  employee_id: number;
  type: EventType;
  ts: string;
}

export type ShiftSlotStatus = "open" | "full" | "closed";

export interface ShiftSlot {
  id: number;
  date: string;
  start_time: string;
  end_time: string;
  capacity: number;
  status: ShiftSlotStatus;
  note: string;
  generated: 0 | 1;
  created_at: string;
  updated_at: string;
}

export type ShiftSignupStatus = "approved" | "cancelled";

export interface ShiftSignup {
  id: number;
  slot_id: number;
  employee_id: number;
  status: ShiftSignupStatus;
  created_at: string;
  cancelled_at: string | null;
  cancelled_by: string | null;
}

export interface PayRate {
  id: number;
  employee_id: number;
  hourly_rate: number;
  valid_from: string;
  created_at: string;
}

export type ClosureStatus = "waiting_employee" | "confirmed" | "locked";

export interface MonthClosure {
  id: number;
  employee_id: number;
  period: string;
  status: ClosureStatus;
  employee_confirmed_at: string | null;
  locked_at: string | null;
}

export type PayrollStatus = "draft" | "ready" | "paid";

export interface Payroll {
  id: number;
  employee_id: number;
  period: string;
  worked_minutes: number;
  base_amount: number;
  tips_amount: number;
  bonus_amount: number;
  other_amount: number;
  final_amount: number;
  status: PayrollStatus;
  payment_date: string | null;
  updated_at: string;
}

export type Role = "admin" | "employee";

export interface SessionUser {
  email: string;
  name: string | null;
  role: Role;
  employeeId: number | null;
}

declare global {
  namespace Express {
    interface Request {
      user?: SessionUser;
    }
  }
}
