"""
Beach-related schemas
"""
from pydantic import BaseModel
from typing import List, Optional
from uuid import UUID
from datetime import datetime, date, time


class BeachTerrainTypeBase(BaseModel):
    terrain_name: str
    photo_path: Optional[str] = None
    description: Optional[str] = None


class BeachTerrainTypeCreate(BeachTerrainTypeBase):
    pass


class BeachTerrainTypeUpdate(BeachTerrainTypeBase):
    pass


class BeachTerrainType(BeachTerrainTypeBase):
    terrain_type_id: int

    class Config:
        orm_mode = True


class BeachBedTypeBase(BaseModel):
    name: str
    description: str
    photo_path: str
    uid: int
    is_layout: bool = False
    has_background_color: bool = False


class BeachBedTypeCreate(BeachBedTypeBase):
    pass


class BeachBedTypeUpdate(BeachBedTypeBase):
    pass


class BeachBedType(BeachBedTypeBase):
    bed_type_id: int

    class Config:
        orm_mode = True


class BeachPlaceBase(BaseModel):
    beach_name: str
    mask: str
    max_seats: int
    top_rows: int
    top_seats: int
    is_double_seat: bool = False
    has_umbrella: bool = False
    has_showers: bool = False
    has_lockers: bool = False
    has_market: bool = False
    has_restaurant: bool = False
    has_swimming_pool: bool = False
    has_parking: bool = False
    has_toilets: bool = False
    has_free_wifi: bool = False
    has_music: bool = False
    has_safety_box: bool = False
    has_access_wheelchair: bool = False
    has_lockers_for_baby: bool = False
    has_beach_volley: bool = False
    has_tennis: bool = False
    has_spa: bool = False
    has_medical: bool = False
    has_lifeguard: bool = False
    pet_allow: bool = False
    enable_beach: bool = True
    beach_information: str
    address: str
    latitude: float
    longitude: float
    city: str
    disable_today: bool = False
    contact_phone: Optional[str] = None
    starttime: Optional[time] = None
    endtime: Optional[time] = None
    opendays: str = '1234567'  # '1234567' for Mon-Sun
    has_sea: bool = False
    sea_location: str = ""
    background_photo: str = ""


class BeachPlaceCreate(BeachPlaceBase):
    company_id: UUID
    terrain_type_id: int
    country_id: int


class BeachPlaceUpdate(BeachPlaceBase):
    company_id: Optional[UUID] = None
    terrain_type_id: Optional[int] = None
    country_id: Optional[int] = None


class BeachPlace(BeachPlaceBase):
    beach_place_id: UUID
    company_id: UUID
    terrain_type_id: int
    country_id: int
    created_at: datetime
    updated_at: datetime

    class Config:
        orm_mode = True


class BeachPlacePhotoBase(BaseModel):
    photo_primary: bool = False
    photo_path: str
    caption: Optional[str] = None
    sort_order: int = 0


class BeachPlacePhotoCreate(BeachPlacePhotoBase):
    beach_place_id: UUID


class BeachPlacePhotoUpdate(BeachPlacePhotoBase):
    pass


class BeachPlacePhoto(BeachPlacePhotoBase):
    photo_id: int
    beach_place_id: UUID

    class Config:
        orm_mode = True


class BeachPlaceScheduleBase(BaseModel):
    from_date: date
    to_date: date
    from_time: time
    to_time: time
    valid_dates: str
    min_hours: int
    can_refund: bool = False
    refund_before_hours: int = 0
    price: float
    price_vip: float
    extras: Optional[str] = None
    extras_vip: Optional[str] = None


class BeachPlaceScheduleCreate(BeachPlaceScheduleBase):
    beach_place_id: UUID
    currency_id: int


class BeachPlaceScheduleUpdate(BeachPlaceScheduleBase):
    beach_place_id: Optional[UUID] = None
    currency_id: Optional[int] = None


class BeachPlaceSchedule(BeachPlaceScheduleBase):
    schedule_id: int
    beach_place_id: UUID
    currency_id: int

    class Config:
        orm_mode = True


class BeachPlaceTerrainBase(BaseModel):
    uid: int
    angle: int = 0
    background_color: str = '#FFFFFF'
    bed_reference: Optional[str] = None
    block_online: bool = False
    classification: int = 0
    covers: Optional[str] = None
    description: Optional[str] = None
    description_text: Optional[str] = None
    description_text_position: Optional[str] = None
    height: float
    left_position: float
    bed_price: float = 0
    min_price: float = 0
    name: str
    top_position: float
    width: float
    z_index: int = 0
    is_layout: bool = False


class BeachPlaceTerrainCreate(BeachPlaceTerrainBase):
    beach_place_id: UUID


class BeachPlaceTerrainUpdate(BeachPlaceTerrainBase):
    beach_place_id: Optional[UUID] = None


class BeachPlaceTerrain(BeachPlaceTerrainBase):
    terrain_id: UUID
    beach_place_id: UUID

    class Config:
        orm_mode = True