fedimint_server_ui/dashboard/
invite.rs1use maud::{Markup, PreEscaped, html};
2use qrcode::QrCode;
3
4pub fn render(invite_code: &str, session_count: u64) -> Markup {
6 html! {
7 div class="card h-100" {
8 div class="card-header dashboard-header" { "Invite Code" }
9 div class="card-body" {
10 @if session_count == 0 {
11 div class="alert alert-warning" {
12 "The invite code will be available once the federation has completed its first consensus session."
13 }
14 } @else {
15 @let observer_link = format!("https://observer.fedimint.org/nostr?check={invite_code}");
16 @let qr_svg = QrCode::new(invite_code)
17 .expect("Failed to generate QR code")
18 .render::<qrcode::render::svg::Color>()
19 .build();
20
21 div class="text-center mb-3" {
23 div class="border rounded p-2 bg-white d-inline-block" style="width: 250px; max-width: 100%;" {
24 div style="width: 100%; height: auto; overflow: hidden;" {
25 (PreEscaped(format!(r#"<div style="width: 100%; height: auto;">{}</div>"#, qr_svg.replace("width=", "data-width=").replace("height=", "data-height=").replace("<svg", r#"<svg style="width: 100%; height: auto; display: block;""#))))
26 }
27 }
28 }
29
30 div class="d-flex justify-content-center gap-2 mt-3" {
32 button type="button" class="btn btn-outline-primary" id="copyInviteCodeBtn"
33 onclick=(format!("navigator.clipboard.writeText('{}').then(() => {{ this.textContent='Copied!'; setTimeout(() => this.textContent='Copy to Clipboard', 2000); }}).catch(() => alert('Copy failed'))", invite_code)) {
34 "Copy to Clipboard"
35 }
36
37 a href=(observer_link) target="_blank" class="btn btn-outline-success" {
38 "Announce on Nostr"
39 }
40 }
41
42 p class="text-center mt-3" {
43 "Share this invite code with users to onboard them to your federation."
44 }
45 }
46 }
47 }
48 }
49}