use chrono::{DateTime, Utc};
use serde::Serialize;
use sqlx::FromRow;
use uuid::Uuid;

pub const READER_MODE_SINGLE: &str = "single";
pub const READER_MODE_CONTINUOUS: &str = "continuous";
pub const READER_MODES: &[&str] = &[READER_MODE_SINGLE, READER_MODE_CONTINUOUS];

pub const READER_GAPS: &[&str] = &["none", "small", "medium", "large"];

#[derive(Debug, Clone, Serialize, FromRow, PartialEq, Eq)]
pub struct UserPreferences {
    #[serde(skip)]
    pub user_id: Uuid,
    pub reader_mode: String,
    pub reader_page_gap: String,
    pub updated_at: DateTime<Utc>,
}

impl UserPreferences {
    pub fn defaults_for(user_id: Uuid) -> Self {
        Self {
            user_id,
            reader_mode: READER_MODE_SINGLE.to_string(),
            reader_page_gap: "none".to_string(),
            updated_at: Utc::now(),
        }
    }
}
