use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Project {
pub id: String,
pub name: String,
pub color: String,
pub icon: String,
pub created_at: DateTime<Utc>,
}
impl Project {
pub fn new(name: &str) -> Self {
Self {
id: Uuid::now_v7().to_string(),
name: name.to_string(),
color: "#3498db".to_string(),
icon: "📁".to_string(),
created_at: Utc::now(),
}
}
pub fn with_style(name: &str, color: &str, icon: &str) -> Self {
Self {
id: Uuid::now_v7().to_string(),
name: name.to_string(),
color: color.to_string(),
icon: icon.to_string(),
created_at: Utc::now(),
}
}
}
impl Default for Project {
fn default() -> Self {
Self::new("Inbox")
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_project_new() {
let project = Project::new("Work");
assert_eq!(project.name, "Work");
assert_eq!(project.color, "#3498db");
assert!(!project.id.is_empty());
}
#[test]
fn test_project_with_style() {
let project = Project::with_style("Personal", "#e74c3c", "🏠");
assert_eq!(project.name, "Personal");
assert_eq!(project.color, "#e74c3c");
assert_eq!(project.icon, "🏠");
}
}