/** * TypeScript types for the employee management module. */ // ── Departments ────────────────────────────────────────────── export interface Department { id: string; organisation_id: string; name: string; created_at: string; } // ── Employees ──────────────────────────────────────────────── export type EmploymentType = "full_time" | "part_time" | "casual" | "contractor"; export type PayFrequency = "weekly" | "fortnightly" | "monthly"; export type EmployeeStatus = "active" | "on_leave" | "terminated"; export interface Employee { id: string; organisation_id: string; user_id: string | null; first_name: string; last_name: string; email: string; phone: string | null; date_of_birth: string | null; address: string | null; job_title: string | null; department_id: string | null; employment_type: EmploymentType; start_date: string | null; end_date: string | null; salary: number | null; hourly_rate: number | null; pay_frequency: PayFrequency; status: EmployeeStatus; manager_id: string | null; created_at: string; } export interface EmployeeWithRelations extends Employee { department: Department | null; department_name?: string; manager: { first_name: string; last_name: string } | null; employee_roles?: any[]; resignation_status?: string; resignation_date?: string; resignation_reason?: string; } // ── Pending Invitations ────────────────────────────────────── export type InvitationStatus = "pending" | "accepted" | "expired"; export interface PendingInvitation { id: string; organisation_id: string; email: string; token: string; role: string; status: InvitationStatus; invited_by: string | null; expires_at: string; created_at: string; } // ── Form Inputs ────────────────────────────────────────────── export interface CreateEmployeeInput { first_name: string; last_name: string; email: string; phone?: string; date_of_birth?: string; address?: string; job_title?: string; department_id?: string; employment_type: EmploymentType; start_date?: string; salary?: number; hourly_rate?: number; pay_frequency: PayFrequency; manager_id?: string; } export interface UpdateEmployeeInput { first_name?: string; last_name?: string; email?: string; phone?: string | null; date_of_birth?: string; address?: string | null; job_title?: string | null; department_id?: string | null; employment_type?: EmploymentType; start_date?: string; end_date?: string | null; salary?: number | null; hourly_rate?: number | null; pay_frequency?: PayFrequency; status?: EmployeeStatus; manager_id?: string | null; } // ── Helpers ────────────────────────────────────────────────── export const EMPLOYMENT_TYPE_LABELS: Record = { full_time: "Full time", part_time: "Part time", casual: "Casual", contractor: "Contractor", }; export const PAY_FREQUENCY_LABELS: Record = { weekly: "Weekly", fortnightly: "Fortnightly", monthly: "Monthly", }; export const EMPLOYEE_STATUS_LABELS: Record = { active: "Active", on_leave: "On leave", terminated: "Terminated", }; export function getInitials(first: string, last: string): string { return `${first.charAt(0)}${last.charAt(0)}`.toUpperCase(); } export function formatCurrency(amount: number | null, frequency?: string): string { if (amount == null) return "—"; const formatted = `$${amount.toLocaleString()}`; return frequency ? `${formatted}/${frequency === "monthly" ? "mo" : frequency === "fortnightly" ? "fn" : "wk"}` : formatted; }