fix: Correct portfolio import and TypeScript errors

- Fixed import: get_current_user from app.api.deps (not app.api.auth)
- Removed empty routes folder
- Fixed TldHistory interface (optional trend fields)
- Fixed DomainCheckResult interface (nullable fields)
- Fixed loadData function to compute values from available API data
This commit is contained in:
yves.gugger
2025-12-08 11:26:35 +01:00
parent 6e84103a5b
commit 74670cf9e5
3 changed files with 36 additions and 20 deletions

View File

@ -7,7 +7,7 @@ from sqlalchemy import select, func, and_
from sqlalchemy.ext.asyncio import AsyncSession
from app.database import get_db
from app.api.auth import get_current_user
from app.api.deps import get_current_user
from app.models.user import User
from app.models.portfolio import PortfolioDomain, DomainValuation
from app.services.valuation import valuation_service

View File

@ -58,7 +58,8 @@ interface TldHistory {
price_change_7d: number
price_change_30d: number
price_change_90d: number
trend: string
trend?: string
trend_reason?: string
history: Array<{
date: string
price: number
@ -69,9 +70,9 @@ interface DomainCheckResult {
domain: string
is_available: boolean
status: string
registrar?: string
creation_date?: string
expiration_date?: string
registrar?: string | null
creation_date?: string | null
expiration_date?: string | null
}
// Registrar URLs with affiliate parameters
@ -420,27 +421,41 @@ export default function TldDetailPage() {
if (historyData && compareData) {
const registrars = compareData.registrars || []
const priceRange = compareData.price_range || { min: 0, max: 0, avg: 0 }
const sortedRegistrars = [...registrars].sort((a, b) =>
a.registration_price - b.registration_price
)
const minPrice = sortedRegistrars[0]?.registration_price || historyData.current_price || 0
const maxPrice = sortedRegistrars[sortedRegistrars.length - 1]?.registration_price || historyData.current_price || 0
const avgPrice = registrars.length > 0
? registrars.reduce((sum, r) => sum + r.registration_price, 0) / registrars.length
: historyData.current_price || 0
// Determine trend from price change
const trend = historyData.price_change_30d > 5 ? 'up'
: historyData.price_change_30d < -5 ? 'down'
: 'stable'
setDetails({
tld: compareData.tld || tld,
type: compareData.type || 'generic',
description: compareData.description || `Domain extension .${tld}`,
registry: compareData.registry || 'Unknown',
introduced: compareData.introduced || 0,
trend: historyData.trend || 'stable',
trend_reason: historyData.trend_reason || 'Price tracking available',
type: 'generic',
description: `Domain extension .${tld}`,
registry: 'Various',
introduced: 0,
trend: trend,
trend_reason: trend === 'up' ? 'Price increase' : trend === 'down' ? 'Price decrease' : 'Stable pricing',
pricing: {
avg: priceRange.avg || historyData.current_price || 0,
min: priceRange.min || historyData.current_price || 0,
max: priceRange.max || historyData.current_price || 0,
avg: avgPrice,
min: minPrice,
max: maxPrice,
},
registrars: registrars.sort((a: { registration_price: number }, b: { registration_price: number }) =>
a.registration_price - b.registration_price
),
cheapest_registrar: compareData.cheapest_registrar || registrars[0]?.name || 'N/A',
registrars: sortedRegistrars,
cheapest_registrar: sortedRegistrars[0]?.name || 'N/A',
})
setHistory({
...historyData,
trend: trend,
trend_reason: trend === 'up' ? 'Price increase' : trend === 'down' ? 'Price decrease' : 'Stable pricing',
})
setHistory(historyData)
} else {
setError('Failed to load TLD data')
}

File diff suppressed because one or more lines are too long