summaryrefslogblamecommitdiff
path: root/makima/src/daemon/tui/views/contracts.rs
blob: 73b7c3399e45199fde3f27fecf13325e5848a168 (plain) (tree)
1
2
3
4
5
6
7
8
9








                                      
                       
                                                        










                                                                            









                                                          
//! Contracts view implementation.

use uuid::Uuid;

use crate::daemon::api::ApiClient;
use crate::daemon::tui::app::ListItem;

/// Load contracts from API
pub async fn load_contracts(
    client: &ApiClient,
) -> Result<Vec<ListItem>, Box<dyn std::error::Error>> {
    let result = client.list_contracts().await?;

    // Response is { "contracts": [...], "total": N }
    let contracts = result
        .0
        .get("contracts")
        .and_then(|v| v.as_array())
        .map(|arr| arr.iter().filter_map(ListItem::from_contract).collect())
        .unwrap_or_default();

    Ok(contracts)
}

/// Get full contract details for preview
pub async fn get_contract_preview(
    _client: &ApiClient,
    _contract_id: Uuid,
) -> Result<String, Box<dyn std::error::Error>> {
    // TODO: Implement contract preview
    Ok("Contract preview not yet implemented".to_string())
}