from dataclasses import dataclass
from models.base import BaseModel


@dataclass
class TaskExtension(BaseModel):
    child_id: str
    task_id: str
    date: str   # ISO date string supplied by client, e.g. '2026-02-22'

    @classmethod
    def from_dict(cls, d: dict) -> 'TaskExtension':
        return cls(
            child_id=d.get('child_id'),
            task_id=d.get('task_id'),
            date=d.get('date'),
            id=d.get('id'),
            created_at=d.get('created_at'),
            updated_at=d.get('updated_at'),
        )

    def to_dict(self) -> dict:
        base = super().to_dict()
        base.update({
            'child_id': self.child_id,
            'task_id': self.task_id,
            'date': self.date,
        })
        return base
