add screen to view a barcode isolated
This commit is contained in:
@@ -1434,6 +1434,7 @@ pub fn rewards_page(user: &User, cards: &[RewardsCard], csrf_token: &str) -> Mar
|
||||
div class="rewards-grid" {
|
||||
@for card in cards {
|
||||
div class="rewards-card" {
|
||||
a class="rewards-card-link" href=(format!("/rewards/{}", card.id)) aria-label=(format!("Show {} barcode", card.store_name)) {}
|
||||
div class="rewards-card-heading" {
|
||||
strong { (card.store_name) }
|
||||
form method="post" action=(format!("/rewards/{}/delete", card.id)) hx-confirm="Remove this rewards card? This cannot be undone." {
|
||||
@@ -1471,6 +1472,29 @@ pub fn rewards_page(user: &User, cards: &[RewardsCard], csrf_token: &str) -> Mar
|
||||
)
|
||||
}
|
||||
|
||||
/// A focused, single-barcode view for scanning at the register. Only one
|
||||
/// barcode is shown at a time so a scanner can't pick up multiple codes.
|
||||
pub fn rewards_scan_page(user: &User, card: &RewardsCard) -> Markup {
|
||||
page(
|
||||
&card.store_name,
|
||||
Some(user),
|
||||
html! {
|
||||
div class="scan-page" {
|
||||
a class="button button-quiet scan-back" href="/rewards" { "← All cards" }
|
||||
div class="scan-card" {
|
||||
p class="eyebrow" { "REWARDS CARD" }
|
||||
h1 class="scan-store" { (card.store_name) }
|
||||
div class="scan-barcode" {
|
||||
(barcode_svg(&card.symbology, &card.number))
|
||||
}
|
||||
p class="rewards-number" { (card.number) }
|
||||
}
|
||||
}
|
||||
script src=(crate::assets::url("rewards.js")) {}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/// Renders a rewards-card number as an inline SVG barcode using the given
|
||||
/// symbology. Falls back to a plain text label if the number can't be encoded
|
||||
/// (for example, a Code 128 number that isn't valid for the chosen symbology).
|
||||
|
||||
Reference in New Issue
Block a user