From da130b0f12ce0acab87163de71c09aa34ea87b95 Mon Sep 17 00:00:00 2001 From: Pavlo Myroniuk Date: Sat, 24 Aug 2024 20:37:32 +0300 Subject: [PATCH] feat(crypto-helper): jwt: add button to share raw jwt; --- src/jwt.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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! {