"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { Button } from "../ui/button";

export const CreateKeyButton = (props: { keyAuthId: string }) => {
  const href = `/app/keys/${props.keyAuthId}/new`;
  const path = usePathname();
  const setUrl = () => {
    window.location.href = href;
  };
  if (path?.match(href)) {
    return (
      <Button onClick={setUrl} variant="secondary">
        创建客服
      </Button>
    );
  }
  return (
    <Link key="new" href={href}>
      <Button variant="secondary">Create Key</Button>
    </Link>
  );
};
