use indexer_service_protocol::{BedrockStatus, Block, BlockBody, BlockHeader}; use leptos::prelude::*; use leptos_router::components::A; use crate::format_utils; /// Get CSS class for bedrock status. const fn status_class(status: &BedrockStatus) -> &'static str { match status { BedrockStatus::Pending => "status-pending", BedrockStatus::Safe => "status-safe", BedrockStatus::Finalized => "status-finalized", } } /// Block preview component #[component] pub fn BlockPreview(block: Block) -> impl IntoView { let Block { header: BlockHeader { block_id, prev_block_hash, hash, timestamp, signature: _, }, body: BlockBody { transactions }, bedrock_status, bedrock_parent_id: _, } = block; let tx_count = transactions.len(); let hash_str = hash.to_string(); let prev_hash_str = prev_block_hash.to_string(); let time_str = format_utils::format_timestamp(timestamp); let status_str = match &bedrock_status { BedrockStatus::Pending => "Pending", BedrockStatus::Safe => "Safe", BedrockStatus::Finalized => "Finalized", }; view! {
"Block " {block_id}
{status_str}
"Hash: " {hash_str}
"Previous: " {prev_hash_str}
"Timestamp: " {time_str}
"Transactions: " {tx_count}
} }