"""Appointments schemas."""
from __future__ import annotations


from datetime import datetime, date, time
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field

from app.models.types import LifecycleStatus, DayOfWeek, ScheduleExceptionKind
from app.schemas.common import ORMBase

_FORBID = ConfigDict(extra="forbid")


class StaffScheduleCreate(BaseModel):
    model_config = _FORBID

    organization_id: UUID
    branch_id: UUID
    staff_ref: str = Field(max_length=100)
    code: str = Field(max_length=50)
    day_of_week: DayOfWeek
    start_time: time
    end_time: time
    is_active: bool = True
    metadata_json: dict | None = None


class StaffScheduleRead(ORMBase):
    id: UUID
    tenant_id: UUID
    organization_id: UUID
    branch_id: UUID
    staff_ref: str
    code: str
    day_of_week: DayOfWeek
    start_time: time
    end_time: time
    is_active: bool
    metadata_json: dict | None
    is_deleted: bool
    created_by: str | None
    updated_by: str | None
    created_at: datetime
    updated_at: datetime


from datetime import datetime, date, time
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field

from app.models.types import LifecycleStatus
from app.schemas.common import ORMBase

_FORBID = ConfigDict(extra="forbid")


class StaffAvailabilityCreate(BaseModel):
    model_config = _FORBID

    organization_id: UUID
    branch_id: UUID
    staff_ref: str = Field(max_length=100)
    code: str = Field(max_length=50)
    starts_at: datetime
    ends_at: datetime
    is_bookable: bool = True
    metadata_json: dict | None = None


class StaffAvailabilityRead(ORMBase):
    id: UUID
    tenant_id: UUID
    organization_id: UUID
    branch_id: UUID
    staff_ref: str
    code: str
    starts_at: datetime
    ends_at: datetime
    is_bookable: bool
    metadata_json: dict | None
    is_deleted: bool
    created_by: str | None
    updated_by: str | None
    created_at: datetime
    updated_at: datetime


from datetime import datetime, date, time
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field

from app.models.types import ScheduleExceptionKind
from app.schemas.common import ORMBase

_FORBID = ConfigDict(extra="forbid")


class ScheduleExceptionCreate(BaseModel):
    model_config = _FORBID

    organization_id: UUID
    branch_id: UUID
    staff_ref: str | None = None
    code: str = Field(max_length=50)
    kind: ScheduleExceptionKind
    exception_date: date
    start_time: time | None = None
    end_time: time | None = None
    reason: str | None = None


class ScheduleExceptionRead(ORMBase):
    id: UUID
    tenant_id: UUID
    organization_id: UUID
    branch_id: UUID
    staff_ref: str | None
    code: str
    kind: ScheduleExceptionKind
    exception_date: date
    start_time: time | None
    end_time: time | None
    reason: str | None
    is_deleted: bool
    created_by: str | None
    updated_by: str | None
    created_at: datetime
    updated_at: datetime


from datetime import datetime, date, time
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field

from app.models.types import LifecycleStatus
from app.schemas.common import ORMBase

_FORBID = ConfigDict(extra="forbid")


class AppointmentTypeCreate(BaseModel):
    model_config = _FORBID

    organization_id: UUID
    code: str = Field(max_length=50)
    name: str = Field(max_length=255)
    description: str | None = None
    default_duration_minutes: int = 30
    status: LifecycleStatus = LifecycleStatus.ACTIVE


class AppointmentTypeRead(ORMBase):
    id: UUID
    tenant_id: UUID
    organization_id: UUID
    code: str
    name: str
    description: str | None
    default_duration_minutes: int
    status: LifecycleStatus
    is_deleted: bool
    created_by: str | None
    updated_by: str | None
    created_at: datetime
    updated_at: datetime


from datetime import datetime, date, time
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field

from app.models.types import LifecycleStatus
from app.schemas.common import ORMBase

_FORBID = ConfigDict(extra="forbid")


class WaitingListEntryCreate(BaseModel):
    model_config = _FORBID

    organization_id: UUID
    branch_id: UUID
    code: str = Field(max_length=50)
    customer_ref: str | None = None
    service_ref: UUID | None = None
    preferred_staff_ref: str | None = None
    requested_date: date | None = None
    notes: str | None = None
    priority: int = 100


class WaitingListEntryRead(ORMBase):
    id: UUID
    tenant_id: UUID
    organization_id: UUID
    branch_id: UUID
    code: str
    customer_ref: str | None
    service_ref: UUID | None
    preferred_staff_ref: str | None
    requested_date: date | None
    notes: str | None
    priority: int
    is_deleted: bool
    created_by: str | None
    updated_by: str | None
    created_at: datetime
    updated_at: datetime
