from typing import Optional
from datetime import datetime
from pydantic import BaseModel, Field


class StoreCreate(BaseModel):
    store_name: str = Field(..., min_length=1, max_length=200)
    store_location: str = Field(..., min_length=1, max_length=500)
    store_operational_hours: str = Field(..., min_length=1, max_length=100)
    state: Optional[str] = Field(None, max_length=100, description="Store state code (e.g., 'SINDH', 'PUNJAB')")
    latitude: Optional[float] = Field(None, ge=-90, le=90, description="Store latitude (-90 to 90)")
    longitude: Optional[float] = Field(None, ge=-180, le=180, description="Store longitude (-180 to 180)")


class StoreUpdate(BaseModel):
    store_name: Optional[str] = Field(None, min_length=1, max_length=200)
    store_location: Optional[str] = Field(None, min_length=1, max_length=500)
    store_operational_hours: Optional[str] = Field(None, min_length=1, max_length=100)
    state: Optional[str] = Field(None, max_length=100, description="Store state code (e.g., 'SINDH', 'PUNJAB')")
    latitude: Optional[float] = Field(None, ge=-90, le=90, description="Store latitude (-90 to 90)")
    longitude: Optional[float] = Field(None, ge=-180, le=180, description="Store longitude (-180 to 180)")


class StoreSchema(BaseModel):
    store_id: int = Field(..., description="ID of the store")
    chain_id: int = Field(..., description="chain_id of store")
    store_name: str = Field(..., description="The name of the store")
    store_location: str = Field(..., description="The location of the store")
    store_operational_hours: str = Field(
        ..., description="The operational hours of the store"
    )
    state: Optional[str] = Field(None, description="Store state code (e.g., 'SINDH', 'PUNJAB')")
    latitude: Optional[float] = Field(None, description="Store latitude")
    longitude: Optional[float] = Field(None, description="Store longitude")
    created_at: datetime = Field(..., description="When the store was created")
    updated_at: datetime = Field(..., description="When the store was last updated")

    class Config:
        from_attributes = True


class StoreUpdateSchemaSchema(BaseModel):
    chain_id: int = Field(..., description="chain_id of store")
    store_name: str = Field(..., description="The name of the store")
    store_location: str = Field(..., description="The location of the store")
    store_operational_hours: str = Field(
        ..., description="The operational hours of the store"
    )
