diff --git a/src/jwt.rs b/src/jwt.rs index 068adaf..fa232aa 100644 --- a/src/jwt.rs +++ b/src/jwt.rs @@ -10,7 +10,7 @@ use std::str::FromStr; use web_sys::{HtmlInputElement, KeyboardEvent}; use yew::{function_component, html, use_effect_with, use_state, Callback, Html, TargetCast}; -use yew_hooks::{use_local_storage, use_location}; +use yew_hooks::{use_clipboard, use_local_storage, use_location}; use yew_notifications::{use_notification, Notification, NotificationType}; use crate::common::Checkbox; @@ -162,6 +162,18 @@ pub fn jwt() -> Html { } }); + let jwt_to_copy = (*raw_jwt).clone(); + let notifications = use_notification::(); + let clipboard = use_clipboard(); + let share_by_link = Callback::from(move |_| { + clipboard.write_text(jwt_to_copy.clone()); + + notifications.spawn(Notification::from_description_and_type( + NotificationType::Info, + "link to jwt copied", + )); + }); + html! {