from dataclasses import dataclass, field
from models.base import BaseModel

@dataclass
class User(BaseModel):
    first_name: str
    last_name: str
    email: str
    password: str  # In production, this should be hashed
    verified: bool = False
    verify_token: str | None = None
    verify_token_created: str | None = None
    reset_token: str | None = None
    reset_token_created: str | None = None
    image_id: str | None = None

    @classmethod
    def from_dict(cls, d: dict):
        return cls(
            first_name=d.get('first_name'),
            last_name=d.get('last_name'),
            email=d.get('email'),
            password=d.get('password'),
            verified=d.get('verified', False),
            verify_token=d.get('verify_token'),
            verify_token_created=d.get('verify_token_created'),
            reset_token=d.get('reset_token'),
            reset_token_created=d.get('reset_token_created'),
            image_id=d.get('image_id'),
            id=d.get('id'),
            created_at=d.get('created_at'),
            updated_at=d.get('updated_at')

        )

    def to_dict(self):
        base = super().to_dict()
        base.update({
            'first_name': self.first_name,
            'last_name': self.last_name,
            'email': self.email,
            'password': self.password,
            'verified': self.verified,
            'verify_token': self.verify_token,
            'verify_token_created': self.verify_token_created,
            'reset_token': self.reset_token,
            'reset_token_created': self.reset_token_created,
            'image_id': self.image_id
        })
        return base
