from pydantic import BaseModel
from typing import Optional
from datetime import datetime


class NoteCreate(BaseModel):
    body: str
    is_pinned: bool = False


class NoteUpdate(BaseModel):
    body: Optional[str] = None
    is_pinned: Optional[bool] = None


class NoteOut(BaseModel):
    id: int
    body: str
    is_pinned: bool
    created_by_id: int
    created_by_name: Optional[str] = None
    created_at: datetime
    updated_at: datetime

    model_config = {"from_attributes": True}


class TodoCreate(BaseModel):
    body: str
    priority: str = "normal"


class TodoUpdate(BaseModel):
    body: Optional[str] = None
    priority: Optional[str] = None
    is_done: Optional[bool] = None


class TodoOut(BaseModel):
    id: int
    body: str
    is_done: bool
    done_at: Optional[datetime] = None
    done_by_id: Optional[int] = None
    done_by_name: Optional[str] = None
    created_by_id: int
    created_by_name: Optional[str] = None
    created_at: datetime
    priority: str

    model_config = {"from_attributes": True}
