updated conditional styling
This commit is contained in:
parent
60f28672d3
commit
4cb62d830d
8 changed files with 1115 additions and 30 deletions
|
|
@ -27,7 +27,7 @@ pub struct CardFromFile {
|
|||
pub struct CardForTemplate {
|
||||
pub name: String,
|
||||
pub count: i32,
|
||||
pub usd_value: String, // No longer an Option
|
||||
pub usd_value: f32, // No longer an Option
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use crate::templates::RootTemplate;
|
|||
use crate::util::HtmlTemplate;
|
||||
|
||||
pub async fn root() -> Result<HtmlTemplate<RootTemplate>, (StatusCode, String)> {
|
||||
let file_path = "test_data/test.json";
|
||||
let file_path = "test_data/cards.json";
|
||||
match read_card_file(file_path).await {
|
||||
Ok(card_file) => {
|
||||
let cards_for_template: Vec<_> = card_file.cards
|
||||
|
|
@ -14,7 +14,7 @@ pub async fn root() -> Result<HtmlTemplate<RootTemplate>, (StatusCode, String)>
|
|||
.map(|card| CardForTemplate {
|
||||
name: card.name,
|
||||
count: card.count,
|
||||
usd_value: card.usd_value.unwrap_or_else(|| "N/A".into()),
|
||||
usd_value: card.usd_value.and_then(|value| value.parse::<f32>().ok()).unwrap_or(0.0),
|
||||
})
|
||||
.collect();
|
||||
let template = RootTemplate {
|
||||
|
|
|
|||
|
|
@ -14,8 +14,4 @@ pub struct RootTemplate {
|
|||
|
||||
#[derive(Template)]
|
||||
#[template(path="base.html")]
|
||||
pub struct BaseTemplate;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path="head.html")]
|
||||
pub struct HeadTemplate;
|
||||
pub struct BaseTemplate;
|
||||
Loading…
Add table
Add a link
Reference in a new issue