@@ -8,8 +8,58 @@ import { Toaster } from '../components/ui/toaster';
88const Scenarios : React . FC = ( ) => {
99 const [ toggleState , setToggleState ] = useState ( false ) ;
1010 const [ progressValue , setProgressValue ] = useState ( 45 ) ;
11+ const [ lastCopiedLink , setLastCopiedLink ] = useState ( '' ) ;
1112 const toastStyles = 'border-2 shadow-lg rounded-lg px-4 py-3 font-semibold transition-all duration-200 bg-blue-100 border-blue-300 text-blue-800' ;
1213
14+ const showCopyToast = ( description : string ) =>
15+ toast ( {
16+ title : 'Link copied' ,
17+ description,
18+ className : toastStyles ,
19+ duration : 800
20+ } ) ;
21+
22+ const fallbackCopyToClipboard = ( value : string ) => {
23+ const textarea = document . createElement ( 'textarea' ) ;
24+ textarea . value = value ;
25+ textarea . setAttribute ( 'readonly' , '' ) ;
26+ textarea . style . position = 'absolute' ;
27+ textarea . style . left = '-9999px' ;
28+ document . body . appendChild ( textarea ) ;
29+ textarea . select ( ) ;
30+ try {
31+ document . execCommand ( 'copy' ) ;
32+ } catch ( error ) {
33+ console . warn ( 'Clipboard fallback failed' , error ) ;
34+ }
35+ document . body . removeChild ( textarea ) ;
36+ } ;
37+
38+ const handleCopyShareLink = ( ) => {
39+ const text = document . getElementById ( 'share-link' ) ?. textContent ?. trim ( ) ;
40+ if ( ! text ) {
41+ return ;
42+ }
43+
44+ if ( navigator . clipboard ?. writeText ) {
45+ navigator . clipboard
46+ . writeText ( text )
47+ . then ( ( ) => {
48+ setLastCopiedLink ( text ) ;
49+ showCopyToast ( 'The scenario URL is ready to share.' ) ;
50+ } )
51+ . catch ( ( ) => {
52+ fallbackCopyToClipboard ( text ) ;
53+ setLastCopiedLink ( text ) ;
54+ showCopyToast ( 'Copied using fallback clipboard support.' ) ;
55+ } ) ;
56+ } else {
57+ fallbackCopyToClipboard ( text ) ;
58+ setLastCopiedLink ( text ) ;
59+ showCopyToast ( 'Copied using fallback clipboard support.' ) ;
60+ }
61+ } ;
62+
1363 return (
1464 < div className = "min-h-screen py-8" >
1565 < Toaster />
@@ -21,18 +71,18 @@ const Scenarios: React.FC = () => {
2171 </ p >
2272 </ div >
2373
24- < div className = "grid lg :grid-cols-2 gap-8 " >
74+ < div className = "grid gap-8 md :grid-cols-1 lg:grid-cols-2 " >
2575 < Card className = "bg-white p-8 rounded-xl shadow-lg" >
2676 < div className = "flex items-center gap-3 mb-6" >
2777 < div className = "p-2 bg-blue-100 text-blue-600 rounded-lg" >
2878 < CheckCircle className = "w-6 h-6" />
2979 </ div >
3080 < div >
31- < h3 className = "text-xl font-bold" > Form Field Target </ h3 >
32- < p className = "text-gray-600" > Demonstrate how your flows handle predictable customer reference fields .</ p >
81+ < h3 className = "text-xl font-bold" > Static ID Field </ h3 >
82+ < p className = "text-gray-600" > Demonstrate how your scripts store and reuse customer references .</ p >
3383 </ div >
3484 </ div >
35- < div className = "space-y-2 " >
85+ < div className = "space-y-4 " >
3686 < label htmlFor = "static-id-field" className = "text-sm font-medium text-gray-600" > Customer reference</ label >
3787 < input
3888 type = "text"
@@ -92,7 +142,7 @@ const Scenarios: React.FC = () => {
92142 title : 'Demo notification' ,
93143 description : 'Content Description button clicked!' ,
94144 className : toastStyles ,
95- duration : 500
145+ duration : 5000
96146 } ) }
97147 >
98148 Submit
@@ -116,22 +166,20 @@ const Scenarios: React.FC = () => {
116166 </ div >
117167 < button
118168 className = "w-full py-3 px-4 rounded-lg font-medium transition-all bg-blue-600 hover:bg-blue-700 text-white"
119- onClick = { ( ) => {
120- const text = document . getElementById ( 'share-link' ) ?. textContent ?. trim ( ) ;
121- if ( text ) {
122- navigator . clipboard . writeText ( text ) . then ( ( ) => {
123- toast ( {
124- title : 'Link copied' ,
125- description : 'The scenario URL is ready to share.' ,
126- className : toastStyles ,
127- duration : 3000
128- } ) ;
129- } ) ;
130- }
131- } }
169+ onClick = { handleCopyShareLink }
132170 >
133171 Copy share link
134172 </ button >
173+ { lastCopiedLink && (
174+ < div
175+ id = "share-copy-result"
176+ className = "mt-3 rounded-lg border border-blue-100 bg-blue-50 px-3 py-2 text-sm font-medium text-blue-700"
177+ aria-live = "polite"
178+ data-automation = "copy-result"
179+ >
180+ Last copied: < span className = "font-mono" > { lastCopiedLink } </ span >
181+ </ div >
182+ ) }
135183 </ div >
136184 </ Card >
137185
0 commit comments