from datetime import date
from enum import Enum

from pydantic import BaseModel, ConfigDict


class PriorityEnum(str, Enum):
    low = "low"
    medium = "medium"
    high = "high"
    critical = "critical"


class StatusEnum(str, Enum):
    open = "open"
    closed = "closed"
    in_progress = "in_progress"
    todo = "todo"


class TaskShort(BaseModel):
    title: str
    due_date: date | None = None
    priority: PriorityEnum = PriorityEnum.medium
    model_config = ConfigDict(from_attributes=True)


class TaskWithId(TaskShort):
    id: int
    status: str


class TaskADDRequest(TaskShort):
    description: str | None = None


class TaskPATCHRequest(BaseModel):
    title: str | None = None
    description: str | None = None
    due_date: date | None = None
    status: StatusEnum | None = None
    priority: PriorityEnum | None = None
    time_spent: int | None = None


class Task(TaskADDRequest):
    id: int
    user_id: int
    status: StatusEnum
    time_spent: int

    model_config = ConfigDict(from_attributes=True)
