Skip to main content

fedimint_server_ui/dashboard/
invite.rs

1use fedimint_ui_common::copiable_text;
2use maud::{Markup, PreEscaped, html};
3use qrcode::QrCode;
4
5// Card with invite code text and copy button
6pub fn render(invite_code: &str, session_count: u64) -> Markup {
7    html! {
8        div class="card h-100" {
9            div class="card-header dashboard-header" { "Invite Code" }
10            div class="card-body" {
11                @if session_count == 0 {
12                    div class="alert alert-warning" {
13                        "The invite code will be available once the federation has completed its first consensus session."
14                    }
15                } @else {
16                    @let observer_link = format!("https://observer.fedimint.org/nostr?check={invite_code}");
17                    @let qr_svg = QrCode::new(invite_code)
18                        .expect("Failed to generate QR code")
19                        .render::<qrcode::render::svg::Color>()
20                        .build();
21
22                    p { "Share this with users to onboard them to your federation." }
23
24                    // QR Code
25                    div class="text-center mb-3" {
26                        div class="border rounded p-2 bg-white d-inline-block" style="width: 250px; max-width: 100%;" {
27                            div style="width: 100%; height: auto; overflow: hidden;" {
28                                (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;""#))))
29                            }
30                        }
31                    }
32
33                    div class="mb-3" {
34                        (copiable_text(invite_code))
35                    }
36
37                    a href=(observer_link) target="_blank" class="btn btn-outline-success w-100 py-2" {
38                        "Announce on Nostr"
39                    }
40                }
41            }
42        }
43    }
44}