Skip to content

Commit 84bc2d4

Browse files
Update V
Co-authored-by: refacto-test[bot] <217047508+refacto-test[bot]@users.noreply.github.com>
1 parent 9b36b50 commit 84bc2d4

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

V

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,20 @@ export default function ValentinePage() {
3737
.catch(console.error)
3838
} else {
3939
// Fallback para navegadores que no soportan Web Share API
40-
navigator.clipboard.writeText(window.location.href).then(
41-
() => {
42-
alert("Enlace copiado al portapapeles!")
43-
},
44-
(err) => {
45-
console.error("No se pudo copiar el texto: ", err)
46-
},
47-
)
40+
// Check for clipboard permissions first
41+
if (navigator.clipboard) {
42+
navigator.permissions.query({ name: 'clipboard-write' as PermissionName }).then(result => {
43+
if (result.state === 'granted' || result.state === 'prompt') {
44+
navigator.clipboard.writeText(window.location.href)
45+
.then(() => alert("Enlace copiado al portapapeles!"))
46+
.catch(() => alert("No se pudo copiar el enlace. Intente de nuevo."))
47+
} else {
48+
alert("No tiene permisos para usar el portapapeles.")
4849
}
50+
})
51+
} else {
52+
alert("Su navegador no soporta esta función.")
53+
}
4954
}
5055

5156
return (

0 commit comments

Comments
 (0)