import type { Paginated, SelectOption } from '@/types/common';

export type { SelectOption } from '@/types/common';

export type PayrollPeriodItem = {
    id: number;
    year: number;
    month: number;
    period_label: string;
    status: string;
    status_label: string;
    closed_at_formatted: string | null;
};

export type PayrollAdjustmentItem = {
    id: number;
    payroll_id: number;
    type: string;
    type_label: string;
    amount: number;
    amount_formatted: string;
    description: string;
    created_at_formatted: string;
    created_by_name: string;
};

export type PayrollListItem = {
    id: number;
    employee_id: number;
    employee_name: string;
    base_salary: number;
    base_salary_formatted: string;
    bonus_amount: number;
    bonus_amount_formatted: string;
    deduction_amount: number;
    deduction_amount_formatted: string;
    total_amount: number;
    total_amount_formatted: string;
    status: string;
    status_label: string;
    paid_at_formatted: string | null;
    can_pay: boolean;
    can_adjust: boolean;
    adjustments?: PayrollAdjustmentItem[];
};

export type PayrollSummary = {
    total_amount: number;
    total_amount_formatted: string;
    total_count: number;
    status: string;
    status_label: string;
};

export type PayrollAdjustmentFormData = {
    type: string;
    amount: string;
    description: string;
};

export type PaginatedPayrolls = Paginated<PayrollListItem>;

export type PayrollPageProps = {
    periods: PayrollPeriodItem[];
    currentPeriod: PayrollPeriodItem | null;
    payrolls: PaginatedPayrolls | null;
    summary: PayrollSummary | null;
    adjustmentTypes: SelectOption[];
    filters: {
        search: string;
        sort?: string;
        direction?: 'asc' | 'desc';
        period_id?: number;
    };
};
