import { CheckCircle2, Circle, TrashIcon } from "lucide-react";
import { Button } from "@/src/components/ui/button";
import { type PromptVariable } from "@langfuse/shared";
import { CodeMirrorEditor } from "@/src/components/editor";
import { usePlaygroundContext } from "../context";
import { useNamingConflicts } from "../hooks/useNamingConflicts";
export const PromptVariableComponent: React.FC<{
promptVariable: PromptVariable;
}> = ({ promptVariable }) => {
const {
updatePromptVariableValue,
deletePromptVariable,
promptVariables,
messagePlaceholders,
} = usePlaygroundContext();
const { name, value, isUsed } = promptVariable;
const { isVariableConflicting } = useNamingConflicts(
promptVariables,
messagePlaceholders,
);
const hasConflict = isVariableConflicting(name);
const handleInputChange = (value: string) => {
updatePromptVariableValue(name, value);
};
const handleDeleteVariable = () => {
deletePromptVariable(name);
};
const isUsedIcon = isUsed ? (
{isUsedIcon}
{name}
Variable name conflicts with placeholder. Names must be unique.
)}