use crate::models;
use leptos::prelude::*;

#[component]
#[tracing::instrument(skip_all)]
pub fn ProblemInfo(#[prop(into)] problem: Signal<models::Problem>) -> impl IntoView {
    tracing::trace!("Enter problem info");

    let method = Signal::derive(move || problem.read().method.to_string());
    // let name = Signal::derive(move || problem.read().name.clone());
    // let set_by = Signal::derive(move || problem.read().set_by.clone());

    view! {
        <div class="grid grid-rows-none gap-x-0.5 gap-y-1 grid-cols-[auto_1fr]">
            <NameValue name="Method:" value=method />
        // <NameValue name="Name:" value=name />
        // <NameValue name="Set By:" value=set_by />
        </div>
    }
}

#[component]
#[tracing::instrument(skip_all)]
fn NameValue(#[prop(into)] name: Signal<String>, #[prop(into)] value: Signal<String>) -> impl IntoView {
    view! {
        <p class="mr-4 font-light text-right text-orange-300">{name.get()}</p>
        <p class="text-white">{value.get()}</p>
    }
}
