export type CompanyStatus = 'prospect' | 'lead' | 'customer' | 'inactive';

export type CompanyFormData = {
    name: string;
    branch_name: string;
    address_line1: string;
    address_line2: string;
    postal_code: string;
    city: string;
    country: string;
    phone_primary: string;
    phone_secondary: string;
    phone_mobile: string;
    email: string;
    website: string;
    activity_label: string;
    naf_code: string;
    siret: string;
    workforce_label: string;
    status: CompanyStatus;
    estimated_potential: string;
    last_contacted_at: string;
    next_follow_up_at: string;
    source: string;
    notes: string;
};

export type Company = {
    id: number;
    owner_id: number | null;
    name: string;
    branch_name: string | null;
    address_line1: string | null;
    address_line2: string | null;
    postal_code: string | null;
    city: string | null;
    country: string;
    phone_primary: string | null;
    phone_secondary: string | null;
    phone_mobile: string | null;
    email: string | null;
    website: string | null;
    activity_label: string | null;
    naf_code: string | null;
    siret: string | null;
    siren: string | null;
    oath_date: string | null;
    languages: string | null;
    workforce_label: string | null;
    status: CompanyStatus;
    estimated_potential: string | null;
    last_contacted_at: string | null;
    next_follow_up_at: string | null;
    source: string | null;
    contact_enrichment_source: string | null;
    contact_enrichment_url: string | null;
    contact_enrichment_notes: string | null;
    contact_enriched_at: string | null;
    contact_enriched_by: number | null;
    import_batch_id: string | null;
    directory_key: string | null;
    bar_association: string | null;
    lawyer_last_name: string | null;
    lawyer_first_name: string | null;
    notes: string | null;
    created_at: string;
    updated_at: string;
    contacts_count?: number;
    open_activities_count?: number;
};

export type CompanyContact = {
    id: number;
    company_id: number;
    first_name: string | null;
    last_name: string | null;
    full_name: string;
    job_title: string | null;
    email: string | null;
    phone: string | null;
    mobile: string | null;
    is_primary: boolean;
    last_contacted_at: string | null;
    notes: string | null;
    created_at: string;
    updated_at: string;
};

export type CompanyActivity = {
    id: number;
    company_id: number;
    company_contact_id: number | null;
    user_id: number | null;
    type: string;
    status: string;
    subject: string;
    details: string | null;
    occurred_at: string | null;
    due_at: string | null;
    metadata: Record<string, unknown> | null;
    created_at: string;
    updated_at: string;
    contact?: CompanyContact;
    user?: {
        id: number;
        name: string;
    };
};

export type CompanyProposal = {
    id: number;
    company_id: number;
    owner_id: number | null;
    reference: string;
    title: string;
    amount: string;
    status: 'draft' | 'sent' | 'accepted' | 'rejected';
    probability: number;
    sent_at: string | null;
    accepted_at: string | null;
    expires_at: string | null;
    notes: string | null;
    created_at: string;
    company: Pick<Company, 'id' | 'name' | 'city'>;
    owner?: { id: number; name: string };
};

export type CompanyContract = {
    id: number;
    company_id: number;
    proposal_id: number | null;
    owner_id: number | null;
    reference: string;
    title: string;
    amount: string;
    billing_frequency: 'one_off' | 'monthly' | 'annual';
    status: 'pending' | 'active' | 'ended' | 'cancelled';
    signed_at: string | null;
    starts_at: string | null;
    ends_at: string | null;
    notes: string | null;
    created_at: string;
    company: Pick<Company, 'id' | 'name' | 'city'>;
    proposal?: Pick<CompanyProposal, 'id' | 'reference'>;
    owner?: { id: number; name: string };
};

export type PaginationLink = {
    url: string | null;
    label: string;
    active: boolean;
};

export type Paginated<T> = {
    data: T[];
    current_page: number;
    from: number | null;
    to: number | null;
    total: number;
    last_page: number;
    links: PaginationLink[];
};
