import { Link, usePage } from '@inertiajs/react';
import type { ReactNode } from 'react';

import { withReturnTo } from '@/lib/admin-return-to';

type AddResourceLinkProps = {
    href: string;
    children: ReactNode;
};

export function AddResourceLink({ href, children }: AddResourceLinkProps) {
    const { url } = usePage();

    return (
        <Link
            href={withReturnTo(href, url)}
            className="mt-2 inline-flex text-xs font-medium text-[#0b7285] hover:text-[#095f6f] dark:text-[#d7c7ff] dark:hover:text-[#efe8ff]"
        >
            {children}
        </Link>
    );
}
