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:
@ -7,7 +7,7 @@ from sqlalchemy import select, func, and_
|
|||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.database import get_db
|
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.user import User
|
||||||
from app.models.portfolio import PortfolioDomain, DomainValuation
|
from app.models.portfolio import PortfolioDomain, DomainValuation
|
||||||
from app.services.valuation import valuation_service
|
from app.services.valuation import valuation_service
|
||||||
|
|||||||
@ -58,7 +58,8 @@ interface TldHistory {
|
|||||||
price_change_7d: number
|
price_change_7d: number
|
||||||
price_change_30d: number
|
price_change_30d: number
|
||||||
price_change_90d: number
|
price_change_90d: number
|
||||||
trend: string
|
trend?: string
|
||||||
|
trend_reason?: string
|
||||||
history: Array<{
|
history: Array<{
|
||||||
date: string
|
date: string
|
||||||
price: number
|
price: number
|
||||||
@ -69,9 +70,9 @@ interface DomainCheckResult {
|
|||||||
domain: string
|
domain: string
|
||||||
is_available: boolean
|
is_available: boolean
|
||||||
status: string
|
status: string
|
||||||
registrar?: string
|
registrar?: string | null
|
||||||
creation_date?: string
|
creation_date?: string | null
|
||||||
expiration_date?: string
|
expiration_date?: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
// Registrar URLs with affiliate parameters
|
// Registrar URLs with affiliate parameters
|
||||||
@ -420,27 +421,41 @@ export default function TldDetailPage() {
|
|||||||
|
|
||||||
if (historyData && compareData) {
|
if (historyData && compareData) {
|
||||||
const registrars = compareData.registrars || []
|
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({
|
setDetails({
|
||||||
tld: compareData.tld || tld,
|
tld: compareData.tld || tld,
|
||||||
type: compareData.type || 'generic',
|
type: 'generic',
|
||||||
description: compareData.description || `Domain extension .${tld}`,
|
description: `Domain extension .${tld}`,
|
||||||
registry: compareData.registry || 'Unknown',
|
registry: 'Various',
|
||||||
introduced: compareData.introduced || 0,
|
introduced: 0,
|
||||||
trend: historyData.trend || 'stable',
|
trend: trend,
|
||||||
trend_reason: historyData.trend_reason || 'Price tracking available',
|
trend_reason: trend === 'up' ? 'Price increase' : trend === 'down' ? 'Price decrease' : 'Stable pricing',
|
||||||
pricing: {
|
pricing: {
|
||||||
avg: priceRange.avg || historyData.current_price || 0,
|
avg: avgPrice,
|
||||||
min: priceRange.min || historyData.current_price || 0,
|
min: minPrice,
|
||||||
max: priceRange.max || historyData.current_price || 0,
|
max: maxPrice,
|
||||||
},
|
},
|
||||||
registrars: registrars.sort((a: { registration_price: number }, b: { registration_price: number }) =>
|
registrars: sortedRegistrars,
|
||||||
a.registration_price - b.registration_price
|
cheapest_registrar: sortedRegistrars[0]?.name || 'N/A',
|
||||||
),
|
})
|
||||||
cheapest_registrar: compareData.cheapest_registrar || registrars[0]?.name || 'N/A',
|
setHistory({
|
||||||
|
...historyData,
|
||||||
|
trend: trend,
|
||||||
|
trend_reason: trend === 'up' ? 'Price increase' : trend === 'down' ? 'Price decrease' : 'Stable pricing',
|
||||||
})
|
})
|
||||||
setHistory(historyData)
|
|
||||||
} else {
|
} else {
|
||||||
setError('Failed to load TLD data')
|
setError('Failed to load TLD data')
|
||||||
}
|
}
|
||||||
|
|||||||
1
frontend/tsconfig.tsbuildinfo
Normal file
1
frontend/tsconfig.tsbuildinfo
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user