use dioxus::prelude::*;

#[component]
pub fn Pagination(
    current_page: u64,
    total_pages: u64,
    on_page_change: EventHandler<u64>,
) -> Element {
    if total_pages <= 1 {
        return rsx! {};
    }

    rsx! {
        div { class: "pagination",
            button {
                class: "btn btn-ghost",
                disabled: current_page <= 1,
                onclick: move |_| on_page_change.call(current_page.saturating_sub(1)),
                "Previous"
            }
            span {
                style: "color: var(--text-secondary); font-size: 14px;",
                "Page {current_page} of {total_pages}"
            }
            button {
                class: "btn btn-ghost",
                disabled: current_page >= total_pages,
                onclick: move |_| on_page_change.call(current_page + 1),
                "Next"
            }
        }
    }
}
