from datetime import time
from typing import List
from pydantic import BaseModel, Field


class WeeklyScheduleSchema(BaseModel):
    id: int
    company_id: int
    day_of_week: int = Field(ge=0, le=6, description="0 = Monday, 6 = Sunday")
    start_time: time
    end_time: time
    is_day_off: int = Field(ge=0, le=1, description="1: Day off, 0: Not off")
    created_at: str
    updated_at: str

    class Config:
        from_attributes = True


class ScheduleResponseSchema(BaseModel):
    id: int
    day_of_week: int = Field(ge=0, le=6, description="0 = Monday, 6 = Sunday")
    start_time: time
    end_time: time
    is_day_off: int = Field(ge=0, le=1, description="1: Day off, 0: Not off")

    class Config:
        from_attributes = True


class CreateWeeklyScheduleSchema(BaseModel):
    company_id: int
    day_of_week: int = Field(ge=0, le=6, description="0 = Monday, 6 = Sunday")
    start_time: time
    end_time: time
    is_day_off: int = Field(ge=0, le=1, description="1: Day off, 0: Not off")


class ScheduleItem(BaseModel):
    day_of_week: int = Field(ge=0, le=6, description="0 = Monday, 6 = Sunday")
    start_time: time | None = None
    end_time: time | None = None
    is_day_off: bool = False

    class Config:
        json_schema_extra = {
            "example": {
                "day_of_week": 0,
                "start_time": "09:00",
                "end_time": "17:00",
                "is_day_off": False
            }
        }


class CreateScheduleRequest(BaseModel):
    schedules: List[ScheduleItem]

    class Config:
        json_schema_extra = {
            "example": {
                "schedules": [
                    {
                        "day_of_week": 0,
                        "start_time": "09:00",
                        "end_time": "17:00",
                        "is_day_off": False
                    },
                    {
                        "day_of_week": 6,
                        "is_day_off": True
                    }
                ]
            }
        } 