use std::fmt;
use chrono::NaiveDateTime;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum ProjectStatus {
Active,
Archived,
}
impl fmt::Display for ProjectStatus {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ProjectStatus::Active => write!(f, "active"),
ProjectStatus::Archived => write!(f, "archived"),
}
}
}
impl ProjectStatus {
pub fn from_str(s: &str) -> Option<Self> {
match s.to_lowercase().as_str() {
"active" => Some(ProjectStatus::Active),
"archived" => Some(ProjectStatus::Archived),
_ => None,
}
}
pub fn as_str(&self) -> &'static str {
match self {
ProjectStatus::Active => "active",
ProjectStatus::Archived => "archived",
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Project {
pub id: i64,
pub name: String,
pub client_id: Option<i64>,
pub color: String,
pub status: ProjectStatus,
pub budget_hours: Option<f64>,
pub notes: Option<String>,
pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime,
}