use crate::{
    types::{Config, DatabasePath},
    ui::Field,
};
use serde::{Deserialize, Serialize};
use typeshare::typeshare;

#[derive(Clone, Debug, Serialize, Deserialize)]
#[typeshare]
pub struct ConfigurationView {
    pub library: Field<()>,
}

pub fn configuration(config: &Config) -> ConfigurationView {
    let path: Option<DatabasePath> = config.get();
    ConfigurationView {
        library: Field {
            id: "library-path-field".to_owned(),
            label: "Library".to_owned(),
            value: path.map(|path| path.to_string_lossy().into_owned()),
            action: (),
        },
    }
}
