"use client";

import { memo } from "react";
import { NodeProps } from "reactflow";
import { Send } from "lucide-react";
import { CompactNodeShell } from "./CompactNodeShell";

export const HttpRequestActionNode = memo(({ data, selected }: NodeProps<any>) => {
  const method = data.method || "GET";
  const summary = data.url
    ? `${method} ${data.url}`
    : "요청 URL을 입력해 주세요";

  return (
    <CompactNodeShell
      color="#06B6D4"
      label={data.displayName || "HTTP 요청"}
      summary={summary}
      icon={<Send className="h-3.5 w-3.5" />}
      selected={selected}
    >
      {data.url && (
        <div className="flex items-center gap-1.5">
          <span className="rounded bg-cyan-500/20 px-1 py-0.5 font-mono text-[9px] font-semibold text-cyan-400">
            {method}
          </span>
          <span className="break-all font-mono">{data.url}</span>
        </div>
      )}
    </CompactNodeShell>
  );
});

HttpRequestActionNode.displayName = "HttpRequestActionNode";
