File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ export default function HcpCliAssistant() {
11
11
] ;
12
12
13
13
const [ step , setStep ] = useState ( 0 ) ;
14
+ const [ copied , setCopied ] = useState ( false ) ;
14
15
const [ form , setForm ] = useState ( {
15
16
name : "" ,
16
17
baseDomain : "" ,
@@ -89,6 +90,12 @@ export default function HcpCliAssistant() {
89
90
return cmd ;
90
91
} ;
91
92
93
+ const handleCopy = ( ) => {
94
+ navigator . clipboard . writeText ( generateCommand ( ) ) ;
95
+ setCopied ( true ) ;
96
+ setTimeout ( ( ) => setCopied ( false ) , 2000 ) ;
97
+ } ;
98
+
92
99
const nextStep = ( ) => {
93
100
if ( isStepValid ( ) ) {
94
101
setStep ( ( prev ) => Math . min ( prev + 1 , steps . length - 1 ) ) ;
@@ -105,7 +112,12 @@ export default function HcpCliAssistant() {
105
112
< div className = "mt-6 p-4 border rounded" >
106
113
< h2 className = "text-lg font-bold" > Generated Command:</ h2 >
107
114
< 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 >
109
121
</ div >
110
122
) : (
111
123
< div className = "space-y-4" >
You can’t perform that action at this time.
0 commit comments