from bson import ObjectId
from motor.motor_asyncio import AsyncIOMotorCollection


class MongoSalonRepository:
    def __init__(self, collection: AsyncIOMotorCollection):
        self._salons = collection

    async def get_timezone(self, salon_id: str) -> str:
        doc = await self._salons.find_one(
            {"_id": ObjectId(salon_id)},
            {"timezone": 1},
        )
        if not doc:
            raise ValueError("Salon not found")
        return doc.get("timezone") or "Asia/Kolkata"
