Skip to content

Commit 553cede

Browse files
committed
app: change button when copied
1 parent 0f25b7b commit 553cede

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/App.jsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default function HcpCliAssistant() {
1111
];
1212

1313
const [step, setStep] = useState(0);
14+
const [copied, setCopied] = useState(false);
1415
const [form, setForm] = useState({
1516
name: "",
1617
baseDomain: "",
@@ -89,6 +90,12 @@ export default function HcpCliAssistant() {
8990
return cmd;
9091
};
9192

93+
const handleCopy = () => {
94+
navigator.clipboard.writeText(generateCommand());
95+
setCopied(true);
96+
setTimeout(() => setCopied(false), 2000);
97+
};
98+
9299
const nextStep = () => {
93100
if (isStepValid()) {
94101
setStep((prev) => Math.min(prev + 1, steps.length - 1));
@@ -105,7 +112,12 @@ export default function HcpCliAssistant() {
105112
<div className="mt-6 p-4 border rounded">
106113
<h2 className="text-lg font-bold">Generated Command:</h2>
107114
<pre className="p-2 bg-black text-white border rounded whitespace-pre-wrap">{generateCommand()}</pre>
108-
<button className="mt-2 p-2 bg-blue-500 text-white rounded" onClick={() => navigator.clipboard.writeText(generateCommand())}>Copy Command</button>
115+
<button
116+
className={`mt-2 p-2 rounded text-white`}
117+
onClick={handleCopy}
118+
>
119+
{copied ? "Copied!" : "Copy Command"}
120+
</button>
109121
</div>
110122
) : (
111123
<div className="space-y-4">

0 commit comments

Comments
 (0)