import React from 'react';
import { Link } from '@inertiajs/react';
import { ChevronLeft, ChevronRight } from 'lucide-react';

interface PaginationProps {
    links: Array<{
        url: string | null;
        label: string;
        active: boolean;
    }>;
    from?: number;
    to?: number;
    total?: number;
}

export const Pagination: React.FC<PaginationProps> = ({ links, from, to, total }) => {
    if (!links || links.length <= 3) return null;

    return (
        <div className="flex flex-col sm:flex-row items-center justify-between gap-4 px-6 py-4 bg-[#0B132B] border-t border-slate-800 text-xs">
            {total !== undefined && (
                <div className="text-slate-400">
                    Showing <span className="font-bold text-white">{from || 0}</span> to{' '}
                    <span className="font-bold text-white">{to || 0}</span> of{' '}
                    <span className="font-bold text-[#00F2FE]">{total}</span> items
                </div>
            )}

            <div className="flex items-center gap-1.5">
                {links.map((link, key) => {
                    if (link.url === null) {
                        return (
                            <div
                                key={key}
                                className="px-3 py-1.5 rounded-lg border border-slate-800 text-slate-600 cursor-not-allowed select-none text-xs"
                                dangerouslySetInnerHTML={{ __html: link.label }}
                            />
                        );
                    }

                    return (
                        <Link
                            key={key}
                            href={link.url}
                            className={`px-3 py-1.5 rounded-lg border text-xs font-semibold transition-all ${
                                link.active
                                    ? 'bg-[#00F2FE] text-[#060B18] border-[#00F2FE] shadow-md shadow-cyan-500/20'
                                    : 'bg-[#060B18] text-slate-300 border-slate-800 hover:border-[#00F2FE]/40 hover:text-white'
                            }`}
                            dangerouslySetInnerHTML={{ __html: link.label }}
                        />
                    );
                })}
            </div>
        </div>
    );
};
