diff --git a/backend/app/api/domains.py b/backend/app/api/domains.py index 0c0a229..969c33e 100644 --- a/backend/app/api/domains.py +++ b/backend/app/api/domains.py @@ -1,6 +1,6 @@ """Domain management API (requires authentication).""" import json -from datetime import datetime +from datetime import datetime, timezone from math import ceil from fastapi import APIRouter, HTTPException, status, Query @@ -16,6 +16,16 @@ from app.services.domain_health import get_health_checker, HealthStatus router = APIRouter() + +def _to_naive_utc(dt: datetime | None) -> datetime | None: + """Convert timezone-aware datetime to naive UTC datetime for PostgreSQL.""" + if dt is None: + return None + if dt.tzinfo is not None: + # Convert to UTC and remove timezone info + return dt.astimezone(timezone.utc).replace(tzinfo=None) + return dt + def _safe_json_loads(value: str | None, default): if not value: return default @@ -265,7 +275,7 @@ async def refresh_domain( domain.status = check_result.status domain.is_available = check_result.is_available domain.registrar = check_result.registrar - domain.expiration_date = check_result.expiration_date + domain.expiration_date = _to_naive_utc(check_result.expiration_date) domain.last_checked = datetime.utcnow() # Create check record @@ -342,7 +352,7 @@ async def refresh_all_domains( domain.status = check_result.status domain.is_available = check_result.is_available domain.registrar = check_result.registrar - domain.expiration_date = check_result.expiration_date + domain.expiration_date = _to_naive_utc(check_result.expiration_date) domain.last_checked = datetime.utcnow() # Create check record diff --git a/frontend/src/app/terminal/watchlist/page.tsx b/frontend/src/app/terminal/watchlist/page.tsx index f120a65..6b07d36 100755 --- a/frontend/src/app/terminal/watchlist/page.tsx +++ b/frontend/src/app/terminal/watchlist/page.tsx @@ -147,7 +147,16 @@ const healthConfig: Record s.open) + const openAnalyzePanel = useAnalyzePanelStore((s) => s.open) + + // Wrapper to open analyze panel with domain status + const openAnalyze = useCallback((domainData: { name: string; is_available: boolean; expiration_date: string | null }) => { + openAnalyzePanel(domainData.name, { + status: domainData.is_available ? 'available' : 'taken', + deletion_date: domainData.expiration_date, + is_drop: false, + }) + }, [openAnalyzePanel]) // Modal state const [showAddModal, setShowAddModal] = useState(false) @@ -608,7 +617,7 @@ export default function WatchlistPage() {