# why schemas? it is a way to define the structure of the data sent to the server and the data received from the server
from pydantic import BaseModel, Field
import datetime as dt

# template for user data. this is used to validate the data sent to the server


class userBase(BaseModel):
    first_name: str = Field(...)
    last_name: str = Field(...)
    email: str = Field(...,)


class userCreate(userBase):
    password: str = Field(...)  # hashed password

    class Config:
        orm_mode = True  # to tell pydantic to read the data even if it is not a dict but an ORM model
        schema_extra = {
            "example": {
                "first_name": "John",
                "last_name": "Doe",
                "email": "qpmzj@example.com",
                "password": "password",
            }
        }


class User(userBase):
    user_id: int

    class Config:
        orm_mode = True


class TodoBase(BaseModel):
    task_name: str
    task_description: str
    priority: int
    category: str
    due_date: dt.date
    status: bool = False


class TodoCreate(TodoBase):
    pass


class Todo(TodoBase):
    todo_id: int
    user_id: int

    class Config:
        orm_mode = True