'use client';

import Link from 'next/link';

/**
 * "Edit this form ↗" at the top of a create panel (create-form.js:189, 229): the object's create
 * form editor, in a new tab. The Leads create drawer had it first; EV9 adds it to Events'.
 */
export function CreateFormEditLink({ objectKey }: { objectKey: string }) {
  return (
    <p className="cf-editlink cc-editlink">
      <Link
        href={`/create-form-editor?object=${encodeURIComponent(objectKey)}`}
        target="_blank"
        rel="noopener"
      >
        Edit this form
        <svg
          className="icon iconSize-14"
          viewBox="0 0 24 24"
          fill="none"
          stroke="currentColor"
          strokeWidth="2"
          aria-hidden
        >
          <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14 21 3" />
        </svg>
        <span className="crm-visually-hidden"> (opens in a new tab)</span>
      </Link>
    </p>
  );
}
